Commit d331f73d authored by Jürg Billeter's avatar Jürg Billeter Committed by Jürg Billeter

fix cheader filenames and default to GObject prerequisite for interfaces,

2007-07-23  Juerg Billeter  <j@bitron.ch>

	* vala/valainterface.vala, vala/valainterfacewriter.vala,
	  vala/valasemanticanalyzer.vala: fix cheader filenames and default to
	  GObject prerequisite for interfaces, fixes bug 459039

svn path=/trunk/; revision=374
parent 66fa35c4
2007-07-23 Jürg Billeter <j@bitron.ch>
* vala/valainterface.vala, vala/valainterfacewriter.vala,
vala/valasemanticanalyzer.vala: fix cheader filenames and default to
GObject prerequisite for interfaces, fixes bug 459039
2007-07-23 Jürg Billeter <j@bitron.ch>
* vala/valainterfacewriter.vala: write interface prerequisites
......
......@@ -85,6 +85,16 @@ public class Vala.Interface : DataType {
prerequisites.append (type);
}
/**
* Prepends the specified interface or class to the list of
* prerequisites of this interface.
*
* @param type an interface or class reference
*/
public void prepend_prerequisite (TypeReference! type) {
prerequisites.prepend (type);
}
/**
* Returns a copy of the base type list.
*
......@@ -265,6 +275,12 @@ public class Vala.Interface : DataType {
if (a.has_argument ("type_cname")) {
set_type_cname (a.get_string ("type_cname"));
}
if (a.has_argument ("cheader_filename")) {
var val = a.get_string ("cheader_filename");
foreach (string filename in val.split (",")) {
add_cheader_filename (filename);
}
}
}
/**
......
......@@ -97,7 +97,7 @@ public class Vala.InterfaceWriter : CodeVisitor {
cheaders = cheader;
first = false;
} else {
cheaders = "%s, %s".printf (cheaders, cheader);
cheaders = "%s,%s".printf (cheaders, cheader);
}
}
write_string ("[CCode (cheader_filename = \"%s\")]".printf (cheaders));
......@@ -190,7 +190,7 @@ public class Vala.InterfaceWriter : CodeVisitor {
cheaders = cheader;
first = false;
} else {
cheaders = "%s, %s".printf (cheaders, cheader);
cheaders = "%s,%s".printf (cheaders, cheader);
}
}
write_string ("[CCode (cheader_filename = \"%s\")]".printf (cheaders));
......@@ -225,7 +225,7 @@ public class Vala.InterfaceWriter : CodeVisitor {
cheaders = cheader;
first = false;
} else {
cheaders = "%s, %s".printf (cheaders, cheader);
cheaders = "%s,%s".printf (cheaders, cheader);
}
}
write_string ("[CCode (cheader_filename = \"%s\")]".printf (cheaders));
......@@ -310,7 +310,7 @@ public class Vala.InterfaceWriter : CodeVisitor {
cheaders = cheader;
first = false;
} else {
cheaders = "%s, %s".printf (cheaders, cheader);
cheaders = "%s,%s".printf (cheaders, cheader);
}
}
write_string ("[CCode (cprefix = \"%s\", cheader_filename = \"%s\")]".printf (en.get_cprefix (), cheaders));
......
......@@ -49,6 +49,7 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
TypeReference unichar_type;
TypeReference type_type;
DataType pointer_type;
DataType object_type;
DataType initially_unowned_type;
DataType glist_type;
DataType gslist_type;
......@@ -91,6 +92,7 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
// TODO: don't require GLib namespace in semantic analyzer
var glib_ns = root_symbol.scope.lookup ("GLib");
if (glib_ns != null) {
object_type = (DataType) glib_ns.scope.lookup ("Object");
initially_unowned_type = (DataType) glib_ns.scope.lookup ("InitiallyUnowned");
type_type = new TypeReference ();
......@@ -264,8 +266,6 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
current_source_file.add_symbol_dependency (prerequisite_reference.data_type, SourceFileDependencyType.HEADER_FULL);
}
iface.accept_children (this);
/* check prerequisites */
Class prereq_class;
foreach (TypeReference prereq in iface.get_prerequisites ()) {
......@@ -283,10 +283,19 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
return;
}
prereq_class = (Class)class_or_interface;
prereq_class = (Class) class_or_interface;
}
}
if (prereq_class == null) {
/* default to GObject */
var obj_type = new TypeReference ();
obj_type.data_type = object_type;
iface.prepend_prerequisite (obj_type);
}
iface.accept_children (this);
current_symbol = current_symbol.parent_symbol;
}
......
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