[ctypes-commit] ctypes/sandbox/tools/codegen gccxmlparser.py,1.2,1.3
Brought to you by:
theller
From: Thomas H. <th...@us...> - 2004-11-02 16:33:10
|
Update of /cvsroot/ctypes/ctypes/sandbox/tools/codegen In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5974 Modified Files: gccxmlparser.py Log Message: Several fixes. Index: gccxmlparser.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/sandbox/tools/codegen/gccxmlparser.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** gccxmlparser.py 1 Oct 2004 19:56:50 -0000 1.2 --- gccxmlparser.py 2 Nov 2004 16:33:00 -0000 1.3 *************** *** 25,32 **** if verbose: print >> sys.stderr, "writing temporary C source file %s" % c_file ! os.write(handle, 'extern "C" {\n'); for fname in fnames: os.write(handle, '#include <%s>\n' % fname) ! os.write(handle, '}'); os.close(handle) --- 25,32 ---- if verbose: print >> sys.stderr, "writing temporary C source file %s" % c_file ! ## os.write(handle, 'extern "C" {\n'); for fname in fnames: os.write(handle, '#include <%s>\n' % fname) ! ## os.write(handle, '}'); os.close(handle) *************** *** 59,63 **** class GCCXML_Handler(xml.sax.handler.ContentHandler): has_values = Set(["Enumeration", "Function", "FunctionType", ! "OperatorFunction", "Method", "Constructor"]) def __init__(self, *args): --- 59,64 ---- class GCCXML_Handler(xml.sax.handler.ContentHandler): has_values = Set(["Enumeration", "Function", "FunctionType", ! "OperatorFunction", "Method", "Constructor", ! "Destructor", "OperatorMethod"]) def __init__(self, *args): *************** *** 74,83 **** mth = getattr(self, name) result = mth(attrs) ! if result is None: ! return ! # record the result ! _id = attrs.get("id", None) ! if _id is not None: ! self.all[_id] = result # if this element has children, push onto the context if name in self.has_values: --- 75,83 ---- mth = getattr(self, name) result = mth(attrs) ! if result is not None: ! # record the result ! _id = attrs.get("id", None) ! if _id is not None: ! self.all[_id] = result # if this element has children, push onto the context if name in self.has_values: *************** *** 87,94 **** # if this element has children, pop the context if name in self.has_values: ! self.context = self.context[:-1] ################################ # do-nothing element handlers def GCC_XML(self, attrs): pass --- 87,97 ---- # if this element has children, pop the context if name in self.has_values: ! self.context.pop() ################################ # do-nothing element handlers + + def Class(self, attrs): pass + def Destructor(self, attrs): pass def GCC_XML(self, attrs): pass *************** *** 99,102 **** --- 102,106 ---- def Ellipsis(self, attrs): pass def File(self, attrs): pass + def OperatorMethod(self, attrs): pass ################################ *************** *** 115,119 **** def FundamentalType(self, attrs): name = attrs["name"] ! return nodes.FundamentalType(name) def _fixup_FundamentalType(self, t): pass --- 119,128 ---- def FundamentalType(self, attrs): name = attrs["name"] ! if name == "void": ! size = "" ! else: ! size = attrs["size"] ! align = attrs["align"] ! return nodes.FundamentalType(name, size, align) def _fixup_FundamentalType(self, t): pass *************** *** 121,125 **** def PointerType(self, attrs): typ = attrs["type"] ! return nodes.PointerType(typ) def _fixup_PointerType(self, p): --- 130,136 ---- def PointerType(self, attrs): typ = attrs["type"] ! size = attrs["size"] ! align = attrs["align"] ! return nodes.PointerType(typ, size, align) def _fixup_PointerType(self, p): *************** *** 201,205 **** def Argument(self, attrs): typ = attrs["type"] ! self.context[-1].add_argument(typ) # name? # enumerations --- 212,218 ---- def Argument(self, attrs): typ = attrs["type"] ! parent = self.context[-1] ! if parent is not None: ! parent.add_argument(typ) # name? # enumerations *************** *** 208,217 **** # id, name name = attrs["name"] if attrs.get("artificial"): # enum {} ENUM_NAME; ! return nodes.Enumeration(name) else: # enum tagENUM {}; ! enum = nodes.Enumeration(None) self.artificial.append(nodes.Typedef(name, enum)) return enum --- 221,232 ---- # id, name name = attrs["name"] + size = attrs["size"] + align = attrs["align"] if attrs.get("artificial"): # enum {} ENUM_NAME; ! return nodes.Enumeration(name, size, align) else: # enum tagENUM {}; ! enum = nodes.Enumeration(None, size, align) self.artificial.append(nodes.Typedef(name, enum)) return enum *************** *** 284,290 **** nodes.Typedef, nodes.Enumeration, nodes.Function, nodes.Structure, nodes.Union) result = [] ! for i in self.all.values(): mth = getattr(self, "_fixup_" + type(i).__name__) ! mth(i) for i in self.artificial + self.all.values(): if isinstance(i, interesting): --- 299,311 ---- nodes.Typedef, nodes.Enumeration, nodes.Function, nodes.Structure, nodes.Union) result = [] ! remove = [] ! for n, i in self.all.items(): mth = getattr(self, "_fixup_" + type(i).__name__) ! try: ! mth(i) ! except KeyError: # XXX better exception catching ! remove.append(n) ! for n in remove: ! del self.all[n] for i in self.artificial + self.all.values(): if isinstance(i, interesting): |