summaryrefslogtreecommitdiffstats
path: root/bindings
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2013-06-11 18:05:42 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2013-06-11 18:05:42 +0000
commitda6a6f087b70cdac18c37028f8cff707f10f91cf (patch)
treee4d2832e63e6bdb25cf697a0574f73a035e0a328 /bindings
parent605c59a1d1a11112c643031770c616e2e441c349 (diff)
[libclang/python] Add a few "cursor kinds" that were missing in the python binding for libclang.
Patch by Mathieu Baudet! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@183760 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'bindings')
-rw-r--r--bindings/python/clang/cindex.py39
-rw-r--r--bindings/python/tests/cindex/test_cursor_kind.py11
2 files changed, 45 insertions, 5 deletions
diff --git a/bindings/python/clang/cindex.py b/bindings/python/clang/cindex.py
index f2e752aed0..8316b1ff9f 100644
--- a/bindings/python/clang/cindex.py
+++ b/bindings/python/clang/cindex.py
@@ -508,7 +508,7 @@ class CursorKind(object):
@staticmethod
def from_id(id):
if id >= len(CursorKind._kinds) or CursorKind._kinds[id] is None:
- raise ValueError,'Unknown cursor kind'
+ raise ValueError,'Unknown cursor kind %d' % id
return CursorKind._kinds[id]
@staticmethod
@@ -721,10 +721,14 @@ CursorKind.MEMBER_REF = CursorKind(47)
# A reference to a labeled statement.
CursorKind.LABEL_REF = CursorKind(48)
-# A reference toa a set of overloaded functions or function templates
+# A reference to a set of overloaded functions or function templates
# that has not yet been resolved to a specific function or function template.
CursorKind.OVERLOADED_DECL_REF = CursorKind(49)
+# A reference to a variable that occurs in some non-expression
+# context, e.g., a C++ lambda capture list.
+CursorKind.VARIABLE_REF = CursorKind(50)
+
###
# Invalid/Error Kinds
@@ -908,6 +912,26 @@ CursorKind.PACK_EXPANSION_EXPR = CursorKind(142)
# pack.
CursorKind.SIZE_OF_PACK_EXPR = CursorKind(143)
+# Represents a C++ lambda expression that produces a local function
+# object.
+#
+# \code
+# void abssort(float *x, unsigned N) {
+# std::sort(x, x + N,
+# [](float a, float b) {
+# return std::abs(a) < std::abs(b);
+# });
+# }
+# \endcode
+CursorKind.LAMBDA_EXPR = CursorKind(144)
+
+# Objective-c Boolean Literal.
+CursorKind.OBJ_BOOL_LITERAL_EXPR = CursorKind(145)
+
+# Represents the "self" expression in a ObjC method.
+CursorKind.OBJ_SELF_EXPR = CursorKind(146)
+
+
# A statement whose specific kind is not exposed via this interface.
#
# Unexposed statements have the same operations as any other kind of statement;
@@ -999,6 +1023,9 @@ CursorKind.SEH_EXCEPT_STMT = CursorKind(227)
# Windows Structured Exception Handling's finally statement.
CursorKind.SEH_FINALLY_STMT = CursorKind(228)
+# A MS inline assembly statement extension.
+CursorKind.MS_ASM_STMT = CursorKind(229)
+
# The null statement.
CursorKind.NULL_STMT = CursorKind(230)
@@ -1036,6 +1063,12 @@ CursorKind.MACRO_DEFINITION = CursorKind(501)
CursorKind.MACRO_INSTANTIATION = CursorKind(502)
CursorKind.INCLUSION_DIRECTIVE = CursorKind(503)
+###
+# Extra declaration
+
+# A module import declaration.
+CursorKind.MODULE_IMPORT_DECL = CursorKind(600)
+
### Cursors ###
class Cursor(Structure):
@@ -1918,7 +1951,7 @@ class Index(ClangObject):
def read(self, path):
"""Load a TranslationUnit from the given AST file."""
- return TranslationUnit.from_ast(path, self)
+ return TranslationUnit.from_ast_file(path, self)
def parse(self, path, args=None, unsaved_files=None, options = 0):
"""Load the translation unit from the given source code file by running
diff --git a/bindings/python/tests/cindex/test_cursor_kind.py b/bindings/python/tests/cindex/test_cursor_kind.py
index f8466e5e0d..8cabc512d4 100644
--- a/bindings/python/tests/cindex/test_cursor_kind.py
+++ b/bindings/python/tests/cindex/test_cursor_kind.py
@@ -4,8 +4,15 @@ def test_name():
assert CursorKind.UNEXPOSED_DECL.name is 'UNEXPOSED_DECL'
def test_get_all_kinds():
- assert CursorKind.UNEXPOSED_DECL in CursorKind.get_all_kinds()
- assert CursorKind.TRANSLATION_UNIT in CursorKind.get_all_kinds()
+ kinds = CursorKind.get_all_kinds()
+ assert CursorKind.UNEXPOSED_DECL in kinds
+ assert CursorKind.TRANSLATION_UNIT in kinds
+ assert CursorKind.VARIABLE_REF in kinds
+ assert CursorKind.LAMBDA_EXPR in kinds
+ assert CursorKind.OBJ_BOOL_LITERAL_EXPR in kinds
+ assert CursorKind.OBJ_SELF_EXPR in kinds
+ assert CursorKind.MS_ASM_STMT in kinds
+ assert CursorKind.MODULE_IMPORT_DECL in kinds
def test_kind_groups():
"""Check that every kind classifies to exactly one group."""