[ctypes-commit] ctypes/sandbox/tools/codegen codegenerator.py,1.5,1.6
Brought to you by:
theller
From: Thomas H. <th...@us...> - 2004-12-17 08:02:30
|
Update of /cvsroot/ctypes/ctypes/sandbox/tools/codegen In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4919 Modified Files: codegenerator.py Log Message: Avoid conflict when a Structure/Uniony contains more than one unnamed field. Names generated are "_", "_1", "_2", and so on. Index: codegenerator.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/sandbox/tools/codegen/codegenerator.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** codegenerator.py 17 Dec 2004 07:56:10 -0000 1.5 --- codegenerator.py 17 Dec 2004 08:02:19 -0000 1.6 *************** *** 341,348 **** else: print >> self.stream, "%s._fields_ = [" % body.struct.name for f in fields: if not f.name: ! print >> self.stream, " # Unnamed field renamed to '_'" ! fieldname = f.name or "_" if f.bits is None: print >> self.stream, " ('%s', %s)," % (fieldname, type_name(f.typ)) --- 341,356 ---- else: print >> self.stream, "%s._fields_ = [" % body.struct.name + # unnamed fields will get autogenerated names "_", "_1". "_2", "_3", ... + unnamed_index = 0 for f in fields: if not f.name: ! if unnamed_index: ! fieldname = "_%d" % unnamed_index ! else: ! fieldname = "_" ! unnamed_index += 1 ! print >> self.stream, " # Unnamed field renamed to '%s'" % fieldname ! else: ! fieldname = f.name if f.bits is None: print >> self.stream, " ('%s', %s)," % (fieldname, type_name(f.typ)) |