[ctypes-commit] ctypes/sandbox/tools/codegen codegenerator.py,1.41,1.42
Brought to you by:
theller
From: Thomas H. <th...@us...> - 2005-01-28 09:27:21
|
Update of /cvsroot/ctypes/ctypes/sandbox/tools/codegen In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22520 Modified Files: codegenerator.py Log Message: Now that all code is generated through calls to the general dispatcher self.generate, we can move common code into this function. Index: codegenerator.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/sandbox/tools/codegen/codegenerator.py,v retrieving revision 1.41 retrieving revision 1.42 diff -C2 -d -r1.41 -r1.42 *** codegenerator.py 28 Jan 2005 09:14:25 -0000 1.41 --- codegenerator.py 28 Jan 2005 09:27:11 -0000 1.42 *************** *** 219,225 **** def Alias(self, alias): - if alias in self.done: - return - self.done.add(alias) if alias.typ is not None: # we can resolve it self.generate(alias.typ) --- 219,222 ---- *************** *** 234,239 **** 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 --- 231,234 ---- *************** *** 248,256 **** print >> self.stream, code self.names.add(macro.name) - self.done.add(macro) def StructureHead(self, head): - if head in self.done: - return for struct in head.struct.bases: self.generate(struct.get_head()) --- 243,248 ---- *************** *** 272,285 **** print >> self.stream, " pass" self.names.add(head.struct.name) - self.done.add(head) _structures = 0 def Structure(self, struct): - if struct in self.done: - return self._structures += 1 self.generate(struct.get_head()) self.generate(struct.get_body()) - self.done.add(struct) Union = Structure --- 264,273 ---- *************** *** 287,292 **** _typedefs = 0 def Typedef(self, tp): - if tp in self.done: - return self._typedefs += 1 if type(tp.typ) in (typedesc.Structure, typedesc.Union): --- 275,278 ---- *************** *** 303,330 **** (tp.name, self.type_name(tp.typ)) self.names.add(tp.name) - self.done.add(tp) _arraytypes = 0 def ArrayType(self, tp): - if tp in self.done: - return self._arraytypes += 1 self.generate(get_real_type(tp.typ)) self.generate(tp.typ) - self.done.add(tp) _functiontypes = 0 def FunctionType(self, tp): - if tp in self.done: - return self._functiontypes += 1 self.generate(tp.returns) self.generate_all(tp.arguments) - self.done.add(tp) _pointertypes = 0 def PointerType(self, tp): - if tp in self.done: - return self._pointertypes += 1 if type(tp.typ) is typedesc.PointerType: --- 289,307 ---- *************** *** 337,354 **** else: self.generate(tp.typ) - self.done.add(tp) def CvQualifiedType(self, tp): - if tp in self.done: - return self.generate(tp.typ) - self.done.add(tp) _variables = 0 def Variable(self, tp): - if tp in self.done: - return self._variables += 1 - self.done.add(tp) if tp.init is None: # wtypes.h contains IID_IProcessInitControl, for example --- 314,324 ---- *************** *** 367,372 **** _enumvalues = 0 def EnumValue(self, tp): - if tp in self.done: - return value = int(tp.value) print >> self.stream, \ --- 337,340 ---- *************** *** 374,384 **** self.names.add(tp.name) self._enumvalues += 1 - self.done.add(tp) _enumtypes = 0 def Enumeration(self, tp): - if tp in self.done: - return - self.done.add(tp) self._enumtypes += 1 if tp.name: --- 342,348 ---- *************** *** 389,394 **** def StructureBody(self, body): - if body in self.done: - return fields = [] methods = [] --- 353,356 ---- *************** *** 473,477 **** print >> self.stream, "]" ! self.done.add(body) def find_dllname(self, func): --- 435,439 ---- print >> self.stream, "]" ! ## self.done.add(body) def find_dllname(self, func): *************** *** 524,529 **** _notfound_functiontypes = 0 def Function(self, func): - if func in self.done: - return dllname = self.find_dllname(func) if dllname: --- 486,489 ---- *************** *** 555,567 **** else: self._notfound_functiontypes += 1 - self.done.add(func) def FundamentalType(self, item): ! if item in self.done: ! return ! name = ctypes_names[item.name] ## if name != "None": ## print >> self.stream, "from ctypes import %s" % name ! self.done.add(item) ######## --- 515,525 ---- else: self._notfound_functiontypes += 1 def FundamentalType(self, item): ! pass # we should check if this is known somewhere ! ## name = ctypes_names[item.name] ## if name != "None": ## print >> self.stream, "from ctypes import %s" % name ! ## self.done.add(item) ######## *************** *** 577,580 **** --- 535,539 ---- mth = getattr(self, type(item).__name__) mth(item) + self.done.add(item) def generate_all(self, items): |