summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohan Dahlin <jdahlin@async.com.br>2009-01-13 00:02:24 +0000
committerJohan Dahlin <johan@src.gnome.org>2009-01-13 00:02:24 +0000
commit19d6a8145200ddccea4ad62ccd93442f30772fe1 (patch)
tree1b534c2e6384723a2bd0b687b38faf0df8aaf618
parent6de1b29629397bc7328f1a44da7530ea2ff53dac (diff)
downloadgobject-introspection-19d6a8145200ddccea4ad62ccd93442f30772fe1.tar.gz
Bug 562467 – Property annotation
2009-01-12 Johan Dahlin <jdahlin@async.com.br> 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
-rw-r--r--ChangeLog12
-rw-r--r--giscanner/annotationparser.py14
-rw-r--r--tests/scanner/annotation-1.0-expected.gir8
-rw-r--r--tests/scanner/annotation-1.0-expected.tgir3
-rw-r--r--tests/scanner/annotation.c57
5 files changed, 88 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index 1d991ee2..f71a1f02 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,17 @@
2009-01-12 Johan Dahlin <jdahlin@async.com.br>
+ 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 <jdahlin@async.com.br>
+
Bug 546739 – Introspection should know precise signal parameter types
* giscanner/annotationparser.py:
diff --git a/giscanner/annotationparser.py b/giscanner/annotationparser.py
index d61d8a5b..230d115b 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 609d6d06..8a3f1559 100644
--- a/tests/scanner/annotation-1.0-expected.gir
+++ b/tests/scanner/annotation-1.0-expected.gir
@@ -314,6 +314,14 @@
<type name="GObject.Object" c:type="GObject*"/>
</return-value>
</method>
+ <property name="string-property"
+ version="1.0"
+ deprecated="Use better-string-property instead"
+ deprecated-version="1.2"
+ writable="1"
+ construct="1">
+ <type name="utf8" c:type="gchararray"/>
+ </property>
<field name="parent_instance">
<type name="GObject.Object" c:type="GObject"/>
</field>
diff --git a/tests/scanner/annotation-1.0-expected.tgir b/tests/scanner/annotation-1.0-expected.tgir
index e06a3379..5ebf1b81 100644
--- a/tests/scanner/annotation-1.0-expected.tgir
+++ b/tests/scanner/annotation-1.0-expected.tgir
@@ -297,6 +297,9 @@
<type name="GObject.Object"/>
</return-value>
</method>
+ <property name="string-property" writable="1" construct="1">
+ <type name="utf8"/>
+ </property>
<glib:signal name="string-signal" when="LAST">
<return-value transfer-ownership="full">
<type name="none"/>
diff --git a/tests/scanner/annotation.c b/tests/scanner/annotation.c
index 98b3b061..3c771dd6 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