put consts into python submodules

maintain set of visited namespaces in CppHeaderParser
WARNING: REMOVED const name conversion (SomeConstName -> SOME_CONST_NAME), discussion needed
This commit is contained in:
Alexander Mordvintsev
2014-08-19 13:35:46 +04:00
parent 6d1c02ffed
commit e74cddfbd1
4 changed files with 57 additions and 38 deletions

View File

@@ -38,6 +38,8 @@ class CppHeaderParser(object):
self.PUBLIC_SECTION = 3
self.CLASS_DECL = 4
self.namespaces = set()
def batch_replace(self, s, pairs):
for before, after in pairs:
s = s.replace(before, after)
@@ -833,6 +835,9 @@ class CppHeaderParser(object):
decls.append(d)
else:
decls.append(decl)
if stmt_type == "namespace":
chunks = [block[1] for block in self.block_stack if block[0] == 'namespace'] + [name]
self.namespaces.add('.'.join(chunks))
else:
stmt_type, name, parse_flag = "block", "", False
@@ -877,3 +882,5 @@ if __name__ == '__main__':
#decls += parser.parse(hname, wmode=False)
parser.print_decls(decls)
print(len(decls))
print("namespaces:", " ".join(sorted(parser.namespaces)))