Initialize GObject to fix scanning interface properties.
authorJuerg Billeter <j@bitron.ch>
Fri, 11 Jan 2008 17:52:29 +0000 (17:52 +0000)
committerJürg Billeter <juergbi@src.gnome.org>
Fri, 11 Jan 2008 17:52:29 +0000 (17:52 +0000)
2008-01-11  Juerg Billeter  <j@bitron.ch>

* src/scanner.c: (g_igenerator_generate):
Initialize GObject to fix scanning interface properties.

* tests/parser/Foo-expected.gidl:
* tests/parser/foo-object.h:
* tests/parser/foo.c: (foo_interface_get_type):
Test interfaces with GObject prerequisite.

* tests/parser/Makefile.am:
Set G_DEBUG=fatal_warnings to abort test on warnings and criticals.

svn path=/trunk/; revision=93

ChangeLog
src/scanner.c
tests/parser/Foo-expected.gidl
tests/parser/Makefile.am
tests/parser/foo-object.h
tests/parser/foo.c

index 694910b827c95a6dbd1562b0910a695f489581a9..cb2905a672a48325e75808eed1c25a1f345190d5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2008-01-11  Jürg Billeter  <j@bitron.ch>
+
+       * src/scanner.c: (g_igenerator_generate):
+       Initialize GObject to fix scanning interface properties.
+
+       * tests/parser/Foo-expected.gidl:
+       * tests/parser/foo-object.h:
+       * tests/parser/foo.c: (foo_interface_get_type):
+       Test interfaces with GObject prerequisite.
+
+       * tests/parser/Makefile.am:
+       Set G_DEBUG=fatal_warnings to abort test on warnings and criticals.
+
 2007-12-27  Johan Dahlin  <johan@gnome.org>
 
        * src/scannerlexer.l:
index 32f5925e4e8efd8d4db475a59fbd1d2686057ffe..b3ca339ce9bfc63dc1203958bd52bc3fe5415869 100644 (file)
@@ -1,6 +1,6 @@
 /* GObject introspection: scanner
  *
- * Copyright (C) 2007  Jürg Billeter
+ * Copyright (C) 2007-2008  Jürg Billeter
  * Copyright (C) 2007  Johan Dahlin
  *
  * This library is free software; you can redistribute it and/or
@@ -1298,6 +1298,9 @@ g_igenerator_generate (GIGenerator * igenerator,
        }
     }
 
+  /* ensure to initialize GObject */
+  g_type_class_ref (G_TYPE_OBJECT);
+
   for (l = libraries; l; l = l->next)
       g_igenerator_process_module (igenerator, (const gchar*)l->data);
 
index a95ce47cd887bb5dc289ca1c73abc846cc7bf6eb..464884a9ea0472983435a9a676d8b206d0e2157c 100644 (file)
                                <return-type type="FooSubobject*"/>
                        </constructor>
                </object>
+               <interface name="FooInterface" type-name="FooInterface" get-type="foo_interface_get_type">
+                       <requires>
+                               <interface name="GObject"/>
+                       </requires>
+               </interface>
        </namespace>
 </api>
index 0c62ff488f7d37a922daaa3c2f80461c2094631b..a4b096f2c9974d35bb7f75cd84272cf053605082 100644 (file)
@@ -14,7 +14,7 @@ CLEANFILES = Foo.gidl
 SCAN_SOURCES = foo-object.h
 
 Foo.gidl: libfoo.la foo-object.h $(top_builddir)/src/g-idl-scanner
-       $(top_builddir)/src/g-idl-scanner -v --namespace=Foo \
+       G_DEBUG=fatal_warnings $(top_builddir)/src/g-idl-scanner -v --namespace=Foo \
        --include-idl=$(top_srcdir)/gidl/GLib.gidl \
        $(SCAN_SOURCES) -I. $(GOBJECT_CFLAGS) \
        libfoo.la --output $@
index 808a5e3b9a634e2905031d5d83a793b887ad0a4c..20f69e4750f32962b8b4da624fc4d937d286cdc4 100644 (file)
@@ -3,6 +3,10 @@
 
 #include <glib-object.h>
 
+#define FOO_TYPE_INTERFACE           (foo_interface_get_type ())
+#define FOO_INTERFACE(object)        (G_TYPE_CHECK_INSTANCE_CAST ((object), FOO_TYPE_INTERFACE, FooInterface))
+#define FOO_IS_INTERFACE(object)     (G_TYPE_CHECK_INSTANCE_TYPE ((object), FOO_TYPE_INTERFACE))
+
 #define FOO_TYPE_OBJECT              (foo_object_get_type ())
 #define FOO_OBJECT(object)           (G_TYPE_CHECK_INSTANCE_CAST ((object), FOO_TYPE_OBJECT, FooObject))
 #define FOO_IS_OBJECT(object)        (G_TYPE_CHECK_INSTANCE_TYPE ((object), FOO_TYPE_OBJECT))
 #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))
 
+typedef struct _FooInterface       FooInterface;
+typedef struct _FooInterfaceIface  FooInterfaceIface;
 typedef struct _FooObject          FooObject;
 typedef struct _FooObjectClass     FooObjectClass;
 typedef struct _FooSubobject       FooSubobject;
 typedef struct _FooSubobjectClass  FooSubobjectClass;
 
+struct _FooInterfaceIface
+{
+  GTypeInterface parent_iface;
+};
+
+GType                 foo_interface_get_type       (void) G_GNUC_CONST;
+
 struct _FooObject
 {
   GObject parent_instance;
index f96072b2eb3223ad29273a1ad01463edbd8ecf4a..b073178ee48797df8e839c1d3288dbb38764c017 100644 (file)
@@ -2,6 +2,24 @@
 
 #include "foo-object.h"
 
+GType
+foo_interface_get_type (void)
+{
+  static GType object_type = 0;
+
+  if (!object_type)
+    {
+      object_type = g_type_register_static_simple (G_TYPE_INTERFACE,
+                                                   "FooInterface",
+                                                   sizeof (FooInterfaceIface),
+                                                   NULL, 0, NULL, 0);
+
+      g_type_interface_add_prerequisite (object_type, G_TYPE_OBJECT);
+    }
+
+  return object_type;
+}
+
 G_DEFINE_TYPE (FooObject, foo_object, G_TYPE_OBJECT);
 
 static void