summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Walters <walters@src.gnome.org>2009-02-05 22:43:39 +0000
committerColin Walters <walters@src.gnome.org>2009-02-05 22:43:39 +0000
commit3ae9127e53032065df14be8539aba0cf50835386 (patch)
tree70f667953d1c6e93bf62287cc702ac87e8d11e78
parent0d6e0ad5fffed6e5660b7d9c84fd1dde7df0f8bc (diff)
downloadgobject-introspection-3ae9127e53032065df14be8539aba0cf50835386.tar.gz
Bug 561360 - If we can't resolve parent class, use GObject
This enables us to support "hidden" parent classes. svn path=/trunk/; revision=1087
-rw-r--r--giscanner/glibtransformer.py12
-rw-r--r--tests/scanner/foo-1.0-expected.gir14
-rw-r--r--tests/scanner/foo-1.0-expected.tgir9
-rw-r--r--tests/scanner/foo.c66
-rw-r--r--tests/scanner/foo.h10
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. -->
<type name="ObjectClass" c:type="FooObjectClass"/>
</field>
</record>
+ <class name="Buffer"
+ c:type="FooBuffer"
+ parent="GObject.Object"
+ glib:type-name="FooBuffer"
+ glib:get-type="foo_buffer_get_type">
+ <implements name="Interface"/>
+ <method name="some_method" c:identifier="foo_buffer_some_method">
+ <return-value transfer-ownership="none">
+ <type name="none" c:type="void"/>
+ </return-value>
+ </method>
+ </class>
+ <record name="BufferClass" c:type="FooBufferClass">
+ </record>
<function name="init" c:identifier="foo_init">
<return-value transfer-ownership="none">
<type name="int" c:type="gint"/>
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 @@
<type name="ObjectClass"/>
</field>
</record>
+ <class name="Buffer" parent="GObject.Object" glib:type-name="FooBuffer" glib:get-type="foo_buffer_get_type">
+ <implements name="Interface"/>
+ <method name="some_method" c:identifier="foo_buffer_some_method">
+ <return-value transfer-ownership="none">
+ <type name="none"/>
+ </return-value>
+ </method>
+ </class>
+ <record name="BufferClass"/>
<function name="init" c:identifier="foo_init">
<return-value transfer-ownership="none">
<type name="int"/>
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,