gobject-introspection r93 - in trunk: . src tests/parser



Author: juergbi
Date: Fri Jan 11 17:52:29 2008
New Revision: 93
URL: http://svn.gnome.org/viewvc/gobject-introspection?rev=93&view=rev

Log:
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.


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

Modified: trunk/src/scanner.c
==============================================================================
--- trunk/src/scanner.c	(original)
+++ trunk/src/scanner.c	Fri Jan 11 17:52:29 2008
@@ -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 @@
 	}
     }
 
+  /* 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);
 

Modified: trunk/tests/parser/Foo-expected.gidl
==============================================================================
--- trunk/tests/parser/Foo-expected.gidl	(original)
+++ trunk/tests/parser/Foo-expected.gidl	Fri Jan 11 17:52:29 2008
@@ -20,5 +20,10 @@
 				<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>

Modified: trunk/tests/parser/Makefile.am
==============================================================================
--- trunk/tests/parser/Makefile.am	(original)
+++ trunk/tests/parser/Makefile.am	Fri Jan 11 17:52:29 2008
@@ -14,7 +14,7 @@
 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 $@

Modified: trunk/tests/parser/foo-object.h
==============================================================================
--- trunk/tests/parser/foo-object.h	(original)
+++ trunk/tests/parser/foo-object.h	Fri Jan 11 17:52:29 2008
@@ -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))
@@ -11,11 +15,20 @@
 #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;

Modified: trunk/tests/parser/foo.c
==============================================================================
--- trunk/tests/parser/foo.c	(original)
+++ trunk/tests/parser/foo.c	Fri Jan 11 17:52:29 2008
@@ -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



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]