From: Johan Dahlin Date: Tue, 13 Jan 2009 00:02:24 +0000 (+0000) Subject: Bug 562467 – Property annotation X-Git-Tag: GOBJECT_INTROSPECTION_0_6_2~32 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=19d6a8145200ddccea4ad62ccd93442f30772fe1;p=platform%2Fupstream%2Fgobject-introspection.git Bug 562467 – Property annotation 2009-01-12 Johan Dahlin Bug 562467 – Property annotation * giscanner/annotationparser.py: * tests/scanner/annotation-1.0-expected.gir: * tests/scanner/annotation-1.0-expected.tgir: * tests/scanner/annotation.c (annotation_object_set_property), (annotation_object_get_property), (annotation_object_class_init): Annotations are parsed for properties. svn path=/trunk/; revision=1027 --- diff --git a/ChangeLog b/ChangeLog index 1d991ee..f71a1f0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,17 @@ 2009-01-12 Johan Dahlin + Bug 562467 – Property annotation + + * giscanner/annotationparser.py: + * tests/scanner/annotation-1.0-expected.gir: + * tests/scanner/annotation-1.0-expected.tgir: + * tests/scanner/annotation.c (annotation_object_set_property), + (annotation_object_get_property), (annotation_object_class_init): + + Annotations are parsed for properties. + +2009-01-12 Johan Dahlin + Bug 546739 – Introspection should know precise signal parameter types * giscanner/annotationparser.py: diff --git a/giscanner/annotationparser.py b/giscanner/annotationparser.py index d61d8a5..230d115 100644 --- a/giscanner/annotationparser.py +++ b/giscanner/annotationparser.py @@ -228,7 +228,7 @@ class AnnotationApplier(object): self._parse_constructors(class_.constructors) self._parse_methods(class_.methods) self._parse_methods(class_.static_methods) - self._parse_properties(class_.properties) + self._parse_properties(class_, class_.properties) self._parse_signals(class_, class_.signals) self._parse_fields(class_, class_.fields) @@ -236,7 +236,7 @@ class AnnotationApplier(object): block = self._blocks.get(interface.name) self._parse_version(interface, block) self._parse_methods(interface.methods) - self._parse_properties(interface.properties) + self._parse_properties(interface, interface.properties) self._parse_signals(interface, interface.signals) self._parse_fields(interface, interface.fields) @@ -273,9 +273,9 @@ class AnnotationApplier(object): for field in fields: self._parse_field(parent, field) - def _parse_properties(self, properties): + def _parse_properties(self, parent, properties): for prop in properties: - self._parse_property(property) + self._parse_property(parent, prop) def _parse_methods(self, methods): for method in methods: @@ -285,8 +285,10 @@ class AnnotationApplier(object): for signal in signals: self._parse_signal(parent, signal) - def _parse_property(self, prop): - pass + def _parse_property(self, parent, prop): + block = self._blocks.get('%s:%s' % (parent.type_name, prop.name)) + self._parse_version(prop, block) + self._parse_deprecated(prop, block) def _parse_callback(self, callback): block = self._blocks.get(callback.ctype) diff --git a/tests/scanner/annotation-1.0-expected.gir b/tests/scanner/annotation-1.0-expected.gir index 609d6d0..8a3f155 100644 --- a/tests/scanner/annotation-1.0-expected.gir +++ b/tests/scanner/annotation-1.0-expected.gir @@ -314,6 +314,14 @@ + + + diff --git a/tests/scanner/annotation-1.0-expected.tgir b/tests/scanner/annotation-1.0-expected.tgir index e06a337..5ebf1b8 100644 --- a/tests/scanner/annotation-1.0-expected.tgir +++ b/tests/scanner/annotation-1.0-expected.tgir @@ -297,6 +297,9 @@ + + + diff --git a/tests/scanner/annotation.c b/tests/scanner/annotation.c index 98b3b06..3c771dd 100644 --- a/tests/scanner/annotation.c +++ b/tests/scanner/annotation.c @@ -5,6 +5,11 @@ static char backslash_parsing_tester = '\\'; G_DEFINE_TYPE (AnnotationObject, annotation_object, G_TYPE_OBJECT); enum { + PROP_0, + PROP_STRING_PROPERTY, +}; + +enum { STRING_SIGNAL, LAST_SIGNAL }; @@ -12,12 +17,47 @@ enum { static guint annotation_object_signals[LAST_SIGNAL] = { 0 }; static void +annotation_object_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) +{ + switch (prop_id) + { + case PROP_STRING_PROPERTY: + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +annotation_object_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) +{ + switch (prop_id) + { + case PROP_STRING_PROPERTY: + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void annotation_object_class_init (AnnotationObjectClass *klass) { GObjectClass *gobject_class; gobject_class = G_OBJECT_CLASS (klass); + gobject_class->set_property = annotation_object_set_property; + gobject_class->get_property = annotation_object_get_property; + /** * AnnotationObject::string-signal: * @annotation: the annotation object @@ -38,6 +78,23 @@ annotation_object_class_init (AnnotationObjectClass *klass) (GSignalCMarshaller)g_cclosure_marshal_VOID__POINTER, G_TYPE_NONE, 1, G_TYPE_POINTER); + + /** + * AnnotationObject:string-property: + * + * This is a property which is a string + * + * Since: 1.0 + * Deprecated: 1.2: Use better-string-property instead + */ + g_object_class_install_property (gobject_class, + PROP_STRING_PROPERTY, + g_param_spec_string ("string-property", + "String property", + "This property is a string", + NULL, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); + } static void