X-Git-Url: http://git.roojs.org/?a=blobdiff_plain;f=giscanner%2Ftransformer.py;h=6179c2b6ed787888650a7a1ba71492665a2b64f5;hb=6e3aa7e84388fa446f82996a7c589dd214cca191;hp=87be006c2767b388cc3bc8d61134395322ad202c;hpb=d57ebd09b238666007986b7afdf589743319c412;p=gnome.gobject-introspection diff --git a/giscanner/transformer.py b/giscanner/transformer.py index 87be006..6179c2b 100644 --- a/giscanner/transformer.py +++ b/giscanner/transformer.py @@ -83,6 +83,9 @@ class Transformer(object): def get_includes(self): return self._includes + def set_strip_suffix(self, strip_suffix): + self._strip_suffix = strip_suffix + def set_strip_prefix(self, strip_prefix): self._strip_prefix = strip_prefix @@ -181,14 +184,23 @@ class Transformer(object): # when --strip-prefix=g: # GHashTable -> HashTable # g_hash_table_new -> hash_table_new + stripped = False prefix = self._strip_prefix.lower() - if isfunction: + + if isfunction and '_' in name: prefix += '_' if len(name) > len(prefix) and name.lower().startswith(prefix): name = name[len(prefix):] + stripped = True while name.startswith('_'): name = name[1:] + + if (stripped and self._strip_suffix and + len(name) > len(self._strip_suffix) and + name.endswith(self._strip_suffix) + name = name[:-1*len(self._strip_suffix)] + return name def _traverse_one(self, symbol, stype=None):