diff options
author | Tobias Grosser <grosser@fim.uni-passau.de> | 2012-02-05 11:42:09 +0000 |
---|---|---|
committer | Tobias Grosser <grosser@fim.uni-passau.de> | 2012-02-05 11:42:09 +0000 |
commit | eb13634e3914ce997f7e2ea5d3e585c79e9e9b4c (patch) | |
tree | 670f89022a1a963a06dbfc475c89286466f9363c /bindings/python | |
parent | 64e7bdc1d4c8c2f40f32e699014e85fbe1be57f7 (diff) |
[clang.py] Add CursorKind.{is_translation_unit, is_preprocessing, is_unexposed}
Contributed by: Gregory Szorc <gregory.szorc@gmail.com>
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149827 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'bindings/python')
-rw-r--r-- | bindings/python/clang/cindex.py | 24 | ||||
-rw-r--r-- | 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 4c9f96ddb3..38f117bb1d 100644 --- a/bindings/python/clang/cindex.py +++ b/bindings/python/clang/cindex.py @@ -379,6 +379,18 @@ class CursorKind(object): """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,) @@ -1716,6 +1728,18 @@ 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 diff --git a/bindings/python/tests/cindex/test_cursor_kind.py b/bindings/python/tests/cindex/test_cursor_kind.py index d7a1cfad8f..f8466e5e0d 100644 --- a/bindings/python/tests/cindex/test_cursor_kind.py +++ b/bindings/python/tests/cindex/test_cursor_kind.py @@ -16,6 +16,15 @@ def test_kind_groups(): 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') |