summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Rottmann <a.rottmann@gmx.at>2009-07-03 23:14:04 +0200
committerAndreas Rottmann <a.rottmann@gmx.at>2009-07-03 23:14:04 +0200
commit5f811f2d0d192c3d546b91e12fcf74b341434ca9 (patch)
tree8a1d43404a7e51d5cc5700233a249a8904c8ccca
parente8d99aad1d29f343583792fac41a5182ab7d2ef7 (diff)
downloadgobject-introspection-5f811f2d0d192c3d546b91e12fcf74b341434ca9.tar.gz
Allow annotations on fields
Plain fields (i.e. non-callbacks) may have a 'type' annotation now.
-rw-r--r--.topdeps1
-rw-r--r--.topmsg2
-rw-r--r--giscanner/annotationparser.py20
-rw-r--r--tests/scanner/utility-1.0-expected.gir8
-rw-r--r--tests/scanner/utility-1.0-expected.tgir8
-rw-r--r--tests/scanner/utility.c6
-rw-r--r--tests/scanner/utility.h7
7 files changed, 44 insertions, 8 deletions
diff --git a/.topdeps b/.topdeps
deleted file mode 100644
index 1f7391f9..00000000
--- a/.topdeps
+++ /dev/null
@@ -1 +0,0 @@
-master
diff --git a/.topmsg b/.topmsg
deleted file mode 100644
index 33a72a5f..00000000
--- a/.topmsg
+++ /dev/null
@@ -1,2 +0,0 @@
-From: Andreas Rottmann <a.rottmann@gmx.at>
-Subject: [PATCH] Everything: add a boxed property to TestObj
diff --git a/giscanner/annotationparser.py b/giscanner/annotationparser.py
index d79a46bb..79cbfe8a 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 02e29136..8c6a602b 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 2a30f850..d25bd59f 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 a54afad9..5ae5ed3e 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 cad93ff5..a3eb3ef8 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;