[gobject-introspection/wip/transformer] Fix type introspectability; handle lists/arrays, etc.



commit f04efdb15975008f73e61dfd6ad4890d89395666
Author: Colin Walters <walters verbum org>
Date:   Thu Jul 29 18:02:49 2010 -0400

    Fix type introspectability; handle lists/arrays, etc.
    
    We also special case types like TYPE_LONG_LONG to be
    not-introspectable; see the comment.

 giscanner/finaltransformer.py |   30 +++++++++++++++++++++---------
 1 files changed, 21 insertions(+), 9 deletions(-)
---
diff --git a/giscanner/finaltransformer.py b/giscanner/finaltransformer.py
index 8df3bb0..0962851 100644
--- a/giscanner/finaltransformer.py
+++ b/giscanner/finaltransformer.py
@@ -24,15 +24,8 @@ import tempfile
 import shutil
 import subprocess
 
-from .ast import (Alias, Bitfield, Callable, Callback, Class, Constant, Enum,
-                  Function, Interface, Member, Namespace, Node, Parameter,
-                  Property, Record, Return, Type, TypeContainer, Union,
-                  Class, Field, VFunction, default_array_types,
-                  TYPE_ANY, TYPE_GTYPE, TYPE_UINT8, PARAM_TRANSFER_FULL, Array, List,
-                  Map, Varargs, type_names)
-from .glibast import (GLibBoxed, GLibEnum, GLibEnumMember, GLibFlags,
-                      GLibInterface, GLibObject, GLibSignal, GLibBoxedStruct,
-                      GLibBoxedUnion, GLibBoxedOther, GLibRecord)
+from .ast import * 
+from .glibast import *
 from .utils import to_underscores, to_underscores_noprefix
 
 class FinalTransformer(object):
@@ -85,6 +78,25 @@ class FinalTransformer(object):
     def _type_is_introspectable(self, typeval, warn=False):
         if not typeval.resolved:
             return False
+        if isinstance(typeval, (Array, List)):
+            return self._type_is_introspectable(typeval.element_type)
+        elif isinstance(typeval, Map):
+            return (self._type_is_introspectable(typeval.key_type)
+                    and self._type_is_introspectable(typeval.value_type))
+        if typeval.target_foreign:
+            return True
+        if typeval.target_fundamental:
+            # Mark UCHAR as not introspectable temporarily until
+            # we're ready to land the typelib changes
+            if typeval.is_equiv(TYPE_UNICHAR):
+                return False
+            # These are not introspectable pending us adding
+            # larger type tags to the typelib (in theory these could
+            # be 128 bit or larger)
+            if typeval.is_equiv((TYPE_LONG_LONG, TYPE_LONG_ULONG, 
+                                 TYPE_LONG_DOUBLE)):
+                return False
+            return True
         target = self._transformer.lookup_typenode(typeval)
         if not target:
             return False



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