[ctypes-commit] ctypes/sandbox/tools/codegen typedesc.py,1.5,1.6 gccxmlparser.py,1.11,1.12 codegener
Brought to you by:
theller
From: Thomas H. <th...@us...> - 2005-01-14 10:48:50
|
Update of /cvsroot/ctypes/ctypes/sandbox/tools/codegen In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30606 Modified Files: typedesc.py gccxmlparser.py codegenerator.py Log Message: The init property of Variables is optional. A hack to generate code for the init value. Index: typedesc.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/sandbox/tools/codegen/typedesc.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** typedesc.py 13 Jan 2005 16:43:42 -0000 1.5 --- typedesc.py 14 Jan 2005 10:48:39 -0000 1.6 *************** *** 139,143 **** class Variable(object): ! def __init__(self, name, typ, init): self.name = name self.typ = typ --- 139,143 ---- class Variable(object): ! def __init__(self, name, typ, init=None): self.name = name self.typ = typ Index: codegenerator.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/sandbox/tools/codegen/codegenerator.py,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** codegenerator.py 13 Jan 2005 16:43:42 -0000 1.20 --- codegenerator.py 14 Jan 2005 10:48:39 -0000 1.21 *************** *** 143,146 **** --- 143,161 ---- return t.name + def init_value(t, init): + if isinstance(t, typedesc.CvQualifiedType): + return init_value(t.typ, init) + if isinstance(t, typedesc.FundamentalType): + name = ctypes_names[t.name] + if name in ("c_double", "c_float"): + return float(init) + if "unsigned" in t.name: + return int(init, 16) + return int(init) + if isinstance(t, typedesc.PointerType): + # XXXXXXXXXXXXXXXXX + return "pointer(%s)" % init_value(t.typ, init) + raise "HALT" + # Is this needed? ##renames = { *************** *** 257,261 **** self.done.add(tp) print >> self.stream, \ ! "%s = %s # Variable" % (tp.name, tp.init) def EnumValue(self, tp): --- 272,276 ---- self.done.add(tp) print >> self.stream, \ ! "%s = %s" % (tp.name, init_value(tp.typ, tp.init)) def EnumValue(self, tp): Index: gccxmlparser.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/sandbox/tools/codegen/gccxmlparser.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** gccxmlparser.py 13 Jan 2005 16:43:42 -0000 1.11 --- gccxmlparser.py 14 Jan 2005 10:48:39 -0000 1.12 *************** *** 73,77 **** # XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXx fix me! name = name[len("cpp_sym_"):] ! init = attrs["init"] typ = attrs["type"] return typedesc.Variable(name, typ, init) --- 73,77 ---- # XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXx fix me! name = name[len("cpp_sym_"):] ! init = attrs.get("init", None) typ = attrs["type"] return typedesc.Variable(name, typ, init) |