diff options
author | Jinkun Jang <jinkun.jang@samsung.com> | 2013-03-13 02:21:24 +0900 |
---|---|---|
committer | Jinkun Jang <jinkun.jang@samsung.com> | 2013-03-13 02:21:24 +0900 |
commit | c6b9e84f2f7f8c85939a8e5ff5d8a5aa067cecf3 (patch) | |
tree | 1436172370a45714687122f914354ad167a2f528 /codegen/scanvirtuals.py | |
parent | f7d643cbb2184346b6f8d26091eb7eb38c6bbfe1 (diff) | |
download | pygobject2-c6b9e84f2f7f8c85939a8e5ff5d8a5aa067cecf3.tar.gz pygobject2-c6b9e84f2f7f8c85939a8e5ff5d8a5aa067cecf3.tar.bz2 pygobject2-c6b9e84f2f7f8c85939a8e5ff5d8a5aa067cecf3.zip |
Tizen 2.1 basesubmit/tizen_2.1/20130425.060530submit/tizen_2.1/20130424.235900submit/tizen/20130517.051955accepted/tizen_2.1/20130425.021253accepted/tizen/20130520.1018302.1b_releasetizen_2.1
Diffstat (limited to 'codegen/scanvirtuals.py')
-rwxr-xr-x | codegen/scanvirtuals.py | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/codegen/scanvirtuals.py b/codegen/scanvirtuals.py new file mode 100755 index 0000000..c108737 --- /dev/null +++ b/codegen/scanvirtuals.py @@ -0,0 +1,54 @@ +#!/usr/bin/env python +import re +import sys + + +def main(): + rx = re.compile(r'^\s*([\w\s\*]+)\(\s*\*\s*(\w+)\s*\)\s*\(([^()]*)\);', + re.DOTALL|re.MULTILINE) + for f in sys.argv[1:]: + #print ";; From", f + buf = file(f).read() + for m in rx.findall(buf): + return_type = m[0].strip() + if 'typedef' in return_type: + continue + if return_type == 'void': + return_type = 'none' + return_type = return_type.replace(' ', '') + virtual_name = m[1] + if 'reserved' in virtual_name: + continue + params = [] + if not m[2]: + print >> sys.stderr, repr(m) + continue + for param in map(str.strip, m[2].split(',')): + if '*' in param: + tokens = param.split('*') + ptype = tokens[0].strip() + '*'*(len(tokens) - 1) + pname = tokens[-1].strip() + else: + if param == 'void': + continue + ptype, pname = map(str.strip, param.split()) + ptype = ptype.replace('const ', 'const-') + while '[]' in pname: + pname = pname.replace('[]', '') + ptype += '[]' + params.append((ptype, pname)) + if not params: + continue + objname = params[0][0].replace('*', '') + print '(define-virtual', virtual_name + print ' (of-object "%s")' % objname + print ' (return-type "%s")' % return_type + if len(params) > 1: + print ' (parameters' + for param in params[1:]: + print ' \'("%s" "%s")' % param + print ' )' + print ')' + +if __name__ == '__main__': + main() |