diff options
Diffstat (limited to 'bindings/python/clang/cindex.py')
-rw-r--r-- | bindings/python/clang/cindex.py | 54 |
1 files changed, 52 insertions, 2 deletions
diff --git a/bindings/python/clang/cindex.py b/bindings/python/clang/cindex.py index e683f5ba72..880a1502a4 100644 --- a/bindings/python/clang/cindex.py +++ b/bindings/python/clang/cindex.py @@ -1314,6 +1314,18 @@ class Cursor(Structure): """ return TokenGroup.get_tokens(self._tu, self.extent) + def is_bitfield(self): + """ + Check if the field is a bitfield. + """ + return conf.lib.clang_Cursor_isBitField(self) + + def get_bitfield_width(self): + """ + Retrieve the width of a bitfield. + """ + return conf.lib.clang_getFieldDeclBitWidth(self) + @staticmethod def from_result(res, fn, args): assert isinstance(res, Cursor) @@ -1613,6 +1625,24 @@ class Type(Structure): """ return conf.lib.clang_getArraySize(self) + def get_align(self): + """ + Retrieve the alignment of the record. + """ + return conf.lib.clang_Type_getAlignOf(self) + + def get_size(self): + """ + Retrieve the size of the record. + """ + return conf.lib.clang_Type_getSizeOf(self) + + def get_offset(self, fieldname): + """ + Retrieve the offset of a field in the record. + """ + return conf.lib.clang_Type_getOffsetOf(self, c_char_p(fieldname)) + def __eq__(self, other): if type(other) != type(self): return False @@ -2015,7 +2045,7 @@ class TranslationUnit(ClangObject): len(args), unsaved_array, len(unsaved_files), options) - if ptr is None: + if not ptr: raise TranslationUnitLoadError("Error parsing translation unit.") return cls(ptr, index=index) @@ -2037,7 +2067,7 @@ class TranslationUnit(ClangObject): index = Index.create() ptr = conf.lib.clang_createTranslationUnit(index, filename) - if ptr is None: + if not ptr: raise TranslationUnitLoadError(filename) return cls(ptr=ptr, index=index) @@ -2623,6 +2653,10 @@ functionList = [ [Type], c_longlong), + ("clang_getFieldDeclBitWidth", + [Cursor], + c_int), + ("clang_getCanonicalCursor", [Cursor], Cursor, @@ -3038,6 +3072,22 @@ functionList = [ [Cursor, c_uint], Cursor, Cursor.from_result), + + ("clang_Cursor_isBitField", + [Cursor], + bool), + + ("clang_Type_getAlignOf", + [Type], + c_longlong), + + ("clang_Type_getOffsetOf", + [Type, c_char_p], + c_longlong), + + ("clang_Type_getSizeOf", + [Type], + c_ulonglong), ] class LibclangError(Exception): |