]> granicus.if.org Git - clang/commitdiff
[libclang/python] Add a few "cursor kinds" that were missing in the python binding...
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Tue, 11 Jun 2013 18:05:42 +0000 (18:05 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Tue, 11 Jun 2013 18:05:42 +0000 (18:05 +0000)
Patch by Mathieu Baudet!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@183760 91177308-0d34-0410-b5e6-96231b3b80d8

bindings/python/clang/cindex.py
bindings/python/tests/cindex/test_cursor_kind.py

index f2e752aed00d353e28dde428fb53ec95a20a1066..8316b1ff9fcd9f174820bf602e46f079e1c1e62e 100644 (file)
@@ -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
index f8466e5e0d1d655102cf7e03e7c93de90e38a245..8cabc512d4c5a123a75a99a71e955acc3c2af5e0 100644 (file)
@@ -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."""