+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
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,
G_BEGIN_DECLS
-#define G_IDL_MAGIC "GOBJ\nMETADATA\r\n\032"
+#define G_IR_MAGIC "GOBJ\nMETADATA\r\n\032"
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
def type_name_from_ctype(ctype):
return type_names.get(ctype, ctype)
-
-
+
+
class Node(object):
+
def __init__(self, name=None):
self.name = name
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):
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)
{
<?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>
<?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>
<?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" />
<constant name="constant4" type="gint32" value="42" />
<constant name="constant5" type="gfloat" value="42.000000" />
</namespace>
-</api>
+</repository>
<?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" />
<member name="value3" value="2" />
</enum>
</namespace>
-</api>
+</repository>
<?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" />
</parameters>
</function>
</namespace>
-</api>
+</repository>
<?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>
</parameters>
</callback>
</namespace>
-</api>
+</repository>
<?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>
<?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>
<interface name="Iface2" type-name="Iface2" get-type="iface2_get_type">
</interface>
</namespace>
-</api>
+</repository>
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
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="."
--- /dev/null
+<?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>
+++ /dev/null
-<?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>
<?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>
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 \
--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 \
#! /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
<?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" />
<field name="string" readable="1" writable="1" offset="24" type="utf8" />
</struct>
</namespace>
-</api>
+</repository>
<?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" />
</parameters>
</function>
</namespace>
-</api>
+</repository>
<?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" />
<field name="field1" readable="1" writable="1" offset="0" type="gdouble" />
</union>
</namespace>
-</api>
+</repository>
<?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>
</parameters>
</function>
</namespace>
-</api>
+</repository>
<?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>
</parameters>
</function>
</namespace>
-</api>
+</repository>
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
#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;
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);
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)
{
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;
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);
break;
}
}
-
+
+ g_debug ("[building] done");
+
return 0;
}
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);
{
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);
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)
}
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++)
{
g_fprintf (file, " </namespace>\n");
}
- g_fprintf (file, "</api>\n");
+ g_fprintf (file, "</repository>\n");
if (output != NULL)
fclose (file);
#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)
}
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);
}
GTypelib *
-g_idl_module_build_metadata (GIdlModule *module,
+g_ir_module_build_metadata (GIrModule *module,
GList *modules)
{
guchar *metadata;
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",
/* 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;
for (e = module->entries, i = 0; e; e = e->next, i++)
{
- GIdlNode *node = e->data;
+ GIrNode *node = e->data;
if (strchr (node->name, '.'))
{
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++;
* 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"
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__ */
#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;
(( ((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:
}
void
-g_idl_node_free (GIdlNode *node)
+g_ir_node_free (GIrNode *node)
{
GList *l;
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);
}
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);
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);
}
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;
/* 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;
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:
{
}
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;
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;
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);
}
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);
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);
}
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);
}
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;
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;
}
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:
}
const gchar *
-g_idl_node_param_direction_string (GIdlNodeParam * node)
+g_ir_node_param_direction_string (GIrNodeParam * node)
{
if (node->out)
{
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)
gint i;
gchar **names;
gint n_names;
- GIdlNode *result = NULL;
+ GIrNode *result = NULL;
names = g_strsplit (name, ".", 0);
n_names = g_strv_length (names);
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;
}
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);
goto out;
}
- g_warning ("Entry %s not found", name);
+ g_warning ("Entry '%s' not found", name);
out:
}
static guint16
-find_entry (GIdlModule *module,
+find_entry (GIrModule *module,
GList *modules,
const gchar *name)
{
}
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)
}
else if (node->tag == 21)
{
- GIdlNode *iface;
+ GIrNode *iface;
gchar *name;
iface = find_entry_node (module, modules, node->interface, NULL);
}
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;
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);
}
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);
}
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);
}
}
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];
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;
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;
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);
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;
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);
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;
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);
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;
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);
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);
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;
*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;
*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;
{
*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);
}
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);
}
}
{
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;
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;
*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);
}
}
*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);
}
}
*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);
}
}
*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);
}
}
*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);
}
}
*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;
*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);
}
}
*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);
}
}
*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);
}
}
*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);
}
}
*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);
}
}
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;
}
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;
}
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;
}
*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;
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 !!");
}
-/* GObject introspection: Parsed IDL
+/* GObject introspection: Parsed GIR
*
* Copyright (C) 2005 Matthias Clasen
*
* 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;
gchar *symbol;
- GIdlNodeParam *result;
+ GIrNodeParam *result;
GList *parameters;
};
-struct _GIdlNodeType
+struct _GIrNodeType
{
- GIdlNode node;
+ GIrNode node;
gboolean is_pointer;
gboolean is_basic;
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;
gboolean transfer;
gboolean shallow_transfer;
- GIdlNodeType *type;
+ GIrNodeType *type;
};
-struct _GIdlNodeProperty
+struct _GIrNodeProperty
{
- GIdlNode node;
+ GIrNode node;
gboolean deprecated;
gboolean construct;
gboolean construct_only;
- GIdlNodeType *type;
+ GIrNodeType *type;
};
-struct _GIdlNodeSignal
+struct _GIrNodeSignal
{
- GIdlNode node;
+ GIrNode node;
gboolean deprecated;
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;
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;
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;
GList *values;
};
-struct _GIdlNodeBoxed
+struct _GIrNodeBoxed
{
- GIdlNode node;
+ GIrNode node;
gboolean deprecated;
GList *members;
};
-struct _GIdlNodeStruct
+struct _GIrNodeStruct
{
- GIdlNode node;
+ GIrNode node;
gboolean deprecated;
GList *members;
};
-struct _GIdlNodeUnion
+struct _GIrNodeUnion
{
- GIdlNode node;
+ GIrNode node;
gboolean deprecated;
gchar *gtype_init;
gint discriminator_offset;
- GIdlNodeType *discriminator_type;
+ GIrNodeType *discriminator_type;
};
-struct _GIdlNodeErrorDomain
+struct _GIrNodeErrorDomain
{
- GIdlNode node;
+ GIrNode node;
gboolean deprecated;
};
-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__ */
-/* 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
#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;
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,
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;
{ "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);
*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;
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);
}
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;
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)
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;
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;
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)
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)
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;
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;
}
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
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;
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);
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
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;
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;
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)
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;
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;
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;
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);
else
value_->deprecated = FALSE;
- enum_ = (GIdlNodeEnum *)ctx->current_node;
+ enum_ = (GIrNodeEnum *)ctx->current_node;
enum_->values = g_list_append (enum_->values, value_);
}
{
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;
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);
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;
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);
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;
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)
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);
}
}
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;
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);
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;
}
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;
}
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;
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;
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;
GError **error)
{
if (strcmp (element_name, "vfunc") == 0 &&
- (ctx->state == STATE_OBJECT ||
+ (ctx->state == STATE_CLASS ||
ctx->state == STATE_INTERFACE))
{
const gchar *name;
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;
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;
ParseContext *ctx,
GError **error)
{
- if (strcmp (element_name, "struct") == 0 &&
+ if (strcmp (element_name, "record") == 0 &&
ctx->state == STATE_NAMESPACE)
{
const gchar *name;
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;
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)
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;
}
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);
}
return FALSE;
}
+extern GLogLevelFlags logged_levels;
+
static void
start_element_handler (GMarkupParseContext *context,
const gchar *element_name,
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,
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':
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':
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;
}
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));
}
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));
}
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;
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;
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;
}
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':
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,
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
{
ParseContext *ctx = user_data;
+ g_debug ("</%s>", element_name);
+
switch (ctx->state)
{
case STATE_START:
/* 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);
{
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;
};
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;
}
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);
-/* GObject introspection: A parser for the XML IDL format
+/* GObject introspection: A parser for the XML GIR format
*
* Copyright (C) 2005 Matthias Clasen
*
* 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__ */
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";
"%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));
{
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\" "
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
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");
}
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;
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");
}
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";
}
{
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:
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);
#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);
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)
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)
{
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;
}
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);
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,
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;
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,
(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);
}
}
{
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,
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 */
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,
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,
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);
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,
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);
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, '_');
while (last_underscore != NULL)
{
char *prefix;
- GIdlNode *node;
+ GIrNode *node;
prefix = g_strndup (sym->ident, last_underscore - sym->ident);
prefix = str_replace (prefix, "_", "");
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
}
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);
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)
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;
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);
{
GISourceType *struct_type = sym->base_type;
gboolean opaque_type = FALSE;
- GIdlNode *type;
+ GIrNode *type;
if (struct_type->child_list == NULL)
{
{
/* 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;
{
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);
{
char *base_name;
GList *member_l;
- GIdlNodeInterface *node;
+ GIrNodeInterface *node;
if (g_str_has_suffix (sym->ident, "Interface"))
{
}
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;
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 =
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);
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);
{
GISourceType *union_type = sym->base_type;
gboolean opaque_type = FALSE;
- GIdlNode *type;
+ GIrNode *type;
if (union_type->child_list == NULL)
{
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);
}
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;
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);
{
GISourceType *enum_type;
GList *member_l;
- GIdlNodeEnum *node;
+ GIrNodeEnum *node;
GISourceSymbol *enum_symbol;
enum_type = sym->base_type;
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,
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;
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 =
(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);
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);
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");
}
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);
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);
for (l = modules; l; l = l->next)
{
- GIdlModule *module = (GIdlModule*)l->data;
+ GIrModule *module = (GIrModule*)l->data;
g_igenerator_add_module (igenerator, module);
}
}