gobject-introspection r443 - in trunk: . giscanner
- From: walters svn gnome org
- To: svn-commits-list gnome org
- Subject: gobject-introspection r443 - in trunk: . giscanner
- Date: Thu, 21 Aug 2008 18:03:21 +0000 (UTC)
Author: walters
Date: Thu Aug 21 18:03:21 2008
New Revision: 443
URL: http://svn.gnome.org/viewvc/gobject-introspection?rev=443&view=rev
Log:
2008-08-21 Colin Walters <walters verbum org>
* giscanner/glibtransformer.py: Much simpler approach
of mapping uscored names to classes.
* giscanner/utils.py: Remove unnecessary function.
Modified:
trunk/ChangeLog
trunk/giscanner/glibtransformer.py
trunk/giscanner/utils.py
Modified: trunk/giscanner/glibtransformer.py
==============================================================================
--- trunk/giscanner/glibtransformer.py (original)
+++ trunk/giscanner/glibtransformer.py Thu Aug 21 18:03:21 2008
@@ -28,7 +28,7 @@
from .transformer import Names
from .glibast import (GLibBoxed, GLibEnum, GLibEnumMember, GLibFlags,
GLibInterface, GLibObject, GLibSignal, type_names)
-from .utils import extract_libtool, to_underscores, to_pascal_combinations
+from .utils import extract_libtool, to_underscores
class Unresolved(object):
@@ -47,6 +47,7 @@
self._transformer = transformer
self._namespace_name = None
self._names = Names()
+ self._uscore_type_names = {}
self._libraries = []
self._failed_types = {}
self._noclosure = noclosure
@@ -113,6 +114,7 @@
def _register_internal_type(self, type_name, node):
self._names.type_names[type_name] = (None, node)
+ self._uscore_type_names[to_underscores(type_name).lower()] = node
# Helper functions
@@ -243,27 +245,16 @@
target_arg = func.parameters[0]
target_arg.type = self._resolve_param_type(target_arg.type)
- # We look at all possible permutations of the symbol prefixes
- # in Pascal case permutations. For example, let's say we
- # see gtk_frob_bar_new. We look for classes named:
- # Frob, FROB, FrobBar, FROBBar, FrobBAR, FROBBAR,
- # FrobBarNew, FrobBarNEW, FrobBARNew, ...
+ klass = None
symbol_components = func.symbol.split('_')
- for i in range(len(symbol_components)):
- subset = symbol_components[:i]
- subsymbol = '_'.join(subset)
+ for key in self._uscore_type_names:
klass = None
- possible_classnames = to_pascal_combinations(subsymbol)
- for possible_classname in possible_classnames:
- strip = self._transformer.strip_namespace_object
- possible_classname = strip(possible_classname)
- klass = self._get_attribute(possible_classname)
+ if func.symbol.startswith(key):
+ klass = self._uscore_type_names.get(key)
if (klass is not None and
isinstance(klass, (GLibObject, GLibBoxed,
GLibInterface))):
break
- if klass is not None:
- break
if klass is None:
return
Modified: trunk/giscanner/utils.py
==============================================================================
--- trunk/giscanner/utils.py (original)
+++ trunk/giscanner/utils.py Thu Aug 21 18:03:21 2008
@@ -37,23 +37,6 @@
return name
-def _gen_pascal_combinations(nameset):
- firstname = [nameset[0].title(), nameset[0].upper()]
- if len(nameset) == 1:
- return firstname
- else:
- subset = _gen_pascal_combinations(nameset[1:])
- results = []
- for x in subset:
- results.append(firstname[0] + x)
- results.append(firstname[1] + x)
- return results
-
-
-def to_pascal_combinations(name):
- return _gen_pascal_combinations(name.split('_'))
-
-
_libtool_pat = re.compile("dlname='([A-z0-9\.\-\+]+)'\n")
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]