gobject-introspection r257 - in trunk: . giscanner tests/parser
- From: johan svn gnome org
- To: svn-commits-list gnome org
- Subject: gobject-introspection r257 - in trunk: . giscanner tests/parser
- Date: Tue, 29 Apr 2008 12:07:35 +0100 (BST)
Author: johan
Date: Tue Apr 29 11:07:35 2008
New Revision: 257
URL: http://svn.gnome.org/viewvc/gobject-introspection?rev=257&view=rev
Log:
2008-04-29 Johan Dahlin <jdahlin async com br>
* giscanner/girwriter.py:
* giscanner/glibtransformer.py:
* giscanner/transformer.py:
* giscanner/xmlwriter.py:
* tests/parser/Foo-expected.gir:
* tests/parser/foo-object.h:
Write record/structs to gir file too. Add a couple of tests,
fix an off by one error in xmlwriter.py.
Modified:
trunk/ChangeLog
trunk/giscanner/girwriter.py
trunk/giscanner/glibtransformer.py
trunk/giscanner/transformer.py
trunk/giscanner/xmlwriter.py
trunk/tests/parser/Foo-expected.gir
trunk/tests/parser/foo-object.h
Modified: trunk/giscanner/girwriter.py
==============================================================================
--- trunk/giscanner/girwriter.py (original)
+++ trunk/giscanner/girwriter.py Tue Apr 29 11:07:35 2008
@@ -20,7 +20,8 @@
from __future__ import with_statement
-from .ast import (Callback, Class, Enum, Function, Interface, Sequence)
+from .ast import (Callback, Class, Enum, Function, Interface, Sequence,
+ Struct)
from .glibast import (GLibBoxed, GLibEnum, GLibEnumMember,
GLibFlags, GLibObject, GLibInterface)
from .xmlwriter import XMLWriter
@@ -57,6 +58,8 @@
self._write_boxed(node)
elif isinstance(node, Callback):
self._write_callback(node)
+ elif isinstance(node, Struct):
+ self._write_record(node)
else:
print 'WRITER: Unhandled node', node
@@ -154,6 +157,10 @@
self._write_method(method)
for prop in node.properties:
self._write_property(prop)
+ for field in node.fields:
+ self._write_field(field)
+ for signal in node.signals:
+ self._write_signal(signal)
def _write_boxed(self, boxed):
attrs = [('c:type', boxed.ctype),
@@ -177,3 +184,29 @@
with self.tagcontext('callback', attrs):
self._write_return_type(callback.retval)
self._write_parameters(callback.parameters)
+
+ def _write_record(self, record):
+ attrs = [('name', record.name),
+ ('c:type', record.symbol)]
+ if record.fields:
+ with self.tagcontext('record', attrs):
+ for field in record.fields:
+ self._write_field(field)
+ else:
+ self.write_tag('record', attrs)
+
+ def _write_field(self, field):
+ if isinstance(field, Callback):
+ self._write_callback(field)
+ return
+
+ attrs = [('name', field.name),
+ ('type', str(field.type))]
+ self.write_tag('field', attrs)
+
+ def _write_signal(self, signal):
+ attrs = [('name', signal.name)]
+ with self.tagcontext('glib:signal', attrs):
+ self._write_return_type(signal.retval)
+ self._write_parameters(signal.parameters)
+
Modified: trunk/giscanner/glibtransformer.py
==============================================================================
--- trunk/giscanner/glibtransformer.py (original)
+++ trunk/giscanner/glibtransformer.py Tue Apr 29 11:07:35 2008
@@ -320,6 +320,7 @@
node = GLibBoxed(self._strip_namespace_object(type_name),
type_name, symbol)
self._add_attribute(node)
+ self._remove_attribute(type_name)
self._register_internal_type(type_name, node)
def _introspect_properties(self, node, type_id):
Modified: trunk/giscanner/transformer.py
==============================================================================
--- trunk/giscanner/transformer.py (original)
+++ trunk/giscanner/transformer.py Tue Apr 29 11:07:35 2008
@@ -163,16 +163,20 @@
return return_
def _create_typedef_struct(self, symbol):
- self._typedefs_ns[symbol.base_type.name] = symbol.ident
+ name = self._remove_prefix(symbol.ident)
+ struct = Struct(name, symbol.ident)
+ self._typedefs_ns[symbol.ident] = struct
+ return struct
def _create_struct(self, symbol):
- name = self._typedefs_ns.get(symbol.ident, None)
- if name is None:
+ struct = self._typedefs_ns.get(symbol.ident, None)
+ if struct is None:
name = self._remove_prefix(symbol.ident)
- struct = Struct(name, symbol.ident)
+ struct = Struct(name, symbol.ident)
+
for child in symbol.base_type.child_list:
- struct.fields.append(self._traverse_one(child,
- child.base_type.type))
+ field = self._traverse_one(child, child.base_type.type)
+ struct.fields.append(field)
return struct
def _create_callback(self, symbol):
Modified: trunk/giscanner/xmlwriter.py
==============================================================================
--- trunk/giscanner/xmlwriter.py (original)
+++ trunk/giscanner/xmlwriter.py Tue Apr 29 11:07:35 2008
@@ -62,7 +62,7 @@
def _open_tag(self, tag_name, attributes=None):
attrs = self._collect_attributes(
- attributes, len(tag_name) + 2)
+ attributes, len(tag_name) + 1)
self.write_line('<%s%s>' % (tag_name, attrs))
def _close_tag(self, tag_name):
Modified: trunk/tests/parser/Foo-expected.gir
==============================================================================
--- trunk/tests/parser/Foo-expected.gir (original)
+++ trunk/tests/parser/Foo-expected.gir Tue Apr 29 11:07:35 2008
@@ -174,6 +174,19 @@
<property name="string">
<type name="gchararray" c:type="gchararray"/>
</property>
+ <glib:signal name="signal">
+ <return-value>
+ <type name="gchararray" c:type="gchararray"/>
+ </return-value>
+ <parameters>
+ <parameter name="object">
+ <type name="GObject" c:type="GObject"/>
+ </parameter>
+ <parameter name="p0">
+ <type name="gpointer" c:type="gpointer"/>
+ </parameter>
+ </parameters>
+ </glib:signal>
</class>
<class name="Subobject"
c:type="FooSubobject"
@@ -253,5 +266,7 @@
</parameter>
</parameters>
</callback>
+ <record name="FooStruct" c:type="FooStruct"/>
+ <record name="FooStructPrivate" c:type="FooStructPrivate"/>
</namespace>
</repository>
Modified: trunk/tests/parser/foo-object.h
==============================================================================
--- trunk/tests/parser/foo-object.h (original)
+++ trunk/tests/parser/foo-object.h Tue Apr 29 11:07:35 2008
@@ -121,4 +121,13 @@
/* @ */
/* @: */
+typedef struct _FooStruct FooStruct;
+typedef struct _FooStructPrivate FooStructPrivate;
+
+struct _FooStruct
+{
+ FooStructPrivate *priv;
+ int member;
+};
+
#endif /* __FOO_OBJECT_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]