[ctypes-commit] ctypes/sandbox/tools inc2py.py,1.6,1.7
Brought to you by:
theller
|
From: Thomas H. <th...@us...> - 2004-09-03 16:47:58
|
Update of /cvsroot/ctypes/ctypes/sandbox/tools In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20897 Modified Files: inc2py.py Log Message: Add some more ignore patterns, and be more careful when comiling them: remove all surrounding whitespace. Allow an environment passed to the IncludeParser. Add a -h command line flag. Index: inc2py.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/sandbox/tools/inc2py.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** inc2py.py 3 Sep 2004 14:38:12 -0000 1.6 --- inc2py.py 3 Sep 2004 16:47:48 -0000 1.7 *************** *** 68,71 **** --- 68,74 ---- not parse. + -h + Display help, and quit. + For a start (on windows), try this: *************** *** 84,89 **** # patterns to replace by a single blank (platform specific) if sys.platform == "win32": - # ignore type casts. Sounds strange, but works. ignores = r""" \(\s*HRESULT\s*\) --- 87,93 ---- # patterns to replace by a single blank (platform specific) + # ignore type casts. Sounds strange, but works. + if sys.platform == "win32": ignores = r""" \(\s*HRESULT\s*\) *************** *** 106,114 **** --- 110,122 ---- \(\s*HANDLE\s*\) \(\s*HWND\s*\) + \(\s*HKEY\s*\) \(\s*HCURSOR\s*\) + \(\s*HBITMAP\s*\) \(\s*HICON\s*\) \(\s*HDDEDATA\s*\) + \(\s*NTSTATUS\s*\) \(\s*int\s*\) \(\s*u_long\s*\) + \(\s*ULONG_PTR\s*\) \(\s*unsigned\s*long\s*\) """ *************** *** 116,120 **** ignores = [] ! ignores = map(re.compile, ignores.strip().splitlines()) # a sequence of pattern / replacement pairs for macro bodies, --- 124,128 ---- ignores = [] ! ignores = [re.compile(p.strip()) for p in ignores.strip().splitlines()] # a sequence of pattern / replacement pairs for macro bodies, *************** *** 204,209 **** class IncludeParser(object): ! def __init__(self, cpp_options=(), verbose=0): ! self._env = {} self._statements = [] self._errlines = [] --- 212,220 ---- class IncludeParser(object): ! def __init__(self, cpp_options=(), verbose=0, env=None): ! if env is None: ! self._env = {} ! else: ! self._env = env self._statements = [] self._errlines = [] *************** *** 331,338 **** raw = 0 try: ! opts, files = getopt.getopt(args, "rvc:D:U:I:o:", ["compiler="]) ! if not files: ! raise ValueError ! except (getopt.GetoptError, ValueError): print >> sys.stderr, __doc__ return 1 --- 342,348 ---- raw = 0 try: ! opts, files = getopt.getopt(args, "hrvc:D:U:I:o:", ["compiler="]) ! except (getopt.GetoptError, ValueError), details: ! print "Error:", details print >> sys.stderr, __doc__ return 1 *************** *** 348,352 **** --- 358,370 ---- elif o == "-r": raw = 1 + elif o == "-h": + print >> sys.stderr, __doc__ + return 0 + if not files: + print "Error: no files to process" + print >> sys.stderr, __doc__ + return 1 + parser = IncludeParser(gccxml_options, verbose=verbose) parser.parse(*files) |