[vala/switch-to-gir: 26/26] girparser: Ensure interfaces have at least one instantiable prerequisite
- From: Luca Bruno <lucabru src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/switch-to-gir: 26/26] girparser: Ensure interfaces have at least one instantiable prerequisite
- Date: Sun, 19 Dec 2010 22:00:37 +0000 (UTC)
commit 93341351b304def1db331af59fffc7c35e36c3ac
Author: Luca Bruno <lucabru src gnome org>
Date: Sun Dec 19 22:46:38 2010 +0100
girparser: Ensure interfaces have at least one instantiable prerequisite
When parsing a GIR file, add a prerequisite on GLib.Object to interfaces
which don't have an instantiable prerequisite specified in the GIR file,
as g-ir-scanner considers this prerequisite to be implicit.
Based on commit 65bc5e64725900961ec, reverts fc7fe82fbd0b19b6caaf7ef.
Fixes bug 624923.
vala/valagirparser.vala | 30 +++++++++++++++++++++++++++++-
1 files changed, 29 insertions(+), 1 deletions(-)
---
diff --git a/vala/valagirparser.vala b/vala/valagirparser.vala
index 26eff63..2a0a71a 100644
--- a/vala/valagirparser.vala
+++ b/vala/valagirparser.vala
@@ -530,6 +530,7 @@ public class Vala.GirParser : CodeVisitor {
HashMap<UnresolvedSymbol,ArrayList<Symbol>> symbol_reparent_map = new HashMap<UnresolvedSymbol,ArrayList<Symbol>> (unresolved_symbol_hash, unresolved_symbol_equal);
HashMap<Namespace,ArrayList<Method>> namespace_methods = new HashMap<Namespace,ArrayList<Method>> ();
ArrayList<Alias> aliases = new ArrayList<Alias> ();
+ ArrayList<Interface> interfaces = new ArrayList<Interface> ();
HashMap<UnresolvedSymbol,ArrayList<Delegate>> gtype_callbacks;
@@ -546,6 +547,7 @@ public class Vala.GirParser : CodeVisitor {
resolve_gir_symbols ();
+ postprocess_interfaces ();
postprocess_reparenting ();
postprocess_aliases ();
postprocess_namespace_methods ();
@@ -1445,7 +1447,9 @@ public class Vala.GirParser : CodeVisitor {
} else if (reader.name == "class") {
add_symbol_info (parse_class ());
} else if (reader.name == "interface") {
- add_symbol_info (parse_interface ());
+ var iface = parse_interface ();
+ add_symbol_info (iface);
+ interfaces.add (iface);
} else if (reader.name == "glib:boxed") {
add_symbol_info (parse_boxed ());
} else if (reader.name == "union") {
@@ -2720,6 +2724,30 @@ public class Vala.GirParser : CodeVisitor {
return null;
}
+ void postprocess_interfaces () {
+ foreach (var iface in interfaces) {
+ // ensure we have at least one instantiable prerequisite (GLib.Object)
+ bool has_instantiable_prereq = false;
+ foreach (DataType prereq in iface.get_prerequisites ()) {
+ Symbol sym = null;
+ if (prereq is UnresolvedType) {
+ var unresolved_symbol = ((UnresolvedType) prereq).unresolved_symbol;
+ sym = resolve_symbol (iface.parent_symbol.scope, unresolved_symbol);
+ } else {
+ sym = prereq.data_type;
+ }
+ if (sym is Class) {
+ has_instantiable_prereq = true;
+ break;
+ }
+ }
+
+ if (!has_instantiable_prereq) {
+ iface.add_prerequisite (new ObjectType ((ObjectTypeSymbol) glib_ns.scope.lookup ("Object")));
+ }
+ }
+ }
+
void postprocess_reparenting () {
foreach (UnresolvedSymbol target_unresolved_symbol in symbol_reparent_map.get_keys ()) {
var target_symbol = resolve_symbol (context.root.scope, target_unresolved_symbol);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]