projects
/
gnome.gobject-introspection
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
[STRIP_SUFFIX] ability to flag suffixes to be stripped.
[gnome.gobject-introspection]
/
giscanner
/
transformer.py
diff --git
a/giscanner/transformer.py
b/giscanner/transformer.py
index
87be006
..
6179c2b
100644
(file)
--- a/
giscanner/transformer.py
+++ b/
giscanner/transformer.py
@@
-83,6
+83,9
@@
class Transformer(object):
def get_includes(self):
return self._includes
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
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
# when --strip-prefix=g:
# GHashTable -> HashTable
# g_hash_table_new -> hash_table_new
+ stripped = False
prefix = self._strip_prefix.lower()
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):]
prefix += '_'
if len(name) > len(prefix) and name.lower().startswith(prefix):
name = name[len(prefix):]
+ stripped = True
while name.startswith('_'):
name = name[1:]
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):
return name
def _traverse_one(self, symbol, stype=None):