aboutsummaryrefslogtreecommitdiff
path: root/bindings/python/clang/cindex.py
diff options
context:
space:
mode:
authorTobias Grosser <grosser@fim.uni-passau.de>2012-02-05 11:42:25 +0000
committerTobias Grosser <grosser@fim.uni-passau.de>2012-02-05 11:42:25 +0000
commiteb9ff2ea9ed829809cb177e74238301cfc2750ca (patch)
tree4490582b7b3cbe8486e978e05759aba8987c9de9 /bindings/python/clang/cindex.py
parent28d939ffd6877f8a2c6a5b6704df792319f3878e (diff)
[clang.py] Implement Cursor.enum_type
Contributed by: Gregory Szorc <gregory.szorc@gmail.com> git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149830 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'bindings/python/clang/cindex.py')
-rw-r--r--bindings/python/clang/cindex.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/bindings/python/clang/cindex.py b/bindings/python/clang/cindex.py
index 4c819c26fe..8629213207 100644
--- a/bindings/python/clang/cindex.py
+++ b/bindings/python/clang/cindex.py
@@ -995,6 +995,19 @@ class Cursor(Structure):
return self._underlying_type
@property
+ def enum_type(self):
+ """Return the integer type of an enum declaration.
+
+ Returns a type corresponding to an integer. If the cursor is not for an
+ enum, this raises.
+ """
+ if not hasattr(self, '_enum_type'):
+ assert self.kind == CursorKind.ENUM_DECL
+ self._enum_type = Cursor_enum_type(self)
+
+ return self._enum_type
+
+ @property
def hash(self):
"""Returns a hash of the cursor as an int."""
if not hasattr(self, '_hash'):
@@ -1818,6 +1831,11 @@ Cursor_underlying_type.argtypes = [Cursor]
Cursor_underlying_type.restype = Type
Cursor_underlying_type.errcheck = Type.from_result
+Cursor_enum_type = lib.clang_getEnumDeclIntegerType
+Cursor_enum_type.argtypes = [Cursor]
+Cursor_enum_type.restype = Type
+Cursor_enum_type.errcheck = Type.from_result
+
Cursor_visit_callback = CFUNCTYPE(c_int, Cursor, Cursor, py_object)
Cursor_visit = lib.clang_visitChildren
Cursor_visit.argtypes = [Cursor, Cursor_visit_callback, py_object]