From: Argyrios Kyrtzidis Date: Thu, 3 Oct 2013 16:19:27 +0000 (+0000) Subject: [libclang] python: expose a few functions, patch by Loïc Jaquemet! X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c23cb2d3e8af8354d43517283d3efb2cb0681f49;p=clang [libclang] python: expose a few functions, patch by Loïc Jaquemet! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@191907 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/bindings/python/clang/cindex.py b/bindings/python/clang/cindex.py index be65ebe39a..5710d7fe28 100644 --- a/bindings/python/clang/cindex.py +++ b/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/bindings/python/tests/cindex/test_type.py b/bindings/python/tests/cindex/test_type.py index 62968d6285..a02c06fe5a 100644 --- a/bindings/python/tests/cindex/test_type.py +++ b/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;')