[gobject-introspection] Allow annotations on fields
- From: Andreas Rottmann <rotty src gnome org>
- To: svn-commits-list gnome org
- Subject: [gobject-introspection] Allow annotations on fields
- Date: Fri, 3 Jul 2009 21:20:58 +0000 (UTC)
commit 5f811f2d0d192c3d546b91e12fcf74b341434ca9
Author: Andreas Rottmann <a rottmann gmx at>
Date: Fri Jul 3 23:14:04 2009 +0200
Allow annotations on fields
Plain fields (i.e. non-callbacks) may have a 'type' annotation now.
.topdeps | 1 -
.topmsg | 2 --
giscanner/annotationparser.py | 20 +++++++++++++++-----
tests/scanner/utility-1.0-expected.gir | 8 ++++++++
tests/scanner/utility-1.0-expected.tgir | 8 ++++++++
tests/scanner/utility.c | 6 ++++++
tests/scanner/utility.h | 7 +++++++
7 files changed, 44 insertions(+), 8 deletions(-)
---
diff --git a/giscanner/annotationparser.py b/giscanner/annotationparser.py
index d79a46b..79cbfe8 100644
--- a/giscanner/annotationparser.py
+++ b/giscanner/annotationparser.py
@@ -332,7 +332,7 @@ class AnnotationApplier(object):
self._parse_node_common(record, block)
self._parse_constructors(record.constructors)
self._parse_methods(record, record.methods)
- self._parse_fields(record, record.fields)
+ self._parse_fields(record, record.fields, block)
if block:
record.doc = block.comment
@@ -347,7 +347,7 @@ class AnnotationApplier(object):
def _parse_union(self, union):
block = self._blocks.get(union.name)
self._parse_node_common(union, block)
- self._parse_fields(union, union.fields)
+ self._parse_fields(union, union.fields, block)
self._parse_constructors(union.constructors)
self._parse_methods(union, union.methods)
if block:
@@ -373,9 +373,9 @@ class AnnotationApplier(object):
for ctor in constructors:
self._parse_function(ctor)
- def _parse_fields(self, parent, fields):
+ def _parse_fields(self, parent, fields, block=None):
for field in fields:
- self._parse_field(parent, field)
+ self._parse_field(parent, field, block)
def _parse_properties(self, parent, properties):
for prop in properties:
@@ -464,9 +464,19 @@ class AnnotationApplier(object):
key = '%s::%s' % (parent.type_name, vfunc.name)
self._parse_callable(vfunc, self._blocks.get(key))
- def _parse_field(self, parent, field):
+ def _parse_field(self, parent, field, block=None):
if isinstance(field, Callback):
self._parse_callback(field)
+ else:
+ if not block:
+ return
+ tag = block.get(field.name)
+ if not tag:
+ return
+ t = tag.options.get('type')
+ if not t:
+ return
+ field.type.name = self._transformer.resolve_type_name(t.one())
def _parse_params(self, parent, params, block):
for param in params:
diff --git a/tests/scanner/utility-1.0-expected.gir b/tests/scanner/utility-1.0-expected.gir
index 02e2913..8c6a602 100644
--- a/tests/scanner/utility-1.0-expected.gir
+++ b/tests/scanner/utility-1.0-expected.gir
@@ -14,6 +14,14 @@ and/or use gtk-doc annotations. -->
shared-library="utility"
c:prefix="utility">
<alias name="Glyph" target="uint32" c:type="UtilityGlyph"/>
+ <record name="Buffer" c:type="UtilityBuffer">
+ <field name="data" writable="1">
+ <type name="any" c:type="char*"/>
+ </field>
+ <field name="length" writable="1">
+ <type name="size_t" c:type="gsize"/>
+ </field>
+ </record>
<union name="Byte" c:type="UtilityByte">
<field name="value" writable="1">
<type name="uint8" c:type="guint8"/>
diff --git a/tests/scanner/utility-1.0-expected.tgir b/tests/scanner/utility-1.0-expected.tgir
index 2a30f85..d25bd59 100644
--- a/tests/scanner/utility-1.0-expected.tgir
+++ b/tests/scanner/utility-1.0-expected.tgir
@@ -6,6 +6,14 @@
<include name="GObject" version="2.0"/>
<include name="GLib" version="2.0"/>
<namespace name="utility" version="1.0" shared-library="utility" c:prefix="utility">
+ <record name="Buffer">
+ <field name="data" writable="1">
+ <type name="any"/>
+ </field>
+ <field name="length" writable="1">
+ <type name="size"/>
+ </field>
+ </record>
<union name="Byte">
<field name="value" writable="1">
<type name="uint8"/>
diff --git a/tests/scanner/utility.c b/tests/scanner/utility.c
index a54afad..5ae5ed3 100644
--- a/tests/scanner/utility.c
+++ b/tests/scanner/utility.c
@@ -6,6 +6,12 @@ G_DEFINE_TYPE (UtilityObject, utility_object, G_TYPE_OBJECT);
* UtilityFlagType: (type bitfield)
**/
+/**
+ * UtilityBuffer:
+ *
+ * @data: (type pointer): the data
+ **/
+
static void
utility_object_class_init (UtilityObjectClass *klass)
{
diff --git a/tests/scanner/utility.h b/tests/scanner/utility.h
index cad93ff..a3eb3ef 100644
--- a/tests/scanner/utility.h
+++ b/tests/scanner/utility.h
@@ -44,6 +44,13 @@ typedef union
};
} UtilityByte;
+/* This one is similiar to Soup.Buffer */
+typedef struct
+{
+ const char *data;
+ gsize length;
+} UtilityBuffer;
+
typedef void (*UtilityFileFunc)(const char *path, gpointer user_data);
GType utility_object_get_type (void) G_GNUC_CONST;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]