summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohan Dahlin <johan@gnome.org>2008-08-08 19:09:17 +0000
committerJohan Dahlin <johan@src.gnome.org>2008-08-08 19:09:17 +0000
commit1401ee41cf294451c139e534ec7afc32acafd81f (patch)
tree2847e9fc6d798f206dd066025cccb7ae8cd4d686
parent8c20989ef537bdc718f62a41f9524cf34920e31a (diff)
downloadgobject-introspection-1401ee41cf294451c139e534ec7afc32acafd81f.tar.gz
Merge in the gir-compiler branch. Thanks to Philip and Colin for their
2008-08-08 Johan Dahlin <johan@gnome.org> * girepository/gtypelib.c (validate_header): * girepository/gtypelib.h: * giscanner/ast.py: * giscanner/girwriter.py: * giscanner/sourcescanner.c (gi_source_symbol_ref), (gi_source_symbol_unref): * tests/array.test: * tests/boxed.test: * tests/constant.test: * tests/enum.test: * tests/errors.test: * tests/function.test: * tests/gobject.test: * tests/interface.test: * tests/invoke/Makefile.am: * tests/invoke/testfns.xml: * tests/object.test: * tests/parser/Makefile.am: * tests/roundtrips.sh: * tests/struct.test: * tests/types.test: * tests/union.test: * tests/xref1.test: * tests/xref2.test: * tools/Makefile.am: * tools/compiler.c (main): * tools/generate.c (write_callable_info), (write_function_info), (write_repository): * tools/gidlmodule.c: * tools/gidlmodule.h: * tools/gidlnode.c: * tools/gidlnode.h: * tools/gidlparser.c: * tools/gidlparser.h: * tools/gidlwriter.c: * tools/gidlwriter.h: * tools/scanner.c (create_node_from_gtype), (create_node_from_ctype), (g_igenerator_process_properties), (g_igenerator_process_signals), (g_igenerator_create_object), (g_igenerator_create_interface), (g_igenerator_create_boxed), (g_igenerator_create_enum), (g_igenerator_create_flags), (g_igenerator_process_function_symbol), (g_igenerator_process_unregistered_struct_typedef), (g_igenerator_process_struct_typedef), (g_igenerator_process_union_typedef), (g_igenerator_process_enum_typedef), (g_igenerator_process_function_typedef), (g_igenerator_process_constant), (g_igenerator_process_symbols), (g_igenerator_add_module), (g_igenerator_add_include_idl): Merge in the gir-compiler branch. Thanks to Philip and Colin for their help. svn path=/trunk/; revision=325
-rw-r--r--ChangeLog54
-rw-r--r--girepository/gtypelib.c2
-rw-r--r--girepository/gtypelib.h7
-rw-r--r--giscanner/ast.py5
-rw-r--r--giscanner/girwriter.py6
-rw-r--r--giscanner/sourcescanner.c3
-rw-r--r--tests/array.test51
-rw-r--r--tests/boxed.test91
-rw-r--r--tests/constant.test7
-rw-r--r--tests/enum.test7
-rw-r--r--tests/errors.test7
-rw-r--r--tests/function.test7
-rw-r--r--tests/gobject.test7
-rw-r--r--tests/interface.test7
-rw-r--r--tests/invoke/Makefile.am10
-rwxr-xr-xtests/invoke/testfns.gir64
-rw-r--r--tests/invoke/testfns.xml62
-rw-r--r--tests/object.test63
-rw-r--r--tests/parser/Makefile.am4
-rwxr-xr-xtests/roundtrips.sh36
-rw-r--r--tests/struct.test7
-rw-r--r--tests/types.test7
-rw-r--r--tests/union.test7
-rw-r--r--tests/xref1.test7
-rw-r--r--tests/xref2.test7
-rw-r--r--tools/Makefile.am30
-rw-r--r--tools/compiler.c26
-rw-r--r--tools/generate.c13
-rw-r--r--tools/girmodule.c (renamed from tools/gidlmodule.c)38
-rw-r--r--tools/girmodule.h (renamed from tools/gidlmodule.h)20
-rw-r--r--tools/girnode.c (renamed from tools/gidlnode.c)880
-rw-r--r--tools/girnode.h (renamed from tools/gidlnode.h)198
-rw-r--r--tools/girparser.c (renamed from tools/gidlparser.c)1339
-rw-r--r--tools/girparser.h (renamed from tools/gidlparser.h)18
-rw-r--r--tools/girwriter.c (renamed from tools/gidlwriter.c)57
-rw-r--r--tools/girwriter.h (renamed from tools/gidlwriter.h)0
-rw-r--r--tools/scanner.c203
37 files changed, 1976 insertions, 1381 deletions
diff --git a/ChangeLog b/ChangeLog
index 78eb372a..9d7504c5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,57 @@
+2008-08-08 Johan Dahlin <johan@gnome.org>
+
+ * girepository/gtypelib.c (validate_header):
+ * girepository/gtypelib.h:
+ * giscanner/ast.py:
+ * giscanner/girwriter.py:
+ * giscanner/sourcescanner.c (gi_source_symbol_ref),
+ (gi_source_symbol_unref):
+ * tests/array.test:
+ * tests/boxed.test:
+ * tests/constant.test:
+ * tests/enum.test:
+ * tests/errors.test:
+ * tests/function.test:
+ * tests/gobject.test:
+ * tests/interface.test:
+ * tests/invoke/Makefile.am:
+ * tests/invoke/testfns.xml:
+ * tests/object.test:
+ * tests/parser/Makefile.am:
+ * tests/roundtrips.sh:
+ * tests/struct.test:
+ * tests/types.test:
+ * tests/union.test:
+ * tests/xref1.test:
+ * tests/xref2.test:
+ * tools/Makefile.am:
+ * tools/compiler.c (main):
+ * tools/generate.c (write_callable_info), (write_function_info),
+ (write_repository):
+ * tools/gidlmodule.c:
+ * tools/gidlmodule.h:
+ * tools/gidlnode.c:
+ * tools/gidlnode.h:
+ * tools/gidlparser.c:
+ * tools/gidlparser.h:
+ * tools/gidlwriter.c:
+ * tools/gidlwriter.h:
+ * tools/scanner.c (create_node_from_gtype),
+ (create_node_from_ctype), (g_igenerator_process_properties),
+ (g_igenerator_process_signals), (g_igenerator_create_object),
+ (g_igenerator_create_interface), (g_igenerator_create_boxed),
+ (g_igenerator_create_enum), (g_igenerator_create_flags),
+ (g_igenerator_process_function_symbol),
+ (g_igenerator_process_unregistered_struct_typedef),
+ (g_igenerator_process_struct_typedef),
+ (g_igenerator_process_union_typedef),
+ (g_igenerator_process_enum_typedef),
+ (g_igenerator_process_function_typedef),
+ (g_igenerator_process_constant), (g_igenerator_process_symbols),
+ (g_igenerator_add_module), (g_igenerator_add_include_idl):
+ Merge in the gir-compiler branch.
+ Thanks to Philip and Colin for their help.
+
2008-07-26 Colin Walters <walters@verbum.org>
* tools/Makefile.am (bin_PROGRAMS): Install g-idl-compiler
diff --git a/girepository/gtypelib.c b/girepository/gtypelib.c
index 3df1918b..cc07e96e 100644
--- a/girepository/gtypelib.c
+++ b/girepository/gtypelib.c
@@ -113,7 +113,7 @@ validate_header (GTypelib *metadata,
header = (Header *)metadata->data;
- if (strncmp (header->magic, G_IDL_MAGIC, 16) != 0)
+ if (strncmp (header->magic, G_IR_MAGIC, 16) != 0)
{
g_set_error (error,
G_TYPELIB_ERROR,
diff --git a/girepository/gtypelib.h b/girepository/gtypelib.h
index 352c3a8e..0152a958 100644
--- a/girepository/gtypelib.h
+++ b/girepository/gtypelib.h
@@ -27,7 +27,7 @@
G_BEGIN_DECLS
-#define G_IDL_MAGIC "GOBJ\nMETADATA\r\n\032"
+#define G_IR_MAGIC "GOBJ\nMETADATA\r\n\032"
enum
{
@@ -126,7 +126,10 @@ typedef enum
TYPE_TAG_LIST = 22,
TYPE_TAG_SLIST = 23,
TYPE_TAG_HASH = 24,
- TYPE_TAG_ERROR = 25
+ TYPE_TAG_ERROR = 25,
+ TYPE_TAG_STRING = 26,
+ TYPE_TAG_SEQUENCE = 27,
+ TYPE_TAG_ANY = 28
} TypeTag;
typedef union
diff --git a/giscanner/ast.py b/giscanner/ast.py
index ca5e66d5..cf744a95 100644
--- a/giscanner/ast.py
+++ b/giscanner/ast.py
@@ -94,9 +94,10 @@ type_names['ssize_t'] = TYPE_SSIZE
def type_name_from_ctype(ctype):
return type_names.get(ctype, ctype)
-
-
+
+
class Node(object):
+
def __init__(self, name=None):
self.name = name
diff --git a/giscanner/girwriter.py b/giscanner/girwriter.py
index af297e79..79287898 100644
--- a/giscanner/girwriter.py
+++ b/giscanner/girwriter.py
@@ -115,13 +115,13 @@ class GIRWriter(XMLWriter):
with self.tagcontext('parameter', attrs):
self._write_type(parameter.type)
- def _write_type(self, type):
- attrs = [('name', type.name)]
+ def _write_type(self, ntype):
+ attrs = [('name', ntype.name)]
# FIXME: figure out if type references a basic type
# or a boxed/class/interface etc. and skip
# writing the ctype if the latter.
if type.ctype is not None:
- attrs.append(('c:type', type.ctype))
+ attrs.append(('c:type', ntype.ctype))
self.write_tag('type', attrs)
def _write_sequence(self, sequence):
diff --git a/giscanner/sourcescanner.c b/giscanner/sourcescanner.c
index 0087f60d..34cb57f4 100644
--- a/giscanner/sourcescanner.c
+++ b/giscanner/sourcescanner.c
@@ -44,11 +44,14 @@ GISourceSymbol *
gi_source_symbol_ref (GISourceSymbol * symbol)
{
symbol->ref_count++;
+ return symbol;
}
void
gi_source_symbol_unref (GISourceSymbol * symbol)
{
+ if (!symbol)
+ return;
symbol->ref_count--;
if (symbol->ref_count == 0)
{
diff --git a/tests/array.test b/tests/array.test
index f204389b..5405c471 100644
--- a/tests/array.test
+++ b/tests/array.test
@@ -1,25 +1,50 @@
<?xml version="1.0"?>
-<api version="1.0">
+<repository version="1.0"
+ xmlns="http://www.gtk.org/introspection/core/1.0"
+ xmlns:c="http://www.gtk.org/introspection/c/1.0"
+ xmlns:glib="http://www.gtk.org/introspection/glib/1.0">
<namespace name="Foo">
- <function name="test1" symbol="test1">
- <return-type type="gboolean" />
+ <function name="test1" c:identifier="test1">
+ <return-value>
+ <type name="boolean" c:type="gboolean"/>
+ </return-value>
<parameters>
- <parameter name="p1" type="guint8[length=1,zero-terminated=1]" transfer="full" direction="in" />
- <parameter name="p2" type="gint" direction="in" />
+ <parameter name="p1">
+ <type name="sequence" c:type="guint8*" length="1" zero-terminated="1">
+ <type name="uint8" c:type="guint8"/>
+ </type>
+ </parameter>
+ <parameter name="p2">
+ <type name="int" c:type="gint"/>
+ </parameter>
</parameters>
</function>
- <function name="test2" symbol="test2">
- <return-type type="gboolean" />
+ <function name="test2" c:identifier="test2">
+ <return-value>
+ <type name="boolean" c:type="gboolean"/>
+ </return-value>
<parameters>
- <parameter name="p2" type="gint" direction="out" />
- <parameter name="p1" type="guint8[length=0]" transfer="full" direction="out" />
+ <parameter name="p2">
+ <type name="uint" c:type="gint" direction="out"/>
+ </parameter>
+ <parameter name="p1">
+ <type name="sequence" c:type="guint8*" length="0" directon="out">
+ <type name="uint8" c:type="guint8"/>
+ </type>
+ </parameter>
</parameters>
</function>
- <function name="test3" symbol="test3">
- <return-type type="gboolean" />
+ <function name="test3" c:identifier="test3">
+ <return-value>
+ <type name="boolean" c:type="gboolean"/>
+ </return-value>
<parameters>
- <parameter name="p1" type="guint8[zero-terminated=1]" transfer="full" direction="in" />
+ <parameter name="p1">
+ <type name="sequence" c:type="guint8*" length="1" zero-terminated="1">
+ <type name="uint8" c:type="guint8"/>
+ </type>
+ </parameter>
</parameters>
</function>
</namespace>
-</api>
+</repository>
diff --git a/tests/boxed.test b/tests/boxed.test
index 29ae8854..fb1b18c0 100644
--- a/tests/boxed.test
+++ b/tests/boxed.test
@@ -1,35 +1,80 @@
<?xml version="1.0"?>
-<api version="1.0">
+<repository version="1.0"
+ xmlns="http://www.gtk.org/introspection/core/1.0"
+ xmlns:c="http://www.gtk.org/introspection/c/1.0"
+ xmlns:glib="http://www.gtk.org/introspection/glib/1.0">
<namespace name="Foo">
- <boxed name="boxed1" type-name="BoxedType1" get-type="boxed1_get_type" deprecated="1">
- <field name="field1" readable="1" writable="1" offset="0" type="guint32" />
- <field name="field2" readable="1" writable="1" offset="4" type="guint32" />
- <field name="field3" readable="1" writable="1" offset="8" type="guint32" />
- <method name="frob_boxed1" symbol="frob_boxed1">
- <return-type type="void" />
+ <glib:boxed glib:name="BoxedType1" glib:type-name="boxed1" glib:get-type="boxed1_get_type" deprecated="1">
+ <field name="field1" readable="1" writable="1" offset="0">
+ <type name="guint32" c:type="guint32"/>
+ </field>
+ <field name="field2" readable="1" writable="1" offset="4">
+ <type name="guint32" c:type="guint32"/>
+ </field>
+ <field name="field3" readable="1" writable="1" offset="8">
+ <type name="guint32" c:type="guint32"/>
+ </field>
+ <method name="frob_boxed1" c:identifier="frob_boxed1">
+ <return-value>
+ <!-- FIXME: name=void should be none -->
+ <type name="void" c:type="void" />
+ </return-value>
<parameters>
- <parameter name="box" type="boxed1*" transfer="full" direction="in" />
- <parameter name="w" type="GList<boxed2*>*" transfer="full" direction="in" />
- <parameter name="t" type="GHashTable<utf8,gint64>*" transfer="full" direction="in" />
- <parameter name="e" type="GError*" transfer="full" direction="out" />
+ <parameter name="box" transfer="full" direction="in">
+ <type name="BoxedType1" c:type="boxed1*"/>
+ </parameter>
+ <parameter name="w" transfer="full" direction="in">
+ <!-- FIXME: put this in a sub node -->
+ <!--
+ <type name="sequence" c:type="GList*">
+ <type name="boxed2" c:type="boxed2*"/>
+ </type>
+ -->
+ <type name="GList<boxed2*>*" c:type="GList*"/>
+ </parameter>
+ <parameter name="t" transfer="full" direction="in">
+ <!-- FIXME: put this in a sub node -->
+ <!--
+ <type name="mapping" c:type="GHashTable*">
+ <type name="utf8" c:type="gchar*"/>
+ <type name="int64" c:type="gint64"/>
+ </type>
+ -->
+ <type name="GHashTable<utf8,gint64>*" c:type="GHashTable*"/>
+ </parameter>
+ <parameter name="e" transfer="full" direction="out">
+ <type name="GError" c:type="GError**"/>
+ </parameter>
</parameters>
</method>
- <method name="lart" symbol="lart">
- <return-type type="gboolean" />
+ <method name="lart" c:identifier="lart">
+ <return-value>
+ <type name="boolean" c:type="gboolean"/>
+ </return-value>
<parameters>
- <parameter name="box" type="boxed2*" transfer="full" direction="in" />
- <parameter name="val" type="gint*" transfer="full" direction="inout" />
+ <parameter name="box" transfer="full" direction="in">
+ <type name="boxed2*" c:type="boxed2*"/>
+ </parameter>
+ <parameter name="val" transfer="full" direction="inout">
+ <type name="uint" c:type="guint*"/>
+ </parameter>
</parameters>
</method>
- </boxed>
- <function name="freefunc" symbol="freefunc" deprecated="1">
- <return-type type="gint" />
+ </glib:boxed>
+ <function name="freefunc" c:identifier="freefunc" deprecated="1">
+ <return-value>
+ <type name="boolean" c:type="gboolean"/>
+ </return-value>
<parameters>
- <parameter name="v1" type="gint" direction="in" />
- <parameter name="val2" type="gint" direction="in" />
+ <parameter name="v1" direction="in">
+ <type name="int" c:type="gint"/>
+ </parameter>
+ <parameter name="val2" direction="in">
+ <type name="int" c:type="gint"/>
+ </parameter>
</parameters>
</function>
- <boxed name="boxed2" type-name="BoxedType2" get-type="boxed2_get_type" deprecated="1">
- </boxed>
+ <glib:boxed glib:name="boxed2" glib:type-name="BoxedType2" glib:get-type="boxed2_get_type" deprecated="1">
+ </glib:boxed>
</namespace>
-</api>
+</repository>
diff --git a/tests/constant.test b/tests/constant.test
index ed3671c5..f5da5358 100644
--- a/tests/constant.test
+++ b/tests/constant.test
@@ -1,5 +1,8 @@
<?xml version="1.0"?>
-<api version="1.0">
+<repository version="1.0"
+ xmlns="http://www.gtk.org/introspection/core/1.0"
+ xmlns:c="http://www.gtk.org/introspection/c/1.0"
+ xmlns:glib="http://www.gtk.org/introspection/glib/1.0">
<namespace name="Foo">
<constant name="constant1" type="gint" value="42" />
<constant name="constant2" type="guint" value="42" />
@@ -7,4 +10,4 @@
<constant name="constant4" type="gint32" value="42" />
<constant name="constant5" type="gfloat" value="42.000000" />
</namespace>
-</api>
+</repository>
diff --git a/tests/enum.test b/tests/enum.test
index 1e056248..f91e6a95 100644
--- a/tests/enum.test
+++ b/tests/enum.test
@@ -1,5 +1,8 @@
<?xml version="1.0"?>
-<api version="1.0">
+<repository version="1.0"
+ xmlns="http://www.gtk.org/introspection/core/1.0"
+ xmlns:c="http://www.gtk.org/introspection/c/1.0"
+ xmlns:glib="http://www.gtk.org/introspection/glib/1.0">
<namespace name="Foo">
<enum name="Enum1" type-name="FooEnum" get-type="foo_enum_get_type">
<member name="value1" value="0" />
@@ -17,4 +20,4 @@
<member name="value3" value="2" />
</enum>
</namespace>
-</api>
+</repository>
diff --git a/tests/errors.test b/tests/errors.test
index ac67c369..206640f2 100644
--- a/tests/errors.test
+++ b/tests/errors.test
@@ -1,5 +1,8 @@
<?xml version="1.0"?>
-<api version="1.0">
+<repository version="1.0"
+ xmlns="http://www.gtk.org/introspection/core/1.0"
+ xmlns:c="http://www.gtk.org/introspection/c/1.0"
+ xmlns:glib="http://www.gtk.org/introspection/glib/1.0">
<namespace name="Foo">
<enum name="ErrorCodes1" type-name="ErrorCodes1" get-type="foo_error_codes1_get_type">
<member name="e1" value="0" />
@@ -19,4 +22,4 @@
</parameters>
</function>
</namespace>
-</api>
+</repository>
diff --git a/tests/function.test b/tests/function.test
index 74691d38..cabeb2e8 100644
--- a/tests/function.test
+++ b/tests/function.test
@@ -1,5 +1,8 @@
<?xml version="1.0"?>
-<api version="1.0">
+<repository version="1.0"
+ xmlns="http://www.gtk.org/introspection/core/1.0"
+ xmlns:c="http://www.gtk.org/introspection/c/1.0"
+ xmlns:glib="http://www.gtk.org/introspection/glib/1.0">
<namespace name="Foo">
<boxed name="Boxed1" type-name="Boxed1" get-type="boxed1_get_type">
</boxed>
@@ -18,4 +21,4 @@
</parameters>
</callback>
</namespace>
-</api>
+</repository>
diff --git a/tests/gobject.test b/tests/gobject.test
index 4715e26a..aa4aa3ae 100644
--- a/tests/gobject.test
+++ b/tests/gobject.test
@@ -1,7 +1,10 @@
<?xml version="1.0"?>
-<api version="1.0">
+<repository version="1.0"
+ xmlns="http://www.gtk.org/introspection/core/1.0"
+ xmlns:c="http://www.gtk.org/introspection/c/1.0"
+ xmlns:glib="http://www.gtk.org/introspection/glib/1.0">
<namespace name="GObject">
<object name="GObject" type-name="GObject" get-type="g_object_get_type">
</object>
</namespace>
-</api>
+</repository>
diff --git a/tests/interface.test b/tests/interface.test
index 08921bce..35ea45eb 100644
--- a/tests/interface.test
+++ b/tests/interface.test
@@ -1,5 +1,8 @@
<?xml version="1.0"?>
-<api version="1.0">
+<repository version="1.0"
+ xmlns="http://www.gtk.org/introspection/core/1.0"
+ xmlns:c="http://www.gtk.org/introspection/c/1.0"
+ xmlns:glib="http://www.gtk.org/introspection/glib/1.0">
<namespace name="Foo">
<interface name="Iface1" type-name="Iface1" get-type="iface1_get_type">
<requires>
@@ -35,4 +38,4 @@
<interface name="Iface2" type-name="Iface2" get-type="iface2_get_type">
</interface>
</namespace>
-</api>
+</repository>
diff --git a/tests/invoke/Makefile.am b/tests/invoke/Makefile.am
index b56ca4dc..fa83d7be 100644
--- a/tests/invoke/Makefile.am
+++ b/tests/invoke/Makefile.am
@@ -16,11 +16,11 @@ testfns_la_LIBADD = $(GIREPO_LIBS) $(top_builddir)/girepository/libgirepository.
BUILT_SOURCES = testfns-metadata.c test.repo
CLEANFILES = testfns-metadata.c test.repo
-testfns-metadata.c: testfns.xml $(top_builddir)/tools/g-idl-compiler
- $(top_builddir)/tools/g-idl-compiler $(srcdir)/testfns.xml -o testfns-metadata.c
+testfns-metadata.c: testfns.gir $(top_builddir)/tools/g-ir-compiler
+ $(CHECK_DEBUG) $(top_builddir)/tools/g-ir-compiler $(srcdir)/testfns.gir -o testfns-metadata.c
-test.repo: testfns.xml
- $(top_builddir)/tools/g-idl-compiler --shared-library testfns.la $< --raw -o $@
+test.repo: testfns.gir
+ $(CHECK_DEBUG) $(top_builddir)/tools/g-ir-compiler --shared-library testfns.la $< --raw -o $@
invoke_SOURCES = invoke.c
invoke_CFLAGS = $(GIREPO_CFLAGS) -I$(top_srcdir)/girepository
@@ -28,6 +28,6 @@ invoke_LDADD = $(GIREPO_LIBS) $(top_builddir)/girepository/libgirepository.la
TESTS = invoke invoke-namespace-find.sh
-EXTRA_DIST = invoke-namespace-find.sh testfns.xml
+EXTRA_DIST = invoke-namespace-find.sh testfns.gir
TESTS_ENVIRONMENT = GIREPOPATH="."
diff --git a/tests/invoke/testfns.gir b/tests/invoke/testfns.gir
new file mode 100755
index 00000000..4d6c520d
--- /dev/null
+++ b/tests/invoke/testfns.gir
@@ -0,0 +1,64 @@
+<?xml version="1.0"?>
+<repository version="1.0"
+ xmlns="http://www.gtk.org/introspection/core/1.0"
+ xmlns:c="http://www.gtk.org/introspection/c/1.0"
+ xmlns:glib="http://www.gtk.org/introspection/glib/1.0">
+ <namespace name="test">
+ <function name="test1" c:identifier="test1">
+ <return-type c:type="gint"/>
+ <parameters>
+ <parameter name="in" c:type="gint" direction="in"/>
+ </parameters>
+ </function>
+
+ <function name="test2" c:identifier="test2">
+ <return-type c:type="void"/>
+ <parameters>
+ <parameter name="in" c:type="gint" direction="in"/>
+ <parameter name="out" c:type="gint" direction="out"/>
+ </parameters>
+ </function>
+
+ <function name="test3" c:identifier="test3">
+ <return-type c:type="void"/>
+ <parameters>
+ <parameter name="inout" c:type="gint" direction="inout"/>
+ </parameters>
+ </function>
+
+ <function name="test4" c:identifier="test4">
+ <return-type c:type="void"/>
+ <parameters>
+ <parameter name="blurb" c:type="gchar*" direction="in"/>
+ </parameters>
+ </function>
+
+ <function name="test5" c:identifier="test5">
+ <return-type c:type="void"/>
+ <parameters>
+ <parameter name="blurb" c:type="gchar*" direction="out" transfer="full"/>
+ <parameter name="len" c:type="gint" direction="out"/>
+ </parameters>
+ </function>
+
+ <function name="test6" c:identifier="test6">
+ <return-type c:type="gint"/>
+ <parameters>
+ <parameter name="list" c:type="GList<gint>*" direction="in"/>
+ </parameters>
+ </function>
+
+
+ <function name="test7" c:identifier="test7">
+ <return-type c:type="utf8" transfer="full"/>
+ <parameters>
+ <parameter name="list" c:type="GList<utf8>*" direction="in"/>
+ </parameters>
+ </function>
+
+ <function name="broken" c:identifier="broken">
+ <return-type c:type="void"/>
+ </function>
+
+ </namespace>
+</repository>
diff --git a/tests/invoke/testfns.xml b/tests/invoke/testfns.xml
deleted file mode 100644
index 7997bfa8..00000000
--- a/tests/invoke/testfns.xml
+++ /dev/null
@@ -1,62 +0,0 @@
-<?xml version="1.0"?>
-<api version="1.0">
- <namespace name="test">
-
- <function name="test1" symbol="test1">
- <return-type type="gint"/>
- <parameters>
- <parameter name="in" type="gint" direction="in"/>
- </parameters>
- </function>
-
- <function name="test2" symbol="test2">
- <return-type type="void"/>
- <parameters>
- <parameter name="in" type="gint" direction="in"/>
- <parameter name="out" type="gint" direction="out"/>
- </parameters>
- </function>
-
- <function name="test3" symbol="test3">
- <return-type type="void"/>
- <parameters>
- <parameter name="inout" type="gint" direction="inout"/>
- </parameters>
- </function>
-
- <function name="test4" symbol="test4">
- <return-type type="void"/>
- <parameters>
- <parameter name="blurb" type="gchar*" direction="in"/>
- </parameters>
- </function>
-
- <function name="test5" symbol="test5">
- <return-type type="void"/>
- <parameters>
- <parameter name="blurb" type="gchar*" direction="out" transfer="full"/>
- <parameter name="len" type="gint" direction="out"/>
- </parameters>
- </function>
-
- <function name="test6" symbol="test6">
- <return-type type="gint"/>
- <parameters>
- <parameter name="list" type="GList<gint>*" direction="in"/>
- </parameters>
- </function>
-
-
- <function name="test7" symbol="test7">
- <return-type type="utf8" transfer="full"/>
- <parameters>
- <parameter name="list" type="GList<utf8>*" direction="in"/>
- </parameters>
- </function>
-
- <function name="broken" symbol="broken">
- <return-type type="void"/>
- </function>
-
- </namespace>
-</api>
diff --git a/tests/object.test b/tests/object.test
index d0f26bc1..dfaf732b 100644
--- a/tests/object.test
+++ b/tests/object.test
@@ -1,40 +1,61 @@
<?xml version="1.0"?>
-<api version="1.0">
+<repository version="1.0"
+ xmlns="http://www.gtk.org/introspection/core/1.0"
+ xmlns:c="http://www.gtk.org/introspection/c/1.0"
+ xmlns:glib="http://www.gtk.org/introspection/glib/1.0">
<namespace name="Foo">
- <object name="Object1" parent="Object2" type-name="Object1" get-type="object1_get_type">
+ <class name="Object1" parent="Object2" glib:type-name="Object1" glib:get-type="object1_get_type">
<implements>
<interface name="Iface1" />
</implements>
- <property name="prop1" readable="0" writable="0" type="gint" />
- <signal name="signal1" when="LAST">
- <return-type type="gboolean" />
+ <property name="prop1" readable="0" writable="0">
+ <type name="int" c:type="gint"/>
+ </property>
+ <glib:signal name="signal1" when="LAST">
+ <return-value>
+ <type name="boolean" c:type="gboolean"/>
+ </return-value>
<parameters>
- <parameter name="obj" type="Object1*" transfer="full" direction="in" />
+ <parameter name="obj" transfer="full" direction="in">
+ <type name="Object1" c:type="Object1*"/>
+ </parameter>
</parameters>
- </signal>
- <signal name="signal2" when="FIRST" no-recurse="1" detailed="1" action="1" no-hooks="1">
- <return-type type="void" />
+ </glib:signal>
+ <glib:signal name="signal2" when="FIRST" no-recurse="1" detailed="1" action="1" no-hooks="1">
+ <return-value>
+ <type name="void" c:type="void"/>
+ </return-value>
<parameters>
- <parameter name="obj" type="Object1*" transfer="full" direction="in" />
+ <parameter name="obj" transfer="full" direction="in">
+ <type name="Object1" c:type="Object1*"/>
+ </parameter>
</parameters>
- </signal>
+ </glib:signal>
<vfunc name="vfunc1" offset="20">
- <return-type type="Object2*" transfer="full" />
+ <return-value>
+ <type name="Object2" c:type="Object2*"/>
+ </return-value>
<parameters>
- <parameter name="param1" type="Object1*" transfer="full" direction="in" />
+ <parameter name="param1" transfer="full" direction="in">
+ <type name="Object1" c:type="Object1*"/>
+ </parameter>
</parameters>
</vfunc>
<vfunc name="vfunc2" offset="24">
- <return-type type="Object2*" transfer="full" />
+ <return-value>
+ <type name="Object2" c:type="Object2*"/>
+ </return-value>
<parameters>
- <parameter name="param1" type="Object1*" transfer="full" direction="in" />
+ <parameter name="param1" transfer="full" direction="in">
+ <type name="Object1" c:type="Object1*"/>
+ </parameter>
</parameters>
</vfunc>
- <constant name="constant1" type="gint" value="42" />
- </object>
- <interface name="Iface1" type-name="Iface1" get-type="iface1_get_type">
+ </class>
+ <constant name="constant1" c:type="gint" value="42" />
+ <interface name="Iface1" glib:type-name="Iface1" glib:get-type="iface1_get_type">
</interface>
- <object name="Object2" parent="GObject.GObject" type-name="Object2" get-type="object2_get_type">
- </object>
+ <class name="Object2" parent="GObject.GObject" glib:type-name="Object2" glib:get-type="object2_get_type">
+ </class>
</namespace>
-</api>
+</repository>
diff --git a/tests/parser/Makefile.am b/tests/parser/Makefile.am
index 93c7d324..1debff3f 100644
--- a/tests/parser/Makefile.am
+++ b/tests/parser/Makefile.am
@@ -20,7 +20,7 @@ EXTRA_DIST = utility-expected.gir Foo-expected.gir
SCANNER = $(top_srcdir)/tools/g-ir-scanner
utility.gir: libutility.la utility.h $(SCANNER)
- @$(SCANNER) -v \
+ @$(CHECK_DEBUG) $(SCANNER) -v \
--include=$(top_srcdir)/gir/gobject-2.0.gir \
--library=libutility.la \
--namespace=utility \
@@ -29,7 +29,7 @@ utility.gir: libutility.la utility.h $(SCANNER)
--output $@
Foo.gir: libfoo.la foo-object.h $(SCANNER)
- @$(SCANNER) -v \
+ @$(CHECK_DEBUG) $(SCANNER) -v \
--include=$(top_srcdir)/gir/gobject-2.0.gir \
--include=$(top_builddir)/tests/parser/utility.gir \
--library=libfoo.la \
diff --git a/tests/roundtrips.sh b/tests/roundtrips.sh
index 65ef78a4..9cf8e77f 100755
--- a/tests/roundtrips.sh
+++ b/tests/roundtrips.sh
@@ -1,26 +1,28 @@
#! /bin/sh
-SIMPLE_TESTS="array.test boxed.test enum.test errors.test function.test interface.test struct.test union.test"
+set -x
+set -e
-for i in $SIMPLE_TESTS; do
- echo $i
- ../tools/g-idl-compiler --raw $srcdir/$i > $i.1;
- ../tools/g-idl-generate --raw $i.1 > $i.2;
+TESTFILES=$(echo "${srcdir}"/../../gir-repository/gir/*.gir)
+
+for i in $TESTFILES; do
+ ${CHECK_DEBUG} ../tools/g-ir-compiler --raw $i > $i.1;
+ ${CHECK_DEBUG} ../tools/g-ir-generate --raw $i.1 > $i.2;
diff -u $srcdir/$i $i.2 || exit 1;
rm $i.1 $i.2
done
-../tools/g-idl-compiler --raw --module=Foo $srcdir/object.test $srcdir/gobject.test > object.test.1
-../tools/g-idl-generate --raw object.test.1 > object.test.2
-diff -u $srcdir/object.test object.test.2 || exit 1
-rm object.test.1 object.test.2
+#../tools/g-ir-compiler --raw --module=Foo $srcdir/object.test $srcdir/gobject.test > object.test.1
+#../tools/g-ir-generate --raw object.test.1 > object.test.2
+#diff -u $srcdir/object.test object.test.2 || exit 1
+#rm object.test.1 object.test.2
-../tools/g-idl-compiler --raw --module=Foo $srcdir/xref1.test $srcdir/xref2.test > xref1.test.1
-../tools/g-idl-generate --raw xref1.test.1 > xref1.test.2
-diff -u $srcdir/xref1.test xref1.test.2 || exit 1
-rm xref1.test.1 xref1.test.2
+#../tools/g-ir-compiler --raw --module=Foo $srcdir/xref1.test $srcdir/xref2.test > xref1.test.1
+#../tools/g-ir-generate --raw xref1.test.1 > xref1.test.2
+#diff -u $srcdir/xref1.test xref1.test.2 || exit 1
+#rm xref1.test.1 xref1.test.2
-../tools/g-idl-compiler --raw --module=Bar $srcdir/xref1.test $srcdir/xref2.test > xref2.test.1
-../tools/g-idl-generate --raw xref2.test.1 > xref2.test.2
-diff -u $srcdir/xref2.test xref2.test.2 || exit 1
-rm xref2.test.1 xref2.test.2
+#../tools/g-ir-compiler --raw --module=Bar $srcdir/xref1.test $srcdir/xref2.test > xref2.test.1
+#../tools/g-ir-generate --raw xref2.test.1 > xref2.test.2
+#diff -u $srcdir/xref2.test xref2.test.2 || exit 1
+#rm xref2.test.1 xref2.test.2
diff --git a/tests/struct.test b/tests/struct.test
index 3596eb18..e94a4352 100644
--- a/tests/struct.test
+++ b/tests/struct.test
@@ -1,5 +1,8 @@
<?xml version="1.0"?>
-<api version="1.0">
+<repository version="1.0"
+ xmlns="http://www.gtk.org/introspection/core/1.0"
+ xmlns:c="http://www.gtk.org/introspection/c/1.0"
+ xmlns:glib="http://www.gtk.org/introspection/glib/1.0">
<namespace name="Foo">
<struct name="FooStruct">
<field name="foo_int" readable="1" writable="1" offset="0" type="gint" />
@@ -13,4 +16,4 @@
<field name="string" readable="1" writable="1" offset="24" type="utf8" />
</struct>
</namespace>
-</api>
+</repository>
diff --git a/tests/types.test b/tests/types.test
index e08d67a4..1c5b9028 100644
--- a/tests/types.test
+++ b/tests/types.test
@@ -1,5 +1,8 @@
<?xml version="1.0"?>
-<api version="1.0">
+<repository version="1.0"
+ xmlns="http://www.gtk.org/introspection/core/1.0"
+ xmlns:c="http://www.gtk.org/introspection/c/1.0"
+ xmlns:glib="http://www.gtk.org/introspection/glib/1.0">
<namespace name="Foo">
<function name="lart" symbol="lart">
<return-type type="gboolean" />
@@ -11,4 +14,4 @@
</parameters>
</function>
</namespace>
-</api>
+</repository>
diff --git a/tests/union.test b/tests/union.test
index 329512e1..9c4ae61a 100644
--- a/tests/union.test
+++ b/tests/union.test
@@ -1,5 +1,8 @@
<?xml version="1.0"?>
-<api version="1.0">
+<repository version="1.0"
+ xmlns="http://www.gtk.org/introspection/core/1.0"
+ xmlns:c="http://www.gtk.org/introspection/c/1.0"
+ xmlns:glib="http://www.gtk.org/introspection/glib/1.0">
<namespace name="Foo">
<union name="union1" type-name="UnionType1" get-type="union1_get_type">
<discriminator offset="-4" type="gint" />
@@ -11,4 +14,4 @@
<field name="field1" readable="1" writable="1" offset="0" type="gdouble" />
</union>
</namespace>
-</api>
+</repository>
diff --git a/tests/xref1.test b/tests/xref1.test
index bef65f6d..8eb57af6 100644
--- a/tests/xref1.test
+++ b/tests/xref1.test
@@ -1,5 +1,8 @@
<?xml version="1.0"?>
-<api version="1.0">
+<repository version="1.0"
+ xmlns="http://www.gtk.org/introspection/core/1.0"
+ xmlns:c="http://www.gtk.org/introspection/c/1.0"
+ xmlns:glib="http://www.gtk.org/introspection/glib/1.0">
<namespace name="Foo">
<boxed name="Boxed" type-name="FooBoxed" get-type="foo_boxed_get_type">
</boxed>
@@ -10,4 +13,4 @@
</parameters>
</function>
</namespace>
-</api>
+</repository>
diff --git a/tests/xref2.test b/tests/xref2.test
index 069c9c67..053e3223 100644
--- a/tests/xref2.test
+++ b/tests/xref2.test
@@ -1,5 +1,8 @@
<?xml version="1.0"?>
-<api version="1.0">
+<repository version="1.0"
+ xmlns="http://www.gtk.org/introspection/core/1.0"
+ xmlns:c="http://www.gtk.org/introspection/c/1.0"
+ xmlns:glib="http://www.gtk.org/introspection/glib/1.0">
<namespace name="Bar">
<boxed name="Boxed" type-name="BarBoxed" get-type="bar_boxed_get_type">
</boxed>
@@ -10,4 +13,4 @@
</parameters>
</function>
</namespace>
-</api>
+</repository>
diff --git a/tools/Makefile.am b/tools/Makefile.am
index 6ebfc382..2fb0e66b 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -8,29 +8,29 @@ INCLUDES = \
EXTRA_DIST = g-ir-scanner
noinst_LTLIBRARIES = libgirepository-parser.la
-bin_PROGRAMS = g-idl-compiler g-idl-generate
+bin_PROGRAMS = g-ir-compiler g-ir-generate
bin_SCRIPTS = g-ir-scanner
libgirepository_parser_la_SOURCES = \
- gidlmodule.c \
- gidlmodule.h \
- gidlnode.c \
- gidlnode.h \
- gidlparser.c \
- gidlparser.h
+ girmodule.c \
+ girmodule.h \
+ girnode.c \
+ girnode.h \
+ girparser.c \
+ girparser.h
libgirepository_parser_la_CFLAGS = $(GIREPO_CFLAGS)
-g_idl_compiler_SOURCES = compiler.c
-g_idl_compiler_CFLAGS = $(GIREPO_CFLAGS)
-g_idl_compiler_LDADD = $(GIREPO_LIBS) $(top_builddir)/girepository/libgirepository.la libgirepository-parser.la
+g_ir_compiler_SOURCES = compiler.c
+g_ir_compiler_CFLAGS = $(GIREPO_CFLAGS)
+g_ir_compiler_LDADD = $(GIREPO_LIBS) $(top_builddir)/girepository/libgirepository.la libgirepository-parser.la
-g_idl_generate_SOURCES = generate.c
-g_idl_generate_CFLAGS = $(GIREPO_CFLAGS)
-g_idl_generate_LDADD = $(GIREPO_LIBS) $(top_builddir)/girepository/libgirepository.la
+g_ir_generate_SOURCES = generate.c
+g_ir_generate_CFLAGS = $(GIREPO_CFLAGS)
+g_ir_generate_LDADD = $(GIREPO_LIBS) $(top_builddir)/girepository/libgirepository.la
GCOVSOURCES = \
$(libgirepository_la_SOURCES) \
- $(g_idl_compiler_SOURCES) \
- $(g_idl_generate_SOURCES)
+ $(g_ir_compiler_SOURCES) \
+ $(g_ir_generate_SOURCES)
include $(top_srcdir)/gcov.mak
diff --git a/tools/compiler.c b/tools/compiler.c
index 68fc3cae..4fff88dc 100644
--- a/tools/compiler.c
+++ b/tools/compiler.c
@@ -24,9 +24,9 @@
#include <glib.h>
#include <glib/gstdio.h>
-#include "gidlmodule.h"
-#include "gidlnode.h"
-#include "gidlparser.h"
+#include "girmodule.h"
+#include "girnode.h"
+#include "girparser.h"
#include "gtypelib.h"
gboolean raw = FALSE;
@@ -179,6 +179,7 @@ main (int argc, char ** argv)
logged_levels = logged_levels | G_LOG_LEVEL_DEBUG;
if (verbose)
logged_levels = logged_levels | G_LOG_LEVEL_MESSAGE;
+ g_log_set_always_fatal (G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL);
g_log_set_default_handler (log_handler, NULL);
@@ -189,11 +190,13 @@ main (int argc, char ** argv)
return 1;
}
+ g_debug ("[parsing] start");
+
modules = NULL;
for (i = 0; input[i]; i++)
{
GList *mods;
- mods = g_idl_parse_file (input[i], &error);
+ mods = g_ir_parse_file (input[i], &error);
if (mods == NULL)
{
@@ -206,9 +209,13 @@ main (int argc, char ** argv)
modules = g_list_concat (modules, mods);
}
+ g_debug ("[parsing] done");
+
+ g_debug ("[building] start");
+
for (m = modules; m; m = m->next)
{
- GIdlModule *module = m->data;
+ GIrModule *module = m->data;
gchar *prefix;
GTypelib *metadata;
@@ -220,7 +227,10 @@ main (int argc, char ** argv)
g_free (module->shared_library);
module->shared_library = g_strdup (shlib);
}
- metadata = g_idl_module_build_metadata (module, modules);
+
+ g_debug ("[building] module %s", module->name);
+
+ metadata = g_ir_module_build_metadata (module, modules);
if (metadata == NULL)
{
g_error ("Failed to build metadata for module '%s'\n", module->name);
@@ -248,6 +258,8 @@ main (int argc, char ** argv)
break;
}
}
-
+
+ g_debug ("[building] done");
+
return 0;
}
diff --git a/tools/generate.c b/tools/generate.c
index 3e057ef1..70085c93 100644
--- a/tools/generate.c
+++ b/tools/generate.c
@@ -237,7 +237,7 @@ write_callable_info (const gchar *namespace,
GITypeInfo *type;
gint i;
- g_fprintf (file, "%*s <return-type type=\"", indent, "");
+ g_fprintf (file, "%*s <return-type c:type=\"", indent, "");
type = g_callable_info_get_return_type (info);
write_type_info (namespace, type, file);
@@ -274,7 +274,7 @@ write_callable_info (const gchar *namespace,
{
GIArgInfo *arg = g_callable_info_get_arg (info, i);
- g_fprintf (file, "%*s <parameter name=\"%s\" type=\"",
+ g_fprintf (file, "%*s <parameter name=\"%s\" c:type=\"",
indent, "", g_base_info_get_name ((GIBaseInfo *) arg));
type = g_arg_info_get_type (arg);
@@ -360,7 +360,7 @@ write_function_info (const gchar *namespace,
else
tag = "function";
- g_fprintf (file, "%*s<%s name=\"%s\" symbol=\"%s\"",
+ g_fprintf (file, "%*s<%s name=\"%s\" c:identifier=\"%s\"",
indent, "", tag, name, symbol);
if (flags & GI_FUNCTION_IS_SETTER)
@@ -1019,7 +1019,10 @@ write_repository (GIRepository *repository,
}
g_fprintf (file, "<?xml version=\"1.0\"?>\n");
- g_fprintf (file, "<api version=\"1.0\">\n");
+ g_fprintf (file, "<repository version=\"1.0\"\n"
+ " xmlns=\"http://www.gtk.org/introspection/core/1.0\"\n"
+ " xmlns:c=\"http://www.gtk.org/introspection/c/1.0\"\n"
+ " xmlns:glib=\"http://www.gtk.org/introspection/glib/1.0\">\n");
for (i = 0; namespaces[i]; i++)
{
@@ -1085,7 +1088,7 @@ write_repository (GIRepository *repository,
g_fprintf (file, " </namespace>\n");
}
- g_fprintf (file, "</api>\n");
+ g_fprintf (file, "</repository>\n");
if (output != NULL)
fclose (file);
diff --git a/tools/gidlmodule.c b/tools/girmodule.c
index d543346b..8f09fb4a 100644
--- a/tools/gidlmodule.c
+++ b/tools/girmodule.c
@@ -21,19 +21,19 @@
#include <stdio.h>
#include <string.h>
-#include "gidlmodule.h"
-#include "gidlnode.h"
+#include "girmodule.h"
+#include "girnode.h"
#define ALIGN_VALUE(this, boundary) \
(( ((unsigned long)(this)) + (((unsigned long)(boundary)) -1)) & (~(((unsigned long)(boundary))-1)))
-GIdlModule *
-g_idl_module_new (const gchar *name, const gchar *shared_library)
+GIrModule *
+g_ir_module_new (const gchar *name, const gchar *shared_library)
{
- GIdlModule *module;
+ GIrModule *module;
- module = g_new (GIdlModule, 1);
+ module = g_new (GIrModule, 1);
module->name = g_strdup (name);
if (shared_library)
@@ -46,14 +46,14 @@ g_idl_module_new (const gchar *name, const gchar *shared_library)
}
void
-g_idl_module_free (GIdlModule *module)
+g_ir_module_free (GIrModule *module)
{
GList *e;
g_free (module->name);
for (e = module->entries; e; e = e->next)
- g_idl_node_free ((GIdlNode *)e->data);
+ g_ir_node_free ((GIrNode *)e->data);
g_list_free (module->entries);
@@ -61,7 +61,7 @@ g_idl_module_free (GIdlModule *module)
}
GTypelib *
-g_idl_module_build_metadata (GIdlModule *module,
+g_ir_module_build_metadata (GIrModule *module,
GList *modules)
{
guchar *metadata;
@@ -97,9 +97,9 @@ g_idl_module_build_metadata (GIdlModule *module,
for (e = module->entries; e; e = e->next)
{
- GIdlNode *node = e->data;
+ GIrNode *node = e->data;
- size += g_idl_node_get_full_size (node);
+ size += g_ir_node_get_full_size (node);
}
g_message ("allocating %d bytes (%d header, %d directory, %d entries)\n",
@@ -109,7 +109,7 @@ g_idl_module_build_metadata (GIdlModule *module,
/* fill in header */
header = (Header *)data;
- memcpy (header, G_IDL_MAGIC, 16);
+ memcpy (header, G_IR_MAGIC, 16);
header->major_version = 1;
header->minor_version = 0;
header->reserved = 0;
@@ -149,7 +149,7 @@ g_idl_module_build_metadata (GIdlModule *module,
for (e = module->entries, i = 0; e; e = e->next, i++)
{
- GIdlNode *node = e->data;
+ GIrNode *node = e->data;
if (strchr (node->name, '.'))
{
@@ -173,28 +173,28 @@ g_idl_module_build_metadata (GIdlModule *module,
offset = offset2;
- if (node->type == G_IDL_NODE_XREF)
+ if (node->type == G_IR_NODE_XREF)
{
entry->blob_type = 0;
entry->local = FALSE;
- entry->offset = write_string (((GIdlNodeXRef*)node)->namespace, strings, data, &offset2);
+ entry->offset = write_string (((GIrNodeXRef*)node)->namespace, strings, data, &offset2);
entry->name = write_string (node->name, strings, data, &offset2);
}
else
{
old_offset = offset;
- offset2 = offset + g_idl_node_get_size (node);
+ offset2 = offset + g_ir_node_get_size (node);
entry->blob_type = node->type;
entry->local = TRUE;
entry->offset = offset;
entry->name = write_string (node->name, strings, data, &offset2);
- g_idl_node_build_metadata (node, module, modules,
+ g_ir_node_build_metadata (node, module, modules,
strings, types, data, &offset, &offset2);
- if (offset2 > old_offset + g_idl_node_get_full_size (node))
- g_error ("left a hole of %d bytes\n", offset2 - old_offset - g_idl_node_get_full_size (node));
+ if (offset2 > old_offset + g_ir_node_get_full_size (node))
+ g_error ("left a hole of %d bytes\n", offset2 - old_offset - g_ir_node_get_full_size (node));
}
entry++;
diff --git a/tools/gidlmodule.h b/tools/girmodule.h
index 0814ed51..a59e9961 100644
--- a/tools/gidlmodule.h
+++ b/tools/girmodule.h
@@ -18,8 +18,8 @@
* Boston, MA 02111-1307, USA.
*/
-#ifndef __G_IDL_MODULE_H__
-#define __G_IDL_MODULE_H__
+#ifndef __G_IR_MODULE_H__
+#define __G_IR_MODULE_H__
#include <glib.h>
#include "gtypelib.h"
@@ -27,22 +27,22 @@
G_BEGIN_DECLS
-typedef struct _GIdlModule GIdlModule;
+typedef struct _GIrModule GIrModule;
-struct _GIdlModule
+struct _GIrModule
{
gchar *name;
gchar *shared_library;
GList *entries;
};
-GIdlModule *g_idl_module_new (const gchar *name,
- const gchar *module_filename);
-void g_idl_module_free (GIdlModule *module);
+GIrModule *g_ir_module_new (const gchar *name,
+ const gchar *module_filename);
+void g_ir_module_free (GIrModule *module);
-GTypelib * g_idl_module_build_metadata (GIdlModule *module,
- GList *modules);
+GTypelib * g_ir_module_build_metadata (GIrModule *module,
+ GList *modules);
G_END_DECLS
-#endif /* __G_IDL_MODULE_H__ */
+#endif /* __G_IR_MODULE_H__ */
diff --git a/tools/gidlnode.c b/tools/girnode.c
index 09f3f072..53da191e 100644
--- a/tools/gidlnode.c
+++ b/tools/girnode.c
@@ -22,8 +22,8 @@
#include <stdlib.h>
#include <string.h>
-#include "gidlmodule.h"
-#include "gidlnode.h"
+#include "girmodule.h"
+#include "girnode.h"
#include "gtypelib.h"
static gulong string_count = 0;
@@ -56,78 +56,188 @@ dump_stats (void)
(( ((unsigned long)(this)) + (((unsigned long)(boundary)) -1)) & (~(((unsigned long)(boundary))-1)))
-GIdlNode *
-g_idl_node_new (GIdlNodeTypeId type)
+static const gchar *
+g_ir_node_type_to_string (GIrNodeTypeId type)
{
- GIdlNode *node = NULL;
+ switch (type)
+ {
+ case G_IR_NODE_FUNCTION:
+ return "function";
+ case G_IR_NODE_CALLBACK:
+ return "callback";
+ case G_IR_NODE_PARAM:
+ return "param";
+ case G_IR_NODE_TYPE:
+ return "type";
+ case G_IR_NODE_OBJECT:
+ return "object";
+ case G_IR_NODE_INTERFACE:
+ return "interface";
+ case G_IR_NODE_SIGNAL:
+ return "signal";
+ case G_IR_NODE_PROPERTY:
+ return "property";
+ case G_IR_NODE_VFUNC:
+ return "vfunc";
+ case G_IR_NODE_FIELD:
+ return "field";
+ case G_IR_NODE_ENUM:
+ return "enum";
+ case G_IR_NODE_FLAGS:
+ return "flags";
+ case G_IR_NODE_BOXED:
+ return "boxed";
+ case G_IR_NODE_STRUCT:
+ return "struct";
+ case G_IR_NODE_VALUE:
+ return "value";
+ case G_IR_NODE_CONSTANT:
+ return "constant";
+ case G_IR_NODE_ERROR_DOMAIN:
+ return "error-domain";
+ case G_IR_NODE_XREF:
+ return "xref";
+ case G_IR_NODE_UNION:
+ return "union";
+ default:
+ return "unknown";
+ }
+}
+static const gchar*
+gi_type_tag_to_string (GITypeTag type)
+{
switch (type)
{
- case G_IDL_NODE_FUNCTION:
- case G_IDL_NODE_CALLBACK:
- node = g_malloc0 (sizeof (GIdlNodeFunction));
+ case GI_TYPE_TAG_VOID:
+ return "void";
+ case GI_TYPE_TAG_BOOLEAN:
+ return "boolean";
+ case GI_TYPE_TAG_INT8:
+ return "int8";
+ case GI_TYPE_TAG_UINT8:
+ return "uint8";
+ case GI_TYPE_TAG_INT16:
+ return "int16";
+ case GI_TYPE_TAG_UINT16:
+ return "uint16";
+ case GI_TYPE_TAG_INT32:
+ return "int32";
+ case GI_TYPE_TAG_UINT32:
+ return "uint32";
+ case GI_TYPE_TAG_INT64:
+ return "int64";
+ case GI_TYPE_TAG_UINT64:
+ return "uint64";
+ case GI_TYPE_TAG_INT:
+ return "int";
+ case GI_TYPE_TAG_UINT:
+ return "uint";
+ case GI_TYPE_TAG_LONG:
+ return "long";
+ case GI_TYPE_TAG_ULONG:
+ return "ulong";
+ case GI_TYPE_TAG_SSIZE:
+ return "ssize";
+ case GI_TYPE_TAG_SIZE:
+ return "size";
+ case GI_TYPE_TAG_FLOAT:
+ return "float";
+ case GI_TYPE_TAG_DOUBLE:
+ return "double";
+ case GI_TYPE_TAG_UTF8:
+ return "utf8";
+ case GI_TYPE_TAG_FILENAME:
+ return "filename";
+ case GI_TYPE_TAG_ARRAY:
+ return "array";
+ case GI_TYPE_TAG_INTERFACE:
+ return "interface";
+ case GI_TYPE_TAG_GLIST:
+ return "glist";
+ case GI_TYPE_TAG_GSLIST:
+ return "gslist";
+ case GI_TYPE_TAG_GHASH:
+ return "ghash";
+ case GI_TYPE_TAG_ERROR:
+ return "error";
+ default:
+ return "unknown";
+ }
+}
+
+GIrNode *
+g_ir_node_new (GIrNodeTypeId type)
+{
+ GIrNode *node = NULL;
+
+ switch (type)
+ {
+ case G_IR_NODE_FUNCTION:
+ case G_IR_NODE_CALLBACK:
+ node = g_malloc0 (sizeof (GIrNodeFunction));
break;
- case G_IDL_NODE_PARAM:
- node = g_malloc0 (sizeof (GIdlNodeParam));
+ case G_IR_NODE_PARAM:
+ node = g_malloc0 (sizeof (GIrNodeParam));
break;
- case G_IDL_NODE_TYPE:
- node = g_malloc0 (sizeof (GIdlNodeType));
+ case G_IR_NODE_TYPE:
+ node = g_malloc0 (sizeof (GIrNodeType));
break;
- case G_IDL_NODE_OBJECT:
- case G_IDL_NODE_INTERFACE:
- node = g_malloc0 (sizeof (GIdlNodeInterface));
+ case G_IR_NODE_OBJECT:
+ case G_IR_NODE_INTERFACE:
+ node = g_malloc0 (sizeof (GIrNodeInterface));
break;
- case G_IDL_NODE_SIGNAL:
- node = g_malloc0 (sizeof (GIdlNodeSignal));
+ case G_IR_NODE_SIGNAL:
+ node = g_malloc0 (sizeof (GIrNodeSignal));
break;
- case G_IDL_NODE_PROPERTY:
- node = g_malloc0 (sizeof (GIdlNodeProperty));
+ case G_IR_NODE_PROPERTY:
+ node = g_malloc0 (sizeof (GIrNodeProperty));
break;
- case G_IDL_NODE_VFUNC:
- node = g_malloc0 (sizeof (GIdlNodeFunction));
+ case G_IR_NODE_VFUNC:
+ node = g_malloc0 (sizeof (GIrNodeFunction));
break;
- case G_IDL_NODE_FIELD:
- node = g_malloc0 (sizeof (GIdlNodeField));
+ case G_IR_NODE_FIELD:
+ node = g_malloc0 (sizeof (GIrNodeField));
break;
- case G_IDL_NODE_ENUM:
- case G_IDL_NODE_FLAGS:
- node = g_malloc0 (sizeof (GIdlNodeEnum));
+ case G_IR_NODE_ENUM:
+ case G_IR_NODE_FLAGS:
+ node = g_malloc0 (sizeof (GIrNodeEnum));
break;
- case G_IDL_NODE_BOXED:
- node = g_malloc0 (sizeof (GIdlNodeBoxed));
+ case G_IR_NODE_BOXED:
+ node = g_malloc0 (sizeof (GIrNodeBoxed));
break;
- case G_IDL_NODE_STRUCT:
- node = g_malloc0 (sizeof (GIdlNodeStruct));
+ case G_IR_NODE_STRUCT:
+ node = g_malloc0 (sizeof (GIrNodeStruct));
break;
- case G_IDL_NODE_VALUE:
- node = g_malloc0 (sizeof (GIdlNodeValue));
+ case G_IR_NODE_VALUE:
+ node = g_malloc0 (sizeof (GIrNodeValue));
break;
- case G_IDL_NODE_CONSTANT:
- node = g_malloc0 (sizeof (GIdlNodeConstant));
+ case G_IR_NODE_CONSTANT:
+ node = g_malloc0 (sizeof (GIrNodeConstant));
break;
- case G_IDL_NODE_ERROR_DOMAIN:
- node = g_malloc0 (sizeof (GIdlNodeErrorDomain));
+ case G_IR_NODE_ERROR_DOMAIN:
+ node = g_malloc0 (sizeof (GIrNodeErrorDomain));
break;
- case G_IDL_NODE_XREF:
- node = g_malloc0 (sizeof (GIdlNodeXRef));
+ case G_IR_NODE_XREF:
+ node = g_malloc0 (sizeof (GIrNodeXRef));
break;
- case G_IDL_NODE_UNION:
- node = g_malloc0 (sizeof (GIdlNodeUnion));
+ case G_IR_NODE_UNION:
+ node = g_malloc0 (sizeof (GIrNodeUnion));
break;
default:
@@ -141,7 +251,7 @@ g_idl_node_new (GIdlNodeTypeId type)
}
void
-g_idl_node_free (GIdlNode *node)
+g_ir_node_free (GIrNode *node)
{
GList *l;
@@ -150,27 +260,27 @@ g_idl_node_free (GIdlNode *node)
switch (node->type)
{
- case G_IDL_NODE_FUNCTION:
- case G_IDL_NODE_CALLBACK:
+ case G_IR_NODE_FUNCTION:
+ case G_IR_NODE_CALLBACK:
{
- GIdlNodeFunction *function = (GIdlNodeFunction *)node;
+ GIrNodeFunction *function = (GIrNodeFunction *)node;
g_free (node->name);
g_free (function->symbol);
- g_idl_node_free ((GIdlNode *)function->result);
+ g_ir_node_free ((GIrNode *)function->result);
for (l = function->parameters; l; l = l->next)
- g_idl_node_free ((GIdlNode *)l->data);
+ g_ir_node_free ((GIrNode *)l->data);
g_list_free (function->parameters);
}
break;
- case G_IDL_NODE_TYPE:
+ case G_IR_NODE_TYPE:
{
- GIdlNodeType *type = (GIdlNodeType *)node;
+ GIrNodeType *type = (GIrNodeType *)node;
g_free (node->name);
- g_idl_node_free ((GIdlNode *)type->parameter_type1);
- g_idl_node_free ((GIdlNode *)type->parameter_type2);
+ g_ir_node_free ((GIrNode *)type->parameter_type1);
+ g_ir_node_free ((GIrNode *)type->parameter_type2);
g_free (type->interface);
g_strfreev (type->errors);
@@ -178,61 +288,61 @@ g_idl_node_free (GIdlNode *node)
}
break;
- case G_IDL_NODE_PARAM:
+ case G_IR_NODE_PARAM:
{
- GIdlNodeParam *param = (GIdlNodeParam *)node;
+ GIrNodeParam *param = (GIrNodeParam *)node;
g_free (node->name);
- g_idl_node_free ((GIdlNode *)param->type);
+ g_ir_node_free ((GIrNode *)param->type);
}
break;
- case G_IDL_NODE_PROPERTY:
+ case G_IR_NODE_PROPERTY:
{
- GIdlNodeProperty *property = (GIdlNodeProperty *)node;
+ GIrNodeProperty *property = (GIrNodeProperty *)node;
g_free (node->name);
- g_idl_node_free ((GIdlNode *)property->type);
+ g_ir_node_free ((GIrNode *)property->type);
}
break;
- case G_IDL_NODE_SIGNAL:
+ case G_IR_NODE_SIGNAL:
{
- GIdlNodeSignal *signal = (GIdlNodeSignal *)node;
+ GIrNodeSignal *signal = (GIrNodeSignal *)node;
g_free (node->name);
for (l = signal->parameters; l; l = l->next)
- g_idl_node_free ((GIdlNode *)l->data);
+ g_ir_node_free ((GIrNode *)l->data);
g_list_free (signal->parameters);
- g_idl_node_free ((GIdlNode *)signal->result);
+ g_ir_node_free ((GIrNode *)signal->result);
}
break;
- case G_IDL_NODE_VFUNC:
+ case G_IR_NODE_VFUNC:
{
- GIdlNodeVFunc *vfunc = (GIdlNodeVFunc *)node;
+ GIrNodeVFunc *vfunc = (GIrNodeVFunc *)node;
g_free (node->name);
for (l = vfunc->parameters; l; l = l->next)
- g_idl_node_free ((GIdlNode *)l->data);
+ g_ir_node_free ((GIrNode *)l->data);
g_list_free (vfunc->parameters);
- g_idl_node_free ((GIdlNode *)vfunc->result);
+ g_ir_node_free ((GIrNode *)vfunc->result);
}
break;
- case G_IDL_NODE_FIELD:
+ case G_IR_NODE_FIELD:
{
- GIdlNodeField *field = (GIdlNodeField *)node;
+ GIrNodeField *field = (GIrNodeField *)node;
g_free (node->name);
- g_idl_node_free ((GIdlNode *)field->type);
+ g_ir_node_free ((GIrNode *)field->type);
}
break;
- case G_IDL_NODE_OBJECT:
- case G_IDL_NODE_INTERFACE:
+ case G_IR_NODE_OBJECT:
+ case G_IR_NODE_INTERFACE:
{
- GIdlNodeInterface *iface = (GIdlNodeInterface *)node;
+ GIrNodeInterface *iface = (GIrNodeInterface *)node;
g_free (node->name);
g_free (iface->gtype_name);
@@ -241,75 +351,75 @@ g_idl_node_free (GIdlNode *node)
g_free (iface->parent);
for (l = iface->interfaces; l; l = l->next)
- g_free ((GIdlNode *)l->data);
+ g_free ((GIrNode *)l->data);
g_list_free (iface->interfaces);
for (l = iface->members; l; l = l->next)
- g_idl_node_free ((GIdlNode *)l->data);
+ g_ir_node_free ((GIrNode *)l->data);
g_list_free (iface->members);
}
break;
- case G_IDL_NODE_VALUE:
+ case G_IR_NODE_VALUE:
{
g_free (node->name);
}
break;
- case G_IDL_NODE_ENUM:
- case G_IDL_NODE_FLAGS:
+ case G_IR_NODE_ENUM:
+ case G_IR_NODE_FLAGS:
{
- GIdlNodeEnum *enum_ = (GIdlNodeEnum *)node;
+ GIrNodeEnum *enum_ = (GIrNodeEnum *)node;
g_free (node->name);
g_free (enum_->gtype_name);
g_free (enum_->gtype_init);
for (l = enum_->values; l; l = l->next)
- g_idl_node_free ((GIdlNode *)l->data);
+ g_ir_node_free ((GIrNode *)l->data);
g_list_free (enum_->values);
}
break;
- case G_IDL_NODE_BOXED:
+ case G_IR_NODE_BOXED:
{
- GIdlNodeBoxed *boxed = (GIdlNodeBoxed *)node;
+ GIrNodeBoxed *boxed = (GIrNodeBoxed *)node;
g_free (node->name);
g_free (boxed->gtype_name);
g_free (boxed->gtype_init);
for (l = boxed->members; l; l = l->next)
- g_idl_node_free ((GIdlNode *)l->data);
+ g_ir_node_free ((GIrNode *)l->data);
g_list_free (boxed->members);
}
break;
- case G_IDL_NODE_STRUCT:
+ case G_IR_NODE_STRUCT:
{
- GIdlNodeStruct *struct_ = (GIdlNodeStruct *)node;
+ GIrNodeStruct *struct_ = (GIrNodeStruct *)node;
g_free (node->name);
for (l = struct_->members; l; l = l->next)
- g_idl_node_free ((GIdlNode *)l->data);
+ g_ir_node_free ((GIrNode *)l->data);
g_list_free (struct_->members);
}
break;
- case G_IDL_NODE_CONSTANT:
+ case G_IR_NODE_CONSTANT:
{
- GIdlNodeConstant *constant = (GIdlNodeConstant *)node;
+ GIrNodeConstant *constant = (GIrNodeConstant *)node;
g_free (node->name);
g_free (constant->value);
- g_idl_node_free ((GIdlNode *)constant->type);
+ g_ir_node_free ((GIrNode *)constant->type);
}
break;
- case G_IDL_NODE_ERROR_DOMAIN:
+ case G_IR_NODE_ERROR_DOMAIN:
{
- GIdlNodeErrorDomain *domain = (GIdlNodeErrorDomain *)node;
+ GIrNodeErrorDomain *domain = (GIrNodeErrorDomain *)node;
g_free (node->name);
g_free (domain->getquark);
@@ -317,28 +427,28 @@ g_idl_node_free (GIdlNode *node)
}
break;
- case G_IDL_NODE_XREF:
+ case G_IR_NODE_XREF:
{
- GIdlNodeXRef *xref = (GIdlNodeXRef *)node;
+ GIrNodeXRef *xref = (GIrNodeXRef *)node;
g_free (node->name);
g_free (xref->namespace);
}
break;
- case G_IDL_NODE_UNION:
+ case G_IR_NODE_UNION:
{
- GIdlNodeUnion *union_ = (GIdlNodeUnion *)node;
+ GIrNodeUnion *union_ = (GIrNodeUnion *)node;
g_free (node->name);
g_free (union_->gtype_name);
g_free (union_->gtype_init);
- g_idl_node_free ((GIdlNode *)union_->discriminator_type);
+ g_ir_node_free ((GIrNode *)union_->discriminator_type);
for (l = union_->members; l; l = l->next)
- g_idl_node_free ((GIdlNode *)l->data);
+ g_ir_node_free ((GIrNode *)l->data);
for (l = union_->discriminators; l; l = l->next)
- g_idl_node_free ((GIdlNode *)l->data);
+ g_ir_node_free ((GIrNode *)l->data);
}
break;
@@ -352,196 +462,204 @@ g_idl_node_free (GIdlNode *node)
/* returns the fixed size of the blob */
guint32
-g_idl_node_get_size (GIdlNode *node)
+g_ir_node_get_size (GIrNode *node)
{
GList *l;
gint size, n;
switch (node->type)
{
- case G_IDL_NODE_CALLBACK:
+ case G_IR_NODE_CALLBACK:
size = 12;
break;
- case G_IDL_NODE_FUNCTION:
+ case G_IR_NODE_FUNCTION:
size = 16;
break;
- case G_IDL_NODE_PARAM:
+ case G_IR_NODE_PARAM:
size = 12;
break;
- case G_IDL_NODE_TYPE:
+ case G_IR_NODE_TYPE:
size = 4;
break;
- case G_IDL_NODE_OBJECT:
+ case G_IR_NODE_OBJECT:
{
- GIdlNodeInterface *iface = (GIdlNodeInterface *)node;
+ GIrNodeInterface *iface = (GIrNodeInterface *)node;
n = g_list_length (iface->interfaces);
size = 32 + 2 * (n + (n % 2));
for (l = iface->members; l; l = l->next)
- size += g_idl_node_get_size ((GIdlNode *)l->data);
+ size += g_ir_node_get_size ((GIrNode *)l->data);
}
break;
- case G_IDL_NODE_INTERFACE:
+ case G_IR_NODE_INTERFACE:
{
- GIdlNodeInterface *iface = (GIdlNodeInterface *)node;
+ GIrNodeInterface *iface = (GIrNodeInterface *)node;
n = g_list_length (iface->prerequisites);
size = 28 + 2 * (n + (n % 2));
for (l = iface->members; l; l = l->next)
- size += g_idl_node_get_size ((GIdlNode *)l->data);
+ size += g_ir_node_get_size ((GIrNode *)l->data);
}
break;
- case G_IDL_NODE_ENUM:
- case G_IDL_NODE_FLAGS:
+ case G_IR_NODE_ENUM:
+ case G_IR_NODE_FLAGS:
{
- GIdlNodeEnum *enum_ = (GIdlNodeEnum *)node;
+ GIrNodeEnum *enum_ = (GIrNodeEnum *)node;
size = 20;
for (l = enum_->values; l; l = l->next)
- size += g_idl_node_get_size ((GIdlNode *)l->data);
+ size += g_ir_node_get_size ((GIrNode *)l->data);
}
break;
- case G_IDL_NODE_VALUE:
+ case G_IR_NODE_VALUE:
size = 12;
break;
- case G_IDL_NODE_STRUCT:
+ case G_IR_NODE_STRUCT:
{
- GIdlNodeStruct *struct_ = (GIdlNodeStruct *)node;
+ GIrNodeStruct *struct_ = (GIrNodeStruct *)node;
size = 20;
for (l = struct_->members; l; l = l->next)
- size += g_idl_node_get_size ((GIdlNode *)l->data);
+ size += g_ir_node_get_size ((GIrNode *)l->data);
}
break;
- case G_IDL_NODE_BOXED:
+ case G_IR_NODE_BOXED:
{
- GIdlNodeBoxed *boxed = (GIdlNodeBoxed *)node;
+ GIrNodeBoxed *boxed = (GIrNodeBoxed *)node;
size = 20;
for (l = boxed->members; l; l = l->next)
- size += g_idl_node_get_size ((GIdlNode *)l->data);
+ size += g_ir_node_get_size ((GIrNode *)l->data);
}
break;
- case G_IDL_NODE_PROPERTY:
+ case G_IR_NODE_PROPERTY:
size = 12;
break;
- case G_IDL_NODE_SIGNAL:
+ case G_IR_NODE_SIGNAL:
size = 12;
break;
- case G_IDL_NODE_VFUNC:
+ case G_IR_NODE_VFUNC:
size = 16;
break;
- case G_IDL_NODE_FIELD:
+ case G_IR_NODE_FIELD:
size = 12;
break;
- case G_IDL_NODE_CONSTANT:
+ case G_IR_NODE_CONSTANT:
size = 20;
break;
- case G_IDL_NODE_ERROR_DOMAIN:
+ case G_IR_NODE_ERROR_DOMAIN:
size = 16;
break;
- case G_IDL_NODE_XREF:
+ case G_IR_NODE_XREF:
size = 0;
break;
- case G_IDL_NODE_UNION:
+ case G_IR_NODE_UNION:
{
- GIdlNodeUnion *union_ = (GIdlNodeUnion *)node;
+ GIrNodeUnion *union_ = (GIrNodeUnion *)node;
size = 28;
for (l = union_->members; l; l = l->next)
- size += g_idl_node_get_size ((GIdlNode *)l->data);
+ size += g_ir_node_get_size ((GIrNode *)l->data);
for (l = union_->discriminators; l; l = l->next)
- size += g_idl_node_get_size ((GIdlNode *)l->data);
+ size += g_ir_node_get_size ((GIrNode *)l->data);
}
break;
default:
- g_error ("Unhandled node type %d\n", node->type);
+ g_error ("Unhandled node type '%s'\n",
+ g_ir_node_type_to_string (node->type));
size = 0;
}
- g_debug ("node %p type %d size %d", node, node->type, size);
+ g_debug ("node %p type '%s' size %d", node,
+ g_ir_node_type_to_string (node->type), size);
return size;
}
/* returns the full size of the blob including variable-size parts */
guint32
-g_idl_node_get_full_size (GIdlNode *node)
+g_ir_node_get_full_size (GIrNode *node)
{
GList *l;
gint size, n;
g_assert (node != NULL);
+ g_debug ("node %p type '%s'", node,
+ g_ir_node_type_to_string (node->type));
+
switch (node->type)
{
- case G_IDL_NODE_CALLBACK:
+ case G_IR_NODE_CALLBACK:
{
- GIdlNodeFunction *function = (GIdlNodeFunction *)node;
+ GIrNodeFunction *function = (GIrNodeFunction *)node;
size = 12;
size += ALIGN_VALUE (strlen (node->name) + 1, 4);
for (l = function->parameters; l; l = l->next)
- size += g_idl_node_get_full_size ((GIdlNode *)l->data);
- size += g_idl_node_get_full_size ((GIdlNode *)function->result);
+ size += g_ir_node_get_full_size ((GIrNode *)l->data);
+ size += g_ir_node_get_full_size ((GIrNode *)function->result);
}
break;
- case G_IDL_NODE_FUNCTION:
+ case G_IR_NODE_FUNCTION:
{
- GIdlNodeFunction *function = (GIdlNodeFunction *)node;
+ GIrNodeFunction *function = (GIrNodeFunction *)node;
size = 24;
size += ALIGN_VALUE (strlen (node->name) + 1, 4);
size += ALIGN_VALUE (strlen (function->symbol) + 1, 4);
for (l = function->parameters; l; l = l->next)
- size += g_idl_node_get_full_size ((GIdlNode *)l->data);
- size += g_idl_node_get_full_size ((GIdlNode *)function->result);
+ size += g_ir_node_get_full_size ((GIrNode *)l->data);
+ size += g_ir_node_get_full_size ((GIrNode *)function->result);
}
break;
- case G_IDL_NODE_PARAM:
+ case G_IR_NODE_PARAM:
{
- GIdlNodeParam *param = (GIdlNodeParam *)node;
+ GIrNodeParam *param = (GIrNodeParam *)node;
size = 12;
if (node->name)
size += ALIGN_VALUE (strlen (node->name) + 1, 4);
- size += g_idl_node_get_full_size ((GIdlNode *)param->type);
+ size += g_ir_node_get_full_size ((GIrNode *)param->type);
}
break;
- case G_IDL_NODE_TYPE:
+ case G_IR_NODE_TYPE:
{
- GIdlNodeType *type = (GIdlNodeType *)node;
+ GIrNodeType *type = (GIrNodeType *)node;
if (type->tag < TYPE_TAG_ARRAY)
size = 4;
else
{
+ g_debug ("node %p type tag '%s'", node,
+ gi_type_tag_to_string (type->tag));
+
switch (type->tag)
{
case TYPE_TAG_ARRAY:
size = 4 + 4;
if (type->parameter_type1)
- size += g_idl_node_get_full_size ((GIdlNode *)type->parameter_type1);
+ size += g_ir_node_get_full_size ((GIrNode *)type->parameter_type1);
break;
case TYPE_TAG_INTERFACE:
size = 4 + 4;
@@ -550,14 +668,14 @@ g_idl_node_get_full_size (GIdlNode *node)
case TYPE_TAG_SLIST:
size = 4 + 4;
if (type->parameter_type1)
- size += g_idl_node_get_full_size ((GIdlNode *)type->parameter_type1);
+ size += g_ir_node_get_full_size ((GIrNode *)type->parameter_type1);
break;
case TYPE_TAG_HASH:
size = 4 + 4 + 4;
if (type->parameter_type1)
- size += g_idl_node_get_full_size ((GIdlNode *)type->parameter_type1);
+ size += g_ir_node_get_full_size ((GIrNode *)type->parameter_type1);
if (type->parameter_type2)
- size += g_idl_node_get_full_size ((GIdlNode *)type->parameter_type2);
+ size += g_ir_node_get_full_size ((GIrNode *)type->parameter_type2);
break;
case TYPE_TAG_ERROR:
{
@@ -579,9 +697,9 @@ g_idl_node_get_full_size (GIdlNode *node)
}
break;
- case G_IDL_NODE_OBJECT:
+ case G_IR_NODE_OBJECT:
{
- GIdlNodeInterface *iface = (GIdlNodeInterface *)node;
+ GIrNodeInterface *iface = (GIrNodeInterface *)node;
n = g_list_length (iface->interfaces);
size = 32;
@@ -593,13 +711,13 @@ g_idl_node_get_full_size (GIdlNode *node)
size += 2 * (n + (n % 2));
for (l = iface->members; l; l = l->next)
- size += g_idl_node_get_full_size ((GIdlNode *)l->data);
+ size += g_ir_node_get_full_size ((GIrNode *)l->data);
}
break;
- case G_IDL_NODE_INTERFACE:
+ case G_IR_NODE_INTERFACE:
{
- GIdlNodeInterface *iface = (GIdlNodeInterface *)node;
+ GIrNodeInterface *iface = (GIrNodeInterface *)node;
n = g_list_length (iface->prerequisites);
size = 28;
@@ -609,14 +727,14 @@ g_idl_node_get_full_size (GIdlNode *node)
size += 2 * (n + (n % 2));
for (l = iface->members; l; l = l->next)
- size += g_idl_node_get_full_size ((GIdlNode *)l->data);
+ size += g_ir_node_get_full_size ((GIrNode *)l->data);
}
break;
- case G_IDL_NODE_ENUM:
- case G_IDL_NODE_FLAGS:
+ case G_IR_NODE_ENUM:
+ case G_IR_NODE_FLAGS:
{
- GIdlNodeEnum *enum_ = (GIdlNodeEnum *)node;
+ GIrNodeEnum *enum_ = (GIrNodeEnum *)node;
size = 20;
size += ALIGN_VALUE (strlen (node->name) + 1, 4);
@@ -627,31 +745,31 @@ g_idl_node_get_full_size (GIdlNode *node)
}
for (l = enum_->values; l; l = l->next)
- size += g_idl_node_get_full_size ((GIdlNode *)l->data);
+ size += g_ir_node_get_full_size ((GIrNode *)l->data);
}
break;
- case G_IDL_NODE_VALUE:
+ case G_IR_NODE_VALUE:
{
size = 12;
size += ALIGN_VALUE (strlen (node->name) + 1, 4);
}
break;
- case G_IDL_NODE_STRUCT:
+ case G_IR_NODE_STRUCT:
{
- GIdlNodeStruct *struct_ = (GIdlNodeStruct *)node;
+ GIrNodeStruct *struct_ = (GIrNodeStruct *)node;
size = 20;
size += ALIGN_VALUE (strlen (node->name) + 1, 4);
for (l = struct_->members; l; l = l->next)
- size += g_idl_node_get_full_size ((GIdlNode *)l->data);
+ size += g_ir_node_get_full_size ((GIrNode *)l->data);
}
break;
- case G_IDL_NODE_BOXED:
+ case G_IR_NODE_BOXED:
{
- GIdlNodeBoxed *boxed = (GIdlNodeBoxed *)node;
+ GIrNodeBoxed *boxed = (GIrNodeBoxed *)node;
size = 20;
size += ALIGN_VALUE (strlen (node->name) + 1, 4);
@@ -661,69 +779,69 @@ g_idl_node_get_full_size (GIdlNode *node)
size += ALIGN_VALUE (strlen (boxed->gtype_init) + 1, 4);
}
for (l = boxed->members; l; l = l->next)
- size += g_idl_node_get_full_size ((GIdlNode *)l->data);
+ size += g_ir_node_get_full_size ((GIrNode *)l->data);
}
break;
- case G_IDL_NODE_PROPERTY:
+ case G_IR_NODE_PROPERTY:
{
- GIdlNodeProperty *prop = (GIdlNodeProperty *)node;
+ GIrNodeProperty *prop = (GIrNodeProperty *)node;
size = 12;
size += ALIGN_VALUE (strlen (node->name) + 1, 4);
- size += g_idl_node_get_full_size ((GIdlNode *)prop->type);
+ size += g_ir_node_get_full_size ((GIrNode *)prop->type);
}
break;
- case G_IDL_NODE_SIGNAL:
+ case G_IR_NODE_SIGNAL:
{
- GIdlNodeSignal *signal = (GIdlNodeSignal *)node;
+ GIrNodeSignal *signal = (GIrNodeSignal *)node;
size = 12;
size += ALIGN_VALUE (strlen (node->name) + 1, 4);
for (l = signal->parameters; l; l = l->next)
- size += g_idl_node_get_full_size ((GIdlNode *)l->data);
- size += g_idl_node_get_full_size ((GIdlNode *)signal->result);
+ size += g_ir_node_get_full_size ((GIrNode *)l->data);
+ size += g_ir_node_get_full_size ((GIrNode *)signal->result);
}
break;
- case G_IDL_NODE_VFUNC:
+ case G_IR_NODE_VFUNC:
{
- GIdlNodeVFunc *vfunc = (GIdlNodeVFunc *)node;
+ GIrNodeVFunc *vfunc = (GIrNodeVFunc *)node;
size = 16;
size += ALIGN_VALUE (strlen (node->name) + 1, 4);
for (l = vfunc->parameters; l; l = l->next)
- size += g_idl_node_get_full_size ((GIdlNode *)l->data);
- size += g_idl_node_get_full_size ((GIdlNode *)vfunc->result);
+ size += g_ir_node_get_full_size ((GIrNode *)l->data);
+ size += g_ir_node_get_full_size ((GIrNode *)vfunc->result);
}
break;
- case G_IDL_NODE_FIELD:
+ case G_IR_NODE_FIELD:
{
- GIdlNodeField *field = (GIdlNodeField *)node;
+ GIrNodeField *field = (GIrNodeField *)node;
size = 12;
size += ALIGN_VALUE (strlen (node->name) + 1, 4);
- size += g_idl_node_get_full_size ((GIdlNode *)field->type);
+ size += g_ir_node_get_full_size ((GIrNode *)field->type);
}
break;
- case G_IDL_NODE_CONSTANT:
+ case G_IR_NODE_CONSTANT:
{
- GIdlNodeConstant *constant = (GIdlNodeConstant *)node;
+ GIrNodeConstant *constant = (GIrNodeConstant *)node;
size = 20;
size += ALIGN_VALUE (strlen (node->name) + 1, 4);
/* FIXME non-string values */
size += ALIGN_VALUE (strlen (constant->value) + 1, 4);
- size += g_idl_node_get_full_size ((GIdlNode *)constant->type);
+ size += g_ir_node_get_full_size ((GIrNode *)constant->type);
}
break;
- case G_IDL_NODE_ERROR_DOMAIN:
+ case G_IR_NODE_ERROR_DOMAIN:
{
- GIdlNodeErrorDomain *domain = (GIdlNodeErrorDomain *)node;
+ GIrNodeErrorDomain *domain = (GIrNodeErrorDomain *)node;
size = 16;
size += ALIGN_VALUE (strlen (node->name) + 1, 4);
@@ -731,9 +849,9 @@ g_idl_node_get_full_size (GIdlNode *node)
}
break;
- case G_IDL_NODE_XREF:
+ case G_IR_NODE_XREF:
{
- GIdlNodeXRef *xref = (GIdlNodeXRef *)node;
+ GIrNodeXRef *xref = (GIrNodeXRef *)node;
size = 0;
size += ALIGN_VALUE (strlen (node->name) + 1, 4);
@@ -741,16 +859,16 @@ g_idl_node_get_full_size (GIdlNode *node)
}
break;
- case G_IDL_NODE_UNION:
+ case G_IR_NODE_UNION:
{
- GIdlNodeUnion *union_ = (GIdlNodeUnion *)node;
+ GIrNodeUnion *union_ = (GIrNodeUnion *)node;
size = 28;
size += ALIGN_VALUE (strlen (node->name) + 1, 4);
for (l = union_->members; l; l = l->next)
- size += g_idl_node_get_full_size ((GIdlNode *)l->data);
+ size += g_ir_node_get_full_size ((GIrNode *)l->data);
for (l = union_->discriminators; l; l = l->next)
- size += g_idl_node_get_full_size ((GIdlNode *)l->data);
+ size += g_ir_node_get_full_size ((GIrNode *)l->data);
}
break;
@@ -759,14 +877,15 @@ g_idl_node_get_full_size (GIdlNode *node)
size = 0;
}
- g_debug ("node %p type %d full size %d", node, node->type, size);
+ g_debug ("node %p type '%s' full size %d", node,
+ g_ir_node_type_to_string (node->type), size);
return size;
}
int
-g_idl_node_cmp (GIdlNode *node,
- GIdlNode *other)
+g_ir_node_cmp (GIrNode *node,
+ GIrNode *other)
{
if (node->type < other->type)
return -1;
@@ -777,60 +896,60 @@ g_idl_node_cmp (GIdlNode *node,
}
gboolean
-g_idl_node_can_have_member (GIdlNode *node)
+g_ir_node_can_have_member (GIrNode *node)
{
switch (node->type)
{
- case G_IDL_NODE_OBJECT:
- case G_IDL_NODE_INTERFACE:
- case G_IDL_NODE_BOXED:
- case G_IDL_NODE_STRUCT:
- case G_IDL_NODE_UNION:
+ case G_IR_NODE_OBJECT:
+ case G_IR_NODE_INTERFACE:
+ case G_IR_NODE_BOXED:
+ case G_IR_NODE_STRUCT:
+ case G_IR_NODE_UNION:
return TRUE;
};
return FALSE;
}
void
-g_idl_node_add_member (GIdlNode *node,
- GIdlNodeFunction *member)
+g_ir_node_add_member (GIrNode *node,
+ GIrNodeFunction *member)
{
g_return_if_fail (node != NULL);
g_return_if_fail (member != NULL);
switch (node->type)
{
- case G_IDL_NODE_OBJECT:
- case G_IDL_NODE_INTERFACE:
+ case G_IR_NODE_OBJECT:
+ case G_IR_NODE_INTERFACE:
{
- GIdlNodeInterface *iface = (GIdlNodeInterface *)node;
+ GIrNodeInterface *iface = (GIrNodeInterface *)node;
iface->members =
g_list_insert_sorted (iface->members, member,
- (GCompareFunc) g_idl_node_cmp);
+ (GCompareFunc) g_ir_node_cmp);
break;
}
- case G_IDL_NODE_BOXED:
+ case G_IR_NODE_BOXED:
{
- GIdlNodeBoxed *boxed = (GIdlNodeBoxed *)node;
+ GIrNodeBoxed *boxed = (GIrNodeBoxed *)node;
boxed->members =
g_list_insert_sorted (boxed->members, member,
- (GCompareFunc) g_idl_node_cmp);
+ (GCompareFunc) g_ir_node_cmp);
break;
}
- case G_IDL_NODE_STRUCT:
+ case G_IR_NODE_STRUCT:
{
- GIdlNodeStruct *struct_ = (GIdlNodeStruct *)node;
+ GIrNodeStruct *struct_ = (GIrNodeStruct *)node;
struct_->members =
g_list_insert_sorted (struct_->members, member,
- (GCompareFunc) g_idl_node_cmp);
+ (GCompareFunc) g_ir_node_cmp);
break;
}
- case G_IDL_NODE_UNION:
+ case G_IR_NODE_UNION:
{
- GIdlNodeUnion *union_ = (GIdlNodeUnion *)node;
+ GIrNodeUnion *union_ = (GIrNodeUnion *)node;
union_->members =
g_list_insert_sorted (union_->members, member,
- (GCompareFunc) g_idl_node_cmp);
+ (GCompareFunc) g_ir_node_cmp);
break;
}
default:
@@ -841,7 +960,7 @@ g_idl_node_add_member (GIdlNode *node,
}
const gchar *
-g_idl_node_param_direction_string (GIdlNodeParam * node)
+g_ir_node_param_direction_string (GIrNodeParam * node)
{
if (node->out)
{
@@ -883,8 +1002,8 @@ parse_boolean_value (const gchar *str)
return parse_int_value (str) ? TRUE : FALSE;
}
-static GIdlNode *
-find_entry_node (GIdlModule *module,
+static GIrNode *
+find_entry_node (GIrModule *module,
GList *modules,
const gchar *name,
guint16 *idx)
@@ -894,7 +1013,7 @@ find_entry_node (GIdlModule *module,
gint i;
gchar **names;
gint n_names;
- GIdlNode *result = NULL;
+ GIrNode *result = NULL;
names = g_strsplit (name, ".", 0);
n_names = g_strv_length (names);
@@ -903,15 +1022,15 @@ find_entry_node (GIdlModule *module,
for (l = module->entries, i = 1; l; l = l->next, i++)
{
- GIdlNode *node = (GIdlNode *)l->data;
+ GIrNode *node = (GIrNode *)l->data;
if (n_names > 1)
{
- if (node->type != G_IDL_NODE_XREF)
+ if (node->type != G_IR_NODE_XREF)
continue;
- if (((GIdlNodeXRef *)node)->namespace == NULL ||
- strcmp (((GIdlNodeXRef *)node)->namespace, names[0]) != 0)
+ if (((GIrNodeXRef *)node)->namespace == NULL ||
+ strcmp (((GIrNodeXRef *)node)->namespace, names[0]) != 0)
continue;
}
@@ -927,9 +1046,9 @@ find_entry_node (GIdlModule *module,
if (n_names > 1)
{
- GIdlNode *node = g_idl_node_new (G_IDL_NODE_XREF);
+ GIrNode *node = g_ir_node_new (G_IR_NODE_XREF);
- ((GIdlNodeXRef *)node)->namespace = g_strdup (names[0]);
+ ((GIrNodeXRef *)node)->namespace = g_strdup (names[0]);
node->name = g_strdup (names[1]);
module->entries = g_list_append (module->entries, node);
@@ -942,7 +1061,7 @@ find_entry_node (GIdlModule *module,
goto out;
}
- g_warning ("Entry %s not found", name);
+ g_warning ("Entry '%s' not found", name);
out:
@@ -952,7 +1071,7 @@ find_entry_node (GIdlModule *module,
}
static guint16
-find_entry (GIdlModule *module,
+find_entry (GIrModule *module,
GList *modules,
const gchar *name)
{
@@ -964,33 +1083,36 @@ find_entry (GIdlModule *module,
}
static void
-serialize_type (GIdlModule *module,
+serialize_type (GIrModule *module,
GList *modules,
- GIdlNodeType *node,
+ GIrNodeType *node,
GString *str)
{
gint i;
const gchar* basic[] = {
"void",
- "gboolean",
- "gint8",
- "guint8",
- "gint16",
- "guint16",
- "gint32",
- "guint32",
- "gint64",
- "guint64",
- "gint",
- "guint",
- "glong",
- "gulong",
- "gssize",
- "gsize",
- "gfloat",
- "gdouble",
+ "boolean",
+ "int8",
+ "uint8",
+ "int16",
+ "uint16",
+ "int32",
+ "uint32",
+ "int64",
+ "uint64",
+ "int",
+ "uint",
+ "long",
+ "ulong",
+ "ssize",
+ "size",
+ "float",
+ "double",
"utf8",
- "filename"
+ "filename",
+ "string",
+ "sequence",
+ "any"
};
if (node->tag < 20)
@@ -1014,7 +1136,7 @@ serialize_type (GIdlModule *module,
}
else if (node->tag == 21)
{
- GIdlNode *iface;
+ GIrNode *iface;
gchar *name;
iface = find_entry_node (module, modules, node->interface, NULL);
@@ -1078,30 +1200,37 @@ serialize_type (GIdlModule *module,
}
void
-g_idl_node_build_metadata (GIdlNode *node,
- GIdlModule *module,
- GList *modules,
- GHashTable *strings,
- GHashTable *types,
- guchar *data,
- guint32 *offset,
- guint32 *offset2)
+g_ir_node_build_metadata (GIrNode *node,
+ GIrModule *module,
+ GList *modules,
+ GHashTable *strings,
+ GHashTable *types,
+ guchar *data,
+ guint32 *offset,
+ guint32 *offset2)
{
GList *l;
guint32 old_offset = *offset;
guint32 old_offset2 = *offset2;
+ g_assert (node != NULL);
+
+ g_debug ("build_metadata (%s)",
+ g_ir_node_type_to_string (node->type));
+
switch (node->type)
{
- case G_IDL_NODE_TYPE:
+ case G_IR_NODE_TYPE:
{
- GIdlNodeType *type = (GIdlNodeType *)node;
+ GIrNodeType *type = (GIrNodeType *)node;
SimpleTypeBlob *blob = (SimpleTypeBlob *)&data[*offset];
*offset += 4;
- if (type->tag < TYPE_TAG_ARRAY)
- {
+ if (type->tag < TYPE_TAG_ARRAY ||
+ type->tag == TYPE_TAG_STRING ||
+ type->tag == TYPE_TAG_ANY)
+ {
blob->reserved = 0;
blob->reserved2 = 0;
blob->pointer = type->is_pointer;
@@ -1149,7 +1278,7 @@ g_idl_node_build_metadata (GIdlNode *node,
pos = *offset2 + 4;
*offset2 += 8;
- g_idl_node_build_metadata ((GIdlNode *)type->parameter_type1,
+ g_ir_node_build_metadata ((GIrNode *)type->parameter_type1,
module, modules, strings, types,
data, &pos, offset2);
}
@@ -1184,7 +1313,7 @@ g_idl_node_build_metadata (GIdlNode *node,
pos = *offset2 + 4;
*offset2 += 8;
- g_idl_node_build_metadata ((GIdlNode *)type->parameter_type1,
+ g_ir_node_build_metadata ((GIrNode *)type->parameter_type1,
module, modules, strings, types,
data, &pos, offset2);
}
@@ -1204,10 +1333,10 @@ g_idl_node_build_metadata (GIdlNode *node,
pos = *offset2 + 4;
*offset2 += 12;
- g_idl_node_build_metadata ((GIdlNode *)type->parameter_type1,
+ g_ir_node_build_metadata ((GIrNode *)type->parameter_type1,
module, modules, strings, types,
data, &pos, offset2);
- g_idl_node_build_metadata ((GIdlNode *)type->parameter_type2,
+ g_ir_node_build_metadata ((GIrNode *)type->parameter_type2,
module, modules, strings, types,
data, &pos, offset2);
}
@@ -1242,9 +1371,9 @@ g_idl_node_build_metadata (GIdlNode *node,
}
break;
- case G_IDL_NODE_FIELD:
+ case G_IR_NODE_FIELD:
{
- GIdlNodeField *field = (GIdlNodeField *)node;
+ GIrNodeField *field = (GIrNodeField *)node;
FieldBlob *blob;
blob = (FieldBlob *)&data[*offset];
@@ -1257,15 +1386,15 @@ g_idl_node_build_metadata (GIdlNode *node,
blob->bits = 0;
blob->struct_offset = field->offset;
- g_idl_node_build_metadata ((GIdlNode *)field->type,
+ g_ir_node_build_metadata ((GIrNode *)field->type,
module, modules, strings, types,
data, offset, offset2);
}
break;
- case G_IDL_NODE_PROPERTY:
+ case G_IR_NODE_PROPERTY:
{
- GIdlNodeProperty *prop = (GIdlNodeProperty *)node;
+ GIrNodeProperty *prop = (GIrNodeProperty *)node;
PropertyBlob *blob = (PropertyBlob *)&data[*offset];
*offset += 8;
@@ -1277,17 +1406,17 @@ g_idl_node_build_metadata (GIdlNode *node,
blob->construct_only = prop->construct_only;
blob->reserved = 0;
- g_idl_node_build_metadata ((GIdlNode *)prop->type,
+ g_ir_node_build_metadata ((GIrNode *)prop->type,
module, modules, strings, types,
data, offset, offset2);
}
break;
- case G_IDL_NODE_FUNCTION:
+ case G_IR_NODE_FUNCTION:
{
FunctionBlob *blob = (FunctionBlob *)&data[*offset];
SignatureBlob *blob2 = (SignatureBlob *)&data[*offset2];
- GIdlNodeFunction *function = (GIdlNodeFunction *)node;
+ GIrNodeFunction *function = (GIrNodeFunction *)node;
guint32 signature;
gint n;
@@ -1309,7 +1438,7 @@ g_idl_node_build_metadata (GIdlNode *node,
blob->symbol = write_string (function->symbol, strings, data, offset2);
blob->signature = signature;
- g_idl_node_build_metadata ((GIdlNode *)function->result->type,
+ g_ir_node_build_metadata ((GIrNode *)function->result->type,
module, modules, strings, types,
data, &signature, offset2);
@@ -1323,20 +1452,20 @@ g_idl_node_build_metadata (GIdlNode *node,
for (l = function->parameters; l; l = l->next)
{
- GIdlNode *param = (GIdlNode *)l->data;
+ GIrNode *param = (GIrNode *)l->data;
- g_idl_node_build_metadata (param,
- module, modules, strings, types,
- data, &signature, offset2);
+ g_ir_node_build_metadata (param,
+ module, modules, strings, types,
+ data, &signature, offset2);
}
}
break;
- case G_IDL_NODE_CALLBACK:
+ case G_IR_NODE_CALLBACK:
{
CallbackBlob *blob = (CallbackBlob *)&data[*offset];
SignatureBlob *blob2 = (SignatureBlob *)&data[*offset2];
- GIdlNodeFunction *function = (GIdlNodeFunction *)node;
+ GIrNodeFunction *function = (GIrNodeFunction *)node;
guint32 signature;
gint n;
@@ -1352,7 +1481,7 @@ g_idl_node_build_metadata (GIdlNode *node,
blob->name = write_string (node->name, strings, data, offset2);
blob->signature = signature;
- g_idl_node_build_metadata ((GIdlNode *)function->result->type,
+ g_ir_node_build_metadata ((GIrNode *)function->result->type,
module, modules, strings, types,
data, &signature, offset2);
@@ -1366,20 +1495,20 @@ g_idl_node_build_metadata (GIdlNode *node,
for (l = function->parameters; l; l = l->next)
{
- GIdlNode *param = (GIdlNode *)l->data;
+ GIrNode *param = (GIrNode *)l->data;
- g_idl_node_build_metadata (param,
+ g_ir_node_build_metadata (param,
module, modules, strings, types,
data, &signature, offset2);
}
}
break;
- case G_IDL_NODE_SIGNAL:
+ case G_IR_NODE_SIGNAL:
{
SignalBlob *blob = (SignalBlob *)&data[*offset];
SignatureBlob *blob2 = (SignatureBlob *)&data[*offset2];
- GIdlNodeSignal *signal = (GIdlNodeSignal *)node;
+ GIrNodeSignal *signal = (GIrNodeSignal *)node;
guint32 signature;
gint n;
@@ -1404,7 +1533,7 @@ g_idl_node_build_metadata (GIdlNode *node,
blob->name = write_string (node->name, strings, data, offset2);
blob->signature = signature;
- g_idl_node_build_metadata ((GIdlNode *)signal->result->type,
+ g_ir_node_build_metadata ((GIrNode *)signal->result->type,
module, modules, strings, types,
data, &signature, offset2);
@@ -1418,19 +1547,19 @@ g_idl_node_build_metadata (GIdlNode *node,
for (l = signal->parameters; l; l = l->next)
{
- GIdlNode *param = (GIdlNode *)l->data;
+ GIrNode *param = (GIrNode *)l->data;
- g_idl_node_build_metadata (param, module, modules, strings, types,
+ g_ir_node_build_metadata (param, module, modules, strings, types,
data, &signature, offset2);
}
}
break;
- case G_IDL_NODE_VFUNC:
+ case G_IR_NODE_VFUNC:
{
VFuncBlob *blob = (VFuncBlob *)&data[*offset];
SignatureBlob *blob2 = (SignatureBlob *)&data[*offset2];
- GIdlNodeVFunc *vfunc = (GIdlNodeVFunc *)node;
+ GIrNodeVFunc *vfunc = (GIrNodeVFunc *)node;
guint32 signature;
gint n;
@@ -1451,7 +1580,7 @@ g_idl_node_build_metadata (GIdlNode *node,
blob->reserved2 = 0;
blob->signature = signature;
- g_idl_node_build_metadata ((GIdlNode *)vfunc->result->type,
+ g_ir_node_build_metadata ((GIrNode *)vfunc->result->type,
module, modules, strings, types,
data, &signature, offset2);
@@ -1465,19 +1594,19 @@ g_idl_node_build_metadata (GIdlNode *node,
for (l = vfunc->parameters; l; l = l->next)
{
- GIdlNode *param = (GIdlNode *)l->data;
+ GIrNode *param = (GIrNode *)l->data;
- g_idl_node_build_metadata (param, module, modules, strings,
+ g_ir_node_build_metadata (param, module, modules, strings,
types, data, &signature, offset2);
}
}
break;
- case G_IDL_NODE_PARAM:
+ case G_IR_NODE_PARAM:
{
ArgBlob *blob = (ArgBlob *)&data[*offset];
- GIdlNodeParam *param = (GIdlNodeParam *)node;
-
+ GIrNodeParam *param = (GIrNodeParam *)node;
+
*offset += 8;
blob->name = write_string (node->name, strings, data, offset2);
@@ -1491,15 +1620,15 @@ g_idl_node_build_metadata (GIdlNode *node,
blob->return_value = param->retval;
blob->reserved = 0;
- g_idl_node_build_metadata ((GIdlNode *)param->type, module, modules,
+ g_ir_node_build_metadata ((GIrNode *)param->type, module, modules,
strings, types, data, offset, offset2);
}
break;
- case G_IDL_NODE_STRUCT:
+ case G_IR_NODE_STRUCT:
{
StructBlob *blob = (StructBlob *)&data[*offset];
- GIdlNodeStruct *struct_ = (GIdlNodeStruct *)node;
+ GIrNodeStruct *struct_ = (GIrNodeStruct *)node;
blob->blob_type = BLOB_TYPE_STRUCT;
blob->deprecated = struct_->deprecated;
@@ -1515,34 +1644,34 @@ g_idl_node_build_metadata (GIdlNode *node,
*offset += 20;
for (l = struct_->members; l; l = l->next)
{
- GIdlNode *member = (GIdlNode *)l->data;
+ GIrNode *member = (GIrNode *)l->data;
- if (member->type == G_IDL_NODE_FIELD)
+ if (member->type == G_IR_NODE_FIELD)
{
blob->n_fields++;
- g_idl_node_build_metadata (member, module, modules, strings,
+ g_ir_node_build_metadata (member, module, modules, strings,
types, data, offset, offset2);
}
}
for (l = struct_->members; l; l = l->next)
{
- GIdlNode *member = (GIdlNode *)l->data;
+ GIrNode *member = (GIrNode *)l->data;
- if (member->type == G_IDL_NODE_FUNCTION)
+ if (member->type == G_IR_NODE_FUNCTION)
{
blob->n_methods++;
- g_idl_node_build_metadata (member, module, modules, strings,
+ g_ir_node_build_metadata (member, module, modules, strings,
types, data, offset, offset2);
}
}
}
break;
- case G_IDL_NODE_BOXED:
+ case G_IR_NODE_BOXED:
{
StructBlob *blob = (StructBlob *)&data[*offset];
- GIdlNodeBoxed *boxed = (GIdlNodeBoxed *)node;
+ GIrNodeBoxed *boxed = (GIrNodeBoxed *)node;
blob->blob_type = BLOB_TYPE_BOXED;
blob->deprecated = boxed->deprecated;
@@ -1558,34 +1687,34 @@ g_idl_node_build_metadata (GIdlNode *node,
*offset += 20;
for (l = boxed->members; l; l = l->next)
{
- GIdlNode *member = (GIdlNode *)l->data;
+ GIrNode *member = (GIrNode *)l->data;
- if (member->type == G_IDL_NODE_FIELD)
+ if (member->type == G_IR_NODE_FIELD)
{
blob->n_fields++;
- g_idl_node_build_metadata (member, module, modules, strings,
+ g_ir_node_build_metadata (member, module, modules, strings,
types, data, offset, offset2);
}
}
for (l = boxed->members; l; l = l->next)
{
- GIdlNode *member = (GIdlNode *)l->data;
+ GIrNode *member = (GIrNode *)l->data;
- if (member->type == G_IDL_NODE_FUNCTION)
+ if (member->type == G_IR_NODE_FUNCTION)
{
blob->n_methods++;
- g_idl_node_build_metadata (member, module, modules, strings,
+ g_ir_node_build_metadata (member, module, modules, strings,
types, data, offset, offset2);
}
}
}
break;
- case G_IDL_NODE_UNION:
+ case G_IR_NODE_UNION:
{
UnionBlob *blob = (UnionBlob *)&data[*offset];
- GIdlNodeUnion *union_ = (GIdlNodeUnion *)node;
+ GIrNodeUnion *union_ = (GIrNodeUnion *)node;
blob->blob_type = BLOB_TYPE_UNION;
blob->deprecated = union_->deprecated;
@@ -1613,7 +1742,7 @@ g_idl_node_build_metadata (GIdlNode *node,
{
*offset += 24;
blob->discriminated = TRUE;
- g_idl_node_build_metadata ((GIdlNode *)union_->discriminator_type,
+ g_ir_node_build_metadata ((GIrNode *)union_->discriminator_type,
module, modules, strings, types,
data, offset, offset2);
}
@@ -1627,24 +1756,24 @@ g_idl_node_build_metadata (GIdlNode *node,
for (l = union_->members; l; l = l->next)
{
- GIdlNode *member = (GIdlNode *)l->data;
+ GIrNode *member = (GIrNode *)l->data;
- if (member->type == G_IDL_NODE_FIELD)
+ if (member->type == G_IR_NODE_FIELD)
{
blob->n_fields++;
- g_idl_node_build_metadata (member, module, modules, strings,
+ g_ir_node_build_metadata (member, module, modules, strings,
types, data, offset, offset2);
}
}
for (l = union_->members; l; l = l->next)
{
- GIdlNode *member = (GIdlNode *)l->data;
+ GIrNode *member = (GIrNode *)l->data;
- if (member->type == G_IDL_NODE_FUNCTION)
+ if (member->type == G_IR_NODE_FUNCTION)
{
blob->n_functions++;
- g_idl_node_build_metadata (member, module, modules, strings,
+ g_ir_node_build_metadata (member, module, modules, strings,
types, data, offset, offset2);
}
}
@@ -1653,24 +1782,24 @@ g_idl_node_build_metadata (GIdlNode *node,
{
for (l = union_->discriminators; l; l = l->next)
{
- GIdlNode *member = (GIdlNode *)l->data;
+ GIrNode *member = (GIrNode *)l->data;
- g_idl_node_build_metadata (member, module, modules, strings,
+ g_ir_node_build_metadata (member, module, modules, strings,
types, data, offset, offset2);
}
}
}
break;
- case G_IDL_NODE_ENUM:
- case G_IDL_NODE_FLAGS:
+ case G_IR_NODE_ENUM:
+ case G_IR_NODE_FLAGS:
{
EnumBlob *blob = (EnumBlob *)&data[*offset];
- GIdlNodeEnum *enum_ = (GIdlNodeEnum *)node;
+ GIrNodeEnum *enum_ = (GIrNodeEnum *)node;
*offset += 20;
- if (node->type == G_IDL_NODE_ENUM)
+ if (node->type == G_IR_NODE_ENUM)
blob->blob_type = BLOB_TYPE_ENUM;
else
blob->blob_type = BLOB_TYPE_FLAGS;
@@ -1696,19 +1825,19 @@ g_idl_node_build_metadata (GIdlNode *node,
for (l = enum_->values; l; l = l->next)
{
- GIdlNode *value = (GIdlNode *)l->data;
+ GIrNode *value = (GIrNode *)l->data;
blob->n_values++;
- g_idl_node_build_metadata (value, module, modules, strings, types,
+ g_ir_node_build_metadata (value, module, modules, strings, types,
data, offset, offset2);
}
}
break;
- case G_IDL_NODE_OBJECT:
+ case G_IR_NODE_OBJECT:
{
ObjectBlob *blob = (ObjectBlob *)&data[*offset];
- GIdlNodeInterface *object = (GIdlNodeInterface *)node;
+ GIrNodeInterface *object = (GIrNodeInterface *)node;
blob->blob_type = BLOB_TYPE_OBJECT;
blob->deprecated = object->deprecated;
@@ -1740,12 +1869,12 @@ g_idl_node_build_metadata (GIdlNode *node,
*offset = ALIGN_VALUE (*offset, 4);
for (l = object->members; l; l = l->next)
{
- GIdlNode *member = (GIdlNode *)l->data;
+ GIrNode *member = (GIrNode *)l->data;
- if (member->type == G_IDL_NODE_FIELD)
+ if (member->type == G_IR_NODE_FIELD)
{
blob->n_fields++;
- g_idl_node_build_metadata (member, module, modules, strings,
+ g_ir_node_build_metadata (member, module, modules, strings,
types, data, offset, offset2);
}
}
@@ -1753,12 +1882,12 @@ g_idl_node_build_metadata (GIdlNode *node,
*offset = ALIGN_VALUE (*offset, 4);
for (l = object->members; l; l = l->next)
{
- GIdlNode *member = (GIdlNode *)l->data;
+ GIrNode *member = (GIrNode *)l->data;
- if (member->type == G_IDL_NODE_PROPERTY)
+ if (member->type == G_IR_NODE_PROPERTY)
{
blob->n_properties++;
- g_idl_node_build_metadata (member, module, modules, strings,
+ g_ir_node_build_metadata (member, module, modules, strings,
types, data, offset, offset2);
}
}
@@ -1766,12 +1895,12 @@ g_idl_node_build_metadata (GIdlNode *node,
*offset = ALIGN_VALUE (*offset, 4);
for (l = object->members; l; l = l->next)
{
- GIdlNode *member = (GIdlNode *)l->data;
+ GIrNode *member = (GIrNode *)l->data;
- if (member->type == G_IDL_NODE_FUNCTION)
+ if (member->type == G_IR_NODE_FUNCTION)
{
blob->n_methods++;
- g_idl_node_build_metadata (member, module, modules, strings,
+ g_ir_node_build_metadata (member, module, modules, strings,
types, data, offset, offset2);
}
}
@@ -1779,12 +1908,12 @@ g_idl_node_build_metadata (GIdlNode *node,
*offset = ALIGN_VALUE (*offset, 4);
for (l = object->members; l; l = l->next)
{
- GIdlNode *member = (GIdlNode *)l->data;
+ GIrNode *member = (GIrNode *)l->data;
- if (member->type == G_IDL_NODE_SIGNAL)
+ if (member->type == G_IR_NODE_SIGNAL)
{
blob->n_signals++;
- g_idl_node_build_metadata (member, module, modules, strings,
+ g_ir_node_build_metadata (member, module, modules, strings,
types, data, offset, offset2);
}
}
@@ -1792,12 +1921,12 @@ g_idl_node_build_metadata (GIdlNode *node,
*offset = ALIGN_VALUE (*offset, 4);
for (l = object->members; l; l = l->next)
{
- GIdlNode *member = (GIdlNode *)l->data;
+ GIrNode *member = (GIrNode *)l->data;
- if (member->type == G_IDL_NODE_VFUNC)
+ if (member->type == G_IR_NODE_VFUNC)
{
blob->n_vfuncs++;
- g_idl_node_build_metadata (member, module, modules, strings,
+ g_ir_node_build_metadata (member, module, modules, strings,
types, data, offset, offset2);
}
}
@@ -1805,22 +1934,22 @@ g_idl_node_build_metadata (GIdlNode *node,
*offset = ALIGN_VALUE (*offset, 4);
for (l = object->members; l; l = l->next)
{
- GIdlNode *member = (GIdlNode *)l->data;
+ GIrNode *member = (GIrNode *)l->data;
- if (member->type == G_IDL_NODE_CONSTANT)
+ if (member->type == G_IR_NODE_CONSTANT)
{
blob->n_constants++;
- g_idl_node_build_metadata (member, module, modules, strings,
+ g_ir_node_build_metadata (member, module, modules, strings,
types, data, offset, offset2);
}
}
}
break;
- case G_IDL_NODE_INTERFACE:
+ case G_IR_NODE_INTERFACE:
{
InterfaceBlob *blob = (InterfaceBlob *)&data[*offset];
- GIdlNodeInterface *iface = (GIdlNodeInterface *)node;
+ GIrNodeInterface *iface = (GIrNodeInterface *)node;
blob->blob_type = BLOB_TYPE_INTERFACE;
blob->deprecated = iface->deprecated;
@@ -1846,12 +1975,12 @@ g_idl_node_build_metadata (GIdlNode *node,
*offset = ALIGN_VALUE (*offset, 4);
for (l = iface->members; l; l = l->next)
{
- GIdlNode *member = (GIdlNode *)l->data;
+ GIrNode *member = (GIrNode *)l->data;
- if (member->type == G_IDL_NODE_PROPERTY)
+ if (member->type == G_IR_NODE_PROPERTY)
{
blob->n_properties++;
- g_idl_node_build_metadata (member, module, modules, strings,
+ g_ir_node_build_metadata (member, module, modules, strings,
types, data, offset, offset2);
}
}
@@ -1859,12 +1988,12 @@ g_idl_node_build_metadata (GIdlNode *node,
*offset = ALIGN_VALUE (*offset, 4);
for (l = iface->members; l; l = l->next)
{
- GIdlNode *member = (GIdlNode *)l->data;
+ GIrNode *member = (GIrNode *)l->data;
- if (member->type == G_IDL_NODE_FUNCTION)
+ if (member->type == G_IR_NODE_FUNCTION)
{
blob->n_methods++;
- g_idl_node_build_metadata (member, module, modules, strings,
+ g_ir_node_build_metadata (member, module, modules, strings,
types, data, offset, offset2);
}
}
@@ -1872,12 +2001,12 @@ g_idl_node_build_metadata (GIdlNode *node,
*offset = ALIGN_VALUE (*offset, 4);
for (l = iface->members; l; l = l->next)
{
- GIdlNode *member = (GIdlNode *)l->data;
+ GIrNode *member = (GIrNode *)l->data;
- if (member->type == G_IDL_NODE_SIGNAL)
+ if (member->type == G_IR_NODE_SIGNAL)
{
blob->n_signals++;
- g_idl_node_build_metadata (member, module, modules, strings,
+ g_ir_node_build_metadata (member, module, modules, strings,
types, data, offset, offset2);
}
}
@@ -1885,12 +2014,12 @@ g_idl_node_build_metadata (GIdlNode *node,
*offset = ALIGN_VALUE (*offset, 4);
for (l = iface->members; l; l = l->next)
{
- GIdlNode *member = (GIdlNode *)l->data;
+ GIrNode *member = (GIrNode *)l->data;
- if (member->type == G_IDL_NODE_VFUNC)
+ if (member->type == G_IR_NODE_VFUNC)
{
blob->n_vfuncs++;
- g_idl_node_build_metadata (member, module, modules, strings,
+ g_ir_node_build_metadata (member, module, modules, strings,
types, data, offset, offset2);
}
}
@@ -1898,12 +2027,12 @@ g_idl_node_build_metadata (GIdlNode *node,
*offset = ALIGN_VALUE (*offset, 4);
for (l = iface->members; l; l = l->next)
{
- GIdlNode *member = (GIdlNode *)l->data;
+ GIrNode *member = (GIrNode *)l->data;
- if (member->type == G_IDL_NODE_CONSTANT)
+ if (member->type == G_IR_NODE_CONSTANT)
{
blob->n_constants++;
- g_idl_node_build_metadata (member, module, modules, strings,
+ g_ir_node_build_metadata (member, module, modules, strings,
types, data, offset, offset2);
}
}
@@ -1911,9 +2040,9 @@ g_idl_node_build_metadata (GIdlNode *node,
break;
- case G_IDL_NODE_VALUE:
+ case G_IR_NODE_VALUE:
{
- GIdlNodeValue *value = (GIdlNodeValue *)node;
+ GIrNodeValue *value = (GIrNodeValue *)node;
ValueBlob *blob = (ValueBlob *)&data[*offset];
*offset += 12;
@@ -1924,9 +2053,9 @@ g_idl_node_build_metadata (GIdlNode *node,
}
break;
- case G_IDL_NODE_ERROR_DOMAIN:
+ case G_IR_NODE_ERROR_DOMAIN:
{
- GIdlNodeErrorDomain *domain = (GIdlNodeErrorDomain *)node;
+ GIrNodeErrorDomain *domain = (GIrNodeErrorDomain *)node;
ErrorDomainBlob *blob = (ErrorDomainBlob *)&data[*offset];
*offset += 16;
@@ -1940,9 +2069,9 @@ g_idl_node_build_metadata (GIdlNode *node,
}
break;
- case G_IDL_NODE_CONSTANT:
+ case G_IR_NODE_CONSTANT:
{
- GIdlNodeConstant *constant = (GIdlNodeConstant *)node;
+ GIrNodeConstant *constant = (GIrNodeConstant *)node;
ConstantBlob *blob = (ConstantBlob *)&data[*offset];
guint32 pos;
@@ -2027,7 +2156,7 @@ g_idl_node_build_metadata (GIdlNode *node,
}
*offset2 += ALIGN_VALUE (blob->size, 4);
- g_idl_node_build_metadata ((GIdlNode *)constant->type, module, modules,
+ g_ir_node_build_metadata ((GIrNode *)constant->type, module, modules,
strings, types, data, &pos, offset2);
}
break;
@@ -2035,10 +2164,11 @@ g_idl_node_build_metadata (GIdlNode *node,
g_assert_not_reached ();
}
- g_debug ("node %p type %d, offset %d -> %d, offset2 %d -> %d",
- node, node->type, old_offset, *offset, old_offset2, *offset2);
+ g_debug ("node %p type '%s', offset %d -> %d, offset2 %d -> %d",
+ node, g_ir_node_type_to_string (node->type),
+ old_offset, *offset, old_offset2, *offset2);
- if (*offset2 - old_offset2 + *offset - old_offset > g_idl_node_get_full_size (node))
+ if (*offset2 - old_offset2 + *offset - old_offset > g_ir_node_get_full_size (node))
g_error ("exceeding space reservation !!");
}
diff --git a/tools/gidlnode.h b/tools/girnode.h
index 32a9a939..66144d38 100644
--- a/tools/gidlnode.h
+++ b/tools/girnode.h
@@ -1,4 +1,4 @@
-/* GObject introspection: Parsed IDL
+/* GObject introspection: Parsed GIR
*
* Copyright (C) 2005 Matthias Clasen
*
@@ -18,71 +18,71 @@
* Boston, MA 02111-1307, USA.
*/
-#ifndef __G_IDL_NODE_H__
-#define __G_IDL_NODE_H__
+#ifndef __G_IR_NODE_H__
+#define __G_IR_NODE_H__
#include <glib.h>
G_BEGIN_DECLS
-typedef struct _GIdlNode GIdlNode;
-typedef struct _GIdlNodeFunction GIdlNodeFunction;
-typedef struct _GIdlNodeParam GIdlNodeParam;
-typedef struct _GIdlNodeType GIdlNodeType;
-typedef struct _GIdlNodeInterface GIdlNodeInterface;
-typedef struct _GIdlNodeSignal GIdlNodeSignal;
-typedef struct _GIdlNodeProperty GIdlNodeProperty;
-typedef struct _GIdlNodeVFunc GIdlNodeVFunc;
-typedef struct _GIdlNodeField GIdlNodeField;
-typedef struct _GIdlNodeValue GIdlNodeValue;
-typedef struct _GIdlNodeEnum GIdlNodeEnum;
-typedef struct _GIdlNodeBoxed GIdlNodeBoxed;
-typedef struct _GIdlNodeStruct GIdlNodeStruct;
-typedef struct _GIdlNodeConstant GIdlNodeConstant;
-typedef struct _GIdlNodeErrorDomain GIdlNodeErrorDomain;
-typedef struct _GIdlNodeXRef GIdlNodeXRef;
-typedef struct _GIdlNodeUnion GIdlNodeUnion;
+typedef struct _GIrNode GIrNode;
+typedef struct _GIrNodeFunction GIrNodeFunction;
+typedef struct _GIrNodeParam GIrNodeParam;
+typedef struct _GIrNodeType GIrNodeType;
+typedef struct _GIrNodeInterface GIrNodeInterface;
+typedef struct _GIrNodeSignal GIrNodeSignal;
+typedef struct _GIrNodeProperty GIrNodeProperty;
+typedef struct _GIrNodeVFunc GIrNodeVFunc;
+typedef struct _GIrNodeField GIrNodeField;
+typedef struct _GIrNodeValue GIrNodeValue;
+typedef struct _GIrNodeEnum GIrNodeEnum;
+typedef struct _GIrNodeBoxed GIrNodeBoxed;
+typedef struct _GIrNodeStruct GIrNodeStruct;
+typedef struct _GIrNodeConstant GIrNodeConstant;
+typedef struct _GIrNodeErrorDomain GIrNodeErrorDomain;
+typedef struct _GIrNodeXRef GIrNodeXRef;
+typedef struct _GIrNodeUnion GIrNodeUnion;
typedef enum
{
- G_IDL_NODE_INVALID,
- G_IDL_NODE_FUNCTION,
- G_IDL_NODE_CALLBACK,
- G_IDL_NODE_STRUCT,
- G_IDL_NODE_BOXED,
- G_IDL_NODE_ENUM,
- G_IDL_NODE_FLAGS,
- G_IDL_NODE_OBJECT,
- G_IDL_NODE_INTERFACE,
- G_IDL_NODE_CONSTANT,
- G_IDL_NODE_ERROR_DOMAIN,
- G_IDL_NODE_UNION,
- G_IDL_NODE_PARAM,
- G_IDL_NODE_TYPE,
- G_IDL_NODE_PROPERTY,
- G_IDL_NODE_SIGNAL,
- G_IDL_NODE_VALUE,
- G_IDL_NODE_VFUNC,
- G_IDL_NODE_FIELD,
- G_IDL_NODE_XREF
-} GIdlNodeTypeId;
-
-struct _GIdlNode
+ G_IR_NODE_INVALID = 0,
+ G_IR_NODE_FUNCTION = 1,
+ G_IR_NODE_CALLBACK = 2,
+ G_IR_NODE_STRUCT = 3,
+ G_IR_NODE_BOXED = 4,
+ G_IR_NODE_ENUM = 5,
+ G_IR_NODE_FLAGS = 6,
+ G_IR_NODE_OBJECT = 7,
+ G_IR_NODE_INTERFACE = 8,
+ G_IR_NODE_CONSTANT = 9,
+ G_IR_NODE_ERROR_DOMAIN = 10,
+ G_IR_NODE_UNION = 11,
+ G_IR_NODE_PARAM = 12,
+ G_IR_NODE_TYPE = 13,
+ G_IR_NODE_PROPERTY = 14,
+ G_IR_NODE_SIGNAL = 15,
+ G_IR_NODE_VALUE = 16,
+ G_IR_NODE_VFUNC = 17,
+ G_IR_NODE_FIELD = 18,
+ G_IR_NODE_XREF = 19
+} GIrNodeTypeId;
+
+struct _GIrNode
{
- GIdlNodeTypeId type;
+ GIrNodeTypeId type;
gchar *name;
};
-struct _GIdlNodeXRef
+struct _GIrNodeXRef
{
- GIdlNode node;
+ GIrNode node;
gchar *namespace;
};
-struct _GIdlNodeFunction
+struct _GIrNodeFunction
{
- GIdlNode node;
+ GIrNode node;
gboolean deprecated;
@@ -94,13 +94,13 @@ struct _GIdlNodeFunction
gchar *symbol;
- GIdlNodeParam *result;
+ GIrNodeParam *result;
GList *parameters;
};
-struct _GIdlNodeType
+struct _GIrNodeType
{
- GIdlNode node;
+ GIrNode node;
gboolean is_pointer;
gboolean is_basic;
@@ -118,16 +118,16 @@ struct _GIdlNodeType
gboolean has_length;
gint length;
- GIdlNodeType *parameter_type1;
- GIdlNodeType *parameter_type2;
+ GIrNodeType *parameter_type1;
+ GIrNodeType *parameter_type2;
gchar *interface;
gchar **errors;
};
-struct _GIdlNodeParam
+struct _GIrNodeParam
{
- GIdlNode node;
+ GIrNode node;
gboolean in;
gboolean out;
@@ -138,12 +138,12 @@ struct _GIdlNodeParam
gboolean transfer;
gboolean shallow_transfer;
- GIdlNodeType *type;
+ GIrNodeType *type;
};
-struct _GIdlNodeProperty
+struct _GIrNodeProperty
{
- GIdlNode node;
+ GIrNode node;
gboolean deprecated;
@@ -153,12 +153,12 @@ struct _GIdlNodeProperty
gboolean construct;
gboolean construct_only;
- GIdlNodeType *type;
+ GIrNodeType *type;
};
-struct _GIdlNodeSignal
+struct _GIrNodeSignal
{
- GIdlNode node;
+ GIrNode node;
gboolean deprecated;
@@ -176,12 +176,12 @@ struct _GIdlNodeSignal
gint class_closure;
GList *parameters;
- GIdlNodeParam *result;
+ GIrNodeParam *result;
};
-struct _GIdlNodeVFunc
+struct _GIrNodeVFunc
{
- GIdlNode node;
+ GIrNode node;
gboolean must_chain_up;
gboolean must_be_implemented;
@@ -189,26 +189,26 @@ struct _GIdlNodeVFunc
gboolean is_class_closure;
GList *parameters;
- GIdlNodeParam *result;
+ GIrNodeParam *result;
gint offset;
};
-struct _GIdlNodeField
+struct _GIrNodeField
{
- GIdlNode node;
+ GIrNode node;
gboolean readable;
gboolean writable;
gint bits;
gint offset;
- GIdlNodeType *type;
+ GIrNodeType *type;
};
-struct _GIdlNodeInterface
+struct _GIrNodeInterface
{
- GIdlNode node;
+ GIrNode node;
gboolean deprecated;
@@ -223,29 +223,29 @@ struct _GIdlNodeInterface
GList *members;
};
-struct _GIdlNodeValue
+struct _GIrNodeValue
{
- GIdlNode node;
+ GIrNode node;
gboolean deprecated;
guint32 value;
};
-struct _GIdlNodeConstant
+struct _GIrNodeConstant
{
- GIdlNode node;
+ GIrNode node;
gboolean deprecated;
- GIdlNodeType *type;
+ GIrNodeType *type;
gchar *value;
};
-struct _GIdlNodeEnum
+struct _GIrNodeEnum
{
- GIdlNode node;
+ GIrNode node;
gboolean deprecated;
@@ -255,9 +255,9 @@ struct _GIdlNodeEnum
GList *values;
};
-struct _GIdlNodeBoxed
+struct _GIrNodeBoxed
{
- GIdlNode node;
+ GIrNode node;
gboolean deprecated;
@@ -267,18 +267,18 @@ struct _GIdlNodeBoxed
GList *members;
};
-struct _GIdlNodeStruct
+struct _GIrNodeStruct
{
- GIdlNode node;
+ GIrNode node;
gboolean deprecated;
GList *members;
};
-struct _GIdlNodeUnion
+struct _GIrNodeUnion
{
- GIdlNode node;
+ GIrNode node;
gboolean deprecated;
@@ -289,13 +289,13 @@ struct _GIdlNodeUnion
gchar *gtype_init;
gint discriminator_offset;
- GIdlNodeType *discriminator_type;
+ GIrNodeType *discriminator_type;
};
-struct _GIdlNodeErrorDomain
+struct _GIrNodeErrorDomain
{
- GIdlNode node;
+ GIrNode node;
gboolean deprecated;
@@ -305,30 +305,30 @@ struct _GIdlNodeErrorDomain
};
-GIdlNode *g_idl_node_new (GIdlNodeTypeId type);
-void g_idl_node_free (GIdlNode *node);
-guint32 g_idl_node_get_size (GIdlNode *node);
-guint32 g_idl_node_get_full_size (GIdlNode *node);
-void g_idl_node_build_metadata (GIdlNode *node,
- GIdlModule *module,
+GIrNode * g_ir_node_new (GIrNodeTypeId type);
+void g_ir_node_free (GIrNode *node);
+guint32 g_ir_node_get_size (GIrNode *node);
+guint32 g_ir_node_get_full_size (GIrNode *node);
+void g_ir_node_build_metadata (GIrNode *node,
+ GIrModule *module,
GList *modules,
GHashTable *strings,
GHashTable *types,
guchar *data,
guint32 *offset,
guint32 *offset2);
-int g_idl_node_cmp (GIdlNode *node,
- GIdlNode *other);
-gboolean g_idl_node_can_have_member (GIdlNode *node);
-void g_idl_node_add_member (GIdlNode *node,
- GIdlNodeFunction *member);
+int g_ir_node_cmp (GIrNode *node,
+ GIrNode *other);
+gboolean g_ir_node_can_have_member (GIrNode *node);
+void g_ir_node_add_member (GIrNode *node,
+ GIrNodeFunction *member);
guint32 write_string (const gchar *str,
GHashTable *strings,
guchar *data,
guint32 *offset);
-const gchar * g_idl_node_param_direction_string (GIdlNodeParam * node);
+const gchar * g_ir_node_param_direction_string (GIrNodeParam * node);
G_END_DECLS
-#endif /* __G_IDL_NODE_H__ */
+#endif /* __G_IR_NODE_H__ */
diff --git a/tools/gidlparser.c b/tools/girparser.c
index 52b3d788..565542c4 100644
--- a/tools/gidlparser.c
+++ b/tools/girparser.c
@@ -1,6 +1,6 @@
-/* GObject introspection: A parser for the XML IDL format
+/* GObject introspection: A parser for the XML GIR format
*
- * Copyright (C) 2005 Matthias Clasen
+ * Copyright (C) 2008 Philip Van Hoof
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -20,31 +20,40 @@
#include <stdlib.h>
#include <string.h>
-#include <stdlib.h>
+#include <stdio.h>
#include <glib.h>
-#include "gidlmodule.h"
-#include "gidlnode.h"
+#include "girmodule.h"
+#include "girnode.h"
#include "gtypelib.h"
typedef enum
{
- STATE_START,
- STATE_END,
- STATE_ROOT,
- STATE_NAMESPACE,
- STATE_FUNCTION,
- STATE_PARAMETERS,
- STATE_OBJECT,
+ STATE_START,
+ STATE_END,
+ STATE_REPOSITORY,
+ STATE_NAMESPACE,
+ STATE_ENUM,
+ STATE_BITFIELD, /* 5 */
+ STATE_FUNCTION,
+ STATE_FUNCTION_RETURN,
+ STATE_FUNCTION_PARAMETERS,
+ STATE_FUNCTION_PARAMETER,
+ STATE_CLASS, /* 10 */
+ STATE_CLASS_FIELD,
+ STATE_CLASS_PROPERTY,
STATE_INTERFACE,
- STATE_IMPLEMENTS,
+ STATE_INTERFACE_PROPERTY,
+ STATE_INTERFACE_FIELD, /* 15 */
+ STATE_IMPLEMENTS,
STATE_REQUIRES,
- STATE_ENUM,
- STATE_BOXED,
- STATE_STRUCT,
- STATE_SIGNAL,
- STATE_ERRORDOMAIN,
- STATE_UNION
+ STATE_BOXED,
+ STATE_BOXED_FIELD,
+ STATE_STRUCT, /* 20 */
+ STATE_STRUCT_FIELD,
+ STATE_ERRORDOMAIN,
+ STATE_UNION,
+ STATE_CONSTANT
} ParseState;
typedef struct _ParseContext ParseContext;
@@ -55,16 +64,43 @@ struct _ParseContext
GList *modules;
- GIdlModule *current_module;
- GIdlNode *current_node;
+ GIrModule *current_module;
+ GIrNode *current_node;
+ GIrNode *current_typed;
};
-#define MISSING_ATTRIBUTE(error,element,attribute) \
- g_set_error (error, \
- G_MARKUP_ERROR, \
- G_MARKUP_ERROR_INVALID_CONTENT, \
- "The attribute '%s' on the element '%s' must be specified", \
- attribute, element)
+#define MISSING_ATTRIBUTE(ctx,error,element,attribute) \
+ do { \
+ int line_number, char_number; \
+ g_markup_parse_context_get_position (context, &line_number, &char_number); \
+ g_set_error (error, \
+ G_MARKUP_ERROR, \
+ G_MARKUP_ERROR_INVALID_CONTENT, \
+ "Line %d, character %d: The attribute '%s' on the element '%s' must be specified", \
+ line_number, char_number, attribute, element); \
+ } while (0)
+
+static void
+backtrace_stderr (void)
+{
+ void *array[50];
+ int size;
+ char **strings;
+ size_t i;
+
+ size = backtrace (array, 50);
+ strings = (char**) backtrace_symbols (array, size);
+
+ fprintf (stderr, "--- BACKTRACE (%zd frames) ---\n", size);
+
+ for (i = 0; i < size; i++)
+ fprintf (stderr, "%s\n", strings[i]);
+
+ fprintf (stderr, "--- END BACKTRACE ---\n", size);
+
+ free (strings);
+}
+
static const gchar *
find_attribute (const gchar *name,
@@ -80,7 +116,14 @@ find_attribute (const gchar *name,
return 0;
}
-static GIdlNodeType *
+static void
+state_switch (ParseContext *ctx, ParseState newstate)
+{
+ ctx->prev_state = ctx->state;
+ ctx->state = newstate;
+}
+
+static GIrNodeType *
parse_type_internal (gchar *str, gchar **rest)
{
gint i;
@@ -141,15 +184,16 @@ parse_type_internal (gchar *str, gchar **rest)
{ "gdouble", TYPE_TAG_DOUBLE, 0 },
{ "utf8", TYPE_TAG_UTF8, 1 },
{ "gchar*", TYPE_TAG_UTF8, 1 },
- { "filename", TYPE_TAG_FILENAME,1 }
+ { "filename", TYPE_TAG_FILENAME,1 },
+ { "string", TYPE_TAG_STRING, 1 }
};
gint n_basic = G_N_ELEMENTS (basic);
gchar *start, *end;
- GIdlNodeType *type;
+ GIrNodeType *type;
- type = (GIdlNodeType *)g_idl_node_new (G_IDL_NODE_TYPE);
+ type = (GIrNodeType *)g_ir_node_new (G_IR_NODE_TYPE);
str = g_strstrip (str);
@@ -293,9 +337,9 @@ parse_type_internal (gchar *str, gchar **rest)
*rest = g_strchug (*rest);
if (g_str_has_prefix (*rest, "["))
{
- GIdlNodeType *array;
+ GIrNodeType *array;
- array = (GIdlNodeType *)g_idl_node_new (G_IDL_NODE_TYPE);
+ array = (GIrNodeType *)g_ir_node_new (G_IR_NODE_TYPE);
array->tag = TYPE_TAG_ARRAY;
array->is_pointer = TRUE;
@@ -344,17 +388,17 @@ parse_type_internal (gchar *str, gchar **rest)
return type;
error:
- g_idl_node_free ((GIdlNode *)type);
+ g_ir_node_free ((GIrNode *)type);
return NULL;
}
-static GIdlNodeType *
+static GIrNodeType *
parse_type (const gchar *type)
{
gchar *str;
gchar *rest;
- GIdlNodeType *node;
+ GIrNodeType *node;
str = g_strdup (type);
node = parse_type_internal (str, &rest);
@@ -364,14 +408,14 @@ parse_type (const gchar *type)
}
static gboolean
-start_boxed (GMarkupParseContext *context,
- const gchar *element_name,
- const gchar **attribute_names,
- const gchar **attribute_values,
- ParseContext *ctx,
- GError **error)
+start_glib_boxed (GMarkupParseContext *context,
+ const gchar *element_name,
+ const gchar **attribute_names,
+ const gchar **attribute_values,
+ ParseContext *ctx,
+ GError **error)
{
- if (strcmp (element_name, "boxed") == 0 &&
+ if (strcmp (element_name, "glib:boxed") == 0 &&
ctx->state == STATE_NAMESPACE)
{
const gchar *name;
@@ -379,24 +423,24 @@ start_boxed (GMarkupParseContext *context,
const gchar *typeinit;
const gchar *deprecated;
- name = find_attribute ("name", attribute_names, attribute_values);
- typename = find_attribute ("type-name", attribute_names, attribute_values);
- typeinit = find_attribute ("get-type", attribute_names, attribute_values);
+ name = find_attribute ("glib:name", attribute_names, attribute_values);
+ typename = find_attribute ("glib:type-name", attribute_names, attribute_values);
+ typeinit = find_attribute ("glib:get-type", attribute_names, attribute_values);
deprecated = find_attribute ("deprecated", attribute_names, attribute_values);
if (name == NULL)
- MISSING_ATTRIBUTE (error, element_name, "name");
+ MISSING_ATTRIBUTE (context, error, element_name, "glib:name");
else if (typename == NULL)
- MISSING_ATTRIBUTE (error, element_name, "type-name");
+ MISSING_ATTRIBUTE (context, error, element_name, "glib:type-name");
else if (typeinit == NULL)
- MISSING_ATTRIBUTE (error, element_name, "get-type");
+ MISSING_ATTRIBUTE (context, error, element_name, "glib:get-type");
else
{
- GIdlNodeBoxed *boxed;
+ GIrNodeBoxed *boxed;
- boxed = (GIdlNodeBoxed *) g_idl_node_new (G_IDL_NODE_BOXED);
+ boxed = (GIrNodeBoxed *) g_ir_node_new (G_IR_NODE_BOXED);
- ((GIdlNode *)boxed)->name = g_strdup (name);
+ ((GIrNode *)boxed)->name = g_strdup (name);
boxed->gtype_name = g_strdup (typename);
boxed->gtype_init = g_strdup (typeinit);
if (deprecated && strcmp (deprecated, "1") == 0)
@@ -404,11 +448,11 @@ start_boxed (GMarkupParseContext *context,
else
boxed->deprecated = FALSE;
- ctx->current_node = (GIdlNode *)boxed;
+ ctx->current_node = (GIrNode *)boxed;
ctx->current_module->entries =
g_list_append (ctx->current_module->entries, boxed);
- ctx->state = STATE_BOXED;
+ state_switch (ctx, STATE_BOXED);
}
return TRUE;
@@ -428,15 +472,16 @@ start_function (GMarkupParseContext *context,
if ((ctx->state == STATE_NAMESPACE &&
(strcmp (element_name, "function") == 0 ||
strcmp (element_name, "callback") == 0)) ||
- ((ctx->state == STATE_OBJECT ||
+ ((ctx->state == STATE_CLASS ||
ctx->state == STATE_INTERFACE ||
ctx->state == STATE_BOXED ||
- ctx->state == STATE_STRUCT ||
ctx->state == STATE_UNION) &&
- strcmp (element_name, "method") == 0) ||
- ((ctx->state == STATE_OBJECT ||
+ (strcmp (element_name, "method") == 0 ||
+ strcmp (element_name, "callback") == 0)) ||
+ ((ctx->state == STATE_CLASS ||
ctx->state == STATE_BOXED) &&
- strcmp (element_name, "constructor") == 0))
+ (strcmp (element_name, "constructor") == 0)) ||
+ (ctx->state == STATE_STRUCT && strcmp (element_name, "callback") == 0))
{
const gchar *name;
const gchar *symbol;
@@ -444,21 +489,21 @@ start_function (GMarkupParseContext *context,
const gchar *type;
name = find_attribute ("name", attribute_names, attribute_values);
- symbol = find_attribute ("symbol", attribute_names, attribute_values);
+ symbol = find_attribute ("c:identifier", attribute_names, attribute_values);
deprecated = find_attribute ("deprecated", attribute_names, attribute_values);
type = find_attribute ("type", attribute_names, attribute_values);
if (name == NULL)
- MISSING_ATTRIBUTE (error, element_name, "name");
+ MISSING_ATTRIBUTE (context, error, element_name, "name");
else if (strcmp (element_name, "callback") != 0 && symbol == NULL)
- MISSING_ATTRIBUTE (error, element_name, "symbol");
+ MISSING_ATTRIBUTE (context, error, element_name, "c:identifier");
else
{
- GIdlNodeFunction *function;
+ GIrNodeFunction *function;
- function = (GIdlNodeFunction *) g_idl_node_new (G_IDL_NODE_FUNCTION);
+ function = (GIrNodeFunction *) g_ir_node_new (G_IR_NODE_FUNCTION);
- ((GIdlNode *)function)->name = g_strdup (name);
+ ((GIrNode *)function)->name = g_strdup (name);
function->symbol = g_strdup (symbol);
function->parameters = NULL;
if (deprecated && strcmp (deprecated, "1") == 0)
@@ -488,7 +533,7 @@ start_function (GMarkupParseContext *context,
function->is_getter = FALSE;
function->is_constructor = FALSE;
if (strcmp (element_name, "callback") == 0)
- ((GIdlNode *)function)->type = G_IDL_NODE_CALLBACK;
+ ((GIrNode *)function)->type = G_IR_NODE_CALLBACK;
}
if (ctx->current_node == NULL)
@@ -499,35 +544,35 @@ start_function (GMarkupParseContext *context,
else
switch (ctx->current_node->type)
{
- case G_IDL_NODE_INTERFACE:
- case G_IDL_NODE_OBJECT:
+ case G_IR_NODE_INTERFACE:
+ case G_IR_NODE_OBJECT:
{
- GIdlNodeInterface *iface;
+ GIrNodeInterface *iface;
- iface = (GIdlNodeInterface *)ctx->current_node;
+ iface = (GIrNodeInterface *)ctx->current_node;
iface->members = g_list_append (iface->members, function);
}
break;
- case G_IDL_NODE_BOXED:
+ case G_IR_NODE_BOXED:
{
- GIdlNodeBoxed *boxed;
+ GIrNodeBoxed *boxed;
- boxed = (GIdlNodeBoxed *)ctx->current_node;
+ boxed = (GIrNodeBoxed *)ctx->current_node;
boxed->members = g_list_append (boxed->members, function);
}
break;
- case G_IDL_NODE_STRUCT:
+ case G_IR_NODE_STRUCT:
{
- GIdlNodeStruct *struct_;
+ GIrNodeStruct *struct_;
- struct_ = (GIdlNodeStruct *)ctx->current_node;
+ struct_ = (GIrNodeStruct *)ctx->current_node;
struct_->members = g_list_append (struct_->members, function); }
break;
- case G_IDL_NODE_UNION:
+ case G_IR_NODE_UNION:
{
- GIdlNodeUnion *union_;
+ GIrNodeUnion *union_;
- union_ = (GIdlNodeUnion *)ctx->current_node;
+ union_ = (GIrNodeUnion *)ctx->current_node;
union_->members = g_list_append (union_->members, function);
}
break;
@@ -535,8 +580,8 @@ start_function (GMarkupParseContext *context,
g_assert_not_reached ();
}
- ctx->current_node = (GIdlNode *)function;
- ctx->state = STATE_FUNCTION;
+ ctx->current_node = (GIrNode *)function;
+ state_switch (ctx, STATE_FUNCTION);
return TRUE;
}
@@ -553,128 +598,122 @@ start_parameter (GMarkupParseContext *context,
ParseContext *ctx,
GError **error)
{
- if (strcmp (element_name, "parameter") == 0 &&
- ctx->state == STATE_PARAMETERS)
- {
- const gchar *type;
- const gchar *name;
- const gchar *direction;
- const gchar *retval;
- const gchar *dipper;
- const gchar *optional;
- const gchar *nullok;
- const gchar *transfer;
+ const gchar *name;
+ const gchar *direction;
+ const gchar *retval;
+ const gchar *dipper;
+ const gchar *optional;
+ const gchar *nullok;
+ const gchar *transfer;
+ GIrNodeParam *param;
- type = find_attribute ("type", attribute_names, attribute_values);
- name = find_attribute ("name", attribute_names, attribute_values);
- direction = find_attribute ("direction", attribute_names, attribute_values);
- retval = find_attribute ("retval", attribute_names, attribute_values);
- dipper = find_attribute ("dipper", attribute_names, attribute_values);
- optional = find_attribute ("optional", attribute_names, attribute_values);
- nullok = find_attribute ("null-ok", attribute_names, attribute_values);
- transfer = find_attribute ("transfer", attribute_names, attribute_values);
+ if (!(strcmp (element_name, "parameter") == 0 &&
+ ctx->state == STATE_FUNCTION_PARAMETERS))
+ return FALSE;
- if (type == NULL)
- MISSING_ATTRIBUTE (error, element_name, "type");
- else if (name == NULL)
- MISSING_ATTRIBUTE (error, element_name, "name");
- else
- {
- GIdlNodeParam *param;
+ name = find_attribute ("name", attribute_names, attribute_values);
+ direction = find_attribute ("direction", attribute_names, attribute_values);
+ retval = find_attribute ("retval", attribute_names, attribute_values);
+ dipper = find_attribute ("dipper", attribute_names, attribute_values);
+ optional = find_attribute ("optional", attribute_names, attribute_values);
+ nullok = find_attribute ("null-ok", attribute_names, attribute_values);
+ transfer = find_attribute ("transfer", attribute_names, attribute_values);
- param = (GIdlNodeParam *)g_idl_node_new (G_IDL_NODE_PARAM);
-
- if (direction && strcmp (direction, "out") == 0)
- {
- param->in = FALSE;
- param->out = TRUE;
- }
- else if (direction && strcmp (direction, "inout") == 0)
- {
- param->in = TRUE;
- param->out = TRUE;
- }
- else
- {
- param->in = TRUE;
- param->out = FALSE;
- }
+ if (name == NULL)
+ name = "unknown";
- if (retval && strcmp (retval, "1") == 0)
- param->retval = TRUE;
- else
- param->retval = FALSE;
+ param = (GIrNodeParam *)g_ir_node_new (G_IR_NODE_PARAM);
- if (dipper && strcmp (dipper, "1") == 0)
- param->dipper = TRUE;
- else
- param->dipper = FALSE;
+ ctx->current_typed = (GIrNode*) param;
- if (optional && strcmp (optional, "1") == 0)
- param->optional = TRUE;
- else
- param->optional = FALSE;
+ state_switch (ctx, STATE_FUNCTION_PARAMETER);
- if (nullok && strcmp (nullok, "1") == 0)
- param->null_ok = TRUE;
- else
- param->null_ok = FALSE;
+ if (direction && strcmp (direction, "out") == 0)
+ {
+ param->in = FALSE;
+ param->out = TRUE;
+ }
+ else if (direction && strcmp (direction, "inout") == 0)
+ {
+ param->in = TRUE;
+ param->out = TRUE;
+ }
+ else
+ {
+ param->in = TRUE;
+ param->out = FALSE;
+ }
- if (transfer && strcmp (transfer, "none") == 0)
- {
- param->transfer = FALSE;
- param->shallow_transfer = FALSE;
- }
- else if (transfer && strcmp (transfer, "shallow") == 0)
- {
- param->transfer = FALSE;
- param->shallow_transfer = TRUE;
- }
- else
- {
- param->transfer = TRUE;
- param->shallow_transfer = FALSE;
- }
+ if (retval && strcmp (retval, "1") == 0)
+ param->retval = TRUE;
+ else
+ param->retval = FALSE;
+
+ if (dipper && strcmp (dipper, "1") == 0)
+ param->dipper = TRUE;
+ else
+ param->dipper = FALSE;
+
+ if (optional && strcmp (optional, "1") == 0)
+ param->optional = TRUE;
+ else
+ param->optional = FALSE;
+
+ if (nullok && strcmp (nullok, "1") == 0)
+ param->null_ok = TRUE;
+ else
+ param->null_ok = FALSE;
+
+ if (transfer && strcmp (transfer, "none") == 0)
+ {
+ param->transfer = FALSE;
+ param->shallow_transfer = FALSE;
+ }
+ else if (transfer && strcmp (transfer, "shallow") == 0)
+ {
+ param->transfer = FALSE;
+ param->shallow_transfer = TRUE;
+ }
+ else
+ {
+ param->transfer = TRUE;
+ param->shallow_transfer = FALSE;
+ }
- ((GIdlNode *)param)->name = g_strdup (name);
- param->type = parse_type (type);
+ ((GIrNode *)param)->name = g_strdup (name);
- switch (ctx->current_node->type)
- {
- case G_IDL_NODE_FUNCTION:
- case G_IDL_NODE_CALLBACK:
- {
- GIdlNodeFunction *func;
-
- func = (GIdlNodeFunction *)ctx->current_node;
- func->parameters = g_list_append (func->parameters, param);
- }
- break;
- case G_IDL_NODE_SIGNAL:
- {
- GIdlNodeSignal *signal;
+ switch (ctx->current_node->type)
+ {
+ case G_IR_NODE_FUNCTION:
+ case G_IR_NODE_CALLBACK:
+ {
+ GIrNodeFunction *func;
+
+ func = (GIrNodeFunction *)ctx->current_node;
+ func->parameters = g_list_append (func->parameters, param);
+ }
+ break;
+ case G_IR_NODE_SIGNAL:
+ {
+ GIrNodeSignal *signal;
- signal = (GIdlNodeSignal *)ctx->current_node;
- signal->parameters = g_list_append (signal->parameters, param);
- }
- break;
- case G_IDL_NODE_VFUNC:
- {
- GIdlNodeVFunc *vfunc;
+ signal = (GIrNodeSignal *)ctx->current_node;
+ signal->parameters = g_list_append (signal->parameters, param);
+ }
+ break;
+ case G_IR_NODE_VFUNC:
+ {
+ GIrNodeVFunc *vfunc;
- vfunc = (GIdlNodeVFunc *)ctx->current_node;
- vfunc->parameters = g_list_append (vfunc->parameters, param);
- }
- break;
- default:
- g_assert_not_reached ();
- }
- }
-
- return TRUE;
+ vfunc = (GIrNodeVFunc *)ctx->current_node;
+ vfunc->parameters = g_list_append (vfunc->parameters, param);
+ }
+ break;
+ default:
+ g_assert_not_reached ();
}
- return FALSE;
+ return TRUE;
}
static gboolean
@@ -686,10 +725,11 @@ start_field (GMarkupParseContext *context,
GError **error)
{
if (strcmp (element_name, "field") == 0 &&
- (ctx->state == STATE_OBJECT ||
+ (ctx->state == STATE_CLASS ||
ctx->state == STATE_BOXED ||
ctx->state == STATE_STRUCT ||
- ctx->state == STATE_UNION))
+ ctx->state == STATE_UNION ||
+ ctx->state == STATE_INTERFACE))
{
const gchar *name;
const gchar *type;
@@ -700,7 +740,7 @@ start_field (GMarkupParseContext *context,
const gchar *offset;
name = find_attribute ("name", attribute_names, attribute_values);
- type = find_attribute ("type", attribute_names, attribute_values);
+ type = find_attribute ("c:type", attribute_names, attribute_values);
readable = find_attribute ("readable", attribute_names, attribute_values);
writable = find_attribute ("writable", attribute_names, attribute_values);
bits = find_attribute ("bits", attribute_names, attribute_values);
@@ -708,15 +748,14 @@ start_field (GMarkupParseContext *context,
offset = find_attribute ("offset", attribute_names, attribute_values);
if (name == NULL)
- MISSING_ATTRIBUTE (error, element_name, "name");
- else if (type == NULL)
- MISSING_ATTRIBUTE (error, element_name, "type");
+ MISSING_ATTRIBUTE (context, error, element_name, "name");
else
{
- GIdlNodeField *field;
+ GIrNodeField *field;
- field = (GIdlNodeField *)g_idl_node_new (G_IDL_NODE_FIELD);
- ((GIdlNode *)field)->name = g_strdup (name);
+ field = (GIrNodeField *)g_ir_node_new (G_IR_NODE_FIELD);
+ ctx->current_typed = (GIrNode*) field;
+ ((GIrNode *)field)->name = g_strdup (name);
if (readable && strcmp (readable, "1") == 0)
field->readable = TRUE;
else
@@ -737,46 +776,56 @@ start_field (GMarkupParseContext *context,
else
field->offset = 0;
- field->type = parse_type (type);
-
switch (ctx->current_node->type)
{
- case G_IDL_NODE_OBJECT:
+ case G_IR_NODE_OBJECT:
{
- GIdlNodeInterface *iface;
+ GIrNodeInterface *iface;
- iface = (GIdlNodeInterface *)ctx->current_node;
+ iface = (GIrNodeInterface *)ctx->current_node;
iface->members = g_list_append (iface->members, field);
+ state_switch (ctx, STATE_CLASS_FIELD);
}
break;
- case G_IDL_NODE_BOXED:
+ case G_IR_NODE_INTERFACE:
{
- GIdlNodeBoxed *boxed;
+ GIrNodeInterface *iface;
- boxed = (GIdlNodeBoxed *)ctx->current_node;
+ iface = (GIrNodeInterface *)ctx->current_node;
+ iface->members = g_list_append (iface->members, field);
+ state_switch (ctx, STATE_INTERFACE_FIELD);
+ }
+ break;
+ case G_IR_NODE_BOXED:
+ {
+ GIrNodeBoxed *boxed;
+
+ boxed = (GIrNodeBoxed *)ctx->current_node;
boxed->members = g_list_append (boxed->members, field);
+ state_switch (ctx, STATE_BOXED_FIELD);
}
break;
- case G_IDL_NODE_STRUCT:
+ case G_IR_NODE_STRUCT:
{
- GIdlNodeStruct *struct_;
+ GIrNodeStruct *struct_;
- struct_ = (GIdlNodeStruct *)ctx->current_node;
+ struct_ = (GIrNodeStruct *)ctx->current_node;
struct_->members = g_list_append (struct_->members, field);
+ state_switch (ctx, STATE_STRUCT_FIELD);
}
break;
- case G_IDL_NODE_UNION:
+ case G_IR_NODE_UNION:
{
- GIdlNodeUnion *union_;
+ GIrNodeUnion *union_;
- union_ = (GIdlNodeUnion *)ctx->current_node;
+ union_ = (GIrNodeUnion *)ctx->current_node;
union_->members = g_list_append (union_->members, field);
if (branch)
{
- GIdlNodeConstant *constant;
+ GIrNodeConstant *constant;
- constant = (GIdlNodeConstant *) g_idl_node_new (G_IDL_NODE_CONSTANT);
- ((GIdlNode *)constant)->name = g_strdup (name);
+ constant = (GIrNodeConstant *) g_ir_node_new (G_IR_NODE_CONSTANT);
+ ((GIrNode *)constant)->name = g_strdup (name);
constant->value = g_strdup (branch);
constant->type = union_->discriminator_type;
constant->deprecated = FALSE;
@@ -803,8 +852,8 @@ start_enum (GMarkupParseContext *context,
ParseContext *ctx,
GError **error)
{
- if ((strcmp (element_name, "enum") == 0 && ctx->state == STATE_NAMESPACE) ||
- (strcmp (element_name, "flags") == 0 && ctx->state == STATE_NAMESPACE))
+ if ((strcmp (element_name, "enumeration") == 0 && ctx->state == STATE_NAMESPACE) ||
+ (strcmp (element_name, "bitfield") == 0 && ctx->state == STATE_NAMESPACE))
{
const gchar *name;
const gchar *typename;
@@ -812,21 +861,21 @@ start_enum (GMarkupParseContext *context,
const gchar *deprecated;
name = find_attribute ("name", attribute_names, attribute_values);
- typename = find_attribute ("type-name", attribute_names, attribute_values);
- typeinit = find_attribute ("get-type", attribute_names, attribute_values);
+ typename = find_attribute ("glib:type-name", attribute_names, attribute_values);
+ typeinit = find_attribute ("glib:get-type", attribute_names, attribute_values);
deprecated = find_attribute ("deprecated", attribute_names, attribute_values);
if (name == NULL)
- MISSING_ATTRIBUTE (error, element_name, "name");
+ MISSING_ATTRIBUTE (context, error, element_name, "name");
else
{
- GIdlNodeEnum *enum_;
+ GIrNodeEnum *enum_;
- if (strcmp (element_name, "enum") == 0)
- enum_ = (GIdlNodeEnum *) g_idl_node_new (G_IDL_NODE_ENUM);
+ if (strcmp (element_name, "enumeration") == 0)
+ enum_ = (GIrNodeEnum *) g_ir_node_new (G_IR_NODE_ENUM);
else
- enum_ = (GIdlNodeEnum *) g_idl_node_new (G_IDL_NODE_FLAGS);
- ((GIdlNode *)enum_)->name = g_strdup (name);
+ enum_ = (GIrNodeEnum *) g_ir_node_new (G_IR_NODE_FLAGS);
+ ((GIrNode *)enum_)->name = g_strdup (name);
enum_->gtype_name = g_strdup (typename);
enum_->gtype_init = g_strdup (typeinit);
if (deprecated && strcmp (deprecated, "1") == 0)
@@ -834,11 +883,11 @@ start_enum (GMarkupParseContext *context,
else
enum_->deprecated = FALSE;
- ctx->current_node = (GIdlNode *) enum_;
+ ctx->current_node = (GIrNode *) enum_;
ctx->current_module->entries =
g_list_append (ctx->current_module->entries, enum_);
- ctx->state = STATE_ENUM;
+ state_switch (ctx, STATE_ENUM);
}
return TRUE;
@@ -855,35 +904,32 @@ start_property (GMarkupParseContext *context,
GError **error)
{
if (strcmp (element_name, "property") == 0 &&
- (ctx->state == STATE_OBJECT ||
+ (ctx->state == STATE_CLASS ||
ctx->state == STATE_INTERFACE))
{
const gchar *name;
- const gchar *type;
const gchar *readable;
const gchar *writable;
const gchar *construct;
const gchar *construct_only;
name = find_attribute ("name", attribute_names, attribute_values);
- type = find_attribute ("type", attribute_names, attribute_values);
readable = find_attribute ("readable", attribute_names, attribute_values);
writable = find_attribute ("writable", attribute_names, attribute_values);
construct = find_attribute ("construct", attribute_names, attribute_values);
construct_only = find_attribute ("construct-only", attribute_names, attribute_values);
if (name == NULL)
- MISSING_ATTRIBUTE (error, element_name, "name");
- else if (type == NULL)
- MISSING_ATTRIBUTE (error, element_name, "type");
+ MISSING_ATTRIBUTE (context, error, element_name, "name");
else
{
- GIdlNodeProperty *property;
- GIdlNodeInterface *iface;
+ GIrNodeProperty *property;
+ GIrNodeInterface *iface;
- property = (GIdlNodeProperty *) g_idl_node_new (G_IDL_NODE_PROPERTY);
+ property = (GIrNodeProperty *) g_ir_node_new (G_IR_NODE_PROPERTY);
+ ctx->current_typed = (GIrNode*) property;
- ((GIdlNode *)property)->name = g_strdup (name);
+ ((GIrNode *)property)->name = g_strdup (name);
if (readable && strcmp (readable, "1") == 0)
property->readable = TRUE;
@@ -902,10 +948,15 @@ start_property (GMarkupParseContext *context,
else
property->construct_only = FALSE;
- property->type = parse_type (type);
-
- iface = (GIdlNodeInterface *)ctx->current_node;
+ iface = (GIrNodeInterface *)ctx->current_node;
iface->members = g_list_append (iface->members, property);
+
+ if (ctx->state == STATE_CLASS)
+ state_switch (ctx, STATE_CLASS_PROPERTY);
+ else if (ctx->state == STATE_INTERFACE)
+ state_switch (ctx, STATE_INTERFACE_PROPERTY);
+ else
+ g_assert_not_reached ();
}
return TRUE;
@@ -956,15 +1007,15 @@ start_member (GMarkupParseContext *context,
deprecated = find_attribute ("deprecated", attribute_names, attribute_values);
if (name == NULL)
- MISSING_ATTRIBUTE (error, element_name, "name");
+ MISSING_ATTRIBUTE (context, error, element_name, "name");
else
{
- GIdlNodeEnum *enum_;
- GIdlNodeValue *value_;
+ GIrNodeEnum *enum_;
+ GIrNodeValue *value_;
- value_ = (GIdlNodeValue *) g_idl_node_new (G_IDL_NODE_VALUE);
+ value_ = (GIrNodeValue *) g_ir_node_new (G_IR_NODE_VALUE);
- ((GIdlNode *)value_)->name = g_strdup (name);
+ ((GIrNode *)value_)->name = g_strdup (name);
value_->value = parse_value (value);
@@ -973,7 +1024,7 @@ start_member (GMarkupParseContext *context,
else
value_->deprecated = FALSE;
- enum_ = (GIdlNodeEnum *)ctx->current_node;
+ enum_ = (GIrNodeEnum *)ctx->current_node;
enum_->values = g_list_append (enum_->values, value_);
}
@@ -992,7 +1043,7 @@ start_constant (GMarkupParseContext *context,
{
if (strcmp (element_name, "constant") == 0 &&
(ctx->state == STATE_NAMESPACE ||
- ctx->state == STATE_OBJECT ||
+ ctx->state == STATE_CLASS ||
ctx->state == STATE_INTERFACE))
{
const gchar *name;
@@ -1001,23 +1052,23 @@ start_constant (GMarkupParseContext *context,
const gchar *deprecated;
name = find_attribute ("name", attribute_names, attribute_values);
- type = find_attribute ("type", attribute_names, attribute_values);
+ type = find_attribute ("c:type", attribute_names, attribute_values);
value = find_attribute ("value", attribute_names, attribute_values);
deprecated = find_attribute ("deprecated", attribute_names, attribute_values);
if (name == NULL)
- MISSING_ATTRIBUTE (error, element_name, "name");
+ MISSING_ATTRIBUTE (context, error, element_name, "name");
else if (type == NULL)
- MISSING_ATTRIBUTE (error, element_name, "type");
+ MISSING_ATTRIBUTE (context, error, element_name, "c:type");
else if (value == NULL)
- MISSING_ATTRIBUTE (error, element_name, "value");
+ MISSING_ATTRIBUTE (context, error, element_name, "value");
else
{
- GIdlNodeConstant *constant;
+ GIrNodeConstant *constant;
- constant = (GIdlNodeConstant *) g_idl_node_new (G_IDL_NODE_CONSTANT);
+ constant = (GIrNodeConstant *) g_ir_node_new (G_IR_NODE_CONSTANT);
- ((GIdlNode *)constant)->name = g_strdup (name);
+ ((GIrNode *)constant)->name = g_strdup (name);
constant->value = g_strdup (value);
constant->type = parse_type (type);
@@ -1029,17 +1080,18 @@ start_constant (GMarkupParseContext *context,
if (ctx->state == STATE_NAMESPACE)
{
- ctx->current_node = (GIdlNode *) constant;
+ ctx->current_node = (GIrNode *) constant;
ctx->current_module->entries =
g_list_append (ctx->current_module->entries, constant);
}
else
{
- GIdlNodeInterface *iface;
+ GIrNodeInterface *iface;
- iface = (GIdlNodeInterface *)ctx->current_node;
+ iface = (GIrNodeInterface *)ctx->current_node;
iface->members = g_list_append (iface->members, constant);
}
+ state_switch (ctx, STATE_CONSTANT);
}
return TRUE;
@@ -1069,18 +1121,18 @@ start_errordomain (GMarkupParseContext *context,
deprecated = find_attribute ("deprecated", attribute_names, attribute_values);
if (name == NULL)
- MISSING_ATTRIBUTE (error, element_name, "name");
+ MISSING_ATTRIBUTE (context, error, element_name, "name");
else if (getquark == NULL)
- MISSING_ATTRIBUTE (error, element_name, "getquark");
+ MISSING_ATTRIBUTE (context, error, element_name, "getquark");
else if (codes == NULL)
- MISSING_ATTRIBUTE (error, element_name, "codes");
+ MISSING_ATTRIBUTE (context, error, element_name, "codes");
else
{
- GIdlNodeErrorDomain *domain;
+ GIrNodeErrorDomain *domain;
- domain = (GIdlNodeErrorDomain *) g_idl_node_new (G_IDL_NODE_ERROR_DOMAIN);
+ domain = (GIrNodeErrorDomain *) g_ir_node_new (G_IR_NODE_ERROR_DOMAIN);
- ((GIdlNode *)domain)->name = g_strdup (name);
+ ((GIrNode *)domain)->name = g_strdup (name);
domain->getquark = g_strdup (getquark);
domain->codes = g_strdup (codes);
@@ -1089,11 +1141,11 @@ start_errordomain (GMarkupParseContext *context,
else
domain->deprecated = FALSE;
- ctx->current_node = (GIdlNode *) domain;
+ ctx->current_node = (GIrNode *) domain;
ctx->current_module->entries =
g_list_append (ctx->current_module->entries, domain);
- ctx->state = STATE_ERRORDOMAIN;
+ state_switch (ctx, STATE_ERRORDOMAIN);
}
return TRUE;
@@ -1118,22 +1170,22 @@ start_interface (GMarkupParseContext *context,
const gchar *deprecated;
name = find_attribute ("name", attribute_names, attribute_values);
- typename = find_attribute ("type-name", attribute_names, attribute_values);
- typeinit = find_attribute ("get-type", attribute_names, attribute_values);
+ typename = find_attribute ("glib:type-name", attribute_names, attribute_values);
+ typeinit = find_attribute ("glib:get-type", attribute_names, attribute_values);
deprecated = find_attribute ("deprecated", attribute_names, attribute_values);
if (name == NULL)
- MISSING_ATTRIBUTE (error, element_name, "name");
+ MISSING_ATTRIBUTE (context, error, element_name, "name");
else if (typename == NULL)
- MISSING_ATTRIBUTE (error, element_name, "type-name");
+ MISSING_ATTRIBUTE (context, error, element_name, "glib:type-name");
else if (typeinit == NULL)
- MISSING_ATTRIBUTE (error, element_name, "get-type");
+ MISSING_ATTRIBUTE (context, error, element_name, "glib:get-type");
else
{
- GIdlNodeInterface *iface;
+ GIrNodeInterface *iface;
- iface = (GIdlNodeInterface *) g_idl_node_new (G_IDL_NODE_INTERFACE);
- ((GIdlNode *)iface)->name = g_strdup (name);
+ iface = (GIrNodeInterface *) g_ir_node_new (G_IR_NODE_INTERFACE);
+ ((GIrNode *)iface)->name = g_strdup (name);
iface->gtype_name = g_strdup (typename);
iface->gtype_init = g_strdup (typeinit);
if (deprecated && strcmp (deprecated, "1") == 0)
@@ -1141,11 +1193,11 @@ start_interface (GMarkupParseContext *context,
else
iface->deprecated = FALSE;
- ctx->current_node = (GIdlNode *) iface;
+ ctx->current_node = (GIrNode *) iface;
ctx->current_module->entries =
g_list_append (ctx->current_module->entries, iface);
- ctx->state = STATE_INTERFACE;
+ state_switch (ctx, STATE_INTERFACE);
}
@@ -1155,14 +1207,14 @@ start_interface (GMarkupParseContext *context,
}
static gboolean
-start_object (GMarkupParseContext *context,
+start_class (GMarkupParseContext *context,
const gchar *element_name,
const gchar **attribute_names,
const gchar **attribute_values,
ParseContext *ctx,
GError **error)
{
- if (strcmp (element_name, "object") == 0 &&
+ if (strcmp (element_name, "class") == 0 &&
ctx->state == STATE_NAMESPACE)
{
const gchar *name;
@@ -1173,22 +1225,22 @@ start_object (GMarkupParseContext *context,
name = find_attribute ("name", attribute_names, attribute_values);
parent = find_attribute ("parent", attribute_names, attribute_values);
- typename = find_attribute ("type-name", attribute_names, attribute_values);
- typeinit = find_attribute ("get-type", attribute_names, attribute_values);
+ typename = find_attribute ("glib:type-name", attribute_names, attribute_values);
+ typeinit = find_attribute ("glib:get-type", attribute_names, attribute_values);
deprecated = find_attribute ("deprecated", attribute_names, attribute_values);
if (name == NULL)
- MISSING_ATTRIBUTE (error, element_name, "name");
+ MISSING_ATTRIBUTE (context, error, element_name, "name");
else if (typename == NULL)
- MISSING_ATTRIBUTE (error, element_name, "type-name");
+ MISSING_ATTRIBUTE (context, error, element_name, "glib:type-name");
else if (typeinit == NULL)
- MISSING_ATTRIBUTE (error, element_name, "get-type");
+ MISSING_ATTRIBUTE (context, error, element_name, "glib:get-type");
else
{
- GIdlNodeInterface *iface;
+ GIrNodeInterface *iface;
- iface = (GIdlNodeInterface *) g_idl_node_new (G_IDL_NODE_OBJECT);
- ((GIdlNode *)iface)->name = g_strdup (name);
+ iface = (GIrNodeInterface *) g_ir_node_new (G_IR_NODE_OBJECT);
+ ((GIrNode *)iface)->name = g_strdup (name);
iface->gtype_name = g_strdup (typename);
iface->gtype_init = g_strdup (typeinit);
iface->parent = g_strdup (parent);
@@ -1197,11 +1249,11 @@ start_object (GMarkupParseContext *context,
else
iface->deprecated = FALSE;
- ctx->current_node = (GIdlNode *) iface;
+ ctx->current_node = (GIrNode *) iface;
ctx->current_module->entries =
g_list_append (ctx->current_module->entries, iface);
- ctx->state = STATE_OBJECT;
+ state_switch (ctx, STATE_CLASS);
}
return TRUE;
@@ -1210,79 +1262,119 @@ start_object (GMarkupParseContext *context,
}
static gboolean
-start_return_type (GMarkupParseContext *context,
- const gchar *element_name,
- const gchar **attribute_names,
- const gchar **attribute_values,
- ParseContext *ctx,
- GError **error)
+start_type (GMarkupParseContext *context,
+ const gchar *element_name,
+ const gchar **attribute_names,
+ const gchar **attribute_values,
+ ParseContext *ctx,
+ GError **error)
+{
+ const gchar *name;
+ const gchar *ctype;
+
+ if (strcmp (element_name, "type") != 0 ||
+ !(ctx->state == STATE_FUNCTION_PARAMETER ||
+ ctx->state == STATE_FUNCTION_RETURN ||
+ ctx->state == STATE_STRUCT_FIELD ||
+ ctx->state == STATE_CLASS_PROPERTY ||
+ ctx->state == STATE_CLASS_FIELD ||
+ ctx->state == STATE_INTERFACE_FIELD ||
+ ctx->state == STATE_BOXED_FIELD
+ ))
+ return FALSE;
+
+ if (!ctx->current_typed)
+ {
+ g_set_error (error,
+ G_MARKUP_ERROR,
+ G_MARKUP_ERROR_INVALID_CONTENT,
+ "The element <type> is invalid here");
+ return FALSE;
+ }
+
+ name = find_attribute ("name", attribute_names, attribute_values);
+ ctype = find_attribute ("c:type", attribute_names, attribute_values);
+
+ if (name == NULL)
+ MISSING_ATTRIBUTE (context, error, element_name, "name");
+ if (ctype == NULL)
+ MISSING_ATTRIBUTE (context, error, element_name, "c:type");
+
+ switch (ctx->current_typed->type)
+ {
+ case G_IR_NODE_PARAM:
+ {
+ GIrNodeParam *param;
+ param = (GIrNodeParam *)ctx->current_typed;
+ param->type = parse_type (name);
+ }
+ break;
+ case G_IR_NODE_FIELD:
+ {
+ GIrNodeField *field = (GIrNodeField *)ctx->current_typed;
+ field->type = parse_type (name);
+ }
+ break;
+ case G_IR_NODE_PROPERTY:
+ {
+ GIrNodeProperty *property = (GIrNodeProperty *) ctx->current_typed;
+ property->type = parse_type (name);
+ }
+ break;
+ default:
+ g_printerr("current node is %d\n", ctx->current_node->type);
+ g_assert_not_reached ();
+ }
+
+ ctx->current_typed = NULL;
+ return TRUE;
+}
+
+static gboolean
+start_return_value (GMarkupParseContext *context,
+ const gchar *element_name,
+ const gchar **attribute_names,
+ const gchar **attribute_values,
+ ParseContext *ctx,
+ GError **error)
{
- if (strcmp (element_name, "return-type") == 0 &&
+ if (strcmp (element_name, "return-value") == 0 &&
ctx->state == STATE_FUNCTION)
{
- const gchar *type;
- const gchar *nullok;
- const gchar *transfer;
-
- type = find_attribute ("type", attribute_names, attribute_values);
- nullok = find_attribute ("null-ok", attribute_names, attribute_values);
- transfer = find_attribute ("transfer", attribute_names, attribute_values);
- if (type == NULL)
- MISSING_ATTRIBUTE (error, element_name, "type");
- else
+ GIrNodeParam *param;
+
+ param = (GIrNodeParam *)g_ir_node_new (G_IR_NODE_PARAM);
+ param->in = FALSE;
+ param->out = FALSE;
+ param->retval = TRUE;
+
+ ctx->current_typed = (GIrNode*) param;
+
+ state_switch (ctx, STATE_FUNCTION_RETURN);
+
+ switch (ctx->current_node->type)
{
- GIdlNodeParam *param;
-
- param = (GIdlNodeParam *)g_idl_node_new (G_IDL_NODE_PARAM);
- param->in = FALSE;
- param->out = FALSE;
- param->retval = TRUE;
- if (nullok && strcmp (nullok, "1") == 0)
- param->null_ok = TRUE;
- else
- param->null_ok = FALSE;
- if (transfer && strcmp (transfer, "none") == 0)
- {
- param->transfer = FALSE;
- param->shallow_transfer = FALSE;
- }
- else if (transfer && strcmp (transfer, "shallow") == 0)
- {
- param->transfer = FALSE;
- param->shallow_transfer = TRUE;
- }
- else
- {
- param->transfer = TRUE;
- param->shallow_transfer = FALSE;
- }
-
- param->type = parse_type (type);
-
- switch (ctx->current_node->type)
- {
- case G_IDL_NODE_FUNCTION:
- case G_IDL_NODE_CALLBACK:
- {
- GIdlNodeFunction *func = (GIdlNodeFunction *)ctx->current_node;
- func->result = param;
- }
- break;
- case G_IDL_NODE_SIGNAL:
- {
- GIdlNodeSignal *signal = (GIdlNodeSignal *)ctx->current_node;
- signal->result = param;
- }
- break;
- case G_IDL_NODE_VFUNC:
- {
- GIdlNodeVFunc *vfunc = (GIdlNodeVFunc *)ctx->current_node;
- vfunc->result = param;
- }
- break;
- default:
- g_assert_not_reached ();
- }
+ case G_IR_NODE_FUNCTION:
+ case G_IR_NODE_CALLBACK:
+ {
+ GIrNodeFunction *func = (GIrNodeFunction *)ctx->current_node;
+ func->result = param;
+ }
+ break;
+ case G_IR_NODE_SIGNAL:
+ {
+ GIrNodeSignal *signal = (GIrNodeSignal *)ctx->current_node;
+ signal->result = param;
+ }
+ break;
+ case G_IR_NODE_VFUNC:
+ {
+ GIrNodeVFunc *vfunc = (GIrNodeVFunc *)ctx->current_node;
+ vfunc->result = param;
+ }
+ break;
+ default:
+ g_assert_not_reached ();
}
return TRUE;
@@ -1292,15 +1384,15 @@ start_return_type (GMarkupParseContext *context,
}
static gboolean
-start_signal (GMarkupParseContext *context,
- const gchar *element_name,
- const gchar **attribute_names,
- const gchar **attribute_values,
- ParseContext *ctx,
- GError **error)
+start_glib_signal (GMarkupParseContext *context,
+ const gchar *element_name,
+ const gchar **attribute_names,
+ const gchar **attribute_values,
+ ParseContext *ctx,
+ GError **error)
{
- if (strcmp (element_name, "signal") == 0 &&
- (ctx->state == STATE_OBJECT ||
+ if (strcmp (element_name, "glib:signal") == 0 &&
+ (ctx->state == STATE_CLASS ||
ctx->state == STATE_INTERFACE))
{
const gchar *name;
@@ -1320,25 +1412,23 @@ start_signal (GMarkupParseContext *context,
has_class_closure = find_attribute ("has-class-closure", attribute_names, attribute_values);
if (name == NULL)
- MISSING_ATTRIBUTE (error, element_name, "name");
- else if (when == NULL)
- MISSING_ATTRIBUTE (error, element_name, "when");
+ MISSING_ATTRIBUTE (context, error, element_name, "name");
else
{
- GIdlNodeInterface *iface;
- GIdlNodeSignal *signal;
+ GIrNodeInterface *iface;
+ GIrNodeSignal *signal;
- signal = (GIdlNodeSignal *)g_idl_node_new (G_IDL_NODE_SIGNAL);
+ signal = (GIrNodeSignal *)g_ir_node_new (G_IR_NODE_SIGNAL);
- ((GIdlNode *)signal)->name = g_strdup (name);
+ ((GIrNode *)signal)->name = g_strdup (name);
signal->run_first = FALSE;
signal->run_last = FALSE;
signal->run_cleanup = FALSE;
- if (strcmp (when, "FIRST") == 0)
- signal->run_first = TRUE;
- else if (strcmp (when, "LAST") == 0)
+ if (when == NULL || strcmp (when, "LAST") == 0)
signal->run_last = TRUE;
+ else if (strcmp (when, "FIRST") == 0)
+ signal->run_first = TRUE;
else
signal->run_cleanup = TRUE;
@@ -1363,11 +1453,11 @@ start_signal (GMarkupParseContext *context,
else
signal->has_class_closure = FALSE;
- iface = (GIdlNodeInterface *)ctx->current_node;
+ iface = (GIrNodeInterface *)ctx->current_node;
iface->members = g_list_append (iface->members, signal);
- ctx->current_node = (GIdlNode *)signal;
- ctx->state = STATE_FUNCTION;
+ ctx->current_node = (GIrNode *)signal;
+ state_switch (ctx, STATE_FUNCTION);
}
return TRUE;
@@ -1384,7 +1474,7 @@ start_vfunc (GMarkupParseContext *context,
GError **error)
{
if (strcmp (element_name, "vfunc") == 0 &&
- (ctx->state == STATE_OBJECT ||
+ (ctx->state == STATE_CLASS ||
ctx->state == STATE_INTERFACE))
{
const gchar *name;
@@ -1400,15 +1490,15 @@ start_vfunc (GMarkupParseContext *context,
offset = find_attribute ("offset", attribute_names, attribute_values);
if (name == NULL)
- MISSING_ATTRIBUTE (error, element_name, "name");
+ MISSING_ATTRIBUTE (context, error, element_name, "name");
else
{
- GIdlNodeInterface *iface;
- GIdlNodeVFunc *vfunc;
+ GIrNodeInterface *iface;
+ GIrNodeVFunc *vfunc;
- vfunc = (GIdlNodeVFunc *)g_idl_node_new (G_IDL_NODE_VFUNC);
+ vfunc = (GIrNodeVFunc *)g_ir_node_new (G_IR_NODE_VFUNC);
- ((GIdlNode *)vfunc)->name = g_strdup (name);
+ ((GIrNode *)vfunc)->name = g_strdup (name);
if (must_chain_up && strcmp (must_chain_up, "1") == 0)
vfunc->must_chain_up = TRUE;
@@ -1441,11 +1531,11 @@ start_vfunc (GMarkupParseContext *context,
else
vfunc->offset = 0;
- iface = (GIdlNodeInterface *)ctx->current_node;
+ iface = (GIrNodeInterface *)ctx->current_node;
iface->members = g_list_append (iface->members, vfunc);
- ctx->current_node = (GIdlNode *)vfunc;
- ctx->state = STATE_FUNCTION;
+ ctx->current_node = (GIrNode *)vfunc;
+ state_switch (ctx, STATE_FUNCTION);
}
return TRUE;
@@ -1462,7 +1552,7 @@ start_struct (GMarkupParseContext *context,
ParseContext *ctx,
GError **error)
{
- if (strcmp (element_name, "struct") == 0 &&
+ if (strcmp (element_name, "record") == 0 &&
ctx->state == STATE_NAMESPACE)
{
const gchar *name;
@@ -1472,25 +1562,25 @@ start_struct (GMarkupParseContext *context,
deprecated = find_attribute ("deprecated", attribute_names, attribute_values);
if (name == NULL)
- MISSING_ATTRIBUTE (error, element_name, "name");
+ MISSING_ATTRIBUTE (context, error, element_name, "name");
else
{
- GIdlNodeStruct *struct_;
+ GIrNodeStruct *struct_;
- struct_ = (GIdlNodeStruct *) g_idl_node_new (G_IDL_NODE_STRUCT);
+ struct_ = (GIrNodeStruct *) g_ir_node_new (G_IR_NODE_STRUCT);
- ((GIdlNode *)struct_)->name = g_strdup (name);
+ ((GIrNode *)struct_)->name = g_strdup (name);
if (deprecated && strcmp (deprecated, "1") == 0)
struct_->deprecated = TRUE;
else
struct_->deprecated = FALSE;
- ctx->current_node = (GIdlNode *)struct_;
+ ctx->current_node = (GIrNode *)struct_;
ctx->current_module->entries =
g_list_append (ctx->current_module->entries, struct_);
- ctx->state = STATE_STRUCT;
- }
+ state_switch (ctx, STATE_STRUCT);
+ }
return TRUE;
}
return FALSE;
@@ -1515,18 +1605,18 @@ start_union (GMarkupParseContext *context,
name = find_attribute ("name", attribute_names, attribute_values);
deprecated = find_attribute ("deprecated", attribute_names, attribute_values);
- typename = find_attribute ("type-name", attribute_names, attribute_values);
- typeinit = find_attribute ("get-type", attribute_names, attribute_values);
+ typename = find_attribute ("glib:type-name", attribute_names, attribute_values);
+ typeinit = find_attribute ("glib:get-type", attribute_names, attribute_values);
if (name == NULL)
- MISSING_ATTRIBUTE (error, element_name, "name");
+ MISSING_ATTRIBUTE (context, error, element_name, "name");
else
{
- GIdlNodeUnion *union_;
+ GIrNodeUnion *union_;
- union_ = (GIdlNodeUnion *) g_idl_node_new (G_IDL_NODE_UNION);
+ union_ = (GIrNodeUnion *) g_ir_node_new (G_IR_NODE_UNION);
- ((GIdlNode *)union_)->name = g_strdup (name);
+ ((GIrNode *)union_)->name = g_strdup (name);
union_->gtype_name = g_strdup (typename);
union_->gtype_init = g_strdup (typeinit);
if (deprecated && strcmp (deprecated, "1") == 0)
@@ -1534,11 +1624,11 @@ start_union (GMarkupParseContext *context,
else
union_->deprecated = FALSE;
- ctx->current_node = (GIdlNode *)union_;
+ ctx->current_node = (GIrNode *)union_;
ctx->current_module->entries =
g_list_append (ctx->current_module->entries, union_);
- ctx->state = STATE_UNION;
+ state_switch (ctx, STATE_UNION);
}
return TRUE;
}
@@ -1562,13 +1652,13 @@ start_discriminator (GMarkupParseContext *context,
type = find_attribute ("type", attribute_names, attribute_values);
offset = find_attribute ("offset", attribute_names, attribute_values);
if (type == NULL)
- MISSING_ATTRIBUTE (error, element_name, "type");
+ MISSING_ATTRIBUTE (context, error, element_name, "type");
else if (offset == NULL)
- MISSING_ATTRIBUTE (error, element_name, "offset");
+ MISSING_ATTRIBUTE (context, error, element_name, "offset");
{
- ((GIdlNodeUnion *)ctx->current_node)->discriminator_type
+ ((GIrNodeUnion *)ctx->current_node)->discriminator_type
= parse_type (type);
- ((GIdlNodeUnion *)ctx->current_node)->discriminator_offset
+ ((GIrNodeUnion *)ctx->current_node)->discriminator_offset
= atoi (offset);
}
@@ -1578,6 +1668,8 @@ start_discriminator (GMarkupParseContext *context,
return FALSE;
}
+extern GLogLevelFlags logged_levels;
+
static void
start_element_handler (GMarkupParseContext *context,
const gchar *element_name,
@@ -1589,37 +1681,32 @@ start_element_handler (GMarkupParseContext *context,
ParseContext *ctx = user_data;
gint line_number, char_number;
- switch (element_name[0])
+ if (logged_levels & G_LOG_LEVEL_DEBUG)
{
- case 'a':
- if (strcmp (element_name, "api") == 0 && ctx->state == STATE_START)
- {
- const gchar *version;
-
- version = find_attribute ("version", attribute_names, attribute_values);
-
- if (version == NULL)
- MISSING_ATTRIBUTE (error, element_name, "version");
- else if (strcmp (version, "1.0") != 0)
- g_set_error (error,
- G_MARKUP_ERROR,
- G_MARKUP_ERROR_INVALID_CONTENT,
- "Unsupported version '%s'",
- version);
- else
- ctx->state = STATE_ROOT;
-
- goto out;
- }
- break;
+ GString *tags = g_string_new ("");
+ int i;
+ for (i = 0; attribute_names[i]; i++)
+ g_string_append_printf (tags, "%s=\"%s\" ",
+ attribute_names[i],
+ attribute_values[i]);
+
+ if (i)
+ {
+ g_string_insert_c (tags, 0, ' ');
+ g_string_truncate (tags, tags->len - 1);
+ }
+ g_debug ("<%s%s>", element_name, tags->str);
+ g_string_free (tags, TRUE);
+ }
+ switch (element_name[0])
+ {
case 'b':
- if (start_boxed (context, element_name,
- attribute_names, attribute_values,
- ctx, error))
+ if (start_enum (context, element_name,
+ attribute_names, attribute_values,
+ ctx, error))
goto out;
break;
-
case 'c':
if (start_function (context, element_name,
attribute_names, attribute_values,
@@ -1629,6 +1716,29 @@ start_element_handler (GMarkupParseContext *context,
attribute_names, attribute_values,
ctx, error))
goto out;
+ else if (start_class (context, element_name,
+ attribute_names, attribute_values,
+ ctx, error))
+ goto out;
+ else if (strcmp (element_name, "class") == 0 &&
+ ctx->state == STATE_REQUIRES)
+ {
+ const gchar *name;
+
+ name = find_attribute ("name", attribute_names, attribute_values);
+
+ if (name == NULL)
+ MISSING_ATTRIBUTE (context, error, element_name, "name");
+ else
+ {
+ GIrNodeInterface *iface;
+
+ iface = (GIrNodeInterface *)ctx->current_node;
+ iface ->prerequisites = g_list_append (iface->prerequisites, g_strdup (name));
+ }
+
+ goto out;
+ }
break;
case 'd':
@@ -1658,11 +1768,21 @@ start_element_handler (GMarkupParseContext *context,
attribute_names, attribute_values,
ctx, error))
goto out;
- else if (start_enum (context, element_name,
- attribute_names, attribute_values,
- ctx, error))
+ break;
+
+ case 'g':
+ if (start_glib_boxed (context, element_name,
+ attribute_names, attribute_values,
+ ctx, error))
+ goto out;
+ else if (start_glib_signal (context, element_name,
+ attribute_names, attribute_values,
+ ctx, error))
+ goto out;
+ else if (start_glib_boxed (context, element_name,
+ attribute_names, attribute_values,
+ ctx, error))
goto out;
-
break;
case 'i':
@@ -1671,9 +1791,9 @@ start_element_handler (GMarkupParseContext *context,
ctx, error))
goto out;
if (strcmp (element_name, "implements") == 0 &&
- ctx->state == STATE_OBJECT)
+ ctx->state == STATE_CLASS)
{
- ctx->state = STATE_IMPLEMENTS;
+ state_switch (ctx, STATE_IMPLEMENTS);
goto out;
}
@@ -1685,12 +1805,12 @@ start_element_handler (GMarkupParseContext *context,
name = find_attribute ("name", attribute_names, attribute_values);
if (name == NULL)
- MISSING_ATTRIBUTE (error, element_name, "name");
+ MISSING_ATTRIBUTE (context, error, element_name, "name");
else
{
- GIdlNodeInterface *iface;
+ GIrNodeInterface *iface;
- iface = (GIdlNodeInterface *)ctx->current_node;
+ iface = (GIrNodeInterface *)ctx->current_node;
iface ->interfaces = g_list_append (iface->interfaces, g_strdup (name));
}
@@ -1704,12 +1824,12 @@ start_element_handler (GMarkupParseContext *context,
name = find_attribute ("name", attribute_names, attribute_values);
if (name == NULL)
- MISSING_ATTRIBUTE (error, element_name, "name");
+ MISSING_ATTRIBUTE (context, error, element_name, "name");
else
{
- GIdlNodeInterface *iface;
+ GIrNodeInterface *iface;
- iface = (GIdlNodeInterface *)ctx->current_node;
+ iface = (GIrNodeInterface *)ctx->current_node;
iface ->prerequisites = g_list_append (iface->prerequisites, g_strdup (name));
}
@@ -1729,7 +1849,7 @@ start_element_handler (GMarkupParseContext *context,
break;
case 'n':
- if (strcmp (element_name, "namespace") == 0 && ctx->state == STATE_ROOT)
+ if (strcmp (element_name, "namespace") == 0 && ctx->state == STATE_REPOSITORY)
{
const gchar *name, *shared_library;
@@ -1737,39 +1857,13 @@ start_element_handler (GMarkupParseContext *context,
shared_library = find_attribute ("shared-library", attribute_names, attribute_values);
if (name == NULL)
- MISSING_ATTRIBUTE (error, element_name, "name");
+ MISSING_ATTRIBUTE (context, error, element_name, "name");
else
{
- ctx->current_module = g_idl_module_new (name, shared_library);
+ ctx->current_module = g_ir_module_new (name, shared_library);
ctx->modules = g_list_append (ctx->modules, ctx->current_module);
- ctx->state = STATE_NAMESPACE;
- }
-
- goto out;
- }
- break;
-
- case 'o':
- if (start_object (context, element_name,
- attribute_names, attribute_values,
- ctx, error))
- goto out;
- else if (strcmp (element_name, "object") == 0 &&
- ctx->state == STATE_REQUIRES)
- {
- const gchar *name;
-
- name = find_attribute ("name", attribute_names, attribute_values);
-
- if (name == NULL)
- MISSING_ATTRIBUTE (error, element_name, "name");
- else
- {
- GIdlNodeInterface *iface;
-
- iface = (GIdlNodeInterface *)ctx->current_node;
- iface ->prerequisites = g_list_append (iface->prerequisites, g_strdup (name));
+ state_switch (ctx, STATE_NAMESPACE);
}
goto out;
@@ -1782,9 +1876,9 @@ start_element_handler (GMarkupParseContext *context,
ctx, error))
goto out;
else if (strcmp (element_name, "parameters") == 0 &&
- ctx->state == STATE_FUNCTION)
+ ctx->state == STATE_FUNCTION)
{
- ctx->state = STATE_PARAMETERS;
+ state_switch (ctx, STATE_FUNCTION_PARAMETERS);
goto out;
}
@@ -1796,30 +1890,40 @@ start_element_handler (GMarkupParseContext *context,
break;
case 'r':
- if (start_return_type (context, element_name,
- attribute_names, attribute_values,
- ctx, error))
+ if (strcmp (element_name, "repository") == 0 && ctx->state == STATE_START)
+ {
+ const gchar *version;
+
+ version = find_attribute ("version", attribute_names, attribute_values);
+
+ if (version == NULL)
+ MISSING_ATTRIBUTE (context, error, element_name, "version");
+ else if (strcmp (version, "1.0") != 0)
+ g_set_error (error,
+ G_MARKUP_ERROR,
+ G_MARKUP_ERROR_INVALID_CONTENT,
+ "Unsupported version '%s'",
+ version);
+ else
+ state_switch (ctx, STATE_REPOSITORY);
+
+ goto out;
+ }
+ else if (start_return_value (context, element_name,
+ attribute_names, attribute_values,
+ ctx, error))
goto out;
else if (strcmp (element_name, "requires") == 0 &&
ctx->state == STATE_INTERFACE)
{
- ctx->state = STATE_REQUIRES;
+ state_switch (ctx, STATE_REQUIRES);
goto out;
}
-
- break;
-
- case 's':
- if (start_signal (context, element_name,
- attribute_names, attribute_values,
- ctx, error))
- goto out;
else if (start_struct (context, element_name,
attribute_names, attribute_values,
ctx, error))
goto out;
-
break;
case 'u':
@@ -1829,6 +1933,13 @@ start_element_handler (GMarkupParseContext *context,
goto out;
break;
+ case 't':
+ if (start_type (context, element_name,
+ attribute_names, attribute_values,
+ ctx, error))
+ goto out;
+ break;
+
case 'v':
if (start_vfunc (context, element_name,
attribute_names, attribute_values,
@@ -1847,7 +1958,60 @@ start_element_handler (GMarkupParseContext *context,
line_number, char_number);
out: ;
-
+ if (*error)
+ {
+ g_markup_parse_context_get_position (context, &line_number, &char_number);
+
+ fprintf (stderr, "Error at line %d, character %d: %s\n", line_number, char_number, (*error)->message);
+ backtrace_stderr ();
+ }
+}
+
+static gboolean
+require_one_of_end_elements (GMarkupParseContext *context,
+ const char *actual_name,
+ GError **error,
+ ...)
+{
+ va_list args;
+ int line_number, char_number;
+ const char *expected;
+ gboolean matched = FALSE;
+
+ va_start (args, error);
+
+ while ((expected = va_arg (args, const char*)) != NULL)
+ {
+ if (strcmp (expected, actual_name) == 0)
+ {
+ matched = TRUE;
+ break;
+ }
+ }
+
+ va_end (args);
+
+ if (matched)
+ return TRUE;
+
+ g_markup_parse_context_get_position (context, &line_number, &char_number);
+ g_set_error (error,
+ G_MARKUP_ERROR,
+ G_MARKUP_ERROR_INVALID_CONTENT,
+ "Unexpected end tag '%s' on line %d char %d",
+ actual_name,
+ line_number, char_number);
+ backtrace_stderr();
+ return FALSE;
+}
+
+static gboolean
+require_end_element (GMarkupParseContext *context,
+ const char *expected_name,
+ const char *actual_name,
+ GError **error)
+{
+ return require_one_of_end_elements (context, actual_name, error, expected_name, NULL);
}
static void
@@ -1858,6 +2022,8 @@ end_element_handler (GMarkupParseContext *context,
{
ParseContext *ctx = user_data;
+ g_debug ("</%s>", element_name);
+
switch (ctx->state)
{
case STATE_START:
@@ -1865,110 +2031,200 @@ end_element_handler (GMarkupParseContext *context,
/* no need to GError here, GMarkup already catches this */
break;
- case STATE_ROOT:
- ctx->state = STATE_END;
+ case STATE_REPOSITORY:
+ state_switch (ctx, STATE_END);
break;
case STATE_NAMESPACE:
- if (strcmp (element_name, "namespace") == 0)
+ if (require_end_element (context, "namespace", element_name, error))
{
ctx->current_module = NULL;
- ctx->state = STATE_ROOT;
+ state_switch (ctx, STATE_REPOSITORY);
}
break;
+ case STATE_FUNCTION_RETURN:
+ if (strcmp ("type", element_name) == 0)
+ break;
+ if (require_end_element (context, "return-value", element_name, error))
+ {
+ state_switch (ctx, STATE_FUNCTION);
+ }
+ break;
+
+ case STATE_FUNCTION_PARAMETERS:
+ if (require_end_element (context, "parameters", element_name, error))
+ {
+ state_switch (ctx, STATE_FUNCTION);
+ }
+ break;
+
+ case STATE_FUNCTION_PARAMETER:
+ if (strcmp ("type", element_name) == 0)
+ break;
+ if (require_end_element (context, "parameter", element_name, error))
+ {
+ state_switch (ctx, STATE_FUNCTION_PARAMETERS);
+ }
+ break;
+
case STATE_FUNCTION:
- if (strcmp (element_name, "return-type") == 0)
- /* do nothing */ ;
-
- else if (ctx->current_node == g_list_last (ctx->current_module->entries)->data)
+ if (ctx->current_node == g_list_last (ctx->current_module->entries)->data)
{
ctx->current_node = NULL;
- ctx->state = STATE_NAMESPACE;
+ state_switch (ctx, STATE_NAMESPACE);
}
else
{
ctx->current_node = g_list_last (ctx->current_module->entries)->data;
- if (ctx->current_node->type == G_IDL_NODE_INTERFACE)
- ctx->state = STATE_INTERFACE;
- else if (ctx->current_node->type == G_IDL_NODE_OBJECT)
- ctx->state = STATE_OBJECT;
- else if (ctx->current_node->type == G_IDL_NODE_BOXED)
- ctx->state = STATE_BOXED;
- else if (ctx->current_node->type == G_IDL_NODE_STRUCT)
- ctx->state = STATE_STRUCT;
- else if (ctx->current_node->type == G_IDL_NODE_UNION)
- ctx->state = STATE_UNION;
+ if (ctx->current_node->type == G_IR_NODE_INTERFACE)
+ state_switch (ctx, STATE_INTERFACE);
+ else if (ctx->current_node->type == G_IR_NODE_OBJECT)
+ state_switch (ctx, STATE_CLASS);
+ else if (ctx->current_node->type == G_IR_NODE_BOXED)
+ state_switch (ctx, STATE_BOXED);
+ else if (ctx->current_node->type == G_IR_NODE_STRUCT)
+ state_switch (ctx, STATE_STRUCT);
+ else if (ctx->current_node->type == G_IR_NODE_UNION)
+ state_switch (ctx, STATE_UNION);
+ else
+ {
+ int line_number, char_number;
+ g_markup_parse_context_get_position (context, &line_number, &char_number);
+ g_set_error (error,
+ G_MARKUP_ERROR,
+ G_MARKUP_ERROR_INVALID_CONTENT,
+ "Unexpected end tag '%s' on line %d char %d",
+ element_name,
+ line_number, char_number);
+ }
+ }
+ break;
+
+ case STATE_CLASS_FIELD:
+ if (strcmp ("type", element_name) == 0)
+ break;
+ if (require_end_element (context, "field", element_name, error))
+ {
+ state_switch (ctx, STATE_CLASS);
+ }
+ break;
+
+ case STATE_CLASS_PROPERTY:
+ if (strcmp ("type", element_name) == 0)
+ break;
+ if (require_end_element (context, "property", element_name, error))
+ {
+ state_switch (ctx, STATE_CLASS);
}
break;
- case STATE_OBJECT:
- if (strcmp (element_name, "object") == 0)
+ case STATE_CLASS:
+ if (require_end_element (context, "class", element_name, error))
{
ctx->current_node = NULL;
- ctx->state = STATE_NAMESPACE;
+ state_switch (ctx, STATE_NAMESPACE);
}
break;
case STATE_ERRORDOMAIN:
- if (strcmp (element_name, "errordomain") == 0)
+ if (require_end_element (context, "errordomain", element_name, error))
{
ctx->current_node = NULL;
- ctx->state = STATE_NAMESPACE;
+ state_switch (ctx, STATE_NAMESPACE);
+ }
+ break;
+
+ case STATE_INTERFACE_PROPERTY:
+ if (require_end_element (context, "property", element_name, error))
+ {
+ state_switch (ctx, STATE_INTERFACE);
+ }
+ break;
+
+ case STATE_INTERFACE_FIELD:
+ if (strcmp ("type", element_name) == 0)
+ break;
+ if (require_end_element (context, "field", element_name, error))
+ {
+ state_switch (ctx, STATE_INTERFACE);
}
break;
case STATE_INTERFACE:
- if (strcmp (element_name, "interface") == 0)
+ if (require_end_element (context, "interface", element_name, error))
{
ctx->current_node = NULL;
- ctx->state = STATE_NAMESPACE;
+ state_switch (ctx, STATE_NAMESPACE);
}
break;
case STATE_ENUM:
- if (strcmp (element_name, "enum") == 0 ||
- strcmp (element_name, "flags") == 0)
+ if (strcmp ("member", element_name) == 0)
+ break;
+ else if (require_one_of_end_elements (context, element_name, error, "enumeration", "bitfield", NULL))
{
ctx->current_node = NULL;
- ctx->state = STATE_NAMESPACE;
+ state_switch (ctx, STATE_NAMESPACE);
}
break;
case STATE_BOXED:
- if (strcmp (element_name, "boxed") == 0)
+ if (require_end_element (context, "glib:boxed", element_name, error))
{
ctx->current_node = NULL;
- ctx->state = STATE_NAMESPACE;
+ state_switch (ctx, STATE_NAMESPACE);
+ }
+ break;
+
+ case STATE_BOXED_FIELD:
+ if (strcmp ("type", element_name) == 0)
+ break;
+ if (require_end_element (context, "field", element_name, error))
+ {
+ state_switch (ctx, STATE_BOXED);
+ }
+ break;
+
+ case STATE_STRUCT_FIELD:
+ if (strcmp ("type", element_name) == 0)
+ break;
+ if (require_end_element (context, "field", element_name, error))
+ {
+ state_switch (ctx, STATE_STRUCT);
}
break;
case STATE_STRUCT:
- if (strcmp (element_name, "struct") == 0)
+ if (require_end_element (context, "record", element_name, error))
{
ctx->current_node = NULL;
- ctx->state = STATE_NAMESPACE;
+ state_switch (ctx, STATE_NAMESPACE);
}
break;
case STATE_UNION:
- if (strcmp (element_name, "union") == 0)
+ if (require_end_element (context, "union", element_name, error))
{
ctx->current_node = NULL;
- ctx->state = STATE_NAMESPACE;
+ state_switch (ctx, STATE_NAMESPACE);
}
break;
-
case STATE_IMPLEMENTS:
- if (strcmp (element_name, "implements") == 0)
- ctx->state = STATE_OBJECT;
+ if (strcmp ("interface", element_name) == 0)
+ break;
+ if (require_end_element (context, "implements", element_name, error))
+ state_switch (ctx, STATE_CLASS);
break;
case STATE_REQUIRES:
- if (strcmp (element_name, "requires") == 0)
- ctx->state = STATE_INTERFACE;
+ if (require_end_element (context, "requires", element_name, error))
+ state_switch (ctx, STATE_INTERFACE);
break;
- case STATE_PARAMETERS:
- if (strcmp (element_name, "parameters") == 0)
- ctx->state = STATE_FUNCTION;
+ case STATE_CONSTANT:
+ if (require_end_element (context, "constant", element_name, error))
+ {
+ ctx->current_node = NULL;
+ state_switch (ctx, STATE_NAMESPACE);
+ }
break;
default:
g_error ("Unhandled state %d in end_element_handler\n", ctx->state);
@@ -1992,9 +2248,10 @@ cleanup (GMarkupParseContext *context,
{
ParseContext *ctx = user_data;
GList *m;
+ int line_number, char_number;
for (m = ctx->modules; m; m = m->next)
- g_idl_module_free (m->data);
+ g_ir_module_free (m->data);
g_list_free (ctx->modules);
ctx->modules = NULL;
@@ -2011,9 +2268,9 @@ static GMarkupParser parser =
};
GList *
-g_idl_parse_string (const gchar *buffer,
- gssize length,
- GError **error)
+g_ir_parse_string (const gchar *buffer,
+ gssize length,
+ GError **error)
{
ParseContext ctx = { 0 };
GMarkupParseContext *context;
@@ -2035,17 +2292,19 @@ g_idl_parse_string (const gchar *buffer,
}
GList *
-g_idl_parse_file (const gchar *filename,
- GError **error)
+g_ir_parse_file (const gchar *filename,
+ GError **error)
{
gchar *buffer;
gsize length;
GList *modules;
+ g_debug ("[parsing] filename %s", filename);
+
if (!g_file_get_contents (filename, &buffer, &length, error))
return NULL;
- modules = g_idl_parse_string (buffer, length, error);
+ modules = g_ir_parse_string (buffer, length, error);
g_free (buffer);
diff --git a/tools/gidlparser.h b/tools/girparser.h
index 2d71aaa0..ed9e6ceb 100644
--- a/tools/gidlparser.h
+++ b/tools/girparser.h
@@ -1,4 +1,4 @@
-/* GObject introspection: A parser for the XML IDL format
+/* GObject introspection: A parser for the XML GIR format
*
* Copyright (C) 2005 Matthias Clasen
*
@@ -18,21 +18,21 @@
* Boston, MA 02111-1307, USA.
*/
-#ifndef __G_IDL_PARSER_H__
-#define __G_IDL_PARSER_H__
+#ifndef __G_GIR_PARSER_H__
+#define __G_GIR_PARSER_H__
#include <glib.h>
G_BEGIN_DECLS
-GList *g_idl_parse_string (const gchar *buffer,
- gssize length,
- GError **error);
-GList *g_idl_parse_file (const gchar *filename,
- GError **error);
+GList *g_ir_parse_string (const gchar *buffer,
+ gssize length,
+ GError **error);
+GList *g_ir_parse_file (const gchar *filename,
+ GError **error);
G_END_DECLS
-#endif /* __G_IDL_PARSER_H__ */
+#endif /* __G_GIR_PARSER_H__ */
diff --git a/tools/gidlwriter.c b/tools/girwriter.c
index c99d1deb..d4d55063 100644
--- a/tools/gidlwriter.c
+++ b/tools/girwriter.c
@@ -124,7 +124,7 @@ function_generate (GIdlWriter * writer, GIdlNodeFunction * node)
GString *markup_s;
gchar *markup;
- if (node->node.type == G_IDL_NODE_CALLBACK)
+ if (node->node.type == G_IR_NODE_CALLBACK)
tag_name = "callback";
else if (node->is_constructor)
tag_name = "constructor";
@@ -138,7 +138,7 @@ function_generate (GIdlWriter * writer, GIdlNodeFunction * node)
"%s name=\"%s\"",
tag_name, node->node.name);
- if (node->node.type != G_IDL_NODE_CALLBACK)
+ if (node->node.type != G_IR_NODE_CALLBACK)
g_string_append_printf (markup_s,
g_markup_printf_escaped (" symbol=\"%s\"", node->symbol));
@@ -280,7 +280,7 @@ interface_generate (GIdlWriter * writer, GIdlNodeInterface * node)
{
GList *l;
char *markup;
- if (node->node.type == G_IDL_NODE_OBJECT)
+ if (node->node.type == G_IR_NODE_OBJECT)
{
markup =
g_markup_printf_escaped ("<object name=\"%s\" "
@@ -292,7 +292,7 @@ interface_generate (GIdlWriter * writer, GIdlNodeInterface * node)
node->gtype_name,
node->gtype_init);
}
- else if (node->node.type == G_IDL_NODE_INTERFACE)
+ else if (node->node.type == G_IR_NODE_INTERFACE)
{
markup =
g_markup_printf_escaped
@@ -302,7 +302,7 @@ interface_generate (GIdlWriter * writer, GIdlNodeInterface * node)
g_writer_write_indent (writer, markup);
g_free (markup);
- if (node->node.type == G_IDL_NODE_OBJECT && node->interfaces != NULL)
+ if (node->node.type == G_IR_NODE_OBJECT && node->interfaces != NULL)
{
GList *l;
g_writer_write_indent (writer, "<implements>\n");
@@ -316,7 +316,7 @@ interface_generate (GIdlWriter * writer, GIdlNodeInterface * node)
}
g_writer_write_unindent (writer, "</implements>\n");
}
- else if (node->node.type == G_IDL_NODE_INTERFACE
+ else if (node->node.type == G_IR_NODE_INTERFACE
&& node->prerequisites != NULL)
{
GList *l;
@@ -337,11 +337,11 @@ interface_generate (GIdlWriter * writer, GIdlNodeInterface * node)
node_generate (writer, l->data);
}
- if (node->node.type == G_IDL_NODE_OBJECT)
+ if (node->node.type == G_IR_NODE_OBJECT)
{
g_writer_write_unindent (writer, "</object>\n");
}
- else if (node->node.type == G_IDL_NODE_INTERFACE)
+ else if (node->node.type == G_IR_NODE_INTERFACE)
{
g_writer_write_unindent (writer, "</interface>\n");
}
@@ -402,11 +402,11 @@ enum_generate (GIdlWriter * writer, GIdlNodeEnum * node)
char *markup;
const char *tag_name = NULL;
- if (node->node.type == G_IDL_NODE_ENUM)
+ if (node->node.type == G_IR_NODE_ENUM)
{
tag_name = "enum";
}
- else if (node->node.type == G_IDL_NODE_FLAGS)
+ else if (node->node.type == G_IR_NODE_FLAGS)
{
tag_name = "flags";
}
@@ -447,43 +447,43 @@ node_generate (GIdlWriter * writer, GIdlNode * node)
{
switch (node->type)
{
- case G_IDL_NODE_FUNCTION:
- case G_IDL_NODE_CALLBACK:
+ case G_IR_NODE_FUNCTION:
+ case G_IR_NODE_CALLBACK:
function_generate (writer, (GIdlNodeFunction *) node);
break;
- case G_IDL_NODE_VFUNC:
+ case G_IR_NODE_VFUNC:
vfunc_generate (writer, (GIdlNodeVFunc *) node);
break;
- case G_IDL_NODE_OBJECT:
- case G_IDL_NODE_INTERFACE:
+ case G_IR_NODE_OBJECT:
+ case G_IR_NODE_INTERFACE:
interface_generate (writer, (GIdlNodeInterface *) node);
break;
- case G_IDL_NODE_STRUCT:
+ case G_IR_NODE_STRUCT:
struct_generate (writer, (GIdlNodeStruct *) node);
break;
- case G_IDL_NODE_UNION:
+ case G_IR_NODE_UNION:
union_generate (writer, (GIdlNodeUnion *) node);
break;
- case G_IDL_NODE_BOXED:
+ case G_IR_NODE_BOXED:
boxed_generate (writer, (GIdlNodeBoxed *) node);
break;
- case G_IDL_NODE_ENUM:
- case G_IDL_NODE_FLAGS:
+ case G_IR_NODE_ENUM:
+ case G_IR_NODE_FLAGS:
enum_generate (writer, (GIdlNodeEnum *) node);
break;
- case G_IDL_NODE_PROPERTY:
+ case G_IR_NODE_PROPERTY:
property_generate (writer, (GIdlNodeProperty *) node);
break;
- case G_IDL_NODE_FIELD:
+ case G_IR_NODE_FIELD:
field_generate (writer, (GIdlNodeField *) node);
break;
- case G_IDL_NODE_SIGNAL:
+ case G_IR_NODE_SIGNAL:
signal_generate (writer, (GIdlNodeSignal *) node);
break;
- case G_IDL_NODE_VALUE:
+ case G_IR_NODE_VALUE:
value_generate (writer, (GIdlNodeValue *) node);
break;
- case G_IDL_NODE_CONSTANT:
+ case G_IR_NODE_CONSTANT:
constant_generate (writer, (GIdlNodeConstant *) node);
break;
default:
@@ -520,9 +520,12 @@ g_idl_writer_save_file (GIdlModule *module,
writer->output = fopen (filename, "w");
g_writer_write (writer, "<?xml version=\"1.0\"?>\n");
- g_writer_write_indent (writer, "<api version=\"1.0\">\n");
+ g_writer_write_indent (writer, "<repository version=\"1.0\""
+ "xmlns=\"http://www.gtk.org/introspection/core/1.0\""
+ "xmlns:c=\"http://www.gtk.org/introspection/c/1.0\""
+ "xmlns:glib=\"http://www.gtk.org/introspection/glib/1.0\">");
g_writer_write_module (writer, module);
- g_writer_write_unindent (writer, "</api>\n");
+ g_writer_write_unindent (writer, "</repository>\n");
if (filename)
fclose (writer->output);
diff --git a/tools/gidlwriter.h b/tools/girwriter.h
index 5d41a0c6..5d41a0c6 100644
--- a/tools/gidlwriter.h
+++ b/tools/girwriter.h
diff --git a/tools/scanner.c b/tools/scanner.c
index 6b064b86..df5e3336 100644
--- a/tools/scanner.c
+++ b/tools/scanner.c
@@ -32,13 +32,12 @@
#include <gmodule.h>
#include "sourcescanner.h"
#include "scanner.h"
-#include "gidlparser.h"
-#include "gidlmodule.h"
-#include "gidlnode.h"
-#include "gidlwriter.h"
+#include "girparser.h"
+#include "girmodule.h"
+#include "girnode.h"
+#include "girwriter.h"
#include "grealpath.h"
-
typedef GType (*TypeFunction) (void);
static void g_igenerator_parse_macros (GIGenerator * igenerator);
@@ -82,13 +81,13 @@ g_igenerator_free (GIGenerator *generator)
g_free (generator);
}
-static GIdlNodeType *
+static GIrNodeType *
create_node_from_gtype (GType type_id)
{
- GIdlNodeType *node;
+ GIrNodeType *node;
GType fundamental;
- node = (GIdlNodeType *) g_idl_node_new (G_IDL_NODE_TYPE);
+ node = (GIrNodeType *) g_idl_node_new (G_IR_NODE_TYPE);
fundamental = g_type_fundamental (type_id);
switch (fundamental)
@@ -115,12 +114,12 @@ create_node_from_gtype (GType type_id)
return node;
}
-static GIdlNodeType *
+static GIrNodeType *
create_node_from_ctype (GISourceType * ctype)
{
- GIdlNodeType *node;
+ GIrNodeType *node;
- node = (GIdlNodeType *) g_idl_node_new (G_IDL_NODE_TYPE);
+ node = (GIrNodeType *) g_idl_node_new (G_IR_NODE_TYPE);
switch (ctype->type)
{
@@ -160,13 +159,13 @@ create_node_from_ctype (GISourceType * ctype)
node->unparsed = g_strdup ("GCallback");
else
{
- GIdlNodeType *gibasetype = create_node_from_ctype (ctype->base_type);
+ GIrNodeType *gibasetype = create_node_from_ctype (ctype->base_type);
node->unparsed = g_strdup_printf ("%s*", gibasetype->unparsed);
}
break;
case CTYPE_ARRAY:
{
- GIdlNodeType *gibasetype = create_node_from_ctype (ctype->base_type);
+ GIrNodeType *gibasetype = create_node_from_ctype (ctype->base_type);
node->unparsed = g_strdup_printf ("%s[]", gibasetype->unparsed);
break;
}
@@ -189,18 +188,18 @@ str_replace (const char *str, const char *needle, const char *replacement)
static void
g_igenerator_process_properties (GIGenerator * igenerator,
- GIdlNodeInterface * node, GType type_id)
+ GIrNodeInterface * node, GType type_id)
{
int i;
guint n_properties;
GParamSpec **properties;
- if (node->node.type == G_IDL_NODE_OBJECT)
+ if (node->node.type == G_IR_NODE_OBJECT)
{
GObjectClass *type_class = g_type_class_ref (type_id);
properties = g_object_class_list_properties (type_class, &n_properties);
}
- else if (node->node.type == G_IDL_NODE_INTERFACE)
+ else if (node->node.type == G_IR_NODE_INTERFACE)
{
GTypeInterface *iface = g_type_default_interface_ref (type_id);
properties = g_object_interface_list_properties (iface, &n_properties);
@@ -212,14 +211,14 @@ g_igenerator_process_properties (GIGenerator * igenerator,
for (i = 0; i < n_properties; i++)
{
- GIdlNodeProperty *giprop;
+ GIrNodeProperty *giprop;
/* ignore inherited properties */
if (properties[i]->owner_type != type_id)
{
continue;
}
- giprop = (GIdlNodeProperty *) g_idl_node_new (G_IDL_NODE_PROPERTY);
+ giprop = (GIrNodeProperty *) g_idl_node_new (G_IR_NODE_PROPERTY);
giprop->node.name = g_strdup (properties[i]->name);
node->members =
g_list_insert_sorted (node->members, giprop,
@@ -235,7 +234,7 @@ g_igenerator_process_properties (GIGenerator * igenerator,
static void
g_igenerator_process_signals (GIGenerator * igenerator,
- GIdlNodeInterface * node, GType type_id)
+ GIrNodeInterface * node, GType type_id)
{
int i, j;
guint n_signal_ids;
@@ -244,11 +243,11 @@ g_igenerator_process_signals (GIGenerator * igenerator,
for (i = 0; i < n_signal_ids; i++)
{
GSignalQuery signal_query;
- GIdlNodeSignal *gisig;
- GIdlNodeParam *giparam;
+ GIrNodeSignal *gisig;
+ GIrNodeParam *giparam;
g_signal_query (signal_ids[i], &signal_query);
- gisig = (GIdlNodeSignal *) g_idl_node_new (G_IDL_NODE_SIGNAL);
+ gisig = (GIrNodeSignal *) g_idl_node_new (G_IR_NODE_SIGNAL);
gisig->node.name = g_strdup (signal_query.signal_name);
node->members =
g_list_insert_sorted (node->members, gisig,
@@ -261,19 +260,19 @@ g_igenerator_process_signals (GIGenerator * igenerator,
(signal_query.signal_flags & G_SIGNAL_RUN_CLEANUP) != 0;
/* add sender parameter */
- giparam = (GIdlNodeParam *) g_idl_node_new (G_IDL_NODE_PARAM);
+ giparam = (GIrNodeParam *) g_idl_node_new (G_IR_NODE_PARAM);
gisig->parameters = g_list_append (gisig->parameters, giparam);
giparam->node.name = g_strdup ("object");
giparam->type = create_node_from_gtype (type_id);
for (j = 0; j < signal_query.n_params; j++)
{
- giparam = (GIdlNodeParam *) g_idl_node_new (G_IDL_NODE_PARAM);
+ giparam = (GIrNodeParam *) g_idl_node_new (G_IR_NODE_PARAM);
gisig->parameters = g_list_append (gisig->parameters, giparam);
giparam->node.name = g_strdup_printf ("p%d", j);
giparam->type = create_node_from_gtype (signal_query.param_types[j]);
}
- gisig->result = (GIdlNodeParam *) g_idl_node_new (G_IDL_NODE_PARAM);
+ gisig->result = (GIrNodeParam *) g_idl_node_new (G_IR_NODE_PARAM);
gisig->result->type = create_node_from_gtype (signal_query.return_type);
}
}
@@ -301,12 +300,12 @@ g_igenerator_create_object (GIGenerator *igenerator,
{
char *alt_lower_case_prefix;
- GIdlNodeInterface *node;
+ GIrNodeInterface *node;
guint n_type_interfaces;
GType *type_interfaces;
int i;
- node = (GIdlNodeInterface *) g_idl_node_new (G_IDL_NODE_OBJECT);
+ node = (GIrNodeInterface *) g_idl_node_new (G_IR_NODE_OBJECT);
node->node.name = g_strdup (g_type_name (type_id));
igenerator->module->entries =
g_list_insert_sorted (igenerator->module->entries, node,
@@ -366,13 +365,13 @@ g_igenerator_create_interface (GIGenerator *igenerator,
char *lower_case_prefix)
{
- GIdlNodeInterface *node;
+ GIrNodeInterface *node;
gboolean is_gobject = FALSE;
guint n_iface_prereqs;
GType *iface_prereqs;
int i;
- node = (GIdlNodeInterface *) g_idl_node_new (G_IDL_NODE_INTERFACE);
+ node = (GIrNodeInterface *) g_idl_node_new (G_IR_NODE_INTERFACE);
node->node.name = g_strdup (g_type_name (type_id));
/* workaround for AtkImplementorIface */
@@ -419,8 +418,8 @@ g_igenerator_create_boxed (GIGenerator *igenerator,
GType type_id,
char *lower_case_prefix)
{
- GIdlNodeBoxed *node =
- (GIdlNodeBoxed *) g_idl_node_new (G_IDL_NODE_BOXED);
+ GIrNodeBoxed *node =
+ (GIrNodeBoxed *) g_idl_node_new (G_IR_NODE_BOXED);
node->node.name = g_strdup (g_type_name (type_id));
igenerator->module->entries =
g_list_insert_sorted (igenerator->module->entries, node,
@@ -439,11 +438,11 @@ g_igenerator_create_enum (GIGenerator *igenerator,
GType type_id,
char *lower_case_prefix)
{
- GIdlNodeEnum *node;
+ GIrNodeEnum *node;
int i;
GEnumClass *type_class;
- node = (GIdlNodeEnum *) g_idl_node_new (G_IDL_NODE_ENUM);
+ node = (GIrNodeEnum *) g_idl_node_new (G_IR_NODE_ENUM);
node->node.name = g_strdup (g_type_name (type_id));
igenerator->module->entries =
g_list_insert_sorted (igenerator->module->entries, node,
@@ -459,8 +458,8 @@ g_igenerator_create_enum (GIGenerator *igenerator,
for (i = 0; i < type_class->n_values; i++)
{
- GIdlNodeValue *gival =
- (GIdlNodeValue *) g_idl_node_new (G_IDL_NODE_VALUE);
+ GIrNodeValue *gival =
+ (GIrNodeValue *) g_idl_node_new (G_IR_NODE_VALUE);
node->values = g_list_append (node->values, gival);
gival->node.name =
g_strdup (type_class->values[i].value_name);
@@ -474,11 +473,11 @@ g_igenerator_create_flags (GIGenerator *igenerator,
GType type_id,
char *lower_case_prefix)
{
- GIdlNodeEnum *node;
+ GIrNodeEnum *node;
GFlagsClass *type_class;
int i;
- node = (GIdlNodeEnum *) g_idl_node_new (G_IDL_NODE_FLAGS);
+ node = (GIrNodeEnum *) g_idl_node_new (G_IR_NODE_FLAGS);
node->node.name = g_strdup (g_type_name (type_id));
igenerator->module->entries =
g_list_insert_sorted (igenerator->module->entries, node,
@@ -494,8 +493,8 @@ g_igenerator_create_flags (GIGenerator *igenerator,
for (i = 0; i < type_class->n_values; i++)
{
- GIdlNodeValue *gival =
- (GIdlNodeValue *) g_idl_node_new (G_IDL_NODE_VALUE);
+ GIrNodeValue *gival =
+ (GIrNodeValue *) g_idl_node_new (G_IR_NODE_VALUE);
node->values = g_list_append (node->values, gival);
gival->node.name =
g_strdup (type_class->values[i].value_name);
@@ -595,14 +594,14 @@ g_igenerator_process_module (GIGenerator * igenerator,
static void
g_igenerator_process_function_symbol (GIGenerator * igenerator, GISourceSymbol * sym)
{
- GIdlNodeFunction *func;
+ GIrNodeFunction *func;
char *last_underscore;
GList *param_l;
int i;
GList *l;
GSList *j, *directives;
- func = (GIdlNodeFunction *) g_idl_node_new (G_IDL_NODE_FUNCTION);
+ func = (GIrNodeFunction *) g_idl_node_new (G_IR_NODE_FUNCTION);
/* check whether this is a type method */
last_underscore = strrchr (sym->ident, '_');
@@ -610,7 +609,7 @@ g_igenerator_process_function_symbol (GIGenerator * igenerator, GISourceSymbol *
while (last_underscore != NULL)
{
char *prefix;
- GIdlNode *node;
+ GIrNode *node;
prefix = g_strndup (sym->ident, last_underscore - sym->ident);
prefix = str_replace (prefix, "_", "");
@@ -625,8 +624,8 @@ g_igenerator_process_function_symbol (GIGenerator * igenerator, GISourceSymbol *
if (strcmp (func->node.name, "get_type") == 0)
return;
- if ((node->type == G_IDL_NODE_OBJECT ||
- node->type == G_IDL_NODE_BOXED) &&
+ if ((node->type == G_IR_NODE_OBJECT ||
+ node->type == G_IR_NODE_BOXED) &&
g_str_has_prefix (func->node.name, "new"))
func->is_constructor = TRUE;
else
@@ -669,7 +668,7 @@ g_igenerator_process_function_symbol (GIGenerator * igenerator, GISourceSymbol *
}
func->symbol = g_strdup (sym->ident);
- func->result = (GIdlNodeParam *) g_idl_node_new (G_IDL_NODE_PARAM);
+ func->result = (GIrNodeParam *) g_idl_node_new (G_IR_NODE_PARAM);
func->result->type = create_node_from_ctype (sym->base_type->base_type);
directives = g_hash_table_lookup (igenerator->scanner->directives_map, func->symbol);
@@ -693,9 +692,9 @@ g_igenerator_process_function_symbol (GIGenerator * igenerator, GISourceSymbol *
param_l = param_l->next, i++)
{
GISourceSymbol *param_sym = param_l->data;
- GIdlNodeParam *param;
+ GIrNodeParam *param;
- param = (GIdlNodeParam *) g_idl_node_new (G_IDL_NODE_PARAM);
+ param = (GIrNodeParam *) g_idl_node_new (G_IR_NODE_PARAM);
param->type = create_node_from_ctype (param_sym->base_type);
for (j = directives; j; j = j->next)
@@ -750,8 +749,8 @@ g_igenerator_process_unregistered_struct_typedef (GIGenerator * igenerator,
GISourceSymbol * sym,
GISourceType * struct_type)
{
- GIdlNodeStruct *node =
- (GIdlNodeStruct *) g_idl_node_new (G_IDL_NODE_STRUCT);
+ GIrNodeStruct *node =
+ (GIrNodeStruct *) g_idl_node_new (G_IR_NODE_STRUCT);
GList *member_l;
char *lower_case_prefix;
@@ -768,8 +767,8 @@ g_igenerator_process_unregistered_struct_typedef (GIGenerator * igenerator,
member_l = member_l->next)
{
GISourceSymbol *member = member_l->data;
- GIdlNodeField *gifield =
- (GIdlNodeField *) g_idl_node_new (G_IDL_NODE_FIELD);
+ GIrNodeField *gifield =
+ (GIrNodeField *) g_idl_node_new (G_IR_NODE_FIELD);
node->members = g_list_append (node->members, gifield);
gifield->node.name = g_strdup (member->ident);
@@ -782,7 +781,7 @@ g_igenerator_process_struct_typedef (GIGenerator * igenerator, GISourceSymbol *
{
GISourceType *struct_type = sym->base_type;
gboolean opaque_type = FALSE;
- GIdlNode *type;
+ GIrNode *type;
if (struct_type->child_list == NULL)
{
@@ -807,10 +806,10 @@ g_igenerator_process_struct_typedef (GIGenerator * igenerator, GISourceSymbol *
{
/* struct of a GTypeInstance */
if (!opaque_type
- && (type->type == G_IDL_NODE_OBJECT
- || type->type == G_IDL_NODE_INTERFACE))
+ && (type->type == G_IR_NODE_OBJECT
+ || type->type == G_IR_NODE_INTERFACE))
{
- GIdlNodeInterface *node = (GIdlNodeInterface *) type;
+ GIrNodeInterface *node = (GIrNodeInterface *) type;
GList *member_l;
/* ignore first field => parent */
for (member_l = struct_type->child_list->next; member_l != NULL;
@@ -823,23 +822,23 @@ g_igenerator_process_struct_typedef (GIGenerator * igenerator, GISourceSymbol *
{
continue;
}
- GIdlNodeField *gifield =
- (GIdlNodeField *) g_idl_node_new (G_IDL_NODE_FIELD);
+ GIrNodeField *gifield =
+ (GIrNodeField *) g_idl_node_new (G_IR_NODE_FIELD);
node->members = g_list_append (node->members, gifield);
gifield->node.name = g_strdup (member->ident);
gifield->type = create_node_from_ctype (member->base_type);
}
}
- else if (type->type == G_IDL_NODE_BOXED)
+ else if (type->type == G_IR_NODE_BOXED)
{
- GIdlNodeBoxed *node = (GIdlNodeBoxed *) type;
+ GIrNodeBoxed *node = (GIrNodeBoxed *) type;
GList *member_l;
for (member_l = struct_type->child_list; member_l != NULL;
member_l = member_l->next)
{
GISourceSymbol *member = member_l->data;
- GIdlNodeField *gifield =
- (GIdlNodeField *) g_idl_node_new (G_IDL_NODE_FIELD);
+ GIrNodeField *gifield =
+ (GIrNodeField *) g_idl_node_new (G_IR_NODE_FIELD);
node->members = g_list_append (node->members, gifield);
gifield->node.name = g_strdup (member->ident);
gifield->type = create_node_from_ctype (member->base_type);
@@ -853,7 +852,7 @@ g_igenerator_process_struct_typedef (GIGenerator * igenerator, GISourceSymbol *
{
char *base_name;
GList *member_l;
- GIdlNodeInterface *node;
+ GIrNodeInterface *node;
if (g_str_has_suffix (sym->ident, "Interface"))
{
@@ -868,14 +867,14 @@ g_igenerator_process_struct_typedef (GIGenerator * igenerator, GISourceSymbol *
}
type = g_hash_table_lookup (igenerator->type_map, base_name);
if (type == NULL
- || (type->type != G_IDL_NODE_OBJECT
- && type->type != G_IDL_NODE_INTERFACE))
+ || (type->type != G_IR_NODE_OBJECT
+ && type->type != G_IR_NODE_INTERFACE))
{
g_igenerator_process_unregistered_struct_typedef (igenerator, sym,
struct_type);
return;
}
- node = (GIdlNodeInterface *) type;
+ node = (GIrNodeInterface *) type;
/* ignore first field => parent */
for (member_l = struct_type->child_list->next; member_l != NULL;
@@ -895,20 +894,20 @@ g_igenerator_process_struct_typedef (GIGenerator * igenerator, GISourceSymbol *
GList *type_member_l;
GList *param_l;
int i;
- GIdlNodeVFunc *givfunc;
+ GIrNodeVFunc *givfunc;
for (type_member_l = node->members; type_member_l != NULL;
type_member_l = type_member_l->next)
{
- GIdlNode *type_member = type_member_l->data;
+ GIrNode *type_member = type_member_l->data;
char *normalized_name =
str_replace (type_member->name, "-", "_");
- if (type_member->type == G_IDL_NODE_SIGNAL
+ if (type_member->type == G_IR_NODE_SIGNAL
&& strcmp (normalized_name, member->ident) == 0)
{
GList *vfunc_param_l;
GList *sig_param_l;
- GIdlNodeSignal *sig = (GIdlNodeSignal *) type_member;
+ GIrNodeSignal *sig = (GIrNodeSignal *) type_member;
found_signal = TRUE;
/* set signal parameter names */
for (vfunc_param_l =
@@ -919,7 +918,7 @@ g_igenerator_process_struct_typedef (GIGenerator * igenerator, GISourceSymbol *
sig_param_l->next)
{
GISourceSymbol *vfunc_param = vfunc_param_l->data;
- GIdlNodeParam *sig_param = sig_param_l->data;
+ GIrNodeParam *sig_param = sig_param_l->data;
if (vfunc_param->ident != NULL)
{
g_free (sig_param->node.name);
@@ -935,21 +934,21 @@ g_igenerator_process_struct_typedef (GIGenerator * igenerator, GISourceSymbol *
continue;
}
- givfunc = (GIdlNodeVFunc *) g_idl_node_new (G_IDL_NODE_VFUNC);
+ givfunc = (GIrNodeVFunc *) g_idl_node_new (G_IR_NODE_VFUNC);
givfunc->node.name = g_strdup (member->ident);
node->members =
g_list_insert_sorted (node->members, givfunc,
(GCompareFunc) g_idl_node_cmp);
givfunc->result =
- (GIdlNodeParam *) g_idl_node_new (G_IDL_NODE_PARAM);
+ (GIrNodeParam *) g_idl_node_new (G_IR_NODE_PARAM);
givfunc->result->type =
create_node_from_ctype (member->base_type->base_type->base_type);
for (param_l = member->base_type->base_type->child_list, i = 1;
param_l != NULL; param_l = param_l->next, i++)
{
GISourceSymbol *param_sym = param_l->data;
- GIdlNodeParam *param =
- (GIdlNodeParam *) g_idl_node_new (G_IDL_NODE_PARAM);
+ GIrNodeParam *param =
+ (GIrNodeParam *) g_idl_node_new (G_IR_NODE_PARAM);
if (param_sym->ident == NULL)
{
param->node.name = g_strdup_printf ("p%d", i);
@@ -981,7 +980,7 @@ g_igenerator_process_union_typedef (GIGenerator * igenerator, GISourceSymbol * s
{
GISourceType *union_type = sym->base_type;
gboolean opaque_type = FALSE;
- GIdlNode *type;
+ GIrNode *type;
if (union_type->child_list == NULL)
{
@@ -1002,15 +1001,15 @@ g_igenerator_process_union_typedef (GIGenerator * igenerator, GISourceSymbol * s
type = g_hash_table_lookup (igenerator->type_map, sym->ident);
if (type != NULL)
{
- g_assert (type->type == G_IDL_NODE_BOXED);
- GIdlNodeBoxed *node = (GIdlNodeBoxed *) type;
+ g_assert (type->type == G_IR_NODE_BOXED);
+ GIrNodeBoxed *node = (GIrNodeBoxed *) type;
GList *member_l;
for (member_l = union_type->child_list; member_l != NULL;
member_l = member_l->next)
{
GISourceSymbol *member = member_l->data;
- GIdlNodeField *gifield =
- (GIdlNodeField *) g_idl_node_new (G_IDL_NODE_FIELD);
+ GIrNodeField *gifield =
+ (GIrNodeField *) g_idl_node_new (G_IR_NODE_FIELD);
node->members = g_list_append (node->members, gifield);
gifield->node.name = g_strdup (member->ident);
gifield->type = create_node_from_ctype (member->base_type);
@@ -1018,8 +1017,8 @@ g_igenerator_process_union_typedef (GIGenerator * igenerator, GISourceSymbol * s
}
else
{
- GIdlNodeUnion *node =
- (GIdlNodeUnion *) g_idl_node_new (G_IDL_NODE_UNION);
+ GIrNodeUnion *node =
+ (GIrNodeUnion *) g_idl_node_new (G_IR_NODE_UNION);
char *lower_case_prefix;
GList *member_l;
@@ -1037,8 +1036,8 @@ g_igenerator_process_union_typedef (GIGenerator * igenerator, GISourceSymbol * s
member_l = member_l->next)
{
GISourceSymbol *member = member_l->data;
- GIdlNodeField *gifield =
- (GIdlNodeField *) g_idl_node_new (G_IDL_NODE_FIELD);
+ GIrNodeField *gifield =
+ (GIrNodeField *) g_idl_node_new (G_IR_NODE_FIELD);
node->members = g_list_append (node->members, gifield);
gifield->node.name = g_strdup (member->ident);
gifield->type = create_node_from_ctype (member->base_type);
@@ -1051,7 +1050,7 @@ g_igenerator_process_enum_typedef (GIGenerator * igenerator, GISourceSymbol * sy
{
GISourceType *enum_type;
GList *member_l;
- GIdlNodeEnum *node;
+ GIrNodeEnum *node;
GISourceSymbol *enum_symbol;
enum_type = sym->base_type;
@@ -1078,7 +1077,7 @@ g_igenerator_process_enum_typedef (GIGenerator * igenerator, GISourceSymbol * sy
return;
}
- node = (GIdlNodeEnum *) g_idl_node_new (G_IDL_NODE_ENUM);
+ node = (GIrNodeEnum *) g_idl_node_new (G_IR_NODE_ENUM);
node->node.name = g_strdup (sym->ident);
igenerator->module->entries =
g_list_insert_sorted (igenerator->module->entries, node,
@@ -1088,8 +1087,8 @@ g_igenerator_process_enum_typedef (GIGenerator * igenerator, GISourceSymbol * sy
member_l = member_l->next)
{
GISourceSymbol *member = member_l->data;
- GIdlNodeValue *gival =
- (GIdlNodeValue *) g_idl_node_new (G_IDL_NODE_VALUE);
+ GIrNodeValue *gival =
+ (GIrNodeValue *) g_idl_node_new (G_IR_NODE_VALUE);
node->values = g_list_append (node->values, gival);
gival->node.name = g_strdup (member->ident);
gival->value = member->const_int;
@@ -1104,8 +1103,8 @@ g_igenerator_process_function_typedef (GIGenerator * igenerator,
int i;
/* handle callback types */
- GIdlNodeFunction *gifunc =
- (GIdlNodeFunction *) g_idl_node_new (G_IDL_NODE_CALLBACK);
+ GIrNodeFunction *gifunc =
+ (GIrNodeFunction *) g_idl_node_new (G_IR_NODE_CALLBACK);
gifunc->node.name = g_strdup (sym->ident);
igenerator->module->entries =
@@ -1113,7 +1112,7 @@ g_igenerator_process_function_typedef (GIGenerator * igenerator,
(GCompareFunc) g_idl_node_cmp);
gifunc->symbol = g_strdup (sym->ident);
- gifunc->result = (GIdlNodeParam *) g_idl_node_new (G_IDL_NODE_PARAM);
+ gifunc->result = (GIrNodeParam *) g_idl_node_new (G_IR_NODE_PARAM);
gifunc->result->type =
create_node_from_ctype (sym->base_type->base_type->base_type);
@@ -1121,8 +1120,8 @@ g_igenerator_process_function_typedef (GIGenerator * igenerator,
param_l != NULL; param_l = param_l->next, i++)
{
GISourceSymbol *param_sym = param_l->data;
- GIdlNodeParam *param =
- (GIdlNodeParam *) g_idl_node_new (G_IDL_NODE_PARAM);
+ GIrNodeParam *param =
+ (GIrNodeParam *) g_idl_node_new (G_IR_NODE_PARAM);
if (param_sym->ident == NULL)
{
param->node.name = g_strdup_printf ("p%d", i);
@@ -1139,14 +1138,14 @@ g_igenerator_process_function_typedef (GIGenerator * igenerator,
static void
g_igenerator_process_constant (GIGenerator * igenerator, GISourceSymbol * sym)
{
- GIdlNodeConstant *giconst =
- (GIdlNodeConstant *) g_idl_node_new (G_IDL_NODE_CONSTANT);
+ GIrNodeConstant *giconst =
+ (GIrNodeConstant *) g_idl_node_new (G_IR_NODE_CONSTANT);
giconst->node.name = g_strdup (sym->ident);
igenerator->module->entries =
g_list_insert_sorted (igenerator->module->entries, giconst,
(GCompareFunc) g_idl_node_cmp);
- giconst->type = (GIdlNodeType *) g_idl_node_new (G_IDL_NODE_TYPE);
+ giconst->type = (GIrNodeType *) g_idl_node_new (G_IR_NODE_TYPE);
if (sym->const_int_set)
{
giconst->type->unparsed = g_strdup ("int");
@@ -1194,8 +1193,8 @@ g_igenerator_process_symbols (GIGenerator * igenerator)
}
else
{
- GIdlNodeStruct *node =
- (GIdlNodeStruct *) g_idl_node_new (G_IDL_NODE_STRUCT);
+ GIrNodeStruct *node =
+ (GIrNodeStruct *) g_idl_node_new (G_IR_NODE_STRUCT);
char *lower_case_prefix;
node->node.name = g_strdup (sym->ident);
@@ -1449,17 +1448,17 @@ g_igenerator_parse_macros (GIGenerator * igenerator)
static void
g_igenerator_add_module (GIGenerator *igenerator,
- GIdlModule *module)
+ GIrModule *module)
{
GList *l;
for (l = module->entries; l; l = l->next)
{
- GIdlNode *node = (GIdlNode*)l->data;
+ GIrNode *node = (GIrNode*)l->data;
- if (node->type == G_IDL_NODE_OBJECT)
+ if (node->type == G_IR_NODE_OBJECT)
{
- GIdlNodeInterface *object = (GIdlNodeInterface*)node;
+ GIrNodeInterface *object = (GIrNodeInterface*)node;
gchar *name;
if (strcmp(module->name, igenerator->namespace) == 0)
name = g_strdup (node->name);
@@ -1491,7 +1490,7 @@ g_igenerator_add_include_idl (GIGenerator *igenerator,
for (l = modules; l; l = l->next)
{
- GIdlModule *module = (GIdlModule*)l->data;
+ GIrModule *module = (GIrModule*)l->data;
g_igenerator_add_module (igenerator, module);
}
}