From 8352e42478f7a088aa0eac7c511f9ac6f0c62101 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Mon, 17 Nov 2008 00:27:37 +0000 Subject: Bug 559706 - interface prequisites svn path=/trunk/; revision=932 --- common.mk | 3 ++- girepository/gdump.c | 7 +++++- girepository/girparser.c | 51 +++++++++++++++++++------------------------- giscanner/ast.py | 1 + giscanner/girwriter.py | 3 +++ giscanner/glibtransformer.py | 7 ++++++ 6 files changed, 41 insertions(+), 31 deletions(-) diff --git a/common.mk b/common.mk index 7458e5fc..3eeb1935 100644 --- a/common.mk +++ b/common.mk @@ -7,4 +7,5 @@ SCANNER_ARGS = -v --add-include-path=$(top_builddir)/gir --add-include-path=. SCANNER = $(SCANNER_ENV) $(SCANNER_BIN) $(SCANNER_ARGS) SCANNER_LIBS = \ $(top_srcdir)/giscanner/*.py \ - $(top_builddir)/giscanner/libgiscanner.la + $(top_builddir)/giscanner/libgiscanner.la \ + $(top_builddir)/girepository/libgirepository.la diff --git a/girepository/gdump.c b/girepository/gdump.c index b26b0e85..a58e620e 100644 --- a/girepository/gdump.c +++ b/girepository/gdump.c @@ -186,7 +186,12 @@ dump_interface_type (GType type, const char *symbol, GOutputStream *out) for (i = 0; i < n_interfaces; i++) { GType itype = interfaces[i]; - escaped_printf (out, " %s\n", + if (itype == G_TYPE_OBJECT) + { + /* This is implicit */ + continue; + } + escaped_printf (out, " \n", g_type_name (itype)); } dump_properties (type, out); diff --git a/girepository/girparser.c b/girepository/girparser.c index ecc2e10f..43f34029 100644 --- a/girepository/girparser.c +++ b/girepository/girparser.c @@ -54,7 +54,7 @@ typedef enum STATE_INTERFACE_PROPERTY, /* 15 */ STATE_INTERFACE_FIELD, STATE_IMPLEMENTS, - STATE_REQUIRES, + STATE_PREREQUISITE, STATE_BOXED, STATE_BOXED_FIELD, /* 20 */ STATE_STRUCT, @@ -2338,25 +2338,6 @@ start_element_handler (GMarkupParseContext *context, attribute_names, attribute_values, ctx, error)) goto out; - else if (strcmp (element_name, "class") == 0 && - ctx->state == STATE_REQUIRES) - { - const gchar *name; - - name = find_attribute ("name", attribute_names, attribute_values); - - if (name == NULL) - MISSING_ATTRIBUTE (context, error, element_name, "name"); - else - { - GIrNodeInterface *iface; - - iface = (GIrNodeInterface *)ctx->current_node; - iface ->prerequisites = g_list_append (iface->prerequisites, g_strdup (name)); - } - - goto out; - } break; case 'd': @@ -2522,7 +2503,26 @@ start_element_handler (GMarkupParseContext *context, attribute_names, attribute_values, ctx, error)) goto out; + else if (strcmp (element_name, "prerequisite") == 0 && + ctx->state == STATE_INTERFACE) + { + const gchar *name; + name = find_attribute ("name", attribute_names, attribute_values); + + state_switch (ctx, STATE_PREREQUISITE); + + if (name == NULL) + MISSING_ATTRIBUTE (context, error, element_name, "name"); + else + { + GIrNodeInterface *iface; + + iface = (GIrNodeInterface *)ctx->current_node; + iface ->prerequisites = g_list_append (iface->prerequisites, g_strdup (name)); + } + goto out; + } break; case 'r': @@ -2549,13 +2549,6 @@ start_element_handler (GMarkupParseContext *context, attribute_names, attribute_values, ctx, error)) goto out; - else if (strcmp (element_name, "requires") == 0 && - ctx->state == STATE_INTERFACE) - { - state_switch (ctx, STATE_REQUIRES); - - goto out; - } else if (start_struct (context, element_name, attribute_names, attribute_values, ctx, error)) @@ -2893,8 +2886,8 @@ end_element_handler (GMarkupParseContext *context, if (require_end_element (context, ctx, "implements", element_name, error)) state_switch (ctx, STATE_CLASS); break; - case STATE_REQUIRES: - if (require_end_element (context, ctx, "requires", element_name, error)) + case STATE_PREREQUISITE: + if (require_end_element (context, ctx, "prerequisite", element_name, error)) state_switch (ctx, STATE_INTERFACE); break; case STATE_NAMESPACE_CONSTANT: diff --git a/giscanner/ast.py b/giscanner/ast.py index b4e8e9ec..41587bce 100644 --- a/giscanner/ast.py +++ b/giscanner/ast.py @@ -385,6 +385,7 @@ class Interface(Node): self.methods = [] self.properties = [] self.fields = [] + self.prerequisites = [] def __repr__(self): return '%s(%r, %r)' % ( diff --git a/giscanner/girwriter.py b/giscanner/girwriter.py index 030ea829..a5c50d97 100644 --- a/giscanner/girwriter.py +++ b/giscanner/girwriter.py @@ -254,6 +254,9 @@ class GIRWriter(XMLWriter): if isinstance(node, GLibObject): for iface in node.interfaces: self.write_tag('implements', [('name', iface)]) + if isinstance(node, Interface): + for iface in node.prerequisites: + self.write_tag('prerequisite', [('name', iface)]) if isinstance(node, Class): for method in node.constructors: self._write_constructor(method) diff --git a/giscanner/glibtransformer.py b/giscanner/glibtransformer.py index 5f079bae..2edab367 100644 --- a/giscanner/glibtransformer.py +++ b/giscanner/glibtransformer.py @@ -575,6 +575,10 @@ class GLibTransformer(object): type_name, xmlnode.attrib['get-type']) self._introspect_properties(node, xmlnode) self._introspect_signals(node, xmlnode) + for child in xmlnode.findall('prerequisite'): + name = child.attrib['name'] + prereq = self._resolve_gtypename(name) + node.prerequisites.append(prereq) # GtkFileChooserEmbed is an example of a private interface, we # just filter them out if xmlnode.attrib['get-type'].startswith('_'): @@ -728,6 +732,9 @@ class GLibTransformer(object): self._resolve_methods(node.methods) self._resolve_properties(node.properties, node) self._resolve_signals(node.signals) + node.prerequisites = filter(None, + [self._force_resolve(x, allow_unknown=True) + for x in node.prerequisites]) def _resolve_glib_object(self, node): node.parent = self._force_resolve(node.parent) -- cgit v1.2.1