aboutsummaryrefslogtreecommitdiff
path: root/bindings
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2012-05-03 16:53:59 +0000
committerDimitry Andric <dim@FreeBSD.org>2012-05-03 16:53:59 +0000
commit6b9a6e390fbb92c40eb9c6ac9e7abbd88dd7a767 (patch)
tree2e51705e103e92c7be1b21e8bd8ffd5b5d0e4d52 /bindings
parentdbe13110f59f48b4dbb7552b3ac2935acdeece7f (diff)
downloadsrc-6b9a6e390fbb92c40eb9c6ac9e7abbd88dd7a767.tar.gz
src-6b9a6e390fbb92c40eb9c6ac9e7abbd88dd7a767.zip
Vendor import of clang release_31 branch r155985:vendor/clang/clang-release_31-r155985
Notes
Notes: svn path=/vendor/clang/dist/; revision=234973 svn path=/vendor/clang/clang-release_31-r155985/; revision=234974; tag=vendor/clang/clang-release_31-r155985
Diffstat (limited to 'bindings')
-rw-r--r--bindings/python/clang/cindex.py9
-rw-r--r--bindings/python/tests/cindex/test_type.py9
2 files changed, 17 insertions, 1 deletions
diff --git a/bindings/python/clang/cindex.py b/bindings/python/clang/cindex.py
index b4563eb0c624..6f0d25f1a8f5 100644
--- a/bindings/python/clang/cindex.py
+++ b/bindings/python/clang/cindex.py
@@ -1079,6 +1079,11 @@ class TypeKind(object):
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:
@@ -1088,6 +1093,10 @@ class TypeKind(object):
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)
diff --git a/bindings/python/tests/cindex/test_type.py b/bindings/python/tests/cindex/test_type.py
index ed852103b94a..03621f3017c7 100644
--- a/bindings/python/tests/cindex/test_type.py
+++ b/bindings/python/tests/cindex/test_type.py
@@ -1,5 +1,4 @@
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
@@ -109,6 +108,14 @@ def test_equal():
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);')