gobject-introspection r757 - in trunk: . docs girepository giscanner tests/scanner



Author: walters
Date: Mon Oct 20 17:04:17 2008
New Revision: 757
URL: http://svn.gnome.org/viewvc/gobject-introspection?rev=757&view=rev

Log:
Bug 557011 - Add g_object_info_get_abstract


Modified:
   trunk/ChangeLog
   trunk/docs/typelib-format.txt
   trunk/girepository/ginfo.c
   trunk/girepository/girepository.h
   trunk/girepository/girnode.c
   trunk/girepository/girnode.h
   trunk/girepository/girparser.c
   trunk/girepository/gtypelib.h
   trunk/giscanner/ast.py
   trunk/giscanner/cgobject.py
   trunk/giscanner/girparser.py
   trunk/giscanner/girwriter.py
   trunk/giscanner/glibast.py
   trunk/giscanner/glibtransformer.py
   trunk/tests/scanner/drawable-1.0-expected.gir
   trunk/tests/scanner/drawable-injected-1.0-expected.gir
   trunk/tests/scanner/foo-1.0-expected.gir
   trunk/tests/scanner/foo.c

Modified: trunk/docs/typelib-format.txt
==============================================================================
--- trunk/docs/typelib-format.txt	(original)
+++ trunk/docs/typelib-format.txt	Mon Oct 20 17:04:17 2008
@@ -873,8 +873,9 @@
 struct ObjectBlob
 {
   guint16 blob_type;  /* 7 */
-  guint   deprecated   : 1; 
-  guint   reserved     :15;
+  guint   deprecated   : 1;
+  guint   abstract     : 1;
+  guint   reserved     :14;
   guint32 name; 
 
   GTypeBlob gtype;

Modified: trunk/girepository/ginfo.c
==============================================================================
--- trunk/girepository/ginfo.c	(original)
+++ trunk/girepository/ginfo.c	Mon Oct 20 17:04:17 2008
@@ -1123,6 +1123,14 @@
     return NULL;
 }
 
+gboolean
+g_object_info_get_abstract (GIObjectInfo    *info)
+{
+  GIBaseInfo *base = (GIBaseInfo *)info;
+  ObjectBlob *blob = (ObjectBlob *)&base->typelib->data[base->offset];
+  return blob->abstract != 0;
+}
+
 const gchar *
 g_object_info_get_type_name (GIObjectInfo *info)
 {

Modified: trunk/girepository/girepository.h
==============================================================================
--- trunk/girepository/girepository.h	(original)
+++ trunk/girepository/girepository.h	Mon Oct 20 17:04:17 2008
@@ -392,6 +392,7 @@
 
 const gchar *          g_object_info_get_type_name 	    (GIObjectInfo    *info);
 const gchar *          g_object_info_get_type_init 	    (GIObjectInfo    *info);
+gboolean               g_object_info_get_abstract           (GIObjectInfo    *info);
 GIObjectInfo *         g_object_info_get_parent             (GIObjectInfo    *info);
 gint                   g_object_info_get_n_interfaces       (GIObjectInfo    *info);
 GIInterfaceInfo *      g_object_info_get_interface          (GIObjectInfo    *info,

Modified: trunk/girepository/girnode.c
==============================================================================
--- trunk/girepository/girnode.c	(original)
+++ trunk/girepository/girnode.c	Mon Oct 20 17:04:17 2008
@@ -1872,6 +1872,7 @@
 	GList *members;
 
 	blob->blob_type = BLOB_TYPE_OBJECT;
+	blob->abstract = object->abstract;
 	blob->deprecated = object->deprecated;
 	blob->reserved = 0;
 	blob->name = write_string (node->name, strings, data, offset2);

Modified: trunk/girepository/girnode.h
==============================================================================
--- trunk/girepository/girnode.h	(original)
+++ trunk/girepository/girnode.h	Mon Oct 20 17:04:17 2008
@@ -212,6 +212,7 @@
 {
   GIrNode node;
 
+  gboolean abstract;
   gboolean deprecated;
 
   gchar *gtype_name;

Modified: trunk/girepository/girparser.c
==============================================================================
--- trunk/girepository/girparser.c	(original)
+++ trunk/girepository/girparser.c	Mon Oct 20 17:04:17 2008
@@ -1362,12 +1362,14 @@
       const gchar *typename;
       const gchar *typeinit;
       const gchar *deprecated;
+      const gchar *abstract;
       
       name = find_attribute ("name", attribute_names, attribute_values);
       parent = find_attribute ("parent", attribute_names, attribute_values);
       typename = find_attribute ("glib:type-name", attribute_names, attribute_values);
       typeinit = find_attribute ("glib:get-type", attribute_names, attribute_values);
       deprecated = find_attribute ("deprecated", attribute_names, attribute_values);
+      abstract = find_attribute ("abstract", attribute_names, attribute_values);
       
       if (name == NULL)
 	MISSING_ATTRIBUTE (context, error, element_name, "name");
@@ -1388,7 +1390,9 @@
 	    iface->deprecated = TRUE;
 	  else
 	    iface->deprecated = FALSE;
-	  
+
+	  iface->abstract = abstract && strcmp (abstract, "1") == 0;
+
 	  ctx->current_node = (GIrNode *) iface;
 	  ctx->current_module->entries = 
 	    g_list_append (ctx->current_module->entries, iface);	      

Modified: trunk/girepository/gtypelib.h
==============================================================================
--- trunk/girepository/gtypelib.h	(original)
+++ trunk/girepository/gtypelib.h	Mon Oct 20 17:04:17 2008
@@ -407,9 +407,10 @@
 typedef struct
 {
   guint16   blob_type;  /* 7 */
-  guint16   deprecated   : 1; 
-  guint16   reserved     :15;
-  guint32   name; 
+  guint16   deprecated   : 1;
+  guint16   abstract     : 1;
+  guint16   reserved     :14;
+  guint32   name;
 
   guint32   gtype_name;
   guint32   gtype_init;
@@ -440,7 +441,7 @@
 typedef struct 
 {
   guint16 blob_type;  
-  guint16 deprecated   : 1; 
+  guint16 deprecated   : 1;
   guint16 reserved     :15;
   guint32 name; 
 

Modified: trunk/giscanner/ast.py
==============================================================================
--- trunk/giscanner/ast.py	(original)
+++ trunk/giscanner/ast.py	Mon Oct 20 17:04:17 2008
@@ -350,10 +350,11 @@
 
 class Class(Node):
 
-    def __init__(self, name, parent):
+    def __init__(self, name, parent, is_abstract):
         Node.__init__(self, name)
         self.ctype = name
         self.parent = parent
+        self.is_abstract = is_abstract
         self.methods = []
         self.interfaces = []
         self.constructors = []

Modified: trunk/giscanner/cgobject.py
==============================================================================
--- trunk/giscanner/cgobject.py	(original)
+++ trunk/giscanner/cgobject.py	Mon Oct 20 17:04:17 2008
@@ -51,6 +51,7 @@
 # FIXME - this is wrong on win64, where long == 32 but size_t == 64
 GType = ctypes.c_ulong
 
+TYPE_FLAG_ABSTRACT = 1 << 4
 
 # Structs
 
@@ -190,6 +191,15 @@
     return _gobj.g_type_fundamental(type_id)
 
 
+ _gwrap('g_type_test_flags', ctypes.c_int, GType, ctypes.c_int)
+def type_test_flags(type_id, flag):
+    return _gobj.g_type_test_flags(type_id, flag)
+
+
+def type_is_abstract(type_id):
+    return type_test_flags(type_id, TYPE_FLAG_ABSTRACT) != 0
+
+
 @_gwrap('g_type_parent', GType, GType)
 def type_parent(type_id):
     return _gobj.g_type_parent(type_id)

Modified: trunk/giscanner/girparser.py
==============================================================================
--- trunk/giscanner/girparser.py	(original)
+++ trunk/giscanner/girparser.py	Mon Oct 20 17:04:17 2008
@@ -123,18 +123,23 @@
                      node.attrib.get(_cns('type')))
 
     def _parse_object_interface(self, node):
+        ctor_args = [node.attrib['name'],
+                     node.attrib.get('parent'),
+                     node.attrib[_glibns('type-name')],
+                     node.attrib[_glibns('get-type')]]
         if node.tag == _corens('interface'):
             klass = GLibInterface
         elif node.tag == _corens('class'):
             klass = GLibObject
+            is_abstract = node.attrib.get('abstract')
+            is_abstract = is_abstract and is_abstract != '0'
+            ctor_args.append(is_abstract)
         else:
             raise AssertionError(node)
 
-        obj = klass(node.attrib['name'],
-                    node.attrib.get('parent'),
-                    node.attrib[_glibns('type-name')],
-                    node.attrib[_glibns('get-type')],
-                    node.attrib.get(_cns('type')))
+        ctor_args.append(node.attrib.get(_cns('type')))
+        obj = klass(*ctor_args)
+
         for iface in node.findall(_corens('implements')):
             obj.interfaces.append(iface.attrib['name'])
         for method in node.findall(_corens('method')):

Modified: trunk/giscanner/girwriter.py
==============================================================================
--- trunk/giscanner/girwriter.py	(original)
+++ trunk/giscanner/girwriter.py	Mon Oct 20 17:04:17 2008
@@ -230,6 +230,8 @@
             tag_name = 'class'
             if node.parent is not None:
                 attrs.append(('parent', node.parent))
+            if node.is_abstract:
+                attrs.append(('abstract', '1'))
         else:
             tag_name = 'interface'
         if isinstance(node, (GLibObject, GLibInterface)):

Modified: trunk/giscanner/glibast.py
==============================================================================
--- trunk/giscanner/glibast.py	(original)
+++ trunk/giscanner/glibast.py	Mon Oct 20 17:04:17 2008
@@ -85,8 +85,9 @@
 
 class GLibObject(Class):
 
-    def __init__(self, name, parent, type_name, get_type, ctype=None):
-        Class.__init__(self, name, parent)
+    def __init__(self, name, parent, type_name, get_type,
+                 is_abstract, ctype=None):
+        Class.__init__(self, name, parent, is_abstract)
         self.type_name = type_name
         self.get_type = get_type
         self.signals = []

Modified: trunk/giscanner/glibtransformer.py
==============================================================================
--- trunk/giscanner/glibtransformer.py	(original)
+++ trunk/giscanner/glibtransformer.py	Mon Oct 20 17:04:17 2008
@@ -203,7 +203,7 @@
                 cgobject.type_parent(type_id))
             parent_gitype = self._resolve_gtypename(parent_type_name)
             symbol = to_underscores(type_name).lower() + '_get_type'
-        node = GLibObject(node.name, parent_gitype, type_name, symbol)
+        node = GLibObject(node.name, parent_gitype, type_name, symbol, True)
         type_id = cgobject.TYPE_OBJECT
         self._introspect_properties(node, type_id)
         self._introspect_signals(node, type_id)
@@ -534,10 +534,12 @@
             return
         parent_type_name = cgobject.type_name(cgobject.type_parent(type_id))
         parent_gitype = self._resolve_gtypename(parent_type_name)
+        is_abstract = cgobject.type_is_abstract(type_id)
         node = GLibObject(
             self._transformer.remove_prefix(type_name),
             parent_gitype,
-            type_name, symbol)
+            type_name,
+            symbol, is_abstract)
         self._introspect_properties(node, type_id)
         self._introspect_signals(node, type_id)
         self._introspect_implemented_interfaces(node, type_id)

Modified: trunk/tests/scanner/drawable-1.0-expected.gir
==============================================================================
--- trunk/tests/scanner/drawable-1.0-expected.gir	(original)
+++ trunk/tests/scanner/drawable-1.0-expected.gir	Mon Oct 20 17:04:17 2008
@@ -10,6 +10,7 @@
     <class name="TestDrawable"
            c:type="TestDrawable"
            parent="GObject.Object"
+           abstract="1"
            glib:type-name="TestDrawable"
            glib:get-type="test_drawable_get_type">
       <method name="do_foo" c:identifier="test_drawable_do_foo">

Modified: trunk/tests/scanner/drawable-injected-1.0-expected.gir
==============================================================================
--- trunk/tests/scanner/drawable-injected-1.0-expected.gir	(original)
+++ trunk/tests/scanner/drawable-injected-1.0-expected.gir	Mon Oct 20 17:04:17 2008
@@ -10,6 +10,7 @@
     <class name="TestDrawable"
            c:type="TestDrawable"
            parent="GObject.Object"
+           abstract="1"
            glib:type-name="TestDrawable"
            glib:get-type="test_drawable_get_type">
       <method name="do_foo" c:identifier="test_drawable_do_foo">

Modified: trunk/tests/scanner/foo-1.0-expected.gir
==============================================================================
--- trunk/tests/scanner/foo-1.0-expected.gir	(original)
+++ trunk/tests/scanner/foo-1.0-expected.gir	Mon Oct 20 17:04:17 2008
@@ -187,6 +187,7 @@
     <class name="Subobject"
            c:type="FooSubobject"
            parent="Object"
+           abstract="1"
            glib:type-name="FooSubobject"
            glib:get-type="foo_subobject_get_type">
       <implements name="Interface"/>

Modified: trunk/tests/scanner/foo.c
==============================================================================
--- trunk/tests/scanner/foo.c	(original)
+++ trunk/tests/scanner/foo.c	Mon Oct 20 17:04:17 2008
@@ -167,7 +167,7 @@
   return g_strdup ("foo");
 }
 
-G_DEFINE_TYPE (FooSubobject, foo_subobject, FOO_TYPE_OBJECT);
+G_DEFINE_ABSTRACT_TYPE (FooSubobject, foo_subobject, FOO_TYPE_OBJECT);
 
 static void
 foo_subobject_class_init (FooSubobjectClass *klass)



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