[ctypes-commit] ctypes/sandbox/tools/codegen xml2py.py,1.6,1.7
Brought to you by:
theller
From: Thomas H. <th...@us...> - 2005-01-07 16:08:18
|
Update of /cvsroot/ctypes/ctypes/sandbox/tools/codegen In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6511 Modified Files: xml2py.py Log Message: Make the --dll and --windows-dlls options work. Add a -m option which allows to specify Python modules containing symbols that will be imported instead of generated. Current defaults are ctypes and comtypes or ctypes.com. Index: xml2py.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/sandbox/tools/codegen/xml2py.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** xml2py.py 7 Jan 2005 15:34:32 -0000 1.6 --- xml2py.py 7 Jan 2005 16:08:09 -0000 1.7 *************** *** 6,9 **** --- 6,40 ---- ################################################################ + windows_dll_names = """\ + imagehlp + user32 + kernel32 + gdi32 + advapi32 + oleaut32 + ole32 + imm32 + comdlg32 + shell32 + version + winmm + mpr + winscard + winspool.drv + urlmon + crypt32 + cryptnet + ws2_32 + opengl32 + glu32 + mswsock + msvcrt + msimg32 + netapi32 + rpcrt4""".split() + ##glut32 + + ##rpcndr + ##ntdll def main(args=None): *************** *** 12,16 **** def windows_dlls(option, opt, value, parser): ! parser.values.dlls.extend("kernel32 gdi32 user32".split()) parser = OptionParser("usage: %prog [options] xmlfile") --- 43,47 ---- def windows_dlls(option, opt, value, parser): ! parser.values.dlls.extend(windows_dll_names) parser = OptionParser("usage: %prog [options] xmlfile") *************** *** 18,26 **** action="callback", callback=windows_dlls, ! help="add all standard windows dlls") parser.add_option("--dll", dest="dlls", action="append", default=[]) parser.add_option("-s", dest="symbols", --- 49,60 ---- action="callback", callback=windows_dlls, ! help="add all standard windows dlls to the searched dlls list") ! parser.add_option("--dll", dest="dlls", + help="dlls to search for exported functions", action="append", default=[]) + parser.add_option("-s", dest="symbols", *************** *** 30,33 **** --- 64,68 ---- "(if neither symbols nor expressions are specified, everything will be included)", default=None) + parser.add_option("-r", dest="expressions", *************** *** 37,40 **** --- 72,76 ---- "(if neither symbols nor expressions are specified, everything will be included)", default=None) + parser.add_option("-o", dest="output", *************** *** 54,57 **** --- 90,107 ---- default=False) + try: + import comtypes + except ImportError: + default_modules = ["ctypes", "ctypes.com"] + else: + default_modules = ["ctypes", "comtypes"] + + parser.add_option("-m", + dest="modules", + metavar="module", + help="Python module(s) containing symbols which will be imported instead of generated", + action="append", + default=default_modules) + options, files = parser.parse_args(args[1:]) *************** *** 70,75 **** stream.write("# flags '%s'\n" % " ".join(sys.argv[1:])) ! import ctypes ! known_symbols = ctypes.__dict__ generate_code(files[0], stream, --- 120,133 ---- stream.write("# flags '%s'\n" % " ".join(sys.argv[1:])) ! known_symbols = {} ! ! from ctypes import CDLL ! dlls = [CDLL(name) for name in options.dlls] ! ! for name in options.modules: ! mod = __import__(name) ! for submodule in name.split(".")[1:]: ! mod = getattr(mod, submodule) ! known_symbols.update(mod.__dict__) generate_code(files[0], stream, *************** *** 78,82 **** verbose=options.verbose, use_decorators=options.use_decorators, ! known_symbols=known_symbols) --- 136,141 ---- verbose=options.verbose, use_decorators=options.use_decorators, ! known_symbols=known_symbols, ! searched_dlls=dlls) |