---
 bindings/python/clang/cindex.py                  |   24 ++++++++++++++++++++++
 bindings/python/tests/cindex/test_cursor_kind.py |    9 ++++++++
 2 files changed, 33 insertions(+), 0 deletions(-)
diff --git a/bindings/python/clang/cindex.py b/bindings/python/clang/cindex.py
index 4c9f96d..38f117b 100644
--- a/bindings/python/clang/cindex.py
+++ b/bindings/python/clang/cindex.py
@@ -374,16 +374,28 @@ class CursorKind(object):
     def is_attribute(self):
         """Test if this is an attribute kind."""
         return CursorKind_is_attribute(self)
 
     def is_invalid(self):
         """Test if this is an invalid kind."""
         return CursorKind_is_inv(self)
 
+    def is_translation_unit(self):
+        """Test if this is a translation unit kind."""
+        return CursorKind_is_translation_unit(self)
+
+    def is_preprocessing(self):
+        """Test if this is a preprocessing kind."""
+        return CursorKind_is_preprocessing(self)
+
+    def is_unexposed(self):
+        """Test if this is an unexposed kind."""
+        return CursorKind_is_unexposed(self)
+
     def __repr__(self):
         return 'CursorKind.%s' % (self.name,)
 
 # FIXME: Is there a nicer way to expose this enumeration? We could potentially
 # represent the nested structure, or even build a class hierarchy. The main
 # things we want for sure are (a) simple external access to kinds, (b) a place
 # to hang a description and name, (c) easy to keep in sync with Index.h.
 
@@ -1711,16 +1723,28 @@ CursorKind_is_stmt.restype = bool
 CursorKind_is_attribute = lib.clang_isAttribute
 CursorKind_is_attribute.argtypes = [CursorKind]
 CursorKind_is_attribute.restype = bool
 
 CursorKind_is_inv = lib.clang_isInvalid
 CursorKind_is_inv.argtypes = [CursorKind]
 CursorKind_is_inv.restype = bool
 
+CursorKind_is_translation_unit = lib.clang_isTranslationUnit
+CursorKind_is_translation_unit.argtypes = [CursorKind]
+CursorKind_is_translation_unit.restype = bool
+
+CursorKind_is_preprocessing = lib.clang_isPreprocessing
+CursorKind_is_preprocessing.argtypes = [CursorKind]
+CursorKind_is_preprocessing.restype = bool
+
+CursorKind_is_unexposed = lib.clang_isUnexposed
+CursorKind_is_unexposed.argtypes = [CursorKind]
+CursorKind_is_unexposed.restype = bool
+
 # Cursor Functions
 # TODO: Implement this function
 Cursor_get = lib.clang_getCursor
 Cursor_get.argtypes = [TranslationUnit, SourceLocation]
 Cursor_get.restype = Cursor
 
 Cursor_null = lib.clang_getNullCursor
 Cursor_null.restype = Cursor
diff --git a/bindings/python/tests/cindex/test_cursor_kind.py b/bindings/python/tests/cindex/test_cursor_kind.py
index d7a1cfa..f8466e5 100644
--- a/bindings/python/tests/cindex/test_cursor_kind.py
+++ b/bindings/python/tests/cindex/test_cursor_kind.py
@@ -11,16 +11,25 @@ def test_kind_groups():
     """Check that every kind classifies to exactly one group."""
 
     assert CursorKind.UNEXPOSED_DECL.is_declaration()
     assert CursorKind.TYPE_REF.is_reference()
     assert CursorKind.DECL_REF_EXPR.is_expression()
     assert CursorKind.UNEXPOSED_STMT.is_statement()
     assert CursorKind.INVALID_FILE.is_invalid()
 
+    assert CursorKind.TRANSLATION_UNIT.is_translation_unit()
+    assert not CursorKind.TYPE_REF.is_translation_unit()
+
+    assert CursorKind.PREPROCESSING_DIRECTIVE.is_preprocessing()
+    assert not CursorKind.TYPE_REF.is_preprocessing()
+
+    assert CursorKind.UNEXPOSED_DECL.is_unexposed()
+    assert not CursorKind.TYPE_REF.is_unexposed()
+
     for k in CursorKind.get_all_kinds():
         group = [n for n in ('is_declaration', 'is_reference', 'is_expression',
                              'is_statement', 'is_invalid', 'is_attribute')
                  if getattr(k, n)()]
 
         if k in (   CursorKind.TRANSLATION_UNIT,
                     CursorKind.MACRO_DEFINITION,
                     CursorKind.MACRO_INSTANTIATION,
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to