gobject-introspection r587 - in trunk: girepository giscanner tests/scanner



Author: walters
Date: Mon Sep  8 22:24:09 2008
New Revision: 587
URL: http://svn.gnome.org/viewvc/gobject-introspection?rev=587&view=rev

Log:
Write out and parse full GObject property information (readable, writable, etc)

	* girepository/girparser.c: Default to "readable" for properties.
	* giscanner/ast.py: Add readable, writable etc.
	* giscanner/girwriter.py: Writ them.
	* giscanner/glibtransformer.py: Inspect them.
	* tests/*: Update.


Modified:
   trunk/girepository/girparser.c
   trunk/giscanner/ast.py
   trunk/giscanner/girwriter.py
   trunk/giscanner/glibtransformer.py
   trunk/tests/scanner/foo-expected.gir

Modified: trunk/girepository/girparser.c
==============================================================================
--- trunk/girepository/girparser.c	(original)
+++ trunk/girepository/girparser.c	Mon Sep  8 22:24:09 2008
@@ -1191,7 +1191,8 @@
 
 	  ((GIrNode *)property)->name = g_strdup (name);
 	  
-	  if (readable && strcmp (readable, "1") == 0)
+	  /* Assume properties are readable */
+	  if (readable == NULL || strcmp (readable, "1") == 0)
 	    property->readable = TRUE;
 	  else
 	    property->readable = FALSE;

Modified: trunk/giscanner/ast.py
==============================================================================
--- trunk/giscanner/ast.py	(original)
+++ trunk/giscanner/ast.py	Mon Sep  8 22:24:09 2008
@@ -280,9 +280,14 @@
 
 class Property(Node):
 
-    def __init__(self, name, type_name, ctype=None):
+    def __init__(self, name, type_name, readable, writable,
+                 construct, construct_only, ctype=None):
         Node.__init__(self, name)
         self.type = Type(type_name, ctype)
+        self.readable = readable
+        self.writable = writable
+        self.construct = construct
+        self.construct_only = construct_only
 
     def __repr__(self):
         return '%s(%r, %r, %r)' % (

Modified: trunk/giscanner/girwriter.py
==============================================================================
--- trunk/giscanner/girwriter.py	(original)
+++ trunk/giscanner/girwriter.py	Mon Sep  8 22:24:09 2008
@@ -216,6 +216,13 @@
 
     def _write_property(self, prop):
         attrs = [('name', prop.name)]
+        # Properties are assumed to be readable
+        if not prop.readable:
+            attrs.append(('readable', '0'))
+        if prop.writable:
+            attrs.append(('writable', '1'))
+        if prop.construct_only:
+            attrs.append(('construct-only', '1'))
         with self.tagcontext('property', attrs):
             self._write_type(prop.type)
 

Modified: trunk/giscanner/glibtransformer.py
==============================================================================
--- trunk/giscanner/glibtransformer.py	(original)
+++ trunk/giscanner/glibtransformer.py	Mon Sep  8 22:24:09 2008
@@ -581,9 +581,14 @@
             if pspec.owner_type != type_id:
                 continue
             ctype = cgobject.type_name(pspec.value_type)
+            readable = (pspec.flags & 1) != 0
+            writable = (pspec.flags & 2) != 0
+            construct = (pspec.flags & 4) != 0
+            construct_only = (pspec.flags & 8) != 0
             node.properties.append(Property(
                 pspec.name,
                 type_name_from_ctype(ctype),
+                readable, writable, construct, construct_only,
                 ctype,
                 ))
 

Modified: trunk/tests/scanner/foo-expected.gir
==============================================================================
--- trunk/tests/scanner/foo-expected.gir	(original)
+++ trunk/tests/scanner/foo-expected.gir	Mon Sep  8 22:24:09 2008
@@ -103,7 +103,7 @@
           </parameter>
         </parameters>
       </method>
-      <property name="string">
+      <property name="string" writable="1">
         <type name="string" c:type="gchararray"/>
       </property>
       <callback name="virtual_method" c:type="virtual_method">



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]