ctypes-commit Mailing List for ctypes (Page 76)
Brought to you by:
theller
You can subscribe to this list here.
2004 |
Jan
|
Feb
|
Mar
|
Apr
(8) |
May
(90) |
Jun
(143) |
Jul
(106) |
Aug
(94) |
Sep
(84) |
Oct
(163) |
Nov
(60) |
Dec
(58) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2005 |
Jan
(128) |
Feb
(79) |
Mar
(227) |
Apr
(192) |
May
(179) |
Jun
(41) |
Jul
(53) |
Aug
(103) |
Sep
(28) |
Oct
(38) |
Nov
(81) |
Dec
(17) |
2006 |
Jan
(184) |
Feb
(111) |
Mar
(188) |
Apr
(67) |
May
(58) |
Jun
(123) |
Jul
(73) |
Aug
|
Sep
|
Oct
(1) |
Nov
|
Dec
|
From: Thomas H. <th...@us...> - 2005-01-24 12:48:22
|
Update of /cvsroot/ctypes/ctypes/sandbox/tools/codegen In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15404 Modified Files: codegenerator.py Log Message: Import _com_interface and STDMETHOD from comtypes, and don't assert sizeof and alignment on com interfaces. Index: codegenerator.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/sandbox/tools/codegen/codegenerator.py,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** codegenerator.py 24 Jan 2005 12:12:18 -0000 1.33 --- codegenerator.py 24 Jan 2005 12:48:08 -0000 1.34 *************** *** 274,277 **** --- 274,278 ---- methods = [m for m in head.struct.members if type(m) is typedesc.Method] if methods: + self.need_cominterface() print >> self.stream, "class %s(_com_interface):" % head.struct.name elif type(head.struct) == typedesc.Structure: *************** *** 459,462 **** --- 460,474 ---- print >> self.stream, " ('%s', %s, %s)," % (fieldname, self.type_name(f.typ), f.bits) print >> self.stream, "]" + # generate assert statements for size and alignment + if body.struct.size and body.struct.name not in dont_assert_size: + size = body.struct.size // 8 + self.need_sizeof() + print >> self.stream, "assert sizeof(%s) == %s, sizeof(%s)" % \ + (body.struct.name, size, body.struct.name) + align = body.struct.align // 8 + self.need_alignment() + print >> self.stream, "assert alignment(%s) == %s, alignment(%s)" % \ + (body.struct.name, align, body.struct.name) + if methods: # method definitions normally span several lines. *************** *** 467,470 **** --- 479,483 ---- for a in m.arguments: self.type_name(a) + self.need_STDMETHOD() print >> self.stream, "%s._methods_ = [" % body.struct.name if body.struct.location: *************** *** 477,489 **** ", ".join(args)) print >> self.stream, "]" ! if body.struct.size and body.struct.name not in dont_assert_size: ! size = body.struct.size // 8 ! self.need_sizeof() ! print >> self.stream, "assert sizeof(%s) == %s, sizeof(%s)" % \ ! (body.struct.name, size, body.struct.name) ! align = body.struct.align // 8 ! self.need_alignment() ! print >> self.stream, "assert alignment(%s) == %s, alignment(%s)" % \ ! (body.struct.name, align, body.struct.name) self.done.add(body) --- 490,494 ---- ", ".join(args)) print >> self.stream, "]" ! self.done.add(body) *************** *** 520,523 **** --- 525,542 ---- return name + _cominterface_defined = False + def need_cominterface(self): + if self._cominterface_defined: + return + print >> self.stream, "from comtypes import _com_interface" + self._cominterface_defined = True + + _STDMETHOD_defined = False + def need_STDMETHOD(self): + if self._STDMETHOD_defined: + return + print >> self.stream, "from comtypes import STDMETHOD" + self._STDMETHOD_defined = True + _stdcall_defined = False def need_stdcall(self): |
From: Thomas H. <th...@us...> - 2005-01-24 12:16:19
|
Update of /cvsroot/ctypes/ctypes/sandbox/tools/codegen In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6543 Modified Files: gccxmlparser.py Log Message: Remove todo's that are done. Index: gccxmlparser.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/sandbox/tools/codegen/gccxmlparser.py,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** gccxmlparser.py 24 Jan 2005 12:13:24 -0000 1.19 --- gccxmlparser.py 24 Jan 2005 12:16:07 -0000 1.20 *************** *** 373,379 **** result.append(i) - - # todo: get cpp_data, and convert it into typedesc nodes. - return result --- 373,376 ---- |
From: Thomas H. <th...@us...> - 2005-01-24 12:14:35
|
Update of /cvsroot/ctypes/ctypes/sandbox/tools/codegen In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6133 Modified Files: typedesc.py Log Message: Add default location parameter. Index: typedesc.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/sandbox/tools/codegen/typedesc.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** typedesc.py 21 Jan 2005 16:35:17 -0000 1.8 --- typedesc.py 24 Jan 2005 12:14:25 -0000 1.9 *************** *** 33,36 **** --- 33,37 ---- class Function(_HasArgs): + location = None def __init__(self, name, returns, attributes, extern): self.name = name *************** *** 41,44 **** --- 42,46 ---- class Constructor(_HasArgs): + location = None def __init__(self, name): self.name = name *************** *** 46,49 **** --- 48,52 ---- class OperatorFunction(_HasArgs): + location = None def __init__(self, name, returns): self.name = name *************** *** 52,55 **** --- 55,59 ---- class FunctionType(_HasArgs): + location = None def __init__(self, returns, attributes): self.returns = returns *************** *** 58,61 **** --- 62,66 ---- class Method(_HasArgs): + location = None def __init__(self, name, returns): self.name = name *************** *** 64,67 **** --- 69,73 ---- class FundamentalType(object): + location = None def __init__(self, name, size, align): self.name = name *************** *** 71,74 **** --- 77,81 ---- class PointerType(object): + location = None def __init__(self, typ, size, align): self.typ = typ *************** *** 77,80 **** --- 84,88 ---- class Typedef(object): + location = None def __init__(self, name, typ): self.name = name *************** *** 82,85 **** --- 90,94 ---- class ArrayType(object): + location = None def __init__(self, typ, min, max): self.typ = typ *************** *** 88,99 **** --- 97,111 ---- class StructureHead(object): + location = None def __init__(self, struct): self.struct = struct class StructureBody(object): + location = None def __init__(self, struct): self.struct = struct class _Struct_Union_Base(object): + location = None def get_body(self): return self.struct_body *************** *** 144,147 **** --- 156,160 ---- class Enumeration(object): + location = None def __init__(self, name, size, align): self.name = name *************** *** 160,163 **** --- 173,177 ---- class Variable(object): + location = None def __init__(self, name, typ, init=None): self.name = name |
From: Thomas H. <th...@us...> - 2005-01-24 12:13:33
|
Update of /cvsroot/ctypes/ctypes/sandbox/tools/codegen In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5861 Modified Files: gccxmlparser.py Log Message: Move the code to convert pathnames from long to short (on windows) out of the fixup method - that's too late. Index: gccxmlparser.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/sandbox/tools/codegen/gccxmlparser.py,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** gccxmlparser.py 21 Jan 2005 20:11:53 -0000 1.18 --- gccxmlparser.py 24 Jan 2005 12:13:24 -0000 1.19 *************** *** 96,108 **** def File(self, attrs): name = attrs["name"] return typedesc.File(name) ! def _fixup_File(self, f): ! if sys.platform == "win32" and " " in f.name: ! # On windows, convert to short filename if it contains blanks ! from ctypes import windll, create_unicode_buffer, sizeof ! buf = create_unicode_buffer(256) ! if windll.kernel32.GetShortPathNameW(f.name, buf, sizeof(buf)): ! f.name = buf.value # simple types and modifiers --- 96,108 ---- def File(self, attrs): name = attrs["name"] + if sys.platform == "win32" and " " in name: + # On windows, convert to short filename if it contains blanks + from ctypes import windll, create_unicode_buffer, sizeof, WinError + buf = create_unicode_buffer(512) + if windll.kernel32.GetShortPathNameW(name, buf, sizeof(buf)): + name = buf.value return typedesc.File(name) ! def _fixup_File(self, f): pass # simple types and modifiers *************** *** 343,346 **** --- 343,350 ---- remove = [] for n, i in self.all.items(): + location = getattr(i, "location", None) + if location: + fil, line = location.split(":") + i.location = self.all[fil].name, line # link together all the nodes (the XML that gccxml generates uses this). mth = getattr(self, "_fixup_" + type(i).__name__) *************** *** 349,357 **** except KeyError: # XXX better exception catching remove.append(n) - else: - location = getattr(i, "location", None) - if location: - fil, line = location.split(":") - i.location = self.all[fil].name, line for n in remove: --- 353,356 ---- |
From: Thomas H. <th...@us...> - 2005-01-24 12:12:27
|
Update of /cvsroot/ctypes/ctypes/sandbox/tools/codegen In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5557 Modified Files: codegenerator.py Log Message: Generate valid code for COM methods import stuff. Index: codegenerator.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/sandbox/tools/codegen/codegenerator.py,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -d -r1.32 -r1.33 *** codegenerator.py 21 Jan 2005 20:16:56 -0000 1.32 --- codegenerator.py 24 Jan 2005 12:12:18 -0000 1.33 *************** *** 460,463 **** --- 460,470 ---- print >> self.stream, "]" if methods: + # method definitions normally span several lines. + # Before we generate them, we need to 'import' everything they need. + # So, call type_name for each field once, + for m in methods: + self.type_name(m.returns) + for a in m.arguments: + self.type_name(a) print >> self.stream, "%s._methods_ = [" % body.struct.name if body.struct.location: |
From: Thomas H. <th...@us...> - 2005-01-24 10:02:45
|
Update of /cvsroot/ctypes/ctypes/sandbox/tools/codegen In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3530 Modified Files: cparser_config.py Log Message: More excludes. Index: cparser_config.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/sandbox/tools/codegen/cparser_config.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** cparser_config.py 19 Jan 2005 18:06:24 -0000 1.3 --- cparser_config.py 24 Jan 2005 10:02:35 -0000 1.4 *************** *** 29,32 **** --- 29,35 ---- # for windows.h EXCLUDED_win32 = """ + TTTOOLINFOA_V3_SIZE + TTTOOLINFOW_V3_SIZE + NMLVCUSTOMDRAW_V3_SIZE NOTIFYICONDATAA_V1_SIZE NOTIFYICONDATAA_V2_SIZE |
From: Thomas H. <th...@us...> - 2005-01-24 10:02:03
|
Update of /cvsroot/ctypes/ctypes/sandbox/tools/codegen In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3332 Modified Files: xml2py.py Log Message: Index: xml2py.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/sandbox/tools/codegen/xml2py.py,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** xml2py.py 21 Jan 2005 16:45:25 -0000 1.13 --- xml2py.py 24 Jan 2005 10:01:42 -0000 1.14 *************** *** 43,47 **** parser.values.dlls.extend(windows_dll_names) ! parser = OptionParser("usage: %prog [options] xmlfile") parser.add_option("-d", action="store_true", --- 43,47 ---- parser.values.dlls.extend(windows_dll_names) ! parser = OptionParser("usage: %prog xmlfile [options]") parser.add_option("-d", action="store_true", |
From: Thomas H. <th...@us...> - 2005-01-24 09:16:49
|
Update of /cvsroot/ctypes/ctypes/sandbox/tools/codegen In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23891 Modified Files: h2xml.py cparser.py Log Message: Allow more than one include file to be processed. Index: cparser.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/sandbox/tools/codegen/cparser.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** cparser.py 21 Jan 2005 13:07:26 -0000 1.8 --- cparser.py 24 Jan 2005 09:16:38 -0000 1.9 *************** *** 84,88 **** os.remove(fname) ! def get_defines(self, include_file): """'Compile' an include file with gccxml, and return a dictionary of preprocessor definitions. Empty and compiler --- 84,88 ---- os.remove(fname) ! def get_defines(self, include_files): """'Compile' an include file with gccxml, and return a dictionary of preprocessor definitions. Empty and compiler *************** *** 93,97 **** for line in lines] # all definitions ! lines = self.compile_and_dump(['#include "%s"' % include_file]) defined = [line.split(None, 1) for line in lines] --- 93,98 ---- for line in lines] # all definitions ! code = ['#include "%s"' % fname for fname in include_files] ! lines = self.compile_and_dump(code) defined = [line.split(None, 1) for line in lines] *************** *** 143,149 **** ################################################################ ! def find_types(self, include_file, defines): source = [] ! source.append('#include "%s"' % include_file) source.append("#define DECLARE(sym) template <typename T> T symbol_##sym(T) {}") source.append("#define DEFINE(sym) symbol_##sym(sym)") --- 144,151 ---- ################################################################ ! def find_types(self, include_files, defines): source = [] ! for fname in include_files: ! source.append('#include "%s"' % fname) source.append("#define DECLARE(sym) template <typename T> T symbol_##sym(T) {}") source.append("#define DEFINE(sym) symbol_##sym(sym)") *************** *** 182,188 **** return types ! def create_final_xml(self, include_file, types): source = [] ! source.append('#include "%s"' % include_file) for name, value in types.iteritems(): source.append("const %s cpp_sym_%s = %s;" % (types[name], name, name)) --- 184,191 ---- return types ! def create_final_xml(self, include_files, types): source = [] ! for fname in include_files: ! source.append('#include "%s"' % fname) for name, value in types.iteritems(): source.append("const %s cpp_sym_%s = %s;" % (types[name], name, name)) *************** *** 215,219 **** ################################################################ ! def parse(self, include_file, options): """Main method. --- 218,222 ---- ################################################################ ! def parse(self, include_files, options): """Main method. *************** *** 226,230 **** if options.verbose: print >> sys.stderr, "finding definitions ..." ! defines = self.get_defines(include_file) if options.verbose: print >> sys.stderr, "%d found" % len(defines) --- 229,233 ---- if options.verbose: print >> sys.stderr, "finding definitions ..." ! defines = self.get_defines(include_files) if options.verbose: print >> sys.stderr, "%d found" % len(defines) *************** *** 238,242 **** print >> sys.stderr, "finding definitions types ..." # invoke C++ template magic ! types = self.find_types(include_file, defines) if options.verbose: print >> sys.stderr, "found %d types ..." % len(types) --- 241,245 ---- print >> sys.stderr, "finding definitions types ..." # invoke C++ template magic ! types = self.find_types(include_files, defines) if options.verbose: print >> sys.stderr, "found %d types ..." % len(types) *************** *** 244,248 **** if options.verbose: print >> sys.stderr, "creating xml output file ..." ! self.create_final_xml(include_file, types) # Include additional preprecessor definitions into the XML file. --- 247,251 ---- if options.verbose: print >> sys.stderr, "creating xml output file ..." ! self.create_final_xml(include_files, types) # Include additional preprecessor definitions into the XML file. Index: h2xml.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/sandbox/tools/codegen/h2xml.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** h2xml.py 21 Jan 2005 13:09:15 -0000 1.8 --- h2xml.py 24 Jan 2005 09:16:38 -0000 1.9 *************** *** 29,33 **** parser.values.gccxml_options.extend((opt, value)) ! parser = OptionParser() ## parser.add_option("-h", action="help") parser.add_option("-q", "--quiet", --- 29,33 ---- parser.values.gccxml_options.extend((opt, value)) ! parser = OptionParser("usage: %prog includefile ... [options]") ## parser.add_option("-h", action="help") parser.add_option("-q", "--quiet", *************** *** 76,80 **** try: parser = cparser.IncludeParser() ! parser.parse(files[0], options) except cparser.CompilerError, detail: import traceback --- 76,80 ---- try: parser = cparser.IncludeParser() ! parser.parse(files, options) except cparser.CompilerError, detail: import traceback |
From: Thomas H. <th...@us...> - 2005-01-21 20:17:07
|
Update of /cvsroot/ctypes/ctypes/sandbox/tools/codegen In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12611 Modified Files: codegenerator.py Log Message: After code for a type descriptions is emitted, the name (if it has one) is added to self.names. So, Alias type descriptions can try to generate their dependencies, and then look if they are resolved. Index: codegenerator.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/sandbox/tools/codegen/codegenerator.py,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** codegenerator.py 21 Jan 2005 19:50:33 -0000 1.31 --- codegenerator.py 21 Jan 2005 20:16:56 -0000 1.32 *************** *** 2,16 **** # Type descriptions are collections of typedesc instances. - # Problems: - # - # SDL.h somewhere contains #define main SDL_main - # - # SDL_main is known to be a Function, but cannot be found in the dll - # (probably because it is in the static library SDLmain.lib). - # So, SDL_main cannot be generated because of the unknown dll. - # - # Hm, should self.generate() return whether code was actually generated, - # or would it be better to have a namespace of generated names? - import typedesc, sys --- 2,5 ---- *************** *** 142,148 **** class Generator(object): def __init__(self, stream, use_decorators=False): - self.done = set() self.stream = stream self.use_decorators = use_decorators def init_value(self, t, init): --- 131,138 ---- class Generator(object): def __init__(self, stream, use_decorators=False): self.stream = stream self.use_decorators = use_decorators + self.done = set() # type descriptions that have been generated + self.names = set() # names that have been generated def init_value(self, t, init): *************** *** 243,253 **** if alias in self.done: return if alias.typ is not None: # we can resolve it self.generate(alias.typ) ! print >> self.stream, "%s = %s # alias" % (alias.name, alias.alias) ! else: # we cannot resolve it ! print >> self.stream, "# %s = %s # alias" % (alias.name, alias.alias) - self.done.add(alias) def Macro(self, macro): --- 233,247 ---- if alias in self.done: return + self.done.add(alias) if alias.typ is not None: # we can resolve it self.generate(alias.typ) ! if alias.alias in self.names: ! print >> self.stream, "%s = %s # alias" % (alias.name, alias.alias) ! self.names.add(alias.name) ! return ! # we cannot resolve it ! print >> self.stream, "# %s = %s # alias" % (alias.name, alias.alias) ! print "# unresolved alias: %s = %s" % (alias.name, alias.alias) def Macro(self, macro): *************** *** 265,268 **** --- 259,263 ---- else: print >> self.stream, code + self.names.add(macro.name) self.done.add(macro) *************** *** 289,292 **** --- 284,288 ---- print >> self.stream, " # %s %s" % head.struct.location print >> self.stream, " pass" + self.names.add(head.struct.name) self.done.add(head) *************** *** 319,322 **** --- 315,319 ---- print >> self.stream, "%s = %s # typedef" % \ (tp.name, self.type_name(tp.typ)) + self.names.add(tp.name) self.done.add(tp) *************** *** 379,382 **** --- 376,380 ---- value, self.type_name(tp.typ, False)) + self.names.add(tp.name) _enumvalues = 0 *************** *** 387,390 **** --- 385,389 ---- print >> self.stream, \ "%s = %d # enum %s" % (tp.name, value, tp.enumeration.name or "") + self.names.add(tp.name) self._enumvalues += 1 self.done.add(tp) *************** *** 618,626 **** print >> self.stream, " # %s %s" % func.location print >> self.stream, " return %s._api_(%s)" % (func.name, ", ".join(argnames)) - ## print >> self.stream, " return _api_(%s)" % ", ".join(argnames) if not self.use_decorators: print >> self.stream, "%s = %s(%s, %s, [%s]) (%s)" % \ (func.name, cc, self.type_name(func.returns), libname, ", ".join(args), func.name) print >> self.stream self._functiontypes += 1 else: --- 617,625 ---- print >> self.stream, " # %s %s" % func.location print >> self.stream, " return %s._api_(%s)" % (func.name, ", ".join(argnames)) if not self.use_decorators: print >> self.stream, "%s = %s(%s, %s, [%s]) (%s)" % \ (func.name, cc, self.type_name(func.returns), libname, ", ".join(args), func.name) print >> self.stream + self.names.add(func.name) self._functiontypes += 1 else: |
From: Thomas H. <th...@us...> - 2005-01-21 20:12:12
|
Update of /cvsroot/ctypes/ctypes/sandbox/tools/codegen In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11071 Modified Files: gccxmlparser.py Log Message: It seems aliases work now - generates code which can be imported without problems, checked with windows.h and SDL.h. Index: gccxmlparser.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/sandbox/tools/codegen/gccxmlparser.py,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** gccxmlparser.py 21 Jan 2005 19:48:37 -0000 1.17 --- gccxmlparser.py 21 Jan 2005 20:11:53 -0000 1.18 *************** *** 321,326 **** for name, a in aliases.items(): - ## if name == "main": - ## continue value = a.alias # the value should be either in namespace... --- 321,324 ---- *************** *** 329,334 **** a.typ = namespace[value] # or in aliases... ! ## elif value in aliases: ! ## a.typ = aliases[value] # or unknown. else: --- 327,332 ---- a.typ = namespace[value] # or in aliases... ! elif value in aliases: ! a.typ = aliases[value] # or unknown. else: |
From: Thomas H. <th...@us...> - 2005-01-21 19:50:48
|
Update of /cvsroot/ctypes/ctypes/sandbox/tools/codegen In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5267 Modified Files: codegenerator.py Log Message: Todo list. Index: codegenerator.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/sandbox/tools/codegen/codegenerator.py,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** codegenerator.py 21 Jan 2005 16:33:44 -0000 1.30 --- codegenerator.py 21 Jan 2005 19:50:33 -0000 1.31 *************** *** 2,5 **** --- 2,16 ---- # Type descriptions are collections of typedesc instances. + # Problems: + # + # SDL.h somewhere contains #define main SDL_main + # + # SDL_main is known to be a Function, but cannot be found in the dll + # (probably because it is in the static library SDLmain.lib). + # So, SDL_main cannot be generated because of the unknown dll. + # + # Hm, should self.generate() return whether code was actually generated, + # or would it be better to have a namespace of generated names? + import typedesc, sys *************** *** 232,236 **** if alias in self.done: return ! if alias.typ is not None: # we can reslove it self.generate(alias.typ) print >> self.stream, "%s = %s # alias" % (alias.name, alias.alias) --- 243,247 ---- if alias in self.done: return ! if alias.typ is not None: # we can resolve it self.generate(alias.typ) print >> self.stream, "%s = %s # alias" % (alias.name, alias.alias) |
From: Thomas H. <th...@us...> - 2005-01-21 19:48:46
|
Update of /cvsroot/ctypes/ctypes/sandbox/tools/codegen In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4638 Modified Files: gccxmlparser.py Log Message: Simpler name mangling, some refactoring and fixing. Index: gccxmlparser.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/sandbox/tools/codegen/gccxmlparser.py,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** gccxmlparser.py 21 Jan 2005 16:42:30 -0000 1.16 --- gccxmlparser.py 21 Jan 2005 19:48:37 -0000 1.17 *************** *** 7,13 **** --- 7,30 ---- except NameError: from sets import Set as set + import re ################################################################ + def MAKE_NAME(name): + name = name.replace("$", "DOLLAR") + name = name.replace(".", "DOT") + if name.startswith("__"): + return "_X" + name + elif name[0] in "01234567879": + return "_" + name + return name + + WORDPAT = re.compile("^[a-zA-Z_][a-zA-Z0-9_]*$") + + def CHECK_NAME(name): + if WORDPAT.match(name): + return name + return None + class GCCXML_Handler(xml.sax.handler.ContentHandler): has_values = set(["Enumeration", "Function", "FunctionType", *************** *** 19,34 **** self.context = [] self.all = {} - self.artificial = [] self.cpp_data = {} - def demangle(self, name): - if name.startswith("__"): - name = "_py_" + name - if name[:0] and name[0] in "0123456789": - name = "_%c" % name[0] + name - name = name.replace("$", "_") - name = name.replace(".", "_") - return name - def startElement(self, name, attrs): # find and call the handler for this element --- 36,41 ---- *************** *** 114,118 **** def Typedef(self, attrs): ! name = self.demangle(attrs["name"]) typ = attrs["type"] return typedesc.Typedef(name, typ) --- 121,125 ---- def Typedef(self, attrs): ! name = attrs["name"] typ = attrs["type"] return typedesc.Typedef(name, typ) *************** *** 122,126 **** def FundamentalType(self, attrs): ! name = self.demangle(attrs["name"]) if name == "void": size = "" --- 129,133 ---- def FundamentalType(self, attrs): ! name = attrs["name"] if name == "void": size = "" *************** *** 170,174 **** def Function(self, attrs): # name, returns, extern, attributes ! name = self.demangle(attrs["name"]) returns = attrs["returns"] attributes = attrs.get("attributes", "").split() --- 177,181 ---- def Function(self, attrs): # name, returns, extern, attributes ! name = attrs["name"] returns = attrs["returns"] attributes = attrs.get("attributes", "").split() *************** *** 192,196 **** def OperatorFunction(self, attrs): # name, returns, extern, attributes ! name = self.demangle(attrs["name"]) returns = attrs["returns"] return typedesc.OperatorFunction(name, returns) --- 199,203 ---- def OperatorFunction(self, attrs): # name, returns, extern, attributes ! name = attrs["name"] returns = attrs["returns"] return typedesc.OperatorFunction(name, returns) *************** *** 200,204 **** def Constructor(self, attrs): ! name = self.demangle(attrs["name"]) return typedesc.Constructor(name) --- 207,211 ---- def Constructor(self, attrs): ! name = attrs["name"] return typedesc.Constructor(name) *************** *** 207,211 **** def Method(self, attrs): # name, virtual, pure_virtual, returns ! name = self.demangle(attrs["name"]) returns = attrs["returns"] return typedesc.Method(name, returns) --- 214,218 ---- def Method(self, attrs): # name, virtual, pure_virtual, returns ! name = attrs["name"] returns = attrs["returns"] return typedesc.Method(name, returns) *************** *** 225,244 **** def Enumeration(self, attrs): # id, name ! name = self.demangle(attrs["name"]) size = attrs["size"] align = attrs["align"] ! if attrs.get("artificial"): ! # enum {} ENUM_NAME; ! return typedesc.Enumeration(name, size, align) ! else: ! # enum tagENUM {}; ! enum = typedesc.Enumeration(None, size, align) ! self.artificial.append(typedesc.Typedef(name, enum)) ! return enum def _fixup_Enumeration(self, e): pass def EnumValue(self, attrs): ! name = self.demangle(attrs["name"]) value = attrs["init"] v = typedesc.EnumValue(name, value, self.context[-1]) --- 232,246 ---- def Enumeration(self, attrs): # id, name ! name = attrs["name"] ! # If the name isn't a valid Python identifier, create an unnamed enum ! name = CHECK_NAME(name) size = attrs["size"] align = attrs["align"] ! return typedesc.Enumeration(name, size, align) def _fixup_Enumeration(self, e): pass def EnumValue(self, attrs): ! name = attrs["name"] value = attrs["init"] v = typedesc.EnumValue(name, value, self.context[-1]) *************** *** 253,274 **** # id, name, members name = attrs.get("name") bases = attrs.get("bases", "").split() members = attrs.get("members", "").split() - ## abstract = attrs.get("abstract", "") align = attrs["align"] size = attrs.get("size") ! artificial = attrs.get("artificial") ! if name is None: ! name = self.demangle(attrs["mangled"]) # for debug only ! ## if abstract: ! ## return typedesc.Class(name, members, bases) ! ## else: ! if artificial: ! return typedesc.Structure(name, align, members, bases, size) ! else: ! ## struct = typedesc.Structure(name, align, members, bases, size) ! struct = typedesc.Structure(name, align, members, bases, size) ! self.artificial.append(typedesc.Typedef(name, struct)) ! return struct def _fixup_Structure(self, s): --- 255,265 ---- # id, name, members name = attrs.get("name") + if name is None: + name = MAKE_NAME(attrs["mangled"]) bases = attrs.get("bases", "").split() members = attrs.get("members", "").split() align = attrs["align"] size = attrs.get("size") ! return typedesc.Structure(name, align, members, bases, size) def _fixup_Structure(self, s): *************** *** 279,295 **** def Union(self, attrs): name = attrs.get("name") bases = attrs.get("bases", "").split() members = attrs.get("members", "").split() - ## abstract = attrs.get("abstract", "") align = attrs["align"] size = attrs.get("size") - ## artificial = attrs.get("artificial") - if name is None: - name = self.demangle(attrs["mangled"]) # for debug only return typedesc.Union(name, align, members, bases, size) def Field(self, attrs): # name, type ! name = self.demangle(attrs["name"]) typ = attrs["type"] bits = attrs.get("bits", None) --- 270,286 ---- def Union(self, attrs): name = attrs.get("name") + if name is None: + name = MAKE_NAME(attrs["mangled"]) bases = attrs.get("bases", "").split() members = attrs.get("members", "").split() align = attrs["align"] size = attrs.get("size") return typedesc.Union(name, align, members, bases, size) def Field(self, attrs): # name, type ! name = attrs["name"] ! ## if name.startswith("__") and not name.endswith("__"): ! ## print "INVALID FIELD NAME", name typ = attrs["type"] bits = attrs.get("bits", None) *************** *** 306,309 **** --- 297,302 ---- def get_macros(self, text): + if text is None: + return text = "".join(text) # preprocessor definitions that look like macros with one or more arguments *************** *** 315,318 **** --- 308,313 ---- def get_aliases(self, text, namespace): + if text is None: + return # preprocessor definitions that look like aliases: # #define A B *************** *** 326,337 **** for name, a in aliases.items(): ! # the value should be either in namespace... value = a.alias if value in namespace: # set the type a.typ = namespace[value] # or in aliases... ! elif value in aliases: ! a.typ = aliases[value] # or unknown. else: --- 321,334 ---- for name, a in aliases.items(): ! ## if name == "main": ! ## continue value = a.alias + # the value should be either in namespace... if value in namespace: # set the type a.typ = namespace[value] # or in aliases... ! ## elif value in aliases: ! ## a.typ = aliases[value] # or unknown. else: *************** *** 375,379 **** result = [] ! for i in self.artificial + self.all.values(): if isinstance(i, interesting): result.append(i) --- 372,376 ---- result = [] ! for i in self.all.values(): if isinstance(i, interesting): result.append(i) *************** *** 381,386 **** # todo: get cpp_data, and convert it into typedesc nodes. - # functions = self.cpp_data.get("functions") - # aliases = self.cpp_data.get("aliases") return result --- 378,381 ---- |
From: Thomas H. <th...@us...> - 2005-01-21 18:58:20
|
Update of /cvsroot/ctypes/ctypes/ctypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25458 Modified Files: __init__.py Log Message: Remove too much docstring magic. Index: __init__.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/ctypes/__init__.py,v retrieving revision 1.50 retrieving revision 1.51 diff -C2 -d -r1.50 -r1.51 *** __init__.py 20 Jan 2005 20:07:18 -0000 1.50 --- __init__.py 21 Jan 2005 18:58:03 -0000 1.51 *************** *** 66,85 **** return create_string_buffer(init, size) - _FUNCTYPE_DOC = """ - restype: the result type - argtypes: a sequence specifying the argument types - - The function prototype can be called in three ways to create a - callable object: - - prototype(vtbl_index, method_name) - a function that calls a COM method - prototype(vtbl_index, method_name, class) - an unbound method that calls a COM method - prototype(callable) - returns a C callable function that calls callable - prototype(funct_name, dll) - a function that calls an exported function in a dll - """ - _c_functype_cache = {} def CFUNCTYPE(restype, *argtypes): ! "CFUNCTYPE(restype, *argtypes) -> function prototype." try: return _c_functype_cache[(restype, argtypes)] --- 66,84 ---- return create_string_buffer(init, size) _c_functype_cache = {} def CFUNCTYPE(restype, *argtypes): ! """CFUNCTYPE(restype, *argtypes) -> function prototype. ! ! restype: the result type ! argtypes: a sequence specifying the argument types ! ! The function prototype can be called in three ways to create a ! callable object: ! ! prototype(vtbl_index, method_name) - a function that calls a COM method ! prototype(vtbl_index, method_name, class) - an unbound method that calls a COM method ! prototype(callable) - returns a C callable function that calls callable ! prototype(funct_name, dll) - a function that calls an exported function in a dll ! """ try: return _c_functype_cache[(restype, argtypes)] *************** *** 91,95 **** _c_functype_cache[(restype, argtypes)] = CFunctionType return CFunctionType - CFUNCTYPE.__doc__ += _FUNCTYPE_DOC if _os.name == "nt": --- 90,93 ---- *************** *** 101,105 **** _win_functype_cache = {} def WINFUNCTYPE(restype, *argtypes): ! "WINFUNCTYPE(restype, *argtypes) -> function prototype." try: return _win_functype_cache[(restype, argtypes)] --- 99,115 ---- _win_functype_cache = {} def WINFUNCTYPE(restype, *argtypes): ! """WINFUNCTYPE(restype, *argtypes) -> function prototype. ! ! restype: the result type ! argtypes: a sequence specifying the argument types ! ! The function prototype can be called in three ways to create a ! callable object: ! ! prototype(vtbl_index, method_name) - a function that calls a COM method ! prototype(vtbl_index, method_name, class) - an unbound method that calls a COM method ! prototype(callable) - returns a C callable function that calls callable ! prototype(funct_name, dll) - a function that calls an exported function in a dll ! """ try: return _win_functype_cache[(restype, argtypes)] *************** *** 111,115 **** _win_functype_cache[(restype, argtypes)] = WinFunctionType return WinFunctionType - WINFUNCTYPE.__doc__ += _FUNCTYPE_DOC elif _os.name == "posix": --- 121,124 ---- |
From: Thomas H. <th...@us...> - 2005-01-21 16:45:34
|
Update of /cvsroot/ctypes/ctypes/sandbox/tools/codegen In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25903 Modified Files: xml2py.py Log Message: Add filters for macros and aliases. Index: xml2py.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/sandbox/tools/codegen/xml2py.py,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** xml2py.py 18 Jan 2005 19:21:25 -0000 1.12 --- xml2py.py 21 Jan 2005 16:45:25 -0000 1.13 *************** *** 149,155 **** types = [] for char in options.kind: ! typ = {"d": [typedesc.Variable], "e": [typedesc.Enumeration, typedesc.EnumValue], "f": [typedesc.Function], "s": [typedesc.Structure], "t": [typedesc.Typedef], --- 149,157 ---- types = [] for char in options.kind: ! typ = {"a": [typedesc.Alias], ! "d": [typedesc.Variable], "e": [typedesc.Enumeration, typedesc.EnumValue], "f": [typedesc.Function], + "m": [typedesc.Macro], "s": [typedesc.Structure], "t": [typedesc.Typedef], |
From: Thomas H. <th...@us...> - 2005-01-21 16:42:38
|
Update of /cvsroot/ctypes/ctypes/sandbox/tools/codegen In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25346 Modified Files: gccxmlparser.py Log Message: Create Macro and Alias type descriptions. Index: gccxmlparser.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/sandbox/tools/codegen/gccxmlparser.py,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** gccxmlparser.py 21 Jan 2005 10:33:25 -0000 1.15 --- gccxmlparser.py 21 Jan 2005 16:42:30 -0000 1.16 *************** *** 255,259 **** bases = attrs.get("bases", "").split() members = attrs.get("members", "").split() ! abstract = attrs.get("abstract", "") align = attrs["align"] size = attrs.get("size") --- 255,259 ---- bases = attrs.get("bases", "").split() members = attrs.get("members", "").split() ! ## abstract = attrs.get("abstract", "") align = attrs["align"] size = attrs.get("size") *************** *** 281,288 **** bases = attrs.get("bases", "").split() members = attrs.get("members", "").split() ! abstract = attrs.get("abstract", "") align = attrs["align"] size = attrs.get("size") ! artificial = attrs.get("artificial") if name is None: name = self.demangle(attrs["mangled"]) # for debug only --- 281,288 ---- bases = attrs.get("bases", "").split() members = attrs.get("members", "").split() ! ## abstract = attrs.get("abstract", "") align = attrs["align"] size = attrs.get("size") ! ## artificial = attrs.get("artificial") if name is None: name = self.demangle(attrs["mangled"]) # for debug only *************** *** 302,310 **** ################ def get_result(self): interesting = (typedesc.Typedef, typedesc.Enumeration, typedesc.EnumValue, typedesc.Function, typedesc.Structure, typedesc.Union, ! typedesc.Variable) ! result = [] remove = [] for n, i in self.all.items(): --- 302,349 ---- ################ + def _fixup_Macro(self, m): + pass + + def get_macros(self, text): + text = "".join(text) + # preprocessor definitions that look like macros with one or more arguments + for m in text.splitlines(): + name, body = m.split(None, 1) + name, args = name.split("(", 1) + args = "(%s" % args + self.all[name] = typedesc.Macro(name, args, body) + + def get_aliases(self, text, namespace): + # preprocessor definitions that look like aliases: + # #define A B + text = "".join(text) + aliases = {} + for a in text.splitlines(): + name, value = a.split(None, 1) + a = typedesc.Alias(name, value) + aliases[name] = a + self.all[name] = a + + for name, a in aliases.items(): + # the value should be either in namespace... + value = a.alias + if value in namespace: + # set the type + a.typ = namespace[value] + # or in aliases... + elif value in aliases: + a.typ = aliases[value] + # or unknown. + else: + # not known + print "skip %s = %s" % (name, value) + def get_result(self): interesting = (typedesc.Typedef, typedesc.Enumeration, typedesc.EnumValue, typedesc.Function, typedesc.Structure, typedesc.Union, ! typedesc.Variable, typedesc.Macro, typedesc.Alias) ! ! self.get_macros(self.cpp_data.get("functions")) ! remove = [] for n, i in self.all.items(): *************** *** 320,329 **** --- 359,383 ---- fil, line = location.split(":") i.location = self.all[fil].name, line + for n in remove: del self.all[n] + + # Now we can build the namespace. + namespace = {} + for i in self.all.values(): + if not isinstance(i, interesting): + continue # we don't want these + name = getattr(i, "name", None) + if name is not None: + namespace[name] = i + + self.get_aliases(self.cpp_data.get("aliases"), namespace) + + result = [] for i in self.artificial + self.all.values(): if isinstance(i, interesting): result.append(i) + # todo: get cpp_data, and convert it into typedesc nodes. # functions = self.cpp_data.get("functions") |
From: Thomas H. <th...@us...> - 2005-01-21 16:35:26
|
Update of /cvsroot/ctypes/ctypes/sandbox/tools/codegen In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23575 Modified Files: typedesc.py Log Message: Add Macro and Alias type descriptions. Index: typedesc.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/sandbox/tools/codegen/typedesc.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** typedesc.py 19 Jan 2005 08:31:09 -0000 1.7 --- typedesc.py 21 Jan 2005 16:35:17 -0000 1.8 *************** *** 11,14 **** --- 11,31 ---- ################ + class Alias(object): + # a C preprocessor alias, like #define A B + def __init__(self, name, alias, typ=None): + self.name = name + self.alias = alias + self.typ = typ + + class Macro(object): + # a C preprocessor definition with arguments + def __init__(self, name, args, body): + # all arguments are strings, args is the literal argument list + # *with* the parens around it: + # Example: Macro("CD_INDRIVE", "(status)", "((int)status > 0)") + self.name = name + self.args = args + self.body = body + class File(object): def __init__(self, name): |
From: Thomas H. <th...@us...> - 2005-01-21 16:33:54
|
Update of /cvsroot/ctypes/ctypes/sandbox/tools/codegen In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22783 Modified Files: codegenerator.py Log Message: Generate code for Macro and Alias type descriptions. Index: codegenerator.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/sandbox/tools/codegen/codegenerator.py,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** codegenerator.py 20 Jan 2005 07:50:08 -0000 1.29 --- codegenerator.py 21 Jan 2005 16:33:44 -0000 1.30 *************** *** 227,230 **** --- 227,259 ---- return t.name + ################################################################ + + def Alias(self, alias): + if alias in self.done: + return + if alias.typ is not None: # we can reslove it + self.generate(alias.typ) + print >> self.stream, "%s = %s # alias" % (alias.name, alias.alias) + else: # we cannot resolve it + print >> self.stream, "# %s = %s # alias" % (alias.name, alias.alias) + + self.done.add(alias) + + def Macro(self, macro): + if macro in self.done: + return + # We don't know if we can generate valid, error free Python + # code All we can do is to try to compile the code. If the + # compile fails, we know it cannot work, so we generate + # commented out code. If it succeeds, it may fail at runtime. + code = "def %s%s: return %s # macro" % (macro.name, macro.args, macro.body) + try: + compile(code, "<string>", "exec") + except SyntaxError: + print >> self.stream, "#", code + else: + print >> self.stream, code + self.done.add(macro) + def StructureHead(self, head): if head in self.done: |
From: Thomas H. <th...@us...> - 2005-01-21 13:09:25
|
Update of /cvsroot/ctypes/ctypes/sandbox/tools/codegen In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7848 Modified Files: h2xml.py Log Message: Typo. Index: h2xml.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/sandbox/tools/codegen/h2xml.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** h2xml.py 21 Jan 2005 11:21:25 -0000 1.7 --- h2xml.py 21 Jan 2005 13:09:15 -0000 1.8 *************** *** 31,35 **** parser = OptionParser() ## parser.add_option("-h", action="help") ! parser.add_option("-q", "--quite", dest="quiet", action="store_true", --- 31,35 ---- parser = OptionParser() ## parser.add_option("-h", action="help") ! parser.add_option("-q", "--quiet", dest="quiet", action="store_true", |
From: Thomas H. <th...@us...> - 2005-01-21 13:07:42
|
Update of /cvsroot/ctypes/ctypes/sandbox/tools/codegen In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7436 Modified Files: cparser.py Log Message: Print only when verbose is set. Index: cparser.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/sandbox/tools/codegen/cparser.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** cparser.py 21 Jan 2005 11:57:59 -0000 1.7 --- cparser.py 21 Jan 2005 13:07:26 -0000 1.8 *************** *** 7,11 **** subprocess = None - if sys.platform == "win32": --- 7,10 ---- *************** *** 49,53 **** if lines and self.options.flags: args.extend(self.options.flags) ! print "run", args if subprocess: proc = subprocess.Popen(args, --- 48,53 ---- if lines and self.options.flags: args.extend(self.options.flags) ! if self.options.verbose: ! print >> sys.stderr, "running:", " ".join(args) if subprocess: proc = subprocess.Popen(args, *************** *** 73,77 **** args.extend(self.options.flags) try: ! print "run", args if subprocess: retcode = subprocess.call(args) --- 73,78 ---- args.extend(self.options.flags) try: ! if self.options.verbose: ! print >> sys.stderr, "running:", " ".join(args) if subprocess: retcode = subprocess.call(args) *************** *** 219,223 **** The options object must have these attribuites: verbose - integer ! flags - string """ self.options = options --- 220,224 ---- The options object must have these attribuites: verbose - integer ! flags - sequence of strings """ self.options = options |
From: Thomas H. <th...@us...> - 2005-01-21 11:58:07
|
Update of /cvsroot/ctypes/ctypes/sandbox/tools/codegen In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25155 Modified Files: cparser.py Log Message: Use subprocess, if available, to run gccxml. Index: cparser.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/sandbox/tools/codegen/cparser.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** cparser.py 21 Jan 2005 11:21:00 -0000 1.6 --- cparser.py 21 Jan 2005 11:57:59 -0000 1.7 *************** *** 2,5 **** --- 2,10 ---- from cparser_config import C_KEYWORDS, EXCLUDED, EXCLUDED_RE import gccxmlparser, typedesc + try: + import subprocess + except ImportError: + subprocess = None + if sys.platform == "win32": *************** *** 44,51 **** if lines and self.options.flags: args.extend(self.options.flags) ! print "run", " ".join(args) ! i, o = os.popen4(" ".join(args)) ! i.close() ! data = o.read() finally: os.remove(fname) --- 49,62 ---- if lines and self.options.flags: args.extend(self.options.flags) ! print "run", args ! if subprocess: ! proc = subprocess.Popen(args, ! stdout=subprocess.PIPE, ! stdin=subprocess.PIPE) ! data, err = proc.communicate() ! else: ! i, o = os.popen4(" ".join(args)) ! i.close() ! data = o.read() finally: os.remove(fname) *************** *** 62,66 **** args.extend(self.options.flags) try: ! retcode = os.system(" ".join(args)) if retcode: raise CompilerError, "gccxml returned %s" % retcode --- 73,81 ---- args.extend(self.options.flags) try: ! print "run", args ! if subprocess: ! retcode = subprocess.call(args) ! else: ! retcode = os.system(" ".join(args)) if retcode: raise CompilerError, "gccxml returned %s" % retcode |
From: Thomas H. <th...@us...> - 2005-01-21 11:21:34
|
Update of /cvsroot/ctypes/ctypes/sandbox/tools/codegen In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17251 Modified Files: h2xml.py Log Message: options.flags is a sequence of flags, no longer a string containing flags. Index: h2xml.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/sandbox/tools/codegen/h2xml.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** h2xml.py 17 Jan 2005 15:58:03 -0000 1.6 --- h2xml.py 21 Jan 2005 11:21:25 -0000 1.7 *************** *** 27,31 **** def add_option(option, opt, value, parser): ! parser.values.gccxml_options.append("%s %s" % (opt, value)) parser = OptionParser() --- 27,31 ---- def add_option(option, opt, value, parser): ! parser.values.gccxml_options.extend((opt, value)) parser = OptionParser() *************** *** 70,74 **** return 1 ! options.flags = " ".join(options.gccxml_options) options.verbose = not options.quiet --- 70,74 ---- return 1 ! options.flags = options.gccxml_options options.verbose = not options.quiet |
From: Thomas H. <th...@us...> - 2005-01-21 11:21:10
|
Update of /cvsroot/ctypes/ctypes/sandbox/tools/codegen In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17137 Modified Files: cparser.py Log Message: options.flags is a sequence of flags, no longer a string containing flags. Index: cparser.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/sandbox/tools/codegen/cparser.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** cparser.py 21 Jan 2005 11:00:37 -0000 1.5 --- cparser.py 21 Jan 2005 11:21:00 -0000 1.6 *************** *** 43,47 **** args = ["gccxml", "--preprocess", "-dM", fname] if lines and self.options.flags: ! args.append(self.options.flags) print "run", " ".join(args) i, o = os.popen4(" ".join(args)) --- 43,47 ---- args = ["gccxml", "--preprocess", "-dM", fname] if lines and self.options.flags: ! args.extend(self.options.flags) print "run", " ".join(args) i, o = os.popen4(" ".join(args)) *************** *** 60,64 **** args = ["gccxml", fname, "-fxml=%s" % xmlfile] if self.options.flags: ! args.append(self.options.flags) try: retcode = os.system(" ".join(args)) --- 60,64 ---- args = ["gccxml", fname, "-fxml=%s" % xmlfile] if self.options.flags: ! args.extend(self.options.flags) try: retcode = os.system(" ".join(args)) |
From: Thomas H. <th...@us...> - 2005-01-21 11:00:45
|
Update of /cvsroot/ctypes/ctypes/sandbox/tools/codegen In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13273 Modified Files: cparser.py Log Message: Work around strange text mode. Index: cparser.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/sandbox/tools/codegen/cparser.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** cparser.py 21 Jan 2005 10:43:56 -0000 1.4 --- cparser.py 21 Jan 2005 11:00:37 -0000 1.5 *************** *** 42,47 **** try: args = ["gccxml", "--preprocess", "-dM", fname] ! if self.options.flags: args.append(self.options.flags) i, o = os.popen4(" ".join(args)) i.close() --- 42,48 ---- try: args = ["gccxml", "--preprocess", "-dM", fname] ! if lines and self.options.flags: args.append(self.options.flags) + print "run", " ".join(args) i, o = os.popen4(" ".join(args)) i.close() *************** *** 233,240 **** if self.options.xmlfile: f = open(self.options.xmlfile, "r+") ! f.seek(-11, 2) data = f.read() ! assert data == "</GCC_XML>\n" ! f.seek(-11, 2) f.flush() --- 234,248 ---- if self.options.xmlfile: f = open(self.options.xmlfile, "r+") ! f.seek(-12, 2) data = f.read() ! if len(data) == 11: ! # text mode on windows is strange. You read 12 ! # characters, but get 11. ! assert data == "</GCC_XML>\n" ! f.seek(-12, 2) ! else: ! # linux, ... ! assert data == "\n</GCC_XML>\n" ! f.seek(-11, 2) f.flush() |
From: Thomas H. <th...@us...> - 2005-01-21 10:44:05
|
Update of /cvsroot/ctypes/ctypes/sandbox/tools/codegen In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9339 Modified Files: cparser.py Log Message: Small bug showed up on linux. Index: cparser.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/sandbox/tools/codegen/cparser.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** cparser.py 21 Jan 2005 10:03:25 -0000 1.3 --- cparser.py 21 Jan 2005 10:43:56 -0000 1.4 *************** *** 233,239 **** if self.options.xmlfile: f = open(self.options.xmlfile, "r+") ! f.seek(-12, 2) ! assert f.read() == "</GCC_XML>\n" ! f.seek(-12, 2) f.flush() --- 233,240 ---- if self.options.xmlfile: f = open(self.options.xmlfile, "r+") ! f.seek(-11, 2) ! data = f.read() ! assert data == "</GCC_XML>\n" ! f.seek(-11, 2) f.flush() |
From: Thomas H. <th...@us...> - 2005-01-21 10:33:33
|
Update of /cvsroot/ctypes/ctypes/sandbox/tools/codegen In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6791 Modified Files: gccxmlparser.py Log Message: Handle the CPP_DUMP element. Index: gccxmlparser.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/sandbox/tools/codegen/gccxmlparser.py,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** gccxmlparser.py 19 Jan 2005 08:30:29 -0000 1.14 --- gccxmlparser.py 21 Jan 2005 10:33:25 -0000 1.15 *************** *** 20,23 **** --- 20,24 ---- self.all = {} self.artificial = [] + self.cpp_data = {} def demangle(self, name): *************** *** 52,59 **** --- 53,62 ---- self.context.append(result) + cdata = None def endElement(self, name): # if this element has children, pop the context if name in self.has_values: self.context.pop() + self.cdata = None ################################ *************** *** 73,76 **** --- 76,90 ---- # real element handlers + def CPP_DUMP(self, attrs): + name = attrs["name"] + # Insert a new list for each named section into self.cpp_data, + # and point self.cdata to it. self.cdata will be set to None + # again at the end of each section. + self.cpp_data[name] = self.cdata = [] + + def characters(self, content): + if self.cdata is not None: + self.cdata.append(content) + def File(self, attrs): name = attrs["name"] *************** *** 311,314 **** --- 325,333 ---- if isinstance(i, interesting): result.append(i) + + # todo: get cpp_data, and convert it into typedesc nodes. + # functions = self.cpp_data.get("functions") + # aliases = self.cpp_data.get("aliases") + return result |