---
 bindings/python/clang/cindex.py           |    9 +++++++++
 bindings/python/tests/cindex/test_type.py |    9 ++++++++-
 2 files changed, 17 insertions(+), 1 deletions(-)
diff --git a/bindings/python/clang/cindex.py b/bindings/python/clang/cindex.py
index a8d715e..7d6001d 100644
--- a/bindings/python/clang/cindex.py
+++ b/bindings/python/clang/cindex.py
@@ -1074,25 +1074,34 @@ class TypeKind(object):
         """Get the enumeration name of this cursor kind."""
         if self._name_map is None:
             self._name_map = {}
             for key,value in TypeKind.__dict__.items():
                 if isinstance(value,TypeKind):
                     self._name_map[value] = key
         return self._name_map[self]
 
+    @property
+    def spelling(self):
+        """Retrieve the spelling of this TypeKind."""
+        return TypeKind_spelling(self.value)
+
     @staticmethod
     def from_id(id):
         if id >= len(TypeKind._kinds) or TypeKind._kinds[id] is None:
             raise ValueError,'Unknown type kind %d' % id
         return TypeKind._kinds[id]
 
     def __repr__(self):
         return 'TypeKind.%s' % (self.name,)
 
+TypeKind_spelling = lib.clang_getTypeKindSpelling
+TypeKind_spelling.argtypes = [c_uint]
+TypeKind_spelling.restype = _CXString
+TypeKind_spelling.errcheck = _CXString.from_result
 
 
 TypeKind.INVALID = TypeKind(0)
 TypeKind.UNEXPOSED = TypeKind(1)
 TypeKind.VOID = TypeKind(2)
 TypeKind.BOOL = TypeKind(3)
 TypeKind.CHAR_U = TypeKind(4)
 TypeKind.UCHAR = TypeKind(5)
diff --git a/bindings/python/tests/cindex/test_type.py b/bindings/python/tests/cindex/test_type.py
index ed85210..03621f3 100644
--- a/bindings/python/tests/cindex/test_type.py
+++ b/bindings/python/tests/cindex/test_type.py
@@ -1,10 +1,9 @@
 from clang.cindex import CursorKind
-from clang.cindex import Index
 from clang.cindex import TypeKind
 from nose.tools import raises
 from .util import get_cursor
 from .util import get_tu
 
 kInput = """\
 
 typedef int I;
@@ -104,16 +103,24 @@ def test_equal():
     assert v is not None
 
     assert a.type == b.type
     assert a.type != v.type
 
     assert a.type != None
     assert a.type != 'foo'
 
+def test_typekind_spelling():
+    """Ensure TypeKind.spelling works."""
+    tu = get_tu('int a;')
+    a = get_cursor(tu, 'a')
+
+    assert a is not None
+    assert a.type.kind.spelling == 'Int'
+
 def test_function_argument_types():
     """Ensure that Type.argument_types() works as expected."""
     tu = get_tu('void f(int, int);')
     f = get_cursor(tu, 'f')
     assert f is not None
 
     args = f.type.argument_types()
     assert args is not None
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to