diff options
Diffstat (limited to 'bindings/python/clang/cindex.py')
-rw-r--r-- | bindings/python/clang/cindex.py | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/bindings/python/clang/cindex.py b/bindings/python/clang/cindex.py index 5792eff..f5caca8 100644 --- a/bindings/python/clang/cindex.py +++ b/bindings/python/clang/cindex.py @@ -1476,6 +1476,18 @@ class Cursor(Structure): """ return TokenGroup.get_tokens(self._tu, self.extent) + def get_field_offsetof(self): + """Returns the offsetof the FIELD_DECL pointed by this Cursor.""" + return conf.lib.clang_Cursor_getOffsetOfField(self) + + def is_anonymous(self): + """ + Check if the record is anonymous. + """ + if self.kind == CursorKind.FIELD_DECL: + return self.type.get_declaration().is_anonymous() + return conf.lib.clang_Cursor_isAnonymous(self) + def is_bitfield(self): """ Check if the field is a bitfield. @@ -1884,6 +1896,21 @@ class Type(Structure): return RefQualifierKind.from_id( conf.lib.clang_Type_getCXXRefQualifier(self)) + def get_fields(self): + """Return an iterator for accessing the fields of this type.""" + + def visitor(field, children): + assert field != conf.lib.clang_getNullCursor() + + # Create reference to TU so it isn't GC'd before Cursor. + field._tu = self._tu + fields.append(field) + return 1 # continue + fields = [] + conf.lib.clang_Type_visitFields(self, + callbacks['fields_visit'](visitor), fields) + return iter(fields) + @property def spelling(self): """Retrieve the spelling of this Type.""" @@ -2780,6 +2807,7 @@ class Token(Structure): callbacks['translation_unit_includes'] = CFUNCTYPE(None, c_object_p, POINTER(SourceLocation), c_uint, py_object) callbacks['cursor_visit'] = CFUNCTYPE(c_int, Cursor, Cursor, py_object) +callbacks['fields_visit'] = CFUNCTYPE(c_int, Cursor, py_object) # Functions strictly alphabetical order. functionList = [ @@ -3367,6 +3395,10 @@ functionList = [ [Cursor, c_uint], c_ulonglong), + ("clang_Cursor_isAnonymous", + [Cursor], + bool), + ("clang_Cursor_isBitField", [Cursor], bool), @@ -3381,6 +3413,10 @@ functionList = [ _CXString, _CXString.from_result), + ("clang_Cursor_getOffsetOfField", + [Cursor], + c_longlong), + ("clang_Type_getAlignOf", [Type], c_longlong), @@ -3401,6 +3437,10 @@ functionList = [ ("clang_Type_getCXXRefQualifier", [Type], c_uint), + + ("clang_Type_visitFields", + [Type, callbacks['fields_visit'], py_object], + c_uint), ] class LibclangError(Exception): |