Bug 556732 – generate gir files consistently
authorTommi Komulainen <tommi.komulainen@iki.fi>
Fri, 17 Oct 2008 14:57:38 +0000 (14:57 +0000)
committerTommi Komulainen <tko@src.gnome.org>
Fri, 17 Oct 2008 14:57:38 +0000 (14:57 +0000)
2008-10-17  Tommi Komulainen  <tommi.komulainen@iki.fi>

Bug 556732 – generate gir files consistently

* giscanner/girwriter.py (_write_property): write properties
'construct' attribute if set
* tools/generate.c (write_property_info): write properties
'readable' and 'writable' attributes only if non-default
* tests/object.gir: add writable="0"
* tests/scanner/foo-1.0-expected.gir: add construct="1"

svn path=/trunk/; revision=742

ChangeLog
giscanner/girwriter.py
tests/object.gir
tests/scanner/foo-1.0-expected.gir
tools/generate.c

index 047257e..3f02fac 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2008-10-17  Tommi Komulainen  <tommi.komulainen@iki.fi>
+
+       Bug 556732 – generate gir files consistently
+
+       * giscanner/girwriter.py (_write_property): write properties
+       'construct' attribute if set
+       * tools/generate.c (write_property_info): write properties
+       'readable' and 'writable' attributes only if non-default
+       * tests/object.gir: add writable="0"
+       * tests/scanner/foo-1.0-expected.gir: add construct="1"
+
 2008-10-17  Johan Bilien  <jobi@via.ecp.fr>
 
        * gir/glib-2.0.c: added annotations
index f6df49d..55176d7 100644 (file)
@@ -261,11 +261,13 @@ class GIRWriter(XMLWriter):
 
     def _write_property(self, prop):
         attrs = [('name', prop.name)]
-        # Properties are assumed to be readable
+        # Properties are assumed to be readable (see also generate.c)
         if not prop.readable:
             attrs.append(('readable', '0'))
         if prop.writable:
             attrs.append(('writable', '1'))
+        if prop.construct:
+            attrs.append(('construct', '1'))
         if prop.construct_only:
             attrs.append(('construct-only', '1'))
         with self.tagcontext('property', attrs):
index b7701c1..937849a 100644 (file)
@@ -8,7 +8,7 @@
     <interface name="IFace1" glib:type-name="IFace1" glib:get-type="iface1_get_type"/>
     <class name="Object1" parent="Object2" glib:type-name="Object1" glib:get-type="object1_get_type">
       <implements name="IFace1"/>
-      <property name="prop1" readable="0" writable="0">
+      <property name="prop1" readable="0">
         <type name="int"/>
       </property>
       <glib:signal name="signal1" when="LAST">
index 7bdb215..17dfc6b 100644 (file)
           </parameter>
         </parameters>
       </method>
-      <property name="string" writable="1">
+      <property name="string" writable="1" construct="1">
         <type name="utf8" c:type="gchararray"/>
       </property>
       <field name="parent_instance">
index 0e286fb..729583f 100644 (file)
@@ -841,16 +841,12 @@ write_property_info (const gchar    *namespace,
 
   if (deprecated)
     xml_printf (file, " deprecated=\"1\"");
-       
-  if (flags & G_PARAM_READABLE)
-    xml_printf (file, " readable=\"1\"");
-  else
-    xml_printf (file, " readable=\"0\"");
 
+  /* Properties are assumed to be read-only (see also girwriter.py) */
+  if (!(flags & G_PARAM_READABLE))
+    xml_printf (file, " readable=\"0\"");
   if (flags & G_PARAM_WRITABLE)
     xml_printf (file, " writable=\"1\"");
-  else
-    xml_printf (file, " writable=\"0\"");
 
   if (flags & G_PARAM_CONSTRUCT)
     xml_printf (file, " construct=\"1\"");