[gobject-introspection] scanner: Cosmetic cleanup to namespace parsing functions



commit 7347095854b8bf5a13a1ba6986a7cdbf508a0776
Author: Colin Walters <walters verbum org>
Date:   Wed Sep 1 12:55:26 2010 -0400

    scanner: Cosmetic cleanup to namespace parsing functions
    
    For symmetry with split_ctype_namespaces, have add split_csymbol_namespaces
    too, and simplify the implementation of split_csymbol.

 giscanner/transformer.py |   14 +++++++++-----
 1 files changed, 9 insertions(+), 5 deletions(-)
---
diff --git a/giscanner/transformer.py b/giscanner/transformer.py
index 5d4c299..a851f79 100644
--- a/giscanner/transformer.py
+++ b/giscanner/transformer.py
@@ -315,13 +315,17 @@ or raise ValueError.  As a special case, if the current namespace matches,
 it is always biggest (i.e. last)."""
         return self._split_c_string_for_namespace_matches(ident, is_identifier=True)
 
+    def split_csymbol_namespaces(self, symbol):
+        """Given a C symbol like foo_bar_do_baz, return a list of
+(namespace, stripped_symbol) sorted by namespace match probablity, or
+raise ValueError."""
+        return self._split_c_string_for_namespace_matches(symbol, is_identifier=False)
+
     def split_csymbol(self, symbol):
-        """Given a C symbol like foo_bar_do_baz, return a pair of
-(namespace, stripped_symbol) or raise ValueError."""
+        """Given a C symbol like foo_bar_do_baz, return the most probable
+(namespace, stripped_symbol) match, or raise ValueError."""
         matches = self._split_c_string_for_namespace_matches(symbol, is_identifier=False)
-        if matches:
-            return (matches[-1][0], matches[-1][1])
-        raise ValueError("Unknown namespace for symbol %r" % (symbol, ))
+        return matches[-1]
 
     def strip_identifier_or_warn(self, ident, fatal=False):
         hidden = ident.startswith('_')



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