diff options
author | Colin Walters <walters@verbum.org> | 2010-09-01 12:55:26 -0400 |
---|---|---|
committer | Colin Walters <walters@verbum.org> | 2010-09-01 12:55:26 -0400 |
commit | 7347095854b8bf5a13a1ba6986a7cdbf508a0776 (patch) | |
tree | 1edd55cb5a0cbc3655ff56fd5cb0052db9599094 /giscanner/transformer.py | |
parent | c8e227432c5072ab858f8acd93b24ffc26ed1c68 (diff) | |
download | gobject-introspection-7347095854b8bf5a13a1ba6986a7cdbf508a0776.tar.gz |
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.
Diffstat (limited to 'giscanner/transformer.py')
-rw-r--r-- | giscanner/transformer.py | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/giscanner/transformer.py b/giscanner/transformer.py index 5d4c299f..a851f791 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('_') |