summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorMarcin Kolny <marcin.kolny@gmail.com>2014-09-13 22:15:43 +0200
committerMarcin Kolny <marcin.kolny@gmail.com>2014-09-16 00:15:30 +0200
commitf2fc8b7490d549cde73d3d33ecbed9ceba64c968 (patch)
tree583118e635af7cab0313af878297b56dd12e3bf2 /tools
parente49299e014a3e405fa3f80c1ee3195172db36fc1 (diff)
downloadglibmm-f2fc8b7490d549cde73d3d33ecbed9ceba64c968.tar.gz
h2def.py: fixed generator in case of inline functions (bgo#736427)
* tools/gen_scripts/h2def.py: removing inline methods body, removing 'static' and 'inline' keywords in function declaration, avoiding double entries of the same method in generated *.def file by storing method's names in a Set collection.
Diffstat (limited to 'tools')
-rwxr-xr-xtools/defs_gen/h2def.py37
1 files changed, 37 insertions, 0 deletions
diff --git a/tools/defs_gen/h2def.py b/tools/defs_gen/h2def.py
index 82651fe8..d0cd5a24 100755
--- a/tools/defs_gen/h2def.py
+++ b/tools/defs_gen/h2def.py
@@ -73,6 +73,8 @@ import sys
import defsparser
+from sets import Set
+
# ------------------ Create typecodes from typenames ---------
_upperstr_pat1 = re.compile(r'([^A-Z])([A-Z])')
@@ -353,6 +355,34 @@ def clean_func(buf):
pat = re.compile(r"""GSEAL""", re.VERBOSE)
buf = pat.sub('', buf)
+ # remove inline method's body
+ pos = 0
+ start = 0
+ bracket_cnt = 0
+ brackets = re.compile("{|}")
+ while (True):
+ match = brackets.search(buf, pos)
+ if (match == None):
+ break;
+ pos = match.start() + 1
+ if (match.group() == "{"):
+ if (bracket_cnt == 0):
+ start = match.start()
+ bracket_cnt += 1
+ else:
+ if (bracket_cnt == 0):
+ continue
+ if (bracket_cnt == 1):
+ buf = buf.replace(buf[start:match.start()+1], "\n")
+ pos = start
+ bracket_cnt -= 1
+ buf = re.sub("^\s+", "", buf, flags=re.MULTILINE)
+
+ # remove static and inline keywords
+ buf = re.sub('^\s*static\s+', '', buf, flags = re.MULTILINE)
+ buf = re.sub('^\s*inline\s+', '', buf, flags = re.MULTILINE)
+ buf = re.sub('^\s*static\s+', '', buf, flags = re.MULTILINE) # in case of "inline static" function declaration
+
return buf
proto_pat=re.compile(r"""
@@ -477,6 +507,7 @@ class DefsWriter:
def _define_func(self, buf):
buf = clean_func(buf)
buf = buf.split('\n')
+ all_functions = Set()
filter = self._functions
for p in buf:
if not p:
@@ -492,6 +523,12 @@ class DefsWriter:
if filter:
if func in filter:
continue
+
+ if (func in all_functions):
+ continue
+
+ all_functions.add(func)
+
ret = m.group('ret')
args = m.group('args')
args = arg_split_pat.split(args)