summaryrefslogtreecommitdiff
path: root/bindings
diff options
context:
space:
mode:
Diffstat (limited to 'bindings')
-rw-r--r--bindings/python/clang/cindex.py11
-rw-r--r--bindings/python/tests/cindex/test_cursor.py16
2 files changed, 26 insertions, 1 deletions
diff --git a/bindings/python/clang/cindex.py b/bindings/python/clang/cindex.py
index 5e70bde770f85..236803a9ab9b1 100644
--- a/bindings/python/clang/cindex.py
+++ b/bindings/python/clang/cindex.py
@@ -782,7 +782,7 @@ CursorKind.CONVERSION_FUNCTION = CursorKind(26)
# A C++ template type parameter
CursorKind.TEMPLATE_TYPE_PARAMETER = CursorKind(27)
-# A C++ non-type template paramater.
+# A C++ non-type template parameter.
CursorKind.TEMPLATE_NON_TYPE_PARAMETER = CursorKind(28)
# A C++ template template parameter.
@@ -1478,6 +1478,11 @@ class Cursor(Structure):
"""
return conf.lib.clang_CXXMethod_isVirtual(self)
+ def is_scoped_enum(self):
+ """Returns True if the cursor refers to a scoped enum declaration.
+ """
+ return conf.lib.clang_EnumDecl_isScoped(self)
+
def get_definition(self):
"""
If the cursor is a reference to a declaration or a declaration of
@@ -3314,6 +3319,10 @@ functionList = [
[Cursor],
bool),
+ ("clang_EnumDecl_isScoped",
+ [Cursor],
+ bool),
+
("clang_defaultDiagnosticDisplayOptions",
[],
c_uint),
diff --git a/bindings/python/tests/cindex/test_cursor.py b/bindings/python/tests/cindex/test_cursor.py
index 8103e96df4f9e..4787ea931e13b 100644
--- a/bindings/python/tests/cindex/test_cursor.py
+++ b/bindings/python/tests/cindex/test_cursor.py
@@ -255,6 +255,22 @@ def test_is_virtual_method():
assert foo.is_virtual_method()
assert not bar.is_virtual_method()
+def test_is_scoped_enum():
+ """Ensure Cursor.is_scoped_enum works."""
+ source = 'class X {}; enum RegularEnum {}; enum class ScopedEnum {};'
+ tu = get_tu(source, lang='cpp')
+
+ cls = get_cursor(tu, 'X')
+ regular_enum = get_cursor(tu, 'RegularEnum')
+ scoped_enum = get_cursor(tu, 'ScopedEnum')
+ assert cls is not None
+ assert regular_enum is not None
+ assert scoped_enum is not None
+
+ assert not cls.is_scoped_enum()
+ assert not regular_enum.is_scoped_enum()
+ assert scoped_enum.is_scoped_enum()
+
def test_underlying_type():
tu = get_tu('typedef int foo;')
typedef = get_cursor(tu, 'foo')