=================================================================== --- ctypeslib/codegen/gccxmlparser.py (revision 66890) +++ ctypeslib/codegen/gccxmlparser.py (working copy) @@ -295,8 +295,12 @@ return typedesc.Structure(name, align, members, bases, size) def _fixup_Structure(self, s): - s.members = [self.all[m] for m in s.members] - s.bases = [self.all[b] for b in s.bases] + # Some tags in gccxml output may not have been recorded in the + # self.all dict, so the original code: + # s.members = [self.all[m] for m in s.members] + # failed, which prevented the printing of struct fields + s.members = [self.all[m] for m in s.members if m in self.all] + s.bases = [self.all[b] for b in s.bases if b in self.all] _fixup_Union = _fixup_Structure def Union(self, attrs): Index: ctypeslib/codegen/codegenerator.py =================================================================== --- ctypeslib/codegen/codegenerator.py (revision 66890) +++ ctypeslib/codegen/codegenerator.py (working copy) @@ -26,6 +26,13 @@ except ImportError: import StringIO +# ignores a trailing "u" in a string representing an integer +def better_int(x): + if x.endswith('u'): + return int( x[:-1] ) + return int(x) + + # This is what GCCXML uses as size of varsized arrays in structure # field: GCCXML_NOSIZE = "0x" + "f" * ctypes.sizeof(ctypes.c_long) * 4 @@ -311,7 +318,9 @@ elif isinstance(t, typedesc.ArrayType): if t.max.lower() == GCCXML_NOSIZE or t.max == "": return "%s * 0" % (self.type_name(t.typ, generate),) - return "%s * %s" % (self.type_name(t.typ, generate), int(t.max)+1) + # using better_int because sometimes gccxml uses a "u" suffix + # on unsigned values, which confuses plain "int()" + return "%s * %s" % (self.type_name(t.typ, generate), better_int(t.max)+1) elif isinstance(t, typedesc.FunctionType): args = [self.type_name(x, generate) for x in [t.returns] + list(t.iterArgTypes())] if "__stdcall__" in t.attributes: