gobject-introspection r280 - in trunk: . giscanner



Author: johan
Date: Sat May 31 21:28:33 2008
New Revision: 280
URL: http://svn.gnome.org/viewvc/gobject-introspection?rev=280&view=rev

Log:
2008-05-31  Johan Dahlin  <jdahlin async com br>

    * giscanner/xmlwriter.py:
    Improve error reporting when trying to quote None.
    * giscanner/girparser.py:
    Do not print warnings when including more complete .gir files
    * giscanner/girwriter.py:
    Do not require a name for parameters, add a todo for singletons
    * giscanner/glibtransformer.py:
    Refactor the way structs are done, add a couple of hacks to allow
    us to get further.
    * giscanner/transformer.py:
    Add enough hacks so cairo, atk and pango.gir can be parsed properly
    * gobject-introspection-1.0.pc.in:
    Export girdir, so we can access gobject-2.0.gir from outside



Modified:
   trunk/ChangeLog
   trunk/giscanner/girparser.py
   trunk/giscanner/girwriter.py
   trunk/giscanner/glibtransformer.py
   trunk/giscanner/transformer.py
   trunk/giscanner/xmlwriter.py
   trunk/gobject-introspection-1.0.pc.in

Modified: trunk/giscanner/girparser.py
==============================================================================
--- trunk/giscanner/girparser.py	(original)
+++ trunk/giscanner/girparser.py	Sat May 31 21:28:33 2008
@@ -48,6 +48,10 @@
         for child in ns.getchildren():
             if child.tag == _corens('class'):
                 self._parse_object(child)
+            elif child.tag in [_corens('callback'),
+                               _corens('function'),
+                               _corens('record')]:
+                continue
             else:
                 print 'PARSER: Unhandled %s' % (child.tag,)
 

Modified: trunk/giscanner/girwriter.py
==============================================================================
--- trunk/giscanner/girwriter.py	(original)
+++ trunk/giscanner/girwriter.py	Sat May 31 21:28:33 2008
@@ -20,8 +20,8 @@
 
 from __future__ import with_statement
 
-from .ast import (Callback, Class, Enum, Function, Interface, Sequence,
-                  Struct)
+from .ast import (Callback, Class, Enum, Function, Interface, Member,
+                  Sequence, Struct)
 from .glibast import (GLibBoxed, GLibEnum, GLibEnumMember,
                       GLibFlags, GLibObject, GLibInterface)
 from .xmlwriter import XMLWriter
@@ -61,6 +61,9 @@
             self._write_callback(node)
         elif isinstance(node, Struct):
             self._write_record(node)
+        elif isinstance(node, Member):
+            # FIXME: atk_misc_instance singleton
+            pass
         else:
             print 'WRITER: Unhandled node', node
 
@@ -99,7 +102,9 @@
                 self._write_parameter(parameter)
 
     def _write_parameter(self, parameter):
-        attrs = [('name', parameter.name)]
+        attrs = []
+        if parameter.name is not None:
+            attrs.append(('name', parameter.name))
         if parameter.direction != 'in':
             attrs.append(('direction', parameter.direction))
         if parameter.transfer:

Modified: trunk/giscanner/glibtransformer.py
==============================================================================
--- trunk/giscanner/glibtransformer.py	(original)
+++ trunk/giscanner/glibtransformer.py	Sat May 31 21:28:33 2008
@@ -24,8 +24,8 @@
 
 from . import cgobject
 from .odict import odict
-from .ast import (Callback, Enum, Function, Namespace, Parameter, Property,
-                  Return, Sequence, Struct, Type)
+from .ast import (Callback, Enum, Function, Member, Namespace, Parameter,
+                  Property, Return, Sequence, Struct, Type)
 from .glibast import (GLibBoxed, GLibEnum, GLibEnumMember, GLibFlags,
                       GLibInterface, GLibObject, GLibSignal)
 
@@ -127,6 +127,9 @@
             self._parse_struct(node)
         elif isinstance(node, Callback):
             self._parse_callback(node)
+        elif isinstance(node, Member):
+            # FIXME: atk_misc_instance singletons
+            pass
         else:
             print 'GOBJECT BUILDER: Unhandled node:', node
 

Modified: trunk/giscanner/transformer.py
==============================================================================
--- trunk/giscanner/transformer.py	(original)
+++ trunk/giscanner/transformer.py	Sat May 31 21:28:33 2008
@@ -21,8 +21,10 @@
 from giscanner.ast import (Callback, Enum, Function, Namespace, Member,
                            Parameter, Return, Sequence, Struct, Type)
 from giscanner.sourcescanner import (
-    SourceSymbol, symbol_type_name, CTYPE_POINTER, CTYPE_TYPEDEF, CTYPE_VOID,
-    CTYPE_BASIC_TYPE, CTYPE_FUNCTION, CTYPE_STRUCT, CSYMBOL_TYPE_FUNCTION,
+    SourceSymbol, ctype_name, symbol_type_name, CTYPE_POINTER,
+    CTYPE_BASIC_TYPE, CTYPE_UNION,
+    CTYPE_TYPEDEF, CTYPE_VOID, CTYPE_BASIC_TYPE, CTYPE_ENUM,
+    CTYPE_FUNCTION, CTYPE_STRUCT, CSYMBOL_TYPE_FUNCTION,
     CSYMBOL_TYPE_TYPEDEF, CSYMBOL_TYPE_STRUCT, CSYMBOL_TYPE_ENUM,
     CSYMBOL_TYPE_UNION, CSYMBOL_TYPE_OBJECT)
 
@@ -104,18 +106,7 @@
         if stype == CSYMBOL_TYPE_FUNCTION:
             return self._create_function(symbol)
         elif stype == CSYMBOL_TYPE_TYPEDEF:
-            if (symbol.base_type.type == CTYPE_POINTER and
-                symbol.base_type.base_type.type == CTYPE_FUNCTION):
-                node = self._create_callback(symbol)
-            elif symbol.base_type.type == CTYPE_STRUCT:
-                node = self._create_typedef_struct(symbol)
-            # This prevents an infinite recursion when scanning structures with
-            # private types not exposed in headers.
-            elif symbol.base_type.type == CSYMBOL_TYPE_TYPEDEF:
-                return
-            else:
-                node = self._traverse_one(symbol, symbol.base_type.type)
-            return node
+            return self._create_typedef(symbol)
         elif stype == CSYMBOL_TYPE_STRUCT:
             return self._create_struct(symbol)
         elif stype == CSYMBOL_TYPE_ENUM:
@@ -127,7 +118,7 @@
             pass
         else:
             raise NotImplementedError(
-                'Transformer: unhandled symbol: %r of type %r'
+                'Transformer: unhandled symbol: %r of type %s'
                 % (symbol.ident, symbol_type_name(stype)))
 
     def _create_enum(self, symbol):
@@ -164,7 +155,8 @@
         elif source_type.type == CTYPE_POINTER:
             value = self._create_source_type(source_type.base_type) + '*'
         else:
-            print 'BUILDER: Unhandled source type: %d' % (source_type.type,)
+            print 'BUILDER: Unhandled source type %s' % (
+                ctype_name(source_type.type),)
             value = '???'
         return value
 
@@ -175,6 +167,25 @@
             yield self._create_parameter(
                 child, options.get(child.ident, []))
 
+    def _create_typedef(self, symbol):
+        ctype = symbol.base_type.type
+        if (ctype == CTYPE_POINTER and
+            symbol.base_type.base_type.type == CTYPE_FUNCTION):
+            node = self._create_callback(symbol)
+        elif ctype == CTYPE_STRUCT:
+            node = self._create_typedef_struct(symbol)
+        elif ctype == CTYPE_ENUM:
+            return self._create_enum(symbol)
+        elif ctype in (CTYPE_TYPEDEF,
+                       CTYPE_POINTER,
+                       CTYPE_BASIC_TYPE,
+                       CTYPE_UNION):
+            return
+        else:
+            raise NotImplementedError(
+                "symbol %r of type %s" % (symbol.ident, ctype_name(ctype)))
+        return node
+
     def _create_type(self, source_type):
         type_name = self._create_source_type(source_type)
         return Type(type_name)
@@ -230,7 +241,13 @@
             struct = Struct(name, symbol.ident)
 
         for child in symbol.base_type.child_list:
-            field = self._traverse_one(child, child.base_type.type)
+            # FIXME: This is obviously wrong, we're sending in data
+            #        of the wrong type to _traverse_one
+            try:
+                field = self._traverse_one(child, child.base_type.type)
+            except NotImplementedError:
+                continue
+            
             if field:
                 struct.fields.append(field)
 

Modified: trunk/giscanner/xmlwriter.py
==============================================================================
--- trunk/giscanner/xmlwriter.py	(original)
+++ trunk/giscanner/xmlwriter.py	Sat May 31 21:28:33 2008
@@ -38,6 +38,9 @@
             return -1
         attr_length = 0
         for attr, value in attributes:
+            if value is None:
+                raise ValueError(
+                    "value for attribute %r cannot be None" % (attr,))
             attr_length += 2 + len(attr) + len(quoteattr(value))
         return attr_length + indent
 
@@ -54,7 +57,9 @@
         for attr, value in attributes:
             if indent_len and not first:
                 attr_value += '\n%s' % (self._indent_char * indent_len)
-            assert value is not None, attr
+            if value is None:
+                raise ValueError(
+                    "value for attribute %r cannot be None" % (attr,))
             attr_value += ' %s=%s' % (attr, quoteattr(value))
             if first:
                 first = False

Modified: trunk/gobject-introspection-1.0.pc.in
==============================================================================
--- trunk/gobject-introspection-1.0.pc.in	(original)
+++ trunk/gobject-introspection-1.0.pc.in	Sat May 31 21:28:33 2008
@@ -5,6 +5,7 @@
 includedir= includedir@
 
 g_ir_scanner=${bindir}/g-ir-scanner
+girdir=${prefix}/share/gir
 
 # FIXME: These needs to be ported to the GIR format first
 # g_idl_generator=${bindir}/g-idl-generator



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