Commit 7d197544 authored by Jürg Billeter's avatar Jürg Billeter Committed by Jürg Billeter

Write qualified types in the interface writer

2008-05-25  Juerg Billeter  <j@bitron.ch>

	* vala/valaarraytype.vala:
	* vala/valadatatype.vala:
	* vala/valadelegatetype.vala:
	* vala/valafieldprototype.vala:
	* vala/valainterfacewriter.vala:
	* vala/valamethodtype.vala:
	* vala/valapointertype.vala:
	* vala/valaunresolvedtype.vala:
	* vala/valavoidtype.vala:

	Write qualified types in the interface writer

svn path=/trunk/; revision=1432
parent 6ed6d1f2
2008-05-25 Jürg Billeter <j@bitron.ch>
* vala/valaarraytype.vala:
* vala/valadatatype.vala:
* vala/valadelegatetype.vala:
* vala/valafieldprototype.vala:
* vala/valainterfacewriter.vala:
* vala/valamethodtype.vala:
* vala/valapointertype.vala:
* vala/valaunresolvedtype.vala:
* vala/valavoidtype.vala:
Write qualified types in the interface writer
2008-05-25 Jürg Billeter <j@bitron.ch>
* vapi/dbus-glib-1.vapi: use [Compact] attribute
......
......@@ -140,8 +140,8 @@ public class Vala.ArrayType : ReferenceType {
return true;
}
public override string to_string () {
return element_type.to_string () + "[]";
public override string to_qualified_string (Scope? scope) {
return element_type.to_qualified_string (scope) + "[]";
}
public override bool compatible (DataType target_type) {
......
......@@ -145,10 +145,30 @@ public abstract class Vala.DataType : CodeNode {
}
public override string to_string () {
return to_qualified_string (null);
}
public virtual string to_qualified_string (Scope? scope = null) {
string s;
if (data_type != null) {
s = data_type.get_full_name ();
Symbol global_symbol = data_type;
while (global_symbol.parent_symbol.name != null) {
global_symbol = global_symbol.parent_symbol;
}
Symbol sym = null;
Scope parent_scope = scope;
while (sym == null && parent_scope != null) {
sym = parent_scope.lookup (global_symbol.name);
parent_scope = parent_scope.parent_scope;
}
if (sym != null && global_symbol != sym) {
s = "global::" + data_type.get_full_name ();;
} else {
s = data_type.get_full_name ();
}
} else if (type_parameter != null) {
s = type_parameter.name;
} else {
......@@ -168,7 +188,7 @@ public abstract class Vala.DataType : CodeNode {
if (!type_arg.value_owned) {
s += "weak ";
}
s += type_arg.to_string ();
s += type_arg.to_qualified_string (scope);
}
s += ">";
}
......
......@@ -45,7 +45,7 @@ public class Vala.DelegateType : DataType {
return delegate_symbol.get_parameters ();
}
public override string to_string () {
public override string to_qualified_string (Scope? scope) {
string s = delegate_symbol.get_full_name ();
if (nullable) {
s += "?";
......
......@@ -37,7 +37,7 @@ public class Vala.FieldPrototype : DataType {
return result;
}
public override string to_string () {
public override string to_qualified_string (Scope? scope) {
return field_symbol.get_full_name ();
}
}
......@@ -38,6 +38,8 @@ public class Vala.InterfaceWriter : CodeVisitor {
string current_cheader_filename;
Scope current_scope;
/**
* Writes the public interface of the specified code context into the
* specified file.
......@@ -54,8 +56,12 @@ public class Vala.InterfaceWriter : CodeVisitor {
write_newline ();
write_newline ();
current_scope = context.root.scope;
context.accept (this);
current_scope = null;
stream = null;
}
......@@ -78,7 +84,9 @@ public class Vala.InterfaceWriter : CodeVisitor {
write_identifier (ns.name);
write_begin_block ();
current_scope = ns.scope;
ns.accept_children (this);
current_scope = current_scope.parent_scope;
write_end_block ();
write_newline ();
......@@ -177,7 +185,9 @@ public class Vala.InterfaceWriter : CodeVisitor {
}
write_begin_block ();
current_scope = cl.scope;
cl.accept_children (this);
current_scope = current_scope.parent_scope;
write_end_block ();
write_newline ();
......@@ -241,7 +251,9 @@ public class Vala.InterfaceWriter : CodeVisitor {
write_begin_block ();
current_scope = st.scope;
st.accept_children (this);
current_scope = current_scope.parent_scope;
write_end_block ();
write_newline ();
......@@ -311,7 +323,9 @@ public class Vala.InterfaceWriter : CodeVisitor {
}
write_begin_block ();
current_scope = iface.scope;
iface.accept_children (this);
current_scope = current_scope.parent_scope;
write_end_block ();
write_newline ();
......@@ -378,9 +392,11 @@ public class Vala.InterfaceWriter : CodeVisitor {
write_newline ();
}
current_scope = en.scope;
foreach (Method m in en.get_methods ()) {
m.accept (this);
}
current_scope = current_scope.parent_scope;
write_end_block ();
write_newline ();
......@@ -851,7 +867,7 @@ public class Vala.InterfaceWriter : CodeVisitor {
}
private void write_type (DataType type) {
write_string (type.to_string ());
write_string (type.to_qualified_string (current_scope));
}
private void write_string (string s) {
......
......@@ -59,7 +59,7 @@ public class Vala.MethodType : DataType {
return dt.delegate_symbol.matches_method (method_symbol);
}
public override string to_string () {
public override string to_qualified_string (Scope? scope) {
return method_symbol.get_full_name ();
}
......
......@@ -46,8 +46,8 @@ public class Vala.PointerType : DataType {
this.source_reference = source_reference;
}
public override string to_string () {
return base_type.to_string () + "*";
public override string to_qualified_string (Scope? scope) {
return base_type.to_qualified_string (scope) + "*";
}
public override string? get_cname () {
......
......@@ -100,7 +100,7 @@ public class Vala.UnresolvedType : DataType {
return result;
}
public override string to_string () {
public override string to_qualified_string (Scope? scope) {
return unresolved_symbol.to_string ();
}
}
......@@ -33,7 +33,7 @@ public class Vala.VoidType : DataType {
return (type2 is VoidType);
}
public override string to_string () {
public override string to_qualified_string (Scope? scope) {
return "void";
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment