diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2013-04-11 01:20:11 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2013-04-11 01:20:11 +0000 |
commit | 411d33aa0b0d3bc9b2faec40cd821bdd836094ab (patch) | |
tree | ad773459e753fb37a1418cf90c351148e0a698c1 /bindings/python/clang/cindex.py | |
parent | 1fd1e288d0f45b86d191d8f53f569e5143f3a18a (diff) |
[libclang] Expose record layout info via new libclang functions:
clang_Type_getAlignOf
clang_Type_getSizeOf
clang_Type_getOffsetOf
clang_Cursor_isBitField
Patch by Loïc Jaquemet!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@179251 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'bindings/python/clang/cindex.py')
-rw-r--r-- | bindings/python/clang/cindex.py | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/bindings/python/clang/cindex.py b/bindings/python/clang/cindex.py index 70f4f36a2c..36761bd859 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 @@ -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], + c_long), + + ("clang_Type_getAlignOf", + [Type], + c_longlong), + + ("clang_Type_getOffsetOf", + [Type, c_char_p], + c_longlong), + + ("clang_Type_getSizeOf", + [Type], + c_ulonglong), ] class LibclangError(Exception): |