[ctypes-commit] ctypes/sandbox/tools/codegen xml2py.py,1.9,1.10
Brought to you by:
theller
From: Thomas H. <th...@us...> - 2005-01-18 11:08:21
|
Update of /cvsroot/ctypes/ctypes/sandbox/tools/codegen In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2703 Modified Files: xml2py.py Log Message: Add command line option '-k' to allow filtering the output for certain types. Changed the order of command line options so that they are printed alphabetically with the --help flag. Index: xml2py.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/sandbox/tools/codegen/xml2py.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** xml2py.py 17 Jan 2005 14:10:15 -0000 1.9 --- xml2py.py 18 Jan 2005 11:08:05 -0000 1.10 *************** *** 2,5 **** --- 2,6 ---- from optparse import OptionParser from codegenerator import generate_code + import typedesc ################################################################ *************** *** 43,50 **** parser = OptionParser("usage: %prog [options] xmlfile") ! parser.add_option("-w", ! action="callback", ! callback=windows_dlls, ! help="add all standard windows dlls to the searched dlls list") parser.add_option("-l", --- 44,64 ---- parser = OptionParser("usage: %prog [options] xmlfile") ! parser.add_option("-d", ! action="store_true", ! dest="use_decorators", ! help="use Python 2.4 function decorators", ! default=False) ! ! parser.add_option("-k", ! action="store", ! dest="kind", ! help="kind of type descriptions to include: " ! "d = #defines, " ! "e = enumerations, " ! "f = functions, " ! "s = structures, " ! "t = typedefs", ! metavar="TYPEKIND", ! default=None) parser.add_option("-l", *************** *** 54,64 **** default=[]) ! parser.add_option("-s", ! dest="symbols", ! metavar="SYMBOL", ! action="append", ! help="symbol to include " ! "(if neither symbols nor expressions are specified, everything will be included)", ! default=None) parser.add_option("-r", --- 68,75 ---- default=[]) ! parser.add_option("-o", ! dest="output", ! help="output filename (if not specified, standard output will be used)", ! default="-") parser.add_option("-r", *************** *** 66,77 **** metavar="EXPRESSION", action="append", ! help="regular expression for symbol to include " ! "(if neither symbols nor expressions are specified, everything will be included)", default=None) ! parser.add_option("-o", ! dest="output", ! help="output filename (if not specified, standard output will be used)", ! default="-") parser.add_option("-v", --- 77,93 ---- metavar="EXPRESSION", action="append", ! help="regular expression for symbols to include " ! "(if neither symbols nor expressions are specified," ! "everything will be included)", default=None) ! parser.add_option("-s", ! dest="symbols", ! metavar="SYMBOL", ! action="append", ! help="symbol to include " ! "(if neither symbols nor expressions are specified," ! "everything will be included)", ! default=None) parser.add_option("-v", *************** *** 81,89 **** default=False) ! parser.add_option("-d", ! action="store_true", ! dest="use_decorators", ! help="use Python 2.4 function decorators", ! default=False) ## try: --- 97,104 ---- default=False) ! parser.add_option("-w", ! action="callback", ! callback=windows_dlls, ! help="add all standard windows dlls to the searched dlls list") ## try: *************** *** 98,102 **** dest="modules", metavar="module", ! help="Python module(s) containing symbols which will be imported instead of generated", action="append", default=default_modules) --- 113,118 ---- dest="modules", metavar="module", ! help="Python module(s) containing symbols which will " ! "be imported instead of generated", action="append", default=default_modules) *************** *** 129,132 **** --- 145,160 ---- known_symbols.update(mod.__dict__) + if options.kind: + types = [] + for char in options.kind: + typ = {"d": [typedesc.Variable], + "e": [typedesc.Enumeration, typedesc.EnumValue], + "f": [typedesc.FunctionType], + "s": [typedesc.Structure], + "t": [typedesc.Typedef], + }[char] + types.extend(typ) + options.kind = tuple(types) + generate_code(files[0], stream, symbols=options.symbols, *************** *** 135,139 **** use_decorators=options.use_decorators, known_symbols=known_symbols, ! searched_dlls=dlls) --- 163,168 ---- use_decorators=options.use_decorators, known_symbols=known_symbols, ! searched_dlls=dlls, ! types=options.kind) |