From c389f15c7f064a8b1777d3a7c47dedd2bb6b1fff Mon Sep 17 00:00:00 2001 From: Johan Dahlin Date: Wed, 13 Aug 2008 20:24:10 +0000 Subject: [PATCH] Allow multiple libraries Rename load_library to add_library, traverse over 2008-08-13 Johan Dahlin * 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 svn path=/trunk/; revision=356 --- ChangeLog | 8 ++++++++ giscanner/glibtransformer.py | 18 +++++++++++------- tools/g-ir-scanner | 9 +++++---- 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index be93fb1..a6502cb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2008-08-13 Johan Dahlin + + * 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 + 2008-08-12 Colin Walters * giscanner/transformer.py: Record typedefs as elements. diff --git a/giscanner/glibtransformer.py b/giscanner/glibtransformer.py index ceb9890..00c689b 100644 --- a/giscanner/glibtransformer.py +++ b/giscanner/glibtransformer.py @@ -38,15 +38,15 @@ class GLibTransformer(object): 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 @@ class GLibTransformer(object): 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 @@ class GLibTransformer(object): 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 diff --git a/tools/g-ir-scanner b/tools/g-ir-scanner index e1ffa2b..4bce433 100755 --- a/tools/g-ir-scanner +++ b/tools/g-ir-scanner @@ -49,8 +49,8 @@ def _get_option_parser(): 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 @@ def main(args): # 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() -- 2.7.4