gobject-introspection r356 - in trunk: . giscanner tools



Author: johan
Date: Wed Aug 13 20:24:10 2008
New Revision: 356
URL: http://svn.gnome.org/viewvc/gobject-introspection?rev=356&view=rev

Log:
2008-08-13  Johan Dahlin  <johan gnome org>

    * tools/g-ir-scanner:
    Allow multiple libraries
    * giscanner/glibtransformer.py:
    Rename load_library to add_library, traverse over all libraries
    when trying to resolve a function



Modified:
   trunk/ChangeLog
   trunk/giscanner/glibtransformer.py
   trunk/tools/g-ir-scanner

Modified: trunk/giscanner/glibtransformer.py
==============================================================================
--- trunk/giscanner/glibtransformer.py	(original)
+++ trunk/giscanner/glibtransformer.py	Wed Aug 13 20:24:10 2008
@@ -38,15 +38,15 @@
         self._transformer = transformer
         self._namespace_name = None
         self._output_ns = odict()
-        self._library = None
+        self._libraries = []
         self._type_names = {}
 
     # Public API
 
-    def load_library(self, libname):
+    def add_library(self, libname):
         if libname.endswith('.la'):
             libname = resolve_libtool(libname)
-        self._library = ctypes.cdll.LoadLibrary(libname)
+        self._libraries.append(ctypes.cdll.LoadLibrary(libname))
 
     def parse(self):
         namespace = self._transformer.parse()
@@ -175,7 +175,7 @@
         field.type = self._resolve_param_type(field.type)
 
     def _parse_get_type_function(self, func):
-        if self._library is None:
+        if not self._libraries:
             return False
         # GType *_get_type(void)
         symbol = func.symbol
@@ -186,9 +186,13 @@
         if func.parameters:
             return False
 
-        try:
-            func = getattr(self._library, symbol)
-        except AttributeError:
+        for library in self._libraries:
+            try:
+                func = getattr(library, symbol)
+                break
+            except AttributeError:
+                continue
+        else:
             print 'Warning: could not find symbol: %s' % symbol
             return False
 

Modified: trunk/tools/g-ir-scanner
==============================================================================
--- trunk/tools/g-ir-scanner	(original)
+++ trunk/tools/g-ir-scanner	Wed Aug 13 20:24:10 2008
@@ -49,8 +49,8 @@
                       action="append", dest="includes", default=[],
                       help="include types for other gidls")
     parser.add_option("-l", "--library",
-                      action="store", dest="library",
-                      help="library of this unit")
+                      action="append", dest="libraries", default=[],
+                      help="libraries of this unit")
     parser.add_option("-n", "--namespace",
                       action="store", dest="namespace_name",
                       help="name of namespace for this unit")
@@ -137,8 +137,9 @@
     # Transform the C AST nodes into higher level
     # GLib/GObject nodes
     glibtransformer = GLibTransformer(transformer)
-    if options.library:
-        glibtransformer.load_library(options.library)
+    if options.libraries:
+        for library in options.libraries:
+            glibtransformer.add_library(library)
 
     namespace = glibtransformer.parse()
 



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