From 3ae9127e53032065df14be8539aba0cf50835386 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Thu, 5 Feb 2009 22:43:39 +0000 Subject: Bug 561360 - If we can't resolve parent class, use GObject This enables us to support "hidden" parent classes. svn path=/trunk/; revision=1087 --- giscanner/glibtransformer.py | 12 ++++++- tests/scanner/foo-1.0-expected.gir | 14 ++++++++ tests/scanner/foo-1.0-expected.tgir | 9 +++++ tests/scanner/foo.c | 66 +++++++++++++++++++++++++++++++++++-- tests/scanner/foo.h | 10 ++++++ 5 files changed, 108 insertions(+), 3 deletions(-) diff --git a/giscanner/glibtransformer.py b/giscanner/glibtransformer.py index 749b6524..6b6a2d38 100644 --- a/giscanner/glibtransformer.py +++ b/giscanner/glibtransformer.py @@ -802,7 +802,17 @@ class GLibTransformer(object): for x in node.prerequisites]) def _resolve_glib_object(self, node): - node.parent = self._force_resolve(node.parent) + # If we can't find the parent class, just drop back to GObject. + # This supports hidden parent classes. + # http://bugzilla.gnome.org/show_bug.cgi?id=561360 + try: + node.parent = self._force_resolve(node.parent) + except KeyError, e: + print ("WARNING: Parent %r of class %r" +\ + " not found; using GObject") % (node.parent.target, + node.name) + node.parent = self._transformer.gtypename_to_giname("GObject", + self._names) node.interfaces = filter(None, [self._force_resolve(x, allow_unknown=True) for x in node.interfaces]) diff --git a/tests/scanner/foo-1.0-expected.gir b/tests/scanner/foo-1.0-expected.gir index d826a5d4..2d69099b 100644 --- a/tests/scanner/foo-1.0-expected.gir +++ b/tests/scanner/foo-1.0-expected.gir @@ -239,6 +239,20 @@ and/or use gtk-doc annotations. --> + + + + + + + + + + diff --git a/tests/scanner/foo-1.0-expected.tgir b/tests/scanner/foo-1.0-expected.tgir index 614f6f84..80e6fc50 100644 --- a/tests/scanner/foo-1.0-expected.tgir +++ b/tests/scanner/foo-1.0-expected.tgir @@ -152,6 +152,15 @@ + + + + + + + + + diff --git a/tests/scanner/foo.c b/tests/scanner/foo.c index ff493736..fa1a66de 100644 --- a/tests/scanner/foo.c +++ b/tests/scanner/foo.c @@ -420,7 +420,6 @@ foo_hidden_free (FooHidden *boxed) g_slice_free (FooHidden, boxed); } - GType foo_hidden_get_type (void) { @@ -458,5 +457,68 @@ foo_error_quark (void) void foo_some_variant (guint x, va_list args) { - +} + +/* This setup of a totally hidden parent class matches + * http://bugzilla.gnome.org/show_bug.cgi?id=561360 + */ +#define FOO_TYPE_TILE_HANDLER (foo_tile_handler_get_type ()) +#define FOO_TILE_HANDLER(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), FOO_TYPE_TILE_HANDLER, FooTileHandler)) +#define FOO_IS_TILE_HANDLER(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), FOO_TYPE_TILE_HANDLER)) + +struct _FooTileHandler +{ + FooObject parent_instance; +}; + + +struct _FooTileHandlerClass +{ + FooObjectClass parent_class; +}; + +typedef struct _FooTileHandler FooTileHandler; +typedef struct _FooTileHandlerClass FooTileHandlerClass; + +G_DEFINE_TYPE(FooTileHandler, foo_tile_handler, FOO_TYPE_OBJECT); + +static void +foo_tile_handler_class_init (FooTileHandlerClass *klass) +{ + +} + +static void +foo_tile_handler_init (FooTileHandler *object) +{ + +} + +struct _FooBuffer +{ + FooTileHandler parent_instance; +}; + +struct _FooBufferClass +{ + FooTileHandlerClass parent_class; +}; + +G_DEFINE_TYPE(FooBuffer, foo_buffer, FOO_TYPE_TILE_HANDLER); + +static void +foo_buffer_class_init (FooBufferClass *klass) +{ + +} + +static void +foo_buffer_init (FooBuffer *object) +{ + +} + +void +foo_buffer_some_method (FooBuffer *buffer) +{ } \ No newline at end of file diff --git a/tests/scanner/foo.h b/tests/scanner/foo.h index 1b7a418c..e866bbea 100644 --- a/tests/scanner/foo.h +++ b/tests/scanner/foo.h @@ -23,6 +23,10 @@ #define FOO_SUBOBJECT(subobject) (G_TYPE_CHECK_INSTANCE_CAST ((subobject), FOO_TYPE_SUBOBJECT, FooSubobject)) #define FOO_IS_SUBOBJECT(subobject) (G_TYPE_CHECK_INSTANCE_TYPE ((subobject), FOO_TYPE_SUBOBJECT)) +#define FOO_TYPE_BUFFER (foo_buffer_get_type ()) +#define FOO_BUFFER(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), FOO_TYPE_BUFFER, FooBuffer)) +#define FOO_IS_BUFFER(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), FOO_TYPE_BUFFER)) + typedef struct _FooInterface FooInterface; typedef struct _FooInterfaceIface FooInterfaceIface; typedef struct _FooSubInterface FooSubInterface; @@ -31,6 +35,8 @@ typedef struct _FooObject FooObject; typedef struct _FooObjectClass FooObjectClass; typedef struct _FooSubobject FooSubobject; typedef struct _FooSubobjectClass FooSubobjectClass; +typedef struct _FooBuffer FooBuffer; +typedef struct _FooBufferClass FooBufferClass; struct _FooInterfaceIface { @@ -108,6 +114,10 @@ struct _FooSubobjectClass GType foo_subobject_get_type (void) G_GNUC_CONST; FooSubobject* foo_subobject_new (); +GType foo_buffer_get_type (void); + +void foo_buffer_some_method (FooBuffer *buffer); + typedef enum { FOO_ENUM_ALPHA, -- cgit v1.2.1