+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:
/* 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
}
}
+ /* 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);
<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>
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 $@
#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;
#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