summaryrefslogtreecommitdiffstats
path: root/clang/bindings/python
diff options
context:
space:
mode:
Diffstat (limited to 'clang/bindings/python')
-rw-r--r--clang/bindings/python/clang/cindex.py30
-rw-r--r--clang/bindings/python/tests/cindex/test_type.py16
2 files changed, 46 insertions, 0 deletions
diff --git a/clang/bindings/python/clang/cindex.py b/clang/bindings/python/clang/cindex.py
index be65ebe39a5..5710d7fe28e 100644
--- a/clang/bindings/python/clang/cindex.py
+++ b/clang/bindings/python/clang/cindex.py
@@ -1316,6 +1316,16 @@ class Cursor(Structure):
return self._referenced
+ @property
+ def brief_comment(self):
+ """Returns the brief comment text associated with that Cursor"""
+ return conf.lib.clang_Cursor_getBriefCommentText(self)
+
+ @property
+ def raw_comment(self):
+ """Returns the raw comment text associated with that Cursor"""
+ return conf.lib.clang_Cursor_getRawCommentText(self)
+
def get_arguments(self):
"""Return an iterator for accessing the arguments of this cursor."""
num_args = conf.lib.clang_Cursor_getNumArguments(self)
@@ -1687,6 +1697,11 @@ class Type(Structure):
"""
return conf.lib.clang_Type_getOffsetOf(self, c_char_p(fieldname))
+ @property
+ def spelling(self):
+ """Retrieve the spelling of this Type."""
+ return conf.lib.clang_getTypeSpelling(self)
+
def __eq__(self, other):
if type(other) != type(self):
return False
@@ -3026,6 +3041,11 @@ functionList = [
_CXString,
_CXString.from_result),
+ ("clang_getTypeSpelling",
+ [Type],
+ _CXString,
+ _CXString.from_result),
+
("clang_hashCursor",
[Cursor],
c_uint),
@@ -3130,6 +3150,16 @@ functionList = [
[Cursor],
bool),
+ ("clang_Cursor_getBriefCommentText",
+ [Cursor],
+ _CXString,
+ _CXString.from_result),
+
+ ("clang_Cursor_getRawCommentText",
+ [Cursor],
+ _CXString,
+ _CXString.from_result),
+
("clang_Type_getAlignOf",
[Type],
c_longlong),
diff --git a/clang/bindings/python/tests/cindex/test_type.py b/clang/bindings/python/tests/cindex/test_type.py
index 62968d6285f..a02c06fe5a1 100644
--- a/clang/bindings/python/tests/cindex/test_type.py
+++ b/clang/bindings/python/tests/cindex/test_type.py
@@ -132,6 +132,22 @@ def test_equal():
assert a.type != None
assert a.type != 'foo'
+def test_type_spelling():
+ """Ensure Type.spelling works."""
+ tu = get_tu('int c[5]; int i[]; int x; int v[x];')
+ c = get_cursor(tu, 'c')
+ i = get_cursor(tu, 'i')
+ x = get_cursor(tu, 'x')
+ v = get_cursor(tu, 'v')
+ assert c is not None
+ assert i is not None
+ assert x is not None
+ assert v is not None
+ assert c.type.spelling == "int [5]"
+ assert i.type.spelling == "int []"
+ assert x.type.spelling == "int"
+ assert v.type.spelling == "int [x]"
+
def test_typekind_spelling():
"""Ensure TypeKind.spelling works."""
tu = get_tu('int a;')
OpenPOWER on IntegriCloud