From 5f811f2d0d192c3d546b91e12fcf74b341434ca9 Mon Sep 17 00:00:00 2001 From: Andreas Rottmann Date: Fri, 3 Jul 2009 23:14:04 +0200 Subject: 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(-) delete mode 100644 .topdeps delete mode 100644 .topmsg 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 -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"> + + + + + + + + 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 @@ + + + + + + + + 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; -- cgit v1.2.1