Bug 562467 – Property annotation
authorJohan Dahlin <jdahlin@async.com.br>
Tue, 13 Jan 2009 00:02:24 +0000 (00:02 +0000)
committerJohan Dahlin <johan@src.gnome.org>
Tue, 13 Jan 2009 00:02:24 +0000 (00:02 +0000)
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

ChangeLog
giscanner/annotationparser.py
tests/scanner/annotation-1.0-expected.gir
tests/scanner/annotation-1.0-expected.tgir
tests/scanner/annotation.c

index 1d991ee..f71a1f0 100644 (file)
--- 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:
index d61d8a5..230d115 100644 (file)
@@ -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)
index 609d6d0..8a3f155 100644 (file)
           <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>
index e06a337..5ebf1b8 100644 (file)
           <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"/>
index 98b3b06..3c771dd 100644 (file)
@@ -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