diff options
author | Frederic Peters <fpeters@entrouvert.com> | 2008-04-29 12:00:40 +0000 |
---|---|---|
committer | Frederic Peters <fpeters@entrouvert.com> | 2008-04-29 12:00:40 +0000 |
commit | 9d9956b25bf2c4e8463de4d502dd1e103b68f017 (patch) | |
tree | 7e13dfd23e7453c91c9ac24caa00325757d5a119 /bindings | |
parent | e696b80c7aa9401bee2aa3163d1a836e367e9309 (diff) | |
download | lasso-9d9956b25bf2c4e8463de4d502dd1e103b68f017.tar.gz lasso-9d9956b25bf2c4e8463de4d502dd1e103b68f017.tar.xz lasso-9d9956b25bf2c4e8463de4d502dd1e103b68f017.zip |
[project @ fpeters@0d.be-20071004185258-quqzvq2tgmbt8u1j]
initial work, extracting constants out of source tree
Original author: Frederic Peters <fpeters@0d.be>
Date: 2007-10-04 20:52:58.486000+02:00
Diffstat (limited to 'bindings')
-rw-r--r-- | bindings/t.py | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/bindings/t.py b/bindings/t.py new file mode 100644 index 00000000..3ba0235f --- /dev/null +++ b/bindings/t.py @@ -0,0 +1,49 @@ +#! /usr/bin/env python + +import os +import re + +constants = [] + +def parse(header_file): + in_comment = False + + content = file(header_file).read().replace('\\\n', ' ') + for line in content.splitlines(): + if in_comment: + if '*/' in line: + in_comment = False + continue + + if '/*' in line and not '*/' in line: + continue + + if line.startswith('#define'): + m = re.match(r'#define\s+([a-zA-Z0-9_]+)\s+[-\w"]', line) + if not m: + continue + constant = m.group(1) + if constant[0] == '_': + # ignore private constants + continue + constants.append(constant) + + +for base, dirnames, filenames in os.walk('../lasso/'): + if base.endswith('/.svn'): + # ignore svn directories + continue + if not 'Makefile.am' in filenames: + # not a source dir + continue + makefile_am = open(os.path.join(base, 'Makefile.am')).read() + filenames = [x for x in filenames if x.endswith('.h') if x in makefile_am] + for filename in filenames: + if filename == 'lasso_config.h': + continue + parse(os.path.join(base, filename)) + + +import pprint +pprint.pprint(constants) + |