diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2013-10-11 19:58:38 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2013-10-11 19:58:38 +0000 |
commit | 659837e0ce0f73c7fdd5941854be3500db2f4013 (patch) | |
tree | e554d7dbe056decd00ae557bae3a0ee0991f9e5d /bindings | |
parent | 1d82b1a33bcfe85f4834fb6920517ed07e9355d3 (diff) |
[libclang] Introduce clang_Type_getCXXRefQualifier whichexposes ref-qualifier information of function type.
Patch by Che-Liang Chiou!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@192493 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'bindings')
-rw-r--r-- | bindings/python/clang/cindex.py | 65 |
1 files changed, 60 insertions, 5 deletions
diff --git a/bindings/python/clang/cindex.py b/bindings/python/clang/cindex.py index 5710d7fe28..cbce1a2d3f 100644 --- a/bindings/python/clang/cindex.py +++ b/bindings/python/clang/cindex.py @@ -1499,6 +1499,50 @@ TypeKind.VARIABLEARRAY = TypeKind(115) TypeKind.DEPENDENTSIZEDARRAY = TypeKind(116) TypeKind.MEMBERPOINTER = TypeKind(117) +class RefQualifierKind(object): + """Describes a specific ref-qualifier of a type.""" + + # The unique kind objects, indexed by id. + _kinds = [] + _name_map = None + + def __init__(self, value): + if value >= len(RefQualifierKind._kinds): + num_kinds = value - len(RefQualifierKind._kinds) + 1 + RefQualifierKind._kinds += [None] * num_kinds + if RefQualifierKind._kinds[value] is not None: + raise ValueError, 'RefQualifierKind already loaded' + self.value = value + RefQualifierKind._kinds[value] = self + RefQualifierKind._name_map = None + + def from_param(self): + return self.value + + @property + def name(self): + """Get the enumeration name of this kind.""" + if self._name_map is None: + self._name_map = {} + for key, value in RefQualifierKind.__dict__.items(): + if isinstance(value, RefQualifierKind): + self._name_map[value] = key + return self._name_map[self] + + @staticmethod + def from_id(id): + if (id >= len(RefQualifierKind._kinds) or + RefQualifierKind._kinds[id] is None): + raise ValueError, 'Unknown type kind %d' % id + return RefQualifierKind._kinds[id] + + def __repr__(self): + return 'RefQualifierKind.%s' % (self.name,) + +RefQualifierKind.NONE = RefQualifierKind(0) +RefQualifierKind.LVALUE = RefQualifierKind(1) +RefQualifierKind.RVALUE = RefQualifierKind(2) + class Type(Structure): """ The type of an element in the abstract syntax tree. @@ -1697,6 +1741,13 @@ class Type(Structure): """ return conf.lib.clang_Type_getOffsetOf(self, c_char_p(fieldname)) + def get_ref_qualifier(self): + """ + Retrieve the ref-qualifier of the type. + """ + return RefQualifierKind.from_id( + conf.lib.clang_Type_getCXXRefQualifier(self)) + @property def spelling(self): """Retrieve the spelling of this Type.""" @@ -2716,11 +2767,6 @@ functionList = [ [Type], c_longlong), - ("clang_Type_getClassType", - [Type], - Type, - Type.from_result), - ("clang_getFieldDeclBitWidth", [Cursor], c_int), @@ -3164,6 +3210,11 @@ functionList = [ [Type], c_longlong), + ("clang_Type_getClassType", + [Type], + Type, + Type.from_result), + ("clang_Type_getOffsetOf", [Type, c_char_p], c_longlong), @@ -3171,6 +3222,10 @@ functionList = [ ("clang_Type_getSizeOf", [Type], c_longlong), + + ("clang_Type_getCXXRefQualifier", + [Type], + c_uint), ] class LibclangError(Exception): |