[clang] [libclang/python] Refactor enum usage (PR #95608)
Jannick Kremer via cfe-commits
cfe-commits at lists.llvm.org
Thu Jul 11 08:23:40 PDT 2024
https://github.com/DeinAlptraum updated https://github.com/llvm/llvm-project/pull/95608
>From 35bfcfbc69ee812c59350440b7b15c5e23ad1307 Mon Sep 17 00:00:00 2001
From: Jannick Kremer <jannick-kremer at gmx.de>
Date: Fri, 14 Jun 2024 22:12:09 +0100
Subject: [PATCH 1/5] [libclang/python] Refactor enum usage
Use Python's builtin enum class instead of writing our own.
This is preparation for strict typing in PR #78114
---
clang/bindings/python/clang/cindex.py | 1670 ++++++++---------
.../python/tests/cindex/test_enums.py | 14 +-
2 files changed, 768 insertions(+), 916 deletions(-)
diff --git a/clang/bindings/python/clang/cindex.py b/clang/bindings/python/clang/cindex.py
index b3d51e4d2a668..aacfc333723c4 100644
--- a/clang/bindings/python/clang/cindex.py
+++ b/clang/bindings/python/clang/cindex.py
@@ -68,6 +68,7 @@
import collections.abc
import os
+from enum import Enum
# Python 3 strings are unicode, translate them to/from utf8 for C-interop.
@@ -611,51 +612,25 @@ def register(value, name):
### Cursor Kinds ###
-class BaseEnumeration:
+class BaseEnumeration(Enum):
"""
Common base class for named enumerations held in sync with Index.h values.
-
- Subclasses must define their own _kinds and _name_map members, as:
- _kinds = []
- _name_map = None
- These values hold the per-subclass instances and value-to-name mappings,
- respectively.
-
"""
- def __init__(self, value):
- if value >= len(self.__class__._kinds):
- self.__class__._kinds += [None] * (value - len(self.__class__._kinds) + 1)
- if self.__class__._kinds[value] is not None:
- raise ValueError(
- "{0} value {1} already loaded".format(str(self.__class__), value)
- )
- self.value = value
- self.__class__._kinds[value] = self
- self.__class__._name_map = None
def from_param(self):
return self.value
- @property
- def name(self):
- """Get the enumeration name of this cursor kind."""
- if self._name_map is None:
- self._name_map = {}
- for key, value in self.__class__.__dict__.items():
- if isinstance(value, self.__class__):
- self._name_map[value] = key
- return self._name_map[self]
-
@classmethod
def from_id(cls, id):
- if id < 0 or id >= len(cls._kinds) or cls._kinds[id] is None:
- raise ValueError("Unknown template argument kind %d" % id)
- return cls._kinds[id]
+ try:
+ return cls(id)
+ except ValueError:
+ raise ValueError("Unknown %s %d" % (cls.__name__, id)) from None
def __repr__(self):
return "%s.%s" % (
- self.__class__,
+ self.__class__.__name__,
self.name,
)
@@ -665,14 +640,10 @@ class CursorKind(BaseEnumeration):
A CursorKind describes the kind of entity that a cursor points to.
"""
- # The required BaseEnumeration declarations.
- _kinds = []
- _name_map = None
-
@staticmethod
def get_all_kinds():
"""Return all CursorKind enumeration instances."""
- return [x for x in CursorKind._kinds if not x is None]
+ return list(CursorKind)
def is_declaration(self):
"""Test if this is a declaration kind."""
@@ -710,822 +681,820 @@ def is_unexposed(self):
"""Test if this is an unexposed kind."""
return conf.lib.clang_isUnexposed(self)
- def __repr__(self):
- return "CursorKind.%s" % (self.name,)
-
-###
-# Declaration Kinds
+ ###
+ # Declaration Kinds
-# A declaration whose specific kind is not exposed via this interface.
-#
-# Unexposed declarations have the same operations as any other kind of
-# declaration; one can extract their location information, spelling, find their
-# definitions, etc. However, the specific kind of the declaration is not
-# reported.
-CursorKind.UNEXPOSED_DECL = CursorKind(1)
+ # A declaration whose specific kind is not exposed via this interface.
+ #
+ # Unexposed declarations have the same operations as any other kind of
+ # declaration; one can extract their location information, spelling, find
+ # their definitions, etc. However, the specific kind of the declaration is
+ # not reported.
+ UNEXPOSED_DECL = 1
-# A C or C++ struct.
-CursorKind.STRUCT_DECL = CursorKind(2)
+ # A C or C++ struct.
+ STRUCT_DECL = 2
-# A C or C++ union.
-CursorKind.UNION_DECL = CursorKind(3)
+ # A C or C++ union.
+ UNION_DECL = 3
-# A C++ class.
-CursorKind.CLASS_DECL = CursorKind(4)
+ # A C++ class.
+ CLASS_DECL = 4
-# An enumeration.
-CursorKind.ENUM_DECL = CursorKind(5)
+ # An enumeration.
+ ENUM_DECL = 5
-# A field (in C) or non-static data member (in C++) in a struct, union, or C++
-# class.
-CursorKind.FIELD_DECL = CursorKind(6)
+ # A field (in C) or non-static data member (in C++) in a struct, union, or
+ # C++ class.
+ FIELD_DECL = 6
-# An enumerator constant.
-CursorKind.ENUM_CONSTANT_DECL = CursorKind(7)
+ # An enumerator constant.
+ ENUM_CONSTANT_DECL = 7
-# A function.
-CursorKind.FUNCTION_DECL = CursorKind(8)
+ # A function.
+ FUNCTION_DECL = 8
-# A variable.
-CursorKind.VAR_DECL = CursorKind(9)
+ # A variable.
+ VAR_DECL = 9
-# A function or method parameter.
-CursorKind.PARM_DECL = CursorKind(10)
+ # A function or method parameter.
+ PARM_DECL = 10
-# An Objective-C @interface.
-CursorKind.OBJC_INTERFACE_DECL = CursorKind(11)
+ # An Objective-C @interface.
+ OBJC_INTERFACE_DECL = 11
-# An Objective-C @interface for a category.
-CursorKind.OBJC_CATEGORY_DECL = CursorKind(12)
+ # An Objective-C @interface for a category.
+ OBJC_CATEGORY_DECL = 12
-# An Objective-C @protocol declaration.
-CursorKind.OBJC_PROTOCOL_DECL = CursorKind(13)
+ # An Objective-C @protocol declaration.
+ OBJC_PROTOCOL_DECL = 13
-# An Objective-C @property declaration.
-CursorKind.OBJC_PROPERTY_DECL = CursorKind(14)
+ # An Objective-C @property declaration.
+ OBJC_PROPERTY_DECL = 14
-# An Objective-C instance variable.
-CursorKind.OBJC_IVAR_DECL = CursorKind(15)
+ # An Objective-C instance variable.
+ OBJC_IVAR_DECL = 15
-# An Objective-C instance method.
-CursorKind.OBJC_INSTANCE_METHOD_DECL = CursorKind(16)
+ # An Objective-C instance method.
+ OBJC_INSTANCE_METHOD_DECL = 16
-# An Objective-C class method.
-CursorKind.OBJC_CLASS_METHOD_DECL = CursorKind(17)
+ # An Objective-C class method.
+ OBJC_CLASS_METHOD_DECL = 17
-# An Objective-C @implementation.
-CursorKind.OBJC_IMPLEMENTATION_DECL = CursorKind(18)
+ # An Objective-C @implementation.
+ OBJC_IMPLEMENTATION_DECL = 18
-# An Objective-C @implementation for a category.
-CursorKind.OBJC_CATEGORY_IMPL_DECL = CursorKind(19)
+ # An Objective-C @implementation for a category.
+ OBJC_CATEGORY_IMPL_DECL = 19
-# A typedef.
-CursorKind.TYPEDEF_DECL = CursorKind(20)
+ # A typedef.
+ TYPEDEF_DECL = 20
-# A C++ class method.
-CursorKind.CXX_METHOD = CursorKind(21)
+ # A C++ class method.
+ CXX_METHOD = 21
-# A C++ namespace.
-CursorKind.NAMESPACE = CursorKind(22)
+ # A C++ namespace.
+ NAMESPACE = 22
-# A linkage specification, e.g. 'extern "C"'.
-CursorKind.LINKAGE_SPEC = CursorKind(23)
+ # A linkage specification, e.g. 'extern "C"'.
+ LINKAGE_SPEC = 23
-# A C++ constructor.
-CursorKind.CONSTRUCTOR = CursorKind(24)
+ # A C++ constructor.
+ CONSTRUCTOR = 24
-# A C++ destructor.
-CursorKind.DESTRUCTOR = CursorKind(25)
+ # A C++ destructor.
+ DESTRUCTOR = 25
-# A C++ conversion function.
-CursorKind.CONVERSION_FUNCTION = CursorKind(26)
+ # A C++ conversion function.
+ CONVERSION_FUNCTION = 26
-# A C++ template type parameter
-CursorKind.TEMPLATE_TYPE_PARAMETER = CursorKind(27)
+ # A C++ template type parameter
+ TEMPLATE_TYPE_PARAMETER = 27
-# A C++ non-type template parameter.
-CursorKind.TEMPLATE_NON_TYPE_PARAMETER = CursorKind(28)
+ # A C++ non-type template parameter.
+ TEMPLATE_NON_TYPE_PARAMETER = 28
-# A C++ template template parameter.
-CursorKind.TEMPLATE_TEMPLATE_PARAMETER = CursorKind(29)
+ # A C++ template template parameter.
+ TEMPLATE_TEMPLATE_PARAMETER = 29
-# A C++ function template.
-CursorKind.FUNCTION_TEMPLATE = CursorKind(30)
+ # A C++ function template.
+ FUNCTION_TEMPLATE = 30
-# A C++ class template.
-CursorKind.CLASS_TEMPLATE = CursorKind(31)
+ # A C++ class template.
+ CLASS_TEMPLATE = 31
-# A C++ class template partial specialization.
-CursorKind.CLASS_TEMPLATE_PARTIAL_SPECIALIZATION = CursorKind(32)
+ # A C++ class template partial specialization.
+ CLASS_TEMPLATE_PARTIAL_SPECIALIZATION = 32
-# A C++ namespace alias declaration.
-CursorKind.NAMESPACE_ALIAS = CursorKind(33)
+ # A C++ namespace alias declaration.
+ NAMESPACE_ALIAS = 33
-# A C++ using directive
-CursorKind.USING_DIRECTIVE = CursorKind(34)
+ # A C++ using directive
+ USING_DIRECTIVE = 34
-# A C++ using declaration
-CursorKind.USING_DECLARATION = CursorKind(35)
+ # A C++ using declaration
+ USING_DECLARATION = 35
-# A Type alias decl.
-CursorKind.TYPE_ALIAS_DECL = CursorKind(36)
+ # A Type alias decl.
+ TYPE_ALIAS_DECL = 36
-# A Objective-C synthesize decl
-CursorKind.OBJC_SYNTHESIZE_DECL = CursorKind(37)
+ # A Objective-C synthesize decl
+ OBJC_SYNTHESIZE_DECL = 37
-# A Objective-C dynamic decl
-CursorKind.OBJC_DYNAMIC_DECL = CursorKind(38)
+ # A Objective-C dynamic decl
+ OBJC_DYNAMIC_DECL = 38
-# A C++ access specifier decl.
-CursorKind.CXX_ACCESS_SPEC_DECL = CursorKind(39)
+ # A C++ access specifier decl.
+ CXX_ACCESS_SPEC_DECL = 39
-###
-# Reference Kinds
+ ###
+ # Reference Kinds
-CursorKind.OBJC_SUPER_CLASS_REF = CursorKind(40)
-CursorKind.OBJC_PROTOCOL_REF = CursorKind(41)
-CursorKind.OBJC_CLASS_REF = CursorKind(42)
+ OBJC_SUPER_CLASS_REF = 40
+ OBJC_PROTOCOL_REF = 41
+ OBJC_CLASS_REF = 42
-# A reference to a type declaration.
-#
-# A type reference occurs anywhere where a type is named but not
-# declared. For example, given:
-# typedef unsigned size_type;
-# size_type size;
-#
-# The typedef is a declaration of size_type (CXCursor_TypedefDecl),
-# while the type of the variable "size" is referenced. The cursor
-# referenced by the type of size is the typedef for size_type.
-CursorKind.TYPE_REF = CursorKind(43)
-CursorKind.CXX_BASE_SPECIFIER = CursorKind(44)
+ # A reference to a type declaration.
+ #
+ # A type reference occurs anywhere where a type is named but not
+ # declared. For example, given:
+ # typedef unsigned size_type;
+ # size_type size;
+ #
+ # The typedef is a declaration of size_type (CXCursor_TypedefDecl),
+ # while the type of the variable "size" is referenced. The cursor
+ # referenced by the type of size is the typedef for size_type.
+ TYPE_REF = 43
+ CXX_BASE_SPECIFIER = 44
-# A reference to a class template, function template, template
-# template parameter, or class template partial specialization.
-CursorKind.TEMPLATE_REF = CursorKind(45)
+ # A reference to a class template, function template, template
+ # template parameter, or class template partial specialization.
+ TEMPLATE_REF = 45
-# A reference to a namespace or namepsace alias.
-CursorKind.NAMESPACE_REF = CursorKind(46)
+ # A reference to a namespace or namepsace alias.
+ NAMESPACE_REF = 46
-# A reference to a member of a struct, union, or class that occurs in
-# some non-expression context, e.g., a designated initializer.
-CursorKind.MEMBER_REF = CursorKind(47)
+ # A reference to a member of a struct, union, or class that occurs in
+ # some non-expression context, e.g., a designated initializer.
+ MEMBER_REF = 47
-# A reference to a labeled statement.
-CursorKind.LABEL_REF = CursorKind(48)
+ # A reference to a labeled statement.
+ LABEL_REF = 48
-# 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 set of overloaded functions or function templates that
+ # has not yet been resolved to a specific function or function template.
+ OVERLOADED_DECL_REF = 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)
+ # A reference to a variable that occurs in some non-expression
+ # context, e.g., a C++ lambda capture list.
+ VARIABLE_REF = 50
-###
-# Invalid/Error Kinds
+ ###
+ # Invalid/Error Kinds
-CursorKind.INVALID_FILE = CursorKind(70)
-CursorKind.NO_DECL_FOUND = CursorKind(71)
-CursorKind.NOT_IMPLEMENTED = CursorKind(72)
-CursorKind.INVALID_CODE = CursorKind(73)
+ INVALID_FILE = 70
+ NO_DECL_FOUND = 71
+ NOT_IMPLEMENTED = 72
+ INVALID_CODE = 73
-###
-# Expression Kinds
+ ###
+ # Expression Kinds
-# An expression whose specific kind is not exposed via this interface.
-#
-# Unexposed expressions have the same operations as any other kind of
-# expression; one can extract their location information, spelling, children,
-# etc. However, the specific kind of the expression is not reported.
-CursorKind.UNEXPOSED_EXPR = CursorKind(100)
+ # An expression whose specific kind is not exposed via this interface.
+ #
+ # Unexposed expressions have the same operations as any other kind of
+ # expression; one can extract their location information, spelling,
+ # children, etc.
+ # However, the specific kind of the expression is not reported.
+ UNEXPOSED_EXPR = 100
-# An expression that refers to some value declaration, such as a function,
-# variable, or enumerator.
-CursorKind.DECL_REF_EXPR = CursorKind(101)
+ # An expression that refers to some value declaration, such as a function,
+ # variable, or enumerator.
+ DECL_REF_EXPR = 101
-# An expression that refers to a member of a struct, union, class, Objective-C
-# class, etc.
-CursorKind.MEMBER_REF_EXPR = CursorKind(102)
+ # An expression that refers to a member of a struct, union, class,
+ # Objective-C class, etc.
+ MEMBER_REF_EXPR = 102
-# An expression that calls a function.
-CursorKind.CALL_EXPR = CursorKind(103)
+ # An expression that calls a function.
+ CALL_EXPR = 103
-# An expression that sends a message to an Objective-C object or class.
-CursorKind.OBJC_MESSAGE_EXPR = CursorKind(104)
+ # An expression that sends a message to an Objective-C object or class.
+ OBJC_MESSAGE_EXPR = 104
-# An expression that represents a block literal.
-CursorKind.BLOCK_EXPR = CursorKind(105)
+ # An expression that represents a block literal.
+ BLOCK_EXPR = 105
-# An integer literal.
-CursorKind.INTEGER_LITERAL = CursorKind(106)
+ # An integer literal.
+ INTEGER_LITERAL = 106
-# A floating point number literal.
-CursorKind.FLOATING_LITERAL = CursorKind(107)
+ # A floating point number literal.
+ FLOATING_LITERAL = 107
-# An imaginary number literal.
-CursorKind.IMAGINARY_LITERAL = CursorKind(108)
+ # An imaginary number literal.
+ IMAGINARY_LITERAL = 108
-# A string literal.
-CursorKind.STRING_LITERAL = CursorKind(109)
+ # A string literal.
+ STRING_LITERAL = 109
-# A character literal.
-CursorKind.CHARACTER_LITERAL = CursorKind(110)
+ # A character literal.
+ CHARACTER_LITERAL = 110
-# A parenthesized expression, e.g. "(1)".
-#
-# This AST node is only formed if full location information is requested.
-CursorKind.PAREN_EXPR = CursorKind(111)
+ # A parenthesized expression, e.g. "(1)".
+ #
+ # This AST node is only formed if full location information is requested.
+ PAREN_EXPR = 111
-# This represents the unary-expression's (except sizeof and
-# alignof).
-CursorKind.UNARY_OPERATOR = CursorKind(112)
+ # This represents the unary-expression's (except sizeof and
+ # alignof).
+ UNARY_OPERATOR = 112
-# [C99 6.5.2.1] Array Subscripting.
-CursorKind.ARRAY_SUBSCRIPT_EXPR = CursorKind(113)
+ # [C99 6.5.2.1] Array Subscripting.
+ ARRAY_SUBSCRIPT_EXPR = 113
-# A builtin binary operation expression such as "x + y" or
-# "x <= y".
-CursorKind.BINARY_OPERATOR = CursorKind(114)
+ # A builtin binary operation expression such as "x + y" or "x <= y".
+ BINARY_OPERATOR = 114
-# Compound assignment such as "+=".
-CursorKind.COMPOUND_ASSIGNMENT_OPERATOR = CursorKind(115)
+ # Compound assignment such as "+=".
+ COMPOUND_ASSIGNMENT_OPERATOR = 115
-# The ?: ternary operator.
-CursorKind.CONDITIONAL_OPERATOR = CursorKind(116)
+ # The ?: ternary operator.
+ CONDITIONAL_OPERATOR = 116
-# An explicit cast in C (C99 6.5.4) or a C-style cast in C++
-# (C++ [expr.cast]), which uses the syntax (Type)expr.
-#
-# For example: (int)f.
-CursorKind.CSTYLE_CAST_EXPR = CursorKind(117)
+ # An explicit cast in C (C99 6.5.4) or a C-style cast in C++
+ # (C++ [expr.cast]), which uses the syntax (Type)expr.
+ #
+ # For example: (int)f.
+ CSTYLE_CAST_EXPR = 117
-# [C99 6.5.2.5]
-CursorKind.COMPOUND_LITERAL_EXPR = CursorKind(118)
+ # [C99 6.5.2.5]
+ COMPOUND_LITERAL_EXPR = 118
-# Describes an C or C++ initializer list.
-CursorKind.INIT_LIST_EXPR = CursorKind(119)
+ # Describes an C or C++ initializer list.
+ INIT_LIST_EXPR = 119
-# The GNU address of label extension, representing &&label.
-CursorKind.ADDR_LABEL_EXPR = CursorKind(120)
+ # The GNU address of label extension, representing &&label.
+ ADDR_LABEL_EXPR = 120
-# This is the GNU Statement Expression extension: ({int X=4; X;})
-CursorKind.StmtExpr = CursorKind(121)
+ # This is the GNU Statement Expression extension: ({int X=4; X;})
+ StmtExpr = 121
-# Represents a C11 generic selection.
-CursorKind.GENERIC_SELECTION_EXPR = CursorKind(122)
+ # Represents a C11 generic selection.
+ GENERIC_SELECTION_EXPR = 122
-# Implements the GNU __null extension, which is a name for a null
-# pointer constant that has integral type (e.g., int or long) and is the same
-# size and alignment as a pointer.
-#
-# The __null extension is typically only used by system headers, which define
-# NULL as __null in C++ rather than using 0 (which is an integer that may not
-# match the size of a pointer).
-CursorKind.GNU_NULL_EXPR = CursorKind(123)
+ # Implements the GNU __null extension, which is a name for a null
+ # pointer constant that has integral type (e.g., int or long) and is the
+ # same size and alignment as a pointer.
+ #
+ # The __null extension is typically only used by system headers, which
+ # define NULL as __null in C++ rather than using 0 (which is an integer that
+ # may not match the size of a pointer).
+ GNU_NULL_EXPR = 123
-# C++'s static_cast<> expression.
-CursorKind.CXX_STATIC_CAST_EXPR = CursorKind(124)
+ # C++'s static_cast<> expression.
+ CXX_STATIC_CAST_EXPR = 124
-# C++'s dynamic_cast<> expression.
-CursorKind.CXX_DYNAMIC_CAST_EXPR = CursorKind(125)
+ # C++'s dynamic_cast<> expression.
+ CXX_DYNAMIC_CAST_EXPR = 125
-# C++'s reinterpret_cast<> expression.
-CursorKind.CXX_REINTERPRET_CAST_EXPR = CursorKind(126)
+ # C++'s reinterpret_cast<> expression.
+ CXX_REINTERPRET_CAST_EXPR = 126
-# C++'s const_cast<> expression.
-CursorKind.CXX_CONST_CAST_EXPR = CursorKind(127)
+ # C++'s const_cast<> expression.
+ CXX_CONST_CAST_EXPR = 127
-# Represents an explicit C++ type conversion that uses "functional"
-# notion (C++ [expr.type.conv]).
-#
-# Example:
-# \code
-# x = int(0.5);
-# \endcode
-CursorKind.CXX_FUNCTIONAL_CAST_EXPR = CursorKind(128)
+ # Represents an explicit C++ type conversion that uses "functional"
+ # notion (C++ [expr.type.conv]).
+ #
+ # Example:
+ # \code
+ # x = int(0.5);
+ # \endcode
+ CXX_FUNCTIONAL_CAST_EXPR = 128
-# A C++ typeid expression (C++ [expr.typeid]).
-CursorKind.CXX_TYPEID_EXPR = CursorKind(129)
+ # A C++ typeid expression (C++ [expr.typeid]).
+ CXX_TYPEID_EXPR = 129
-# [C++ 2.13.5] C++ Boolean Literal.
-CursorKind.CXX_BOOL_LITERAL_EXPR = CursorKind(130)
+ # [C++ 2.13.5] C++ Boolean Literal.
+ CXX_BOOL_LITERAL_EXPR = 130
-# [C++0x 2.14.7] C++ Pointer Literal.
-CursorKind.CXX_NULL_PTR_LITERAL_EXPR = CursorKind(131)
+ # [C++0x 2.14.7] C++ Pointer Literal.
+ CXX_NULL_PTR_LITERAL_EXPR = 131
-# Represents the "this" expression in C++
-CursorKind.CXX_THIS_EXPR = CursorKind(132)
+ # Represents the "this" expression in C++
+ CXX_THIS_EXPR = 132
-# [C++ 15] C++ Throw Expression.
-#
-# This handles 'throw' and 'throw' assignment-expression. When
-# assignment-expression isn't present, Op will be null.
-CursorKind.CXX_THROW_EXPR = CursorKind(133)
+ # [C++ 15] C++ Throw Expression.
+ #
+ # This handles 'throw' and 'throw' assignment-expression. When
+ # assignment-expression isn't present, Op will be null.
+ CXX_THROW_EXPR = 133
-# A new expression for memory allocation and constructor calls, e.g:
-# "new CXXNewExpr(foo)".
-CursorKind.CXX_NEW_EXPR = CursorKind(134)
+ # A new expression for memory allocation and constructor calls, e.g:
+ # "new CXXNewExpr(foo)".
+ CXX_NEW_EXPR = 134
-# A delete expression for memory deallocation and destructor calls,
-# e.g. "delete[] pArray".
-CursorKind.CXX_DELETE_EXPR = CursorKind(135)
+ # A delete expression for memory deallocation and destructor calls,
+ # e.g. "delete[] pArray".
+ CXX_DELETE_EXPR = 135
-# Represents a unary expression.
-CursorKind.CXX_UNARY_EXPR = CursorKind(136)
+ # Represents a unary expression.
+ CXX_UNARY_EXPR = 136
-# ObjCStringLiteral, used for Objective-C string literals i.e. "foo".
-CursorKind.OBJC_STRING_LITERAL = CursorKind(137)
+ # ObjCStringLiteral, used for Objective-C string literals i.e. "foo".
+ OBJC_STRING_LITERAL = 137
-# ObjCEncodeExpr, used for in Objective-C.
-CursorKind.OBJC_ENCODE_EXPR = CursorKind(138)
+ # ObjCEncodeExpr, used for in Objective-C.
+ OBJC_ENCODE_EXPR = 138
-# ObjCSelectorExpr used for in Objective-C.
-CursorKind.OBJC_SELECTOR_EXPR = CursorKind(139)
+ # ObjCSelectorExpr used for in Objective-C.
+ OBJC_SELECTOR_EXPR = 139
-# Objective-C's protocol expression.
-CursorKind.OBJC_PROTOCOL_EXPR = CursorKind(140)
+ # Objective-C's protocol expression.
+ OBJC_PROTOCOL_EXPR = 140
-# An Objective-C "bridged" cast expression, which casts between
-# Objective-C pointers and C pointers, transferring ownership in the process.
-#
-# \code
-# NSString *str = (__bridge_transfer NSString *)CFCreateString();
-# \endcode
-CursorKind.OBJC_BRIDGE_CAST_EXPR = CursorKind(141)
+ # An Objective-C "bridged" cast expression, which casts between Objective-C
+ # pointers and C pointers, transferring ownership in the process.
+ #
+ # \code
+ # NSString *str = (__bridge_transfer NSString *)CFCreateString();
+ # \endcode
+ OBJC_BRIDGE_CAST_EXPR = 141
-# Represents a C++0x pack expansion that produces a sequence of
-# expressions.
-#
-# A pack expansion expression contains a pattern (which itself is an
-# expression) followed by an ellipsis. For example:
-CursorKind.PACK_EXPANSION_EXPR = CursorKind(142)
+ # Represents a C++0x pack expansion that produces a sequence of
+ # expressions.
+ #
+ # A pack expansion expression contains a pattern (which itself is an
+ # expression) followed by an ellipsis. For example:
+ PACK_EXPANSION_EXPR = 142
-# Represents an expression that computes the length of a parameter
-# pack.
-CursorKind.SIZE_OF_PACK_EXPR = CursorKind(143)
+ # Represents an expression that computes the length of a parameter
+ # pack.
+ SIZE_OF_PACK_EXPR = 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)
+ # 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
+ LAMBDA_EXPR = 144
-# Objective-c Boolean Literal.
-CursorKind.OBJ_BOOL_LITERAL_EXPR = CursorKind(145)
+ # Objective-c Boolean Literal.
+ OBJ_BOOL_LITERAL_EXPR = 145
-# Represents the "self" expression in a ObjC method.
-CursorKind.OBJ_SELF_EXPR = CursorKind(146)
+ # Represents the "self" expression in a ObjC method.
+ OBJ_SELF_EXPR = 146
-# OpenMP 4.0 [2.4, Array Section].
-CursorKind.OMP_ARRAY_SECTION_EXPR = CursorKind(147)
+ # OpenMP 4.0 [2.4, Array Section].
+ OMP_ARRAY_SECTION_EXPR = 147
-# Represents an @available(...) check.
-CursorKind.OBJC_AVAILABILITY_CHECK_EXPR = CursorKind(148)
+ # Represents an @available(...) check.
+ OBJC_AVAILABILITY_CHECK_EXPR = 148
-# Fixed point literal.
-CursorKind.FIXED_POINT_LITERAL = CursorKind(149)
+ # Fixed point literal.
+ FIXED_POINT_LITERAL = 149
-# OpenMP 5.0 [2.1.4, Array Shaping].
-CursorKind.OMP_ARRAY_SHAPING_EXPR = CursorKind(150)
+ # OpenMP 5.0 [2.1.4, Array Shaping].
+ OMP_ARRAY_SHAPING_EXPR = 150
-# OpenMP 5.0 [2.1.6 Iterators].
-CursorKind.OMP_ITERATOR_EXPR = CursorKind(151)
+ # OpenMP 5.0 [2.1.6 Iterators].
+ OMP_ITERATOR_EXPR = 151
-# OpenCL's addrspace_cast<> expression.
-CursorKind.CXX_ADDRSPACE_CAST_EXPR = CursorKind(152)
+ # OpenCL's addrspace_cast<> expression.
+ CXX_ADDRSPACE_CAST_EXPR = 152
-# Expression that references a C++20 concept.
-CursorKind.CONCEPT_SPECIALIZATION_EXPR = CursorKind(153)
+ # Expression that references a C++20 concept.
+ CONCEPT_SPECIALIZATION_EXPR = 153
-# Expression that references a C++20 requires expression.
-CursorKind.REQUIRES_EXPR = CursorKind(154)
+ # Expression that references a C++20 requires expression.
+ REQUIRES_EXPR = 154
-# Expression that references a C++20 parenthesized list aggregate initializer.
-CursorKind.CXX_PAREN_LIST_INIT_EXPR = CursorKind(155)
+ # Expression that references a C++20 parenthesized list aggregate
+ # initializer.
+ CXX_PAREN_LIST_INIT_EXPR = 155
-# Represents a C++26 pack indexing expression.
-CursorKind.PACK_INDEXING_EXPR = CursorKind(156)
+ # Represents a C++26 pack indexing expression.
+ PACK_INDEXING_EXPR = 156
-# A statement whose specific kind is not exposed via this interface.
-#
-# Unexposed statements have the same operations as any other kind of statement;
-# one can extract their location information, spelling, children, etc. However,
-# the specific kind of the statement is not reported.
-CursorKind.UNEXPOSED_STMT = CursorKind(200)
+ # A statement whose specific kind is not exposed via this interface.
+ #
+ # Unexposed statements have the same operations as any other kind of
+ # statement; one can extract their location information, spelling, children,
+ # etc. However, the specific kind of the statement is not reported.
+ UNEXPOSED_STMT = 200
-# A labelled statement in a function.
-CursorKind.LABEL_STMT = CursorKind(201)
+ # A labelled statement in a function.
+ LABEL_STMT = 201
-# A compound statement
-CursorKind.COMPOUND_STMT = CursorKind(202)
+ # A compound statement
+ COMPOUND_STMT = 202
-# A case statement.
-CursorKind.CASE_STMT = CursorKind(203)
+ # A case statement.
+ CASE_STMT = 203
-# A default statement.
-CursorKind.DEFAULT_STMT = CursorKind(204)
+ # A default statement.
+ DEFAULT_STMT = 204
-# An if statement.
-CursorKind.IF_STMT = CursorKind(205)
+ # An if statement.
+ IF_STMT = 205
-# A switch statement.
-CursorKind.SWITCH_STMT = CursorKind(206)
+ # A switch statement.
+ SWITCH_STMT = 206
-# A while statement.
-CursorKind.WHILE_STMT = CursorKind(207)
+ # A while statement.
+ WHILE_STMT = 207
-# A do statement.
-CursorKind.DO_STMT = CursorKind(208)
+ # A do statement.
+ DO_STMT = 208
-# A for statement.
-CursorKind.FOR_STMT = CursorKind(209)
+ # A for statement.
+ FOR_STMT = 209
-# A goto statement.
-CursorKind.GOTO_STMT = CursorKind(210)
+ # A goto statement.
+ GOTO_STMT = 210
-# An indirect goto statement.
-CursorKind.INDIRECT_GOTO_STMT = CursorKind(211)
+ # An indirect goto statement.
+ INDIRECT_GOTO_STMT = 211
-# A continue statement.
-CursorKind.CONTINUE_STMT = CursorKind(212)
+ # A continue statement.
+ CONTINUE_STMT = 212
-# A break statement.
-CursorKind.BREAK_STMT = CursorKind(213)
+ # A break statement.
+ BREAK_STMT = 213
-# A return statement.
-CursorKind.RETURN_STMT = CursorKind(214)
+ # A return statement.
+ RETURN_STMT = 214
-# A GNU-style inline assembler statement.
-CursorKind.ASM_STMT = CursorKind(215)
+ # A GNU-style inline assembler statement.
+ ASM_STMT = 215
-# Objective-C's overall @try- at catch-@finally statement.
-CursorKind.OBJC_AT_TRY_STMT = CursorKind(216)
+ # Objective-C's overall @try- at catch-@finally statement.
+ OBJC_AT_TRY_STMT = 216
-# Objective-C's @catch statement.
-CursorKind.OBJC_AT_CATCH_STMT = CursorKind(217)
+ # Objective-C's @catch statement.
+ OBJC_AT_CATCH_STMT = 217
-# Objective-C's @finally statement.
-CursorKind.OBJC_AT_FINALLY_STMT = CursorKind(218)
+ # Objective-C's @finally statement.
+ OBJC_AT_FINALLY_STMT = 218
-# Objective-C's @throw statement.
-CursorKind.OBJC_AT_THROW_STMT = CursorKind(219)
+ # Objective-C's @throw statement.
+ OBJC_AT_THROW_STMT = 219
-# Objective-C's @synchronized statement.
-CursorKind.OBJC_AT_SYNCHRONIZED_STMT = CursorKind(220)
+ # Objective-C's @synchronized statement.
+ OBJC_AT_SYNCHRONIZED_STMT = 220
-# Objective-C's autorelease pool statement.
-CursorKind.OBJC_AUTORELEASE_POOL_STMT = CursorKind(221)
+ # Objective-C's autorelease pool statement.
+ OBJC_AUTORELEASE_POOL_STMT = 221
-# Objective-C's for collection statement.
-CursorKind.OBJC_FOR_COLLECTION_STMT = CursorKind(222)
+ # Objective-C's for collection statement.
+ OBJC_FOR_COLLECTION_STMT = 222
-# C++'s catch statement.
-CursorKind.CXX_CATCH_STMT = CursorKind(223)
+ # C++'s catch statement.
+ CXX_CATCH_STMT = 223
-# C++'s try statement.
-CursorKind.CXX_TRY_STMT = CursorKind(224)
+ # C++'s try statement.
+ CXX_TRY_STMT = 224
-# C++'s for (* : *) statement.
-CursorKind.CXX_FOR_RANGE_STMT = CursorKind(225)
+ # C++'s for (* : *) statement.
+ CXX_FOR_RANGE_STMT = 225
-# Windows Structured Exception Handling's try statement.
-CursorKind.SEH_TRY_STMT = CursorKind(226)
+ # Windows Structured Exception Handling's try statement.
+ SEH_TRY_STMT = 226
-# Windows Structured Exception Handling's except statement.
-CursorKind.SEH_EXCEPT_STMT = CursorKind(227)
+ # Windows Structured Exception Handling's except statement.
+ SEH_EXCEPT_STMT = 227
-# Windows Structured Exception Handling's finally statement.
-CursorKind.SEH_FINALLY_STMT = CursorKind(228)
+ # Windows Structured Exception Handling's finally statement.
+ SEH_FINALLY_STMT = 228
-# A MS inline assembly statement extension.
-CursorKind.MS_ASM_STMT = CursorKind(229)
+ # A MS inline assembly statement extension.
+ MS_ASM_STMT = 229
-# The null statement.
-CursorKind.NULL_STMT = CursorKind(230)
+ # The null statement.
+ NULL_STMT = 230
-# Adaptor class for mixing declarations with statements and expressions.
-CursorKind.DECL_STMT = CursorKind(231)
+ # Adaptor class for mixing declarations with statements and expressions.
+ DECL_STMT = 231
-# OpenMP parallel directive.
-CursorKind.OMP_PARALLEL_DIRECTIVE = CursorKind(232)
+ # OpenMP parallel directive.
+ OMP_PARALLEL_DIRECTIVE = 232
-# OpenMP SIMD directive.
-CursorKind.OMP_SIMD_DIRECTIVE = CursorKind(233)
+ # OpenMP SIMD directive.
+ OMP_SIMD_DIRECTIVE = 233
-# OpenMP for directive.
-CursorKind.OMP_FOR_DIRECTIVE = CursorKind(234)
+ # OpenMP for directive.
+ OMP_FOR_DIRECTIVE = 234
-# OpenMP sections directive.
-CursorKind.OMP_SECTIONS_DIRECTIVE = CursorKind(235)
+ # OpenMP sections directive.
+ OMP_SECTIONS_DIRECTIVE = 235
-# OpenMP section directive.
-CursorKind.OMP_SECTION_DIRECTIVE = CursorKind(236)
+ # OpenMP section directive.
+ OMP_SECTION_DIRECTIVE = 236
-# OpenMP single directive.
-CursorKind.OMP_SINGLE_DIRECTIVE = CursorKind(237)
+ # OpenMP single directive.
+ OMP_SINGLE_DIRECTIVE = 237
-# OpenMP parallel for directive.
-CursorKind.OMP_PARALLEL_FOR_DIRECTIVE = CursorKind(238)
+ # OpenMP parallel for directive.
+ OMP_PARALLEL_FOR_DIRECTIVE = 238
-# OpenMP parallel sections directive.
-CursorKind.OMP_PARALLEL_SECTIONS_DIRECTIVE = CursorKind(239)
+ # OpenMP parallel sections directive.
+ OMP_PARALLEL_SECTIONS_DIRECTIVE = 239
-# OpenMP task directive.
-CursorKind.OMP_TASK_DIRECTIVE = CursorKind(240)
+ # OpenMP task directive.
+ OMP_TASK_DIRECTIVE = 240
-# OpenMP master directive.
-CursorKind.OMP_MASTER_DIRECTIVE = CursorKind(241)
+ # OpenMP master directive.
+ OMP_MASTER_DIRECTIVE = 241
-# OpenMP critical directive.
-CursorKind.OMP_CRITICAL_DIRECTIVE = CursorKind(242)
+ # OpenMP critical directive.
+ OMP_CRITICAL_DIRECTIVE = 242
-# OpenMP taskyield directive.
-CursorKind.OMP_TASKYIELD_DIRECTIVE = CursorKind(243)
+ # OpenMP taskyield directive.
+ OMP_TASKYIELD_DIRECTIVE = 243
-# OpenMP barrier directive.
-CursorKind.OMP_BARRIER_DIRECTIVE = CursorKind(244)
+ # OpenMP barrier directive.
+ OMP_BARRIER_DIRECTIVE = 244
-# OpenMP taskwait directive.
-CursorKind.OMP_TASKWAIT_DIRECTIVE = CursorKind(245)
+ # OpenMP taskwait directive.
+ OMP_TASKWAIT_DIRECTIVE = 245
-# OpenMP flush directive.
-CursorKind.OMP_FLUSH_DIRECTIVE = CursorKind(246)
+ # OpenMP flush directive.
+ OMP_FLUSH_DIRECTIVE = 246
-# Windows Structured Exception Handling's leave statement.
-CursorKind.SEH_LEAVE_STMT = CursorKind(247)
+ # Windows Structured Exception Handling's leave statement.
+ SEH_LEAVE_STMT = 247
-# OpenMP ordered directive.
-CursorKind.OMP_ORDERED_DIRECTIVE = CursorKind(248)
+ # OpenMP ordered directive.
+ OMP_ORDERED_DIRECTIVE = 248
-# OpenMP atomic directive.
-CursorKind.OMP_ATOMIC_DIRECTIVE = CursorKind(249)
+ # OpenMP atomic directive.
+ OMP_ATOMIC_DIRECTIVE = 249
-# OpenMP for SIMD directive.
-CursorKind.OMP_FOR_SIMD_DIRECTIVE = CursorKind(250)
+ # OpenMP for SIMD directive.
+ OMP_FOR_SIMD_DIRECTIVE = 250
-# OpenMP parallel for SIMD directive.
-CursorKind.OMP_PARALLELFORSIMD_DIRECTIVE = CursorKind(251)
+ # OpenMP parallel for SIMD directive.
+ OMP_PARALLELFORSIMD_DIRECTIVE = 251
-# OpenMP target directive.
-CursorKind.OMP_TARGET_DIRECTIVE = CursorKind(252)
+ # OpenMP target directive.
+ OMP_TARGET_DIRECTIVE = 252
-# OpenMP teams directive.
-CursorKind.OMP_TEAMS_DIRECTIVE = CursorKind(253)
+ # OpenMP teams directive.
+ OMP_TEAMS_DIRECTIVE = 253
-# OpenMP taskgroup directive.
-CursorKind.OMP_TASKGROUP_DIRECTIVE = CursorKind(254)
+ # OpenMP taskgroup directive.
+ OMP_TASKGROUP_DIRECTIVE = 254
-# OpenMP cancellation point directive.
-CursorKind.OMP_CANCELLATION_POINT_DIRECTIVE = CursorKind(255)
+ # OpenMP cancellation point directive.
+ OMP_CANCELLATION_POINT_DIRECTIVE = 255
-# OpenMP cancel directive.
-CursorKind.OMP_CANCEL_DIRECTIVE = CursorKind(256)
+ # OpenMP cancel directive.
+ OMP_CANCEL_DIRECTIVE = 256
-# OpenMP target data directive.
-CursorKind.OMP_TARGET_DATA_DIRECTIVE = CursorKind(257)
+ # OpenMP target data directive.
+ OMP_TARGET_DATA_DIRECTIVE = 257
-# OpenMP taskloop directive.
-CursorKind.OMP_TASK_LOOP_DIRECTIVE = CursorKind(258)
+ # OpenMP taskloop directive.
+ OMP_TASK_LOOP_DIRECTIVE = 258
-# OpenMP taskloop simd directive.
-CursorKind.OMP_TASK_LOOP_SIMD_DIRECTIVE = CursorKind(259)
+ # OpenMP taskloop simd directive.
+ OMP_TASK_LOOP_SIMD_DIRECTIVE = 259
-# OpenMP distribute directive.
-CursorKind.OMP_DISTRIBUTE_DIRECTIVE = CursorKind(260)
+ # OpenMP distribute directive.
+ OMP_DISTRIBUTE_DIRECTIVE = 260
-# OpenMP target enter data directive.
-CursorKind.OMP_TARGET_ENTER_DATA_DIRECTIVE = CursorKind(261)
+ # OpenMP target enter data directive.
+ OMP_TARGET_ENTER_DATA_DIRECTIVE = 261
-# OpenMP target exit data directive.
-CursorKind.OMP_TARGET_EXIT_DATA_DIRECTIVE = CursorKind(262)
+ # OpenMP target exit data directive.
+ OMP_TARGET_EXIT_DATA_DIRECTIVE = 262
-# OpenMP target parallel directive.
-CursorKind.OMP_TARGET_PARALLEL_DIRECTIVE = CursorKind(263)
+ # OpenMP target parallel directive.
+ OMP_TARGET_PARALLEL_DIRECTIVE = 263
-# OpenMP target parallel for directive.
-CursorKind.OMP_TARGET_PARALLELFOR_DIRECTIVE = CursorKind(264)
+ # OpenMP target parallel for directive.
+ OMP_TARGET_PARALLELFOR_DIRECTIVE = 264
-# OpenMP target update directive.
-CursorKind.OMP_TARGET_UPDATE_DIRECTIVE = CursorKind(265)
+ # OpenMP target update directive.
+ OMP_TARGET_UPDATE_DIRECTIVE = 265
-# OpenMP distribute parallel for directive.
-CursorKind.OMP_DISTRIBUTE_PARALLELFOR_DIRECTIVE = CursorKind(266)
+ # OpenMP distribute parallel for directive.
+ OMP_DISTRIBUTE_PARALLELFOR_DIRECTIVE = 266
-# OpenMP distribute parallel for simd directive.
-CursorKind.OMP_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE = CursorKind(267)
+ # OpenMP distribute parallel for simd directive.
+ OMP_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE = 267
-# OpenMP distribute simd directive.
-CursorKind.OMP_DISTRIBUTE_SIMD_DIRECTIVE = CursorKind(268)
+ # OpenMP distribute simd directive.
+ OMP_DISTRIBUTE_SIMD_DIRECTIVE = 268
-# OpenMP target parallel for simd directive.
-CursorKind.OMP_TARGET_PARALLEL_FOR_SIMD_DIRECTIVE = CursorKind(269)
+ # OpenMP target parallel for simd directive.
+ OMP_TARGET_PARALLEL_FOR_SIMD_DIRECTIVE = 269
-# OpenMP target simd directive.
-CursorKind.OMP_TARGET_SIMD_DIRECTIVE = CursorKind(270)
+ # OpenMP target simd directive.
+ OMP_TARGET_SIMD_DIRECTIVE = 270
-# OpenMP teams distribute directive.
-CursorKind.OMP_TEAMS_DISTRIBUTE_DIRECTIVE = CursorKind(271)
+ # OpenMP teams distribute directive.
+ OMP_TEAMS_DISTRIBUTE_DIRECTIVE = 271
-# OpenMP teams distribute simd directive.
-CursorKind.OMP_TEAMS_DISTRIBUTE_SIMD_DIRECTIVE = CursorKind(272)
+ # OpenMP teams distribute simd directive.
+ OMP_TEAMS_DISTRIBUTE_SIMD_DIRECTIVE = 272
-# OpenMP teams distribute parallel for simd directive.
-CursorKind.OMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE = CursorKind(273)
+ # OpenMP teams distribute parallel for simd directive.
+ OMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE = 273
-# OpenMP teams distribute parallel for directive.
-CursorKind.OMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE = CursorKind(274)
+ # OpenMP teams distribute parallel for directive.
+ OMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE = 274
-# OpenMP target teams directive.
-CursorKind.OMP_TARGET_TEAMS_DIRECTIVE = CursorKind(275)
+ # OpenMP target teams directive.
+ OMP_TARGET_TEAMS_DIRECTIVE = 275
-# OpenMP target teams distribute directive.
-CursorKind.OMP_TARGET_TEAMS_DISTRIBUTE_DIRECTIVE = CursorKind(276)
+ # OpenMP target teams distribute directive.
+ OMP_TARGET_TEAMS_DISTRIBUTE_DIRECTIVE = 276
-# OpenMP target teams distribute parallel for directive.
-CursorKind.OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE = CursorKind(277)
+ # OpenMP target teams distribute parallel for directive.
+ OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE = 277
-# OpenMP target teams distribute parallel for simd directive.
-CursorKind.OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE = CursorKind(278)
+ # OpenMP target teams distribute parallel for simd directive.
+ OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE = 278
-# OpenMP target teams distribute simd directive.
-CursorKind.OMP_TARGET_TEAMS_DISTRIBUTE_SIMD_DIRECTIVE = CursorKind(279)
+ # OpenMP target teams distribute simd directive.
+ OMP_TARGET_TEAMS_DISTRIBUTE_SIMD_DIRECTIVE = 279
-# C++2a std::bit_cast expression.
-CursorKind.BUILTIN_BIT_CAST_EXPR = CursorKind(280)
+ # C++2a std::bit_cast expression.
+ BUILTIN_BIT_CAST_EXPR = 280
-# OpenMP master taskloop directive.
-CursorKind.OMP_MASTER_TASK_LOOP_DIRECTIVE = CursorKind(281)
+ # OpenMP master taskloop directive.
+ OMP_MASTER_TASK_LOOP_DIRECTIVE = 281
-# OpenMP parallel master taskloop directive.
-CursorKind.OMP_PARALLEL_MASTER_TASK_LOOP_DIRECTIVE = CursorKind(282)
+ # OpenMP parallel master taskloop directive.
+ OMP_PARALLEL_MASTER_TASK_LOOP_DIRECTIVE = 282
-# OpenMP master taskloop simd directive.
-CursorKind.OMP_MASTER_TASK_LOOP_SIMD_DIRECTIVE = CursorKind(283)
+ # OpenMP master taskloop simd directive.
+ OMP_MASTER_TASK_LOOP_SIMD_DIRECTIVE = 283
-# OpenMP parallel master taskloop simd directive.
-CursorKind.OMP_PARALLEL_MASTER_TASK_LOOP_SIMD_DIRECTIVE = CursorKind(284)
+ # OpenMP parallel master taskloop simd directive.
+ OMP_PARALLEL_MASTER_TASK_LOOP_SIMD_DIRECTIVE = 284
-# OpenMP parallel master directive.
-CursorKind.OMP_PARALLEL_MASTER_DIRECTIVE = CursorKind(285)
+ # OpenMP parallel master directive.
+ OMP_PARALLEL_MASTER_DIRECTIVE = 285
-# OpenMP depobj directive.
-CursorKind.OMP_DEPOBJ_DIRECTIVE = CursorKind(286)
+ # OpenMP depobj directive.
+ OMP_DEPOBJ_DIRECTIVE = 286
-# OpenMP scan directive.
-CursorKind.OMP_SCAN_DIRECTIVE = CursorKind(287)
+ # OpenMP scan directive.
+ OMP_SCAN_DIRECTIVE = 287
-# OpenMP tile directive.
-CursorKind.OMP_TILE_DIRECTIVE = CursorKind(288)
+ # OpenMP tile directive.
+ OMP_TILE_DIRECTIVE = 288
-# OpenMP canonical loop.
-CursorKind.OMP_CANONICAL_LOOP = CursorKind(289)
+ # OpenMP canonical loop.
+ OMP_CANONICAL_LOOP = 289
-# OpenMP interop directive.
-CursorKind.OMP_INTEROP_DIRECTIVE = CursorKind(290)
+ # OpenMP interop directive.
+ OMP_INTEROP_DIRECTIVE = 290
-# OpenMP dispatch directive.
-CursorKind.OMP_DISPATCH_DIRECTIVE = CursorKind(291)
+ # OpenMP dispatch directive.
+ OMP_DISPATCH_DIRECTIVE = 291
-# OpenMP masked directive.
-CursorKind.OMP_MASKED_DIRECTIVE = CursorKind(292)
+ # OpenMP masked directive.
+ OMP_MASKED_DIRECTIVE = 292
-# OpenMP unroll directive.
-CursorKind.OMP_UNROLL_DIRECTIVE = CursorKind(293)
+ # OpenMP unroll directive.
+ OMP_UNROLL_DIRECTIVE = 293
-# OpenMP metadirective directive.
-CursorKind.OMP_META_DIRECTIVE = CursorKind(294)
+ # OpenMP metadirective directive.
+ OMP_META_DIRECTIVE = 294
-# OpenMP loop directive.
-CursorKind.OMP_GENERIC_LOOP_DIRECTIVE = CursorKind(295)
+ # OpenMP loop directive.
+ OMP_GENERIC_LOOP_DIRECTIVE = 295
-# OpenMP teams loop directive.
-CursorKind.OMP_TEAMS_GENERIC_LOOP_DIRECTIVE = CursorKind(296)
+ # OpenMP teams loop directive.
+ OMP_TEAMS_GENERIC_LOOP_DIRECTIVE = 296
-# OpenMP target teams loop directive.
-CursorKind.OMP_TARGET_TEAMS_GENERIC_LOOP_DIRECTIVE = CursorKind(297)
+ # OpenMP target teams loop directive.
+ OMP_TARGET_TEAMS_GENERIC_LOOP_DIRECTIVE = 297
-# OpenMP parallel loop directive.
-CursorKind.OMP_PARALLEL_GENERIC_LOOP_DIRECTIVE = CursorKind(298)
+ # OpenMP parallel loop directive.
+ OMP_PARALLEL_GENERIC_LOOP_DIRECTIVE = 298
-# OpenMP target parallel loop directive.
-CursorKind.OMP_TARGET_PARALLEL_GENERIC_LOOP_DIRECTIVE = CursorKind(299)
+ # OpenMP target parallel loop directive.
+ OMP_TARGET_PARALLEL_GENERIC_LOOP_DIRECTIVE = 299
-# OpenMP parallel masked directive.
-CursorKind.OMP_PARALLEL_MASKED_DIRECTIVE = CursorKind(300)
+ # OpenMP parallel masked directive.
+ OMP_PARALLEL_MASKED_DIRECTIVE = 300
-# OpenMP masked taskloop directive.
-CursorKind.OMP_MASKED_TASK_LOOP_DIRECTIVE = CursorKind(301)
+ # OpenMP masked taskloop directive.
+ OMP_MASKED_TASK_LOOP_DIRECTIVE = 301
-# OpenMP masked taskloop simd directive.
-CursorKind.OMP_MASKED_TASK_LOOP_SIMD_DIRECTIVE = CursorKind(302)
+ # OpenMP masked taskloop simd directive.
+ OMP_MASKED_TASK_LOOP_SIMD_DIRECTIVE = 302
-# OpenMP parallel masked taskloop directive.
-CursorKind.OMP_PARALLEL_MASKED_TASK_LOOP_DIRECTIVE = CursorKind(303)
+ # OpenMP parallel masked taskloop directive.
+ OMP_PARALLEL_MASKED_TASK_LOOP_DIRECTIVE = 303
-# OpenMP parallel masked taskloop simd directive.
-CursorKind.OMP_PARALLEL_MASKED_TASK_LOOP_SIMD_DIRECTIVE = CursorKind(304)
+ # OpenMP parallel masked taskloop simd directive.
+ OMP_PARALLEL_MASKED_TASK_LOOP_SIMD_DIRECTIVE = 304
-# OpenMP error directive.
-CursorKind.OMP_ERROR_DIRECTIVE = CursorKind(305)
+ # OpenMP error directive.
+ OMP_ERROR_DIRECTIVE = 305
-# OpenMP scope directive.
-CursorKind.OMP_SCOPE_DIRECTIVE = CursorKind(306)
+ # OpenMP scope directive.
+ OMP_SCOPE_DIRECTIVE = 306
-# OpenACC Compute Construct.
-CursorKind.OPEN_ACC_COMPUTE_DIRECTIVE = CursorKind(320)
+ # OpenACC Compute Construct.
+ OPEN_ACC_COMPUTE_DIRECTIVE = 320
-###
-# Other Kinds
+ ###
+ # Other Kinds
-# Cursor that represents the translation unit itself.
-#
-# The translation unit cursor exists primarily to act as the root cursor for
-# traversing the contents of a translation unit.
-CursorKind.TRANSLATION_UNIT = CursorKind(350)
-
-###
-# Attributes
-
-# An attribute whoe specific kind is note exposed via this interface
-CursorKind.UNEXPOSED_ATTR = CursorKind(400)
-
-CursorKind.IB_ACTION_ATTR = CursorKind(401)
-CursorKind.IB_OUTLET_ATTR = CursorKind(402)
-CursorKind.IB_OUTLET_COLLECTION_ATTR = CursorKind(403)
-
-CursorKind.CXX_FINAL_ATTR = CursorKind(404)
-CursorKind.CXX_OVERRIDE_ATTR = CursorKind(405)
-CursorKind.ANNOTATE_ATTR = CursorKind(406)
-CursorKind.ASM_LABEL_ATTR = CursorKind(407)
-CursorKind.PACKED_ATTR = CursorKind(408)
-CursorKind.PURE_ATTR = CursorKind(409)
-CursorKind.CONST_ATTR = CursorKind(410)
-CursorKind.NODUPLICATE_ATTR = CursorKind(411)
-CursorKind.CUDACONSTANT_ATTR = CursorKind(412)
-CursorKind.CUDADEVICE_ATTR = CursorKind(413)
-CursorKind.CUDAGLOBAL_ATTR = CursorKind(414)
-CursorKind.CUDAHOST_ATTR = CursorKind(415)
-CursorKind.CUDASHARED_ATTR = CursorKind(416)
-
-CursorKind.VISIBILITY_ATTR = CursorKind(417)
-
-CursorKind.DLLEXPORT_ATTR = CursorKind(418)
-CursorKind.DLLIMPORT_ATTR = CursorKind(419)
-CursorKind.NS_RETURNS_RETAINED = CursorKind(420)
-CursorKind.NS_RETURNS_NOT_RETAINED = CursorKind(421)
-CursorKind.NS_RETURNS_AUTORELEASED = CursorKind(422)
-CursorKind.NS_CONSUMES_SELF = CursorKind(423)
-CursorKind.NS_CONSUMED = CursorKind(424)
-CursorKind.OBJC_EXCEPTION = CursorKind(425)
-CursorKind.OBJC_NSOBJECT = CursorKind(426)
-CursorKind.OBJC_INDEPENDENT_CLASS = CursorKind(427)
-CursorKind.OBJC_PRECISE_LIFETIME = CursorKind(428)
-CursorKind.OBJC_RETURNS_INNER_POINTER = CursorKind(429)
-CursorKind.OBJC_REQUIRES_SUPER = CursorKind(430)
-CursorKind.OBJC_ROOT_CLASS = CursorKind(431)
-CursorKind.OBJC_SUBCLASSING_RESTRICTED = CursorKind(432)
-CursorKind.OBJC_EXPLICIT_PROTOCOL_IMPL = CursorKind(433)
-CursorKind.OBJC_DESIGNATED_INITIALIZER = CursorKind(434)
-CursorKind.OBJC_RUNTIME_VISIBLE = CursorKind(435)
-CursorKind.OBJC_BOXABLE = CursorKind(436)
-CursorKind.FLAG_ENUM = CursorKind(437)
-CursorKind.CONVERGENT_ATTR = CursorKind(438)
-CursorKind.WARN_UNUSED_ATTR = CursorKind(439)
-CursorKind.WARN_UNUSED_RESULT_ATTR = CursorKind(440)
-CursorKind.ALIGNED_ATTR = CursorKind(441)
-
-###
-# Preprocessing
-CursorKind.PREPROCESSING_DIRECTIVE = CursorKind(500)
-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)
-# A type alias template declaration
-CursorKind.TYPE_ALIAS_TEMPLATE_DECL = CursorKind(601)
-# A static_assert or _Static_assert node
-CursorKind.STATIC_ASSERT = CursorKind(602)
-# A friend declaration
-CursorKind.FRIEND_DECL = CursorKind(603)
-# A concept declaration
-CursorKind.CONCEPT_DECL = CursorKind(604)
-
-# A code completion overload candidate.
-CursorKind.OVERLOAD_CANDIDATE = CursorKind(700)
+ # Cursor that represents the translation unit itself.
+ #
+ # The translation unit cursor exists primarily to act as the root cursor for
+ # traversing the contents of a translation unit.
+ TRANSLATION_UNIT = 350
+
+ ###
+ # Attributes
+
+ # An attribute whoe specific kind is note exposed via this interface
+ UNEXPOSED_ATTR = 400
+
+ IB_ACTION_ATTR = 401
+ IB_OUTLET_ATTR = 402
+ IB_OUTLET_COLLECTION_ATTR = 403
+
+ CXX_FINAL_ATTR = 404
+ CXX_OVERRIDE_ATTR = 405
+ ANNOTATE_ATTR = 406
+ ASM_LABEL_ATTR = 407
+ PACKED_ATTR = 408
+ PURE_ATTR = 409
+ CONST_ATTR = 410
+ NODUPLICATE_ATTR = 411
+ CUDACONSTANT_ATTR = 412
+ CUDADEVICE_ATTR = 413
+ CUDAGLOBAL_ATTR = 414
+ CUDAHOST_ATTR = 415
+ CUDASHARED_ATTR = 416
+
+ VISIBILITY_ATTR = 417
+
+ DLLEXPORT_ATTR = 418
+ DLLIMPORT_ATTR = 419
+ NS_RETURNS_RETAINED = 420
+ NS_RETURNS_NOT_RETAINED = 421
+ NS_RETURNS_AUTORELEASED = 422
+ NS_CONSUMES_SELF = 423
+ NS_CONSUMED = 424
+ OBJC_EXCEPTION = 425
+ OBJC_NSOBJECT = 426
+ OBJC_INDEPENDENT_CLASS = 427
+ OBJC_PRECISE_LIFETIME = 428
+ OBJC_RETURNS_INNER_POINTER = 429
+ OBJC_REQUIRES_SUPER = 430
+ OBJC_ROOT_CLASS = 431
+ OBJC_SUBCLASSING_RESTRICTED = 432
+ OBJC_EXPLICIT_PROTOCOL_IMPL = 433
+ OBJC_DESIGNATED_INITIALIZER = 434
+ OBJC_RUNTIME_VISIBLE = 435
+ OBJC_BOXABLE = 436
+ FLAG_ENUM = 437
+ CONVERGENT_ATTR = 438
+ WARN_UNUSED_ATTR = 439
+ WARN_UNUSED_RESULT_ATTR = 440
+ ALIGNED_ATTR = 441
+
+ ###
+ # Preprocessing
+ PREPROCESSING_DIRECTIVE = 500
+ MACRO_DEFINITION = 501
+ MACRO_INSTANTIATION = 502
+ INCLUSION_DIRECTIVE = 503
+
+ ###
+ # Extra declaration
+
+ # A module import declaration.
+ MODULE_IMPORT_DECL = 600
+ # A type alias template declaration
+ TYPE_ALIAS_TEMPLATE_DECL = 601
+ # A static_assert or _Static_assert node
+ STATIC_ASSERT = 602
+ # A friend declaration
+ FRIEND_DECL = 603
+ # A concept declaration
+ CONCEPT_DECL = 604
+
+ # A code completion overload candidate.
+ OVERLOAD_CANDIDATE = 700
### Template Argument Kinds ###
class TemplateArgumentKind(BaseEnumeration):
@@ -1534,21 +1503,16 @@ class TemplateArgumentKind(BaseEnumeration):
represents.
"""
- # The required BaseEnumeration declarations.
- _kinds = []
- _name_map = None
-
-
-TemplateArgumentKind.NULL = TemplateArgumentKind(0)
-TemplateArgumentKind.TYPE = TemplateArgumentKind(1)
-TemplateArgumentKind.DECLARATION = TemplateArgumentKind(2)
-TemplateArgumentKind.NULLPTR = TemplateArgumentKind(3)
-TemplateArgumentKind.INTEGRAL = TemplateArgumentKind(4)
-TemplateArgumentKind.TEMPLATE = TemplateArgumentKind(5)
-TemplateArgumentKind.TEMPLATE_EXPANSION = TemplateArgumentKind(6)
-TemplateArgumentKind.EXPRESSION = TemplateArgumentKind(7)
-TemplateArgumentKind.PACK = TemplateArgumentKind(8)
-TemplateArgumentKind.INVALID = TemplateArgumentKind(9)
+ NULL = 0
+ TYPE = 1
+ DECLARATION = 2
+ NULLPTR = 3
+ INTEGRAL = 4
+ TEMPLATE = 5
+ TEMPLATE_EXPANSION = 6
+ EXPRESSION = 7
+ PACK = 8
+ INVALID = 9
### Exception Specification Kinds ###
class ExceptionSpecificationKind(BaseEnumeration):
@@ -1557,23 +1521,15 @@ class ExceptionSpecificationKind(BaseEnumeration):
that a function has.
"""
- # The required BaseEnumeration declarations.
- _kinds = []
- _name_map = None
-
- def __repr__(self):
- return "ExceptionSpecificationKind.{}".format(self.name)
-
-
-ExceptionSpecificationKind.NONE = ExceptionSpecificationKind(0)
-ExceptionSpecificationKind.DYNAMIC_NONE = ExceptionSpecificationKind(1)
-ExceptionSpecificationKind.DYNAMIC = ExceptionSpecificationKind(2)
-ExceptionSpecificationKind.MS_ANY = ExceptionSpecificationKind(3)
-ExceptionSpecificationKind.BASIC_NOEXCEPT = ExceptionSpecificationKind(4)
-ExceptionSpecificationKind.COMPUTED_NOEXCEPT = ExceptionSpecificationKind(5)
-ExceptionSpecificationKind.UNEVALUATED = ExceptionSpecificationKind(6)
-ExceptionSpecificationKind.UNINSTANTIATED = ExceptionSpecificationKind(7)
-ExceptionSpecificationKind.UNPARSED = ExceptionSpecificationKind(8)
+ NONE = 0
+ DYNAMIC_NONE = 1
+ DYNAMIC = 2
+ MS_ANY = 3
+ BASIC_NOEXCEPT = 4
+ COMPUTED_NOEXCEPT = 5
+ UNEVALUATED = 6
+ UNINSTANTIATED = 7
+ UNPARSED = 8
### Cursors ###
@@ -2182,55 +2138,19 @@ def from_cursor_result(res, fn, args):
return res
-class StorageClass:
+class StorageClass(BaseEnumeration):
"""
Describes the storage class of a declaration
"""
- # The unique kind objects, index by id.
- _kinds = []
- _name_map = None
-
- def __init__(self, value):
- if value >= len(StorageClass._kinds):
- StorageClass._kinds += [None] * (value - len(StorageClass._kinds) + 1)
- if StorageClass._kinds[value] is not None:
- raise ValueError("StorageClass already loaded")
- self.value = value
- StorageClass._kinds[value] = self
- StorageClass._name_map = None
-
- def from_param(self):
- return self.value
-
- @property
- def name(self):
- """Get the enumeration name of this storage class."""
- if self._name_map is None:
- self._name_map = {}
- for key, value in StorageClass.__dict__.items():
- if isinstance(value, StorageClass):
- self._name_map[value] = key
- return self._name_map[self]
-
- @staticmethod
- def from_id(id):
- if id < 0 or id >= len(StorageClass._kinds) or not StorageClass._kinds[id]:
- raise ValueError("Unknown storage class %d" % id)
- return StorageClass._kinds[id]
-
- def __repr__(self):
- return "StorageClass.%s" % (self.name,)
-
-
-StorageClass.INVALID = StorageClass(0)
-StorageClass.NONE = StorageClass(1)
-StorageClass.EXTERN = StorageClass(2)
-StorageClass.STATIC = StorageClass(3)
-StorageClass.PRIVATEEXTERN = StorageClass(4)
-StorageClass.OPENCLWORKGROUPLOCAL = StorageClass(5)
-StorageClass.AUTO = StorageClass(6)
-StorageClass.REGISTER = StorageClass(7)
+ INVALID = 0
+ NONE = 1
+ EXTERN = 2
+ STATIC = 3
+ PRIVATEEXTERN = 4
+ OPENCLWORKGROUPLOCAL = 5
+ AUTO = 6
+ REGISTER = 7
### Availability Kinds ###
@@ -2240,18 +2160,10 @@ class AvailabilityKind(BaseEnumeration):
Describes the availability of an entity.
"""
- # The unique kind objects, indexed by id.
- _kinds = []
- _name_map = None
-
- def __repr__(self):
- return "AvailabilityKind.%s" % (self.name,)
-
-
-AvailabilityKind.AVAILABLE = AvailabilityKind(0)
-AvailabilityKind.DEPRECATED = AvailabilityKind(1)
-AvailabilityKind.NOT_AVAILABLE = AvailabilityKind(2)
-AvailabilityKind.NOT_ACCESSIBLE = AvailabilityKind(3)
+ AVAILABLE = 0
+ DEPRECATED = 1
+ NOT_AVAILABLE = 2
+ NOT_ACCESSIBLE = 3
### C++ access specifiers ###
@@ -2261,22 +2173,11 @@ class AccessSpecifier(BaseEnumeration):
Describes the access of a C++ class member
"""
- # The unique kind objects, index by id.
- _kinds = []
- _name_map = None
-
- def from_param(self):
- return self.value
-
- def __repr__(self):
- return "AccessSpecifier.%s" % (self.name,)
-
-
-AccessSpecifier.INVALID = AccessSpecifier(0)
-AccessSpecifier.PUBLIC = AccessSpecifier(1)
-AccessSpecifier.PROTECTED = AccessSpecifier(2)
-AccessSpecifier.PRIVATE = AccessSpecifier(3)
-AccessSpecifier.NONE = AccessSpecifier(4)
+ INVALID = 0
+ PUBLIC = 1
+ PROTECTED = 2
+ PRIVATE = 3
+ NONE = 4
### Type Kinds ###
@@ -2286,192 +2187,151 @@ class TypeKind(BaseEnumeration):
Describes the kind of type.
"""
- # The unique kind objects, indexed by id.
- _kinds = []
- _name_map = None
-
@property
def spelling(self):
"""Retrieve the spelling of this TypeKind."""
return conf.lib.clang_getTypeKindSpelling(self.value)
- def __repr__(self):
- return "TypeKind.%s" % (self.name,)
-
-
-TypeKind.INVALID = TypeKind(0)
-TypeKind.UNEXPOSED = TypeKind(1)
-TypeKind.VOID = TypeKind(2)
-TypeKind.BOOL = TypeKind(3)
-TypeKind.CHAR_U = TypeKind(4)
-TypeKind.UCHAR = TypeKind(5)
-TypeKind.CHAR16 = TypeKind(6)
-TypeKind.CHAR32 = TypeKind(7)
-TypeKind.USHORT = TypeKind(8)
-TypeKind.UINT = TypeKind(9)
-TypeKind.ULONG = TypeKind(10)
-TypeKind.ULONGLONG = TypeKind(11)
-TypeKind.UINT128 = TypeKind(12)
-TypeKind.CHAR_S = TypeKind(13)
-TypeKind.SCHAR = TypeKind(14)
-TypeKind.WCHAR = TypeKind(15)
-TypeKind.SHORT = TypeKind(16)
-TypeKind.INT = TypeKind(17)
-TypeKind.LONG = TypeKind(18)
-TypeKind.LONGLONG = TypeKind(19)
-TypeKind.INT128 = TypeKind(20)
-TypeKind.FLOAT = TypeKind(21)
-TypeKind.DOUBLE = TypeKind(22)
-TypeKind.LONGDOUBLE = TypeKind(23)
-TypeKind.NULLPTR = TypeKind(24)
-TypeKind.OVERLOAD = TypeKind(25)
-TypeKind.DEPENDENT = TypeKind(26)
-TypeKind.OBJCID = TypeKind(27)
-TypeKind.OBJCCLASS = TypeKind(28)
-TypeKind.OBJCSEL = TypeKind(29)
-TypeKind.FLOAT128 = TypeKind(30)
-TypeKind.HALF = TypeKind(31)
-TypeKind.IBM128 = TypeKind(40)
-TypeKind.COMPLEX = TypeKind(100)
-TypeKind.POINTER = TypeKind(101)
-TypeKind.BLOCKPOINTER = TypeKind(102)
-TypeKind.LVALUEREFERENCE = TypeKind(103)
-TypeKind.RVALUEREFERENCE = TypeKind(104)
-TypeKind.RECORD = TypeKind(105)
-TypeKind.ENUM = TypeKind(106)
-TypeKind.TYPEDEF = TypeKind(107)
-TypeKind.OBJCINTERFACE = TypeKind(108)
-TypeKind.OBJCOBJECTPOINTER = TypeKind(109)
-TypeKind.FUNCTIONNOPROTO = TypeKind(110)
-TypeKind.FUNCTIONPROTO = TypeKind(111)
-TypeKind.CONSTANTARRAY = TypeKind(112)
-TypeKind.VECTOR = TypeKind(113)
-TypeKind.INCOMPLETEARRAY = TypeKind(114)
-TypeKind.VARIABLEARRAY = TypeKind(115)
-TypeKind.DEPENDENTSIZEDARRAY = TypeKind(116)
-TypeKind.MEMBERPOINTER = TypeKind(117)
-TypeKind.AUTO = TypeKind(118)
-TypeKind.ELABORATED = TypeKind(119)
-TypeKind.PIPE = TypeKind(120)
-TypeKind.OCLIMAGE1DRO = TypeKind(121)
-TypeKind.OCLIMAGE1DARRAYRO = TypeKind(122)
-TypeKind.OCLIMAGE1DBUFFERRO = TypeKind(123)
-TypeKind.OCLIMAGE2DRO = TypeKind(124)
-TypeKind.OCLIMAGE2DARRAYRO = TypeKind(125)
-TypeKind.OCLIMAGE2DDEPTHRO = TypeKind(126)
-TypeKind.OCLIMAGE2DARRAYDEPTHRO = TypeKind(127)
-TypeKind.OCLIMAGE2DMSAARO = TypeKind(128)
-TypeKind.OCLIMAGE2DARRAYMSAARO = TypeKind(129)
-TypeKind.OCLIMAGE2DMSAADEPTHRO = TypeKind(130)
-TypeKind.OCLIMAGE2DARRAYMSAADEPTHRO = TypeKind(131)
-TypeKind.OCLIMAGE3DRO = TypeKind(132)
-TypeKind.OCLIMAGE1DWO = TypeKind(133)
-TypeKind.OCLIMAGE1DARRAYWO = TypeKind(134)
-TypeKind.OCLIMAGE1DBUFFERWO = TypeKind(135)
-TypeKind.OCLIMAGE2DWO = TypeKind(136)
-TypeKind.OCLIMAGE2DARRAYWO = TypeKind(137)
-TypeKind.OCLIMAGE2DDEPTHWO = TypeKind(138)
-TypeKind.OCLIMAGE2DARRAYDEPTHWO = TypeKind(139)
-TypeKind.OCLIMAGE2DMSAAWO = TypeKind(140)
-TypeKind.OCLIMAGE2DARRAYMSAAWO = TypeKind(141)
-TypeKind.OCLIMAGE2DMSAADEPTHWO = TypeKind(142)
-TypeKind.OCLIMAGE2DARRAYMSAADEPTHWO = TypeKind(143)
-TypeKind.OCLIMAGE3DWO = TypeKind(144)
-TypeKind.OCLIMAGE1DRW = TypeKind(145)
-TypeKind.OCLIMAGE1DARRAYRW = TypeKind(146)
-TypeKind.OCLIMAGE1DBUFFERRW = TypeKind(147)
-TypeKind.OCLIMAGE2DRW = TypeKind(148)
-TypeKind.OCLIMAGE2DARRAYRW = TypeKind(149)
-TypeKind.OCLIMAGE2DDEPTHRW = TypeKind(150)
-TypeKind.OCLIMAGE2DARRAYDEPTHRW = TypeKind(151)
-TypeKind.OCLIMAGE2DMSAARW = TypeKind(152)
-TypeKind.OCLIMAGE2DARRAYMSAARW = TypeKind(153)
-TypeKind.OCLIMAGE2DMSAADEPTHRW = TypeKind(154)
-TypeKind.OCLIMAGE2DARRAYMSAADEPTHRW = TypeKind(155)
-TypeKind.OCLIMAGE3DRW = TypeKind(156)
-TypeKind.OCLSAMPLER = TypeKind(157)
-TypeKind.OCLEVENT = TypeKind(158)
-TypeKind.OCLQUEUE = TypeKind(159)
-TypeKind.OCLRESERVEID = TypeKind(160)
-
-TypeKind.OBJCOBJECT = TypeKind(161)
-TypeKind.OBJCTYPEPARAM = TypeKind(162)
-TypeKind.ATTRIBUTED = TypeKind(163)
-
-TypeKind.OCLINTELSUBGROUPAVCMCEPAYLOAD = TypeKind(164)
-TypeKind.OCLINTELSUBGROUPAVCIMEPAYLOAD = TypeKind(165)
-TypeKind.OCLINTELSUBGROUPAVCREFPAYLOAD = TypeKind(166)
-TypeKind.OCLINTELSUBGROUPAVCSICPAYLOAD = TypeKind(167)
-TypeKind.OCLINTELSUBGROUPAVCMCERESULT = TypeKind(168)
-TypeKind.OCLINTELSUBGROUPAVCIMERESULT = TypeKind(169)
-TypeKind.OCLINTELSUBGROUPAVCREFRESULT = TypeKind(170)
-TypeKind.OCLINTELSUBGROUPAVCSICRESULT = TypeKind(171)
-TypeKind.OCLINTELSUBGROUPAVCIMERESULTSINGLEREFERENCESTREAMOUT = TypeKind(172)
-TypeKind.OCLINTELSUBGROUPAVCIMERESULTSDUALREFERENCESTREAMOUT = TypeKind(173)
-TypeKind.OCLINTELSUBGROUPAVCIMERESULTSSINGLEREFERENCESTREAMIN = TypeKind(174)
-TypeKind.OCLINTELSUBGROUPAVCIMEDUALREFERENCESTREAMIN = TypeKind(175)
-
-TypeKind.EXTVECTOR = TypeKind(176)
-TypeKind.ATOMIC = TypeKind(177)
-TypeKind.BTFTAGATTRIBUTED = TypeKind(178)
+ INVALID = 0
+ UNEXPOSED = 1
+ VOID = 2
+ BOOL = 3
+ CHAR_U = 4
+ UCHAR = 5
+ CHAR16 = 6
+ CHAR32 = 7
+ USHORT = 8
+ UINT = 9
+ ULONG = 10
+ ULONGLONG = 11
+ UINT128 = 12
+ CHAR_S = 13
+ SCHAR = 14
+ WCHAR = 15
+ SHORT = 16
+ INT = 17
+ LONG = 18
+ LONGLONG = 19
+ INT128 = 20
+ FLOAT = 21
+ DOUBLE = 22
+ LONGDOUBLE = 23
+ NULLPTR = 24
+ OVERLOAD = 25
+ DEPENDENT = 26
+ OBJCID = 27
+ OBJCCLASS = 28
+ OBJCSEL = 29
+ FLOAT128 = 30
+ HALF = 31
+ IBM128 = 40
+ COMPLEX = 100
+ POINTER = 101
+ BLOCKPOINTER = 102
+ LVALUEREFERENCE = 103
+ RVALUEREFERENCE = 104
+ RECORD = 105
+ ENUM = 106
+ TYPEDEF = 107
+ OBJCINTERFACE = 108
+ OBJCOBJECTPOINTER = 109
+ FUNCTIONNOPROTO = 110
+ FUNCTIONPROTO = 111
+ CONSTANTARRAY = 112
+ VECTOR = 113
+ INCOMPLETEARRAY = 114
+ VARIABLEARRAY = 115
+ DEPENDENTSIZEDARRAY = 116
+ MEMBERPOINTER = 117
+ AUTO = 118
+ ELABORATED = 119
+ PIPE = 120
+ OCLIMAGE1DRO = 121
+ OCLIMAGE1DARRAYRO = 122
+ OCLIMAGE1DBUFFERRO = 123
+ OCLIMAGE2DRO = 124
+ OCLIMAGE2DARRAYRO = 125
+ OCLIMAGE2DDEPTHRO = 126
+ OCLIMAGE2DARRAYDEPTHRO = 127
+ OCLIMAGE2DMSAARO = 128
+ OCLIMAGE2DARRAYMSAARO = 129
+ OCLIMAGE2DMSAADEPTHRO = 130
+ OCLIMAGE2DARRAYMSAADEPTHRO = 131
+ OCLIMAGE3DRO = 132
+ OCLIMAGE1DWO = 133
+ OCLIMAGE1DARRAYWO = 134
+ OCLIMAGE1DBUFFERWO = 135
+ OCLIMAGE2DWO = 136
+ OCLIMAGE2DARRAYWO = 137
+ OCLIMAGE2DDEPTHWO = 138
+ OCLIMAGE2DARRAYDEPTHWO = 139
+ OCLIMAGE2DMSAAWO = 140
+ OCLIMAGE2DARRAYMSAAWO = 141
+ OCLIMAGE2DMSAADEPTHWO = 142
+ OCLIMAGE2DARRAYMSAADEPTHWO = 143
+ OCLIMAGE3DWO = 144
+ OCLIMAGE1DRW = 145
+ OCLIMAGE1DARRAYRW = 146
+ OCLIMAGE1DBUFFERRW = 147
+ OCLIMAGE2DRW = 148
+ OCLIMAGE2DARRAYRW = 149
+ OCLIMAGE2DDEPTHRW = 150
+ OCLIMAGE2DARRAYDEPTHRW = 151
+ OCLIMAGE2DMSAARW = 152
+ OCLIMAGE2DARRAYMSAARW = 153
+ OCLIMAGE2DMSAADEPTHRW = 154
+ OCLIMAGE2DARRAYMSAADEPTHRW = 155
+ OCLIMAGE3DRW = 156
+ OCLSAMPLER = 157
+ OCLEVENT = 158
+ OCLQUEUE = 159
+ OCLRESERVEID = 160
+
+ OBJCOBJECT = 161
+ OBJCTYPEPARAM = 162
+ ATTRIBUTED = 163
+
+ OCLINTELSUBGROUPAVCMCEPAYLOAD = 164
+ OCLINTELSUBGROUPAVCIMEPAYLOAD = 165
+ OCLINTELSUBGROUPAVCREFPAYLOAD = 166
+ OCLINTELSUBGROUPAVCSICPAYLOAD = 167
+ OCLINTELSUBGROUPAVCMCERESULT = 168
+ OCLINTELSUBGROUPAVCIMERESULT = 169
+ OCLINTELSUBGROUPAVCREFRESULT = 170
+ OCLINTELSUBGROUPAVCSICRESULT = 171
+ OCLINTELSUBGROUPAVCIMERESULTSINGLEREFERENCESTREAMOUT = 172
+ OCLINTELSUBGROUPAVCIMERESULTSDUALREFERENCESTREAMOUT = 173
+ OCLINTELSUBGROUPAVCIMERESULTSSINGLEREFERENCESTREAMIN = 174
+ OCLINTELSUBGROUPAVCIMEDUALREFERENCESTREAMIN = 175
+
+ EXTVECTOR = 176
+ ATOMIC = 177
+ BTFTAGATTRIBUTED = 178
class RefQualifierKind(BaseEnumeration):
"""Describes a specific ref-qualifier of a type."""
- # The unique kind objects, indexed by id.
- _kinds = []
- _name_map = None
-
- def from_param(self):
- return self.value
-
- def __repr__(self):
- return "RefQualifierKind.%s" % (self.name,)
-
-
-RefQualifierKind.NONE = RefQualifierKind(0)
-RefQualifierKind.LVALUE = RefQualifierKind(1)
-RefQualifierKind.RVALUE = RefQualifierKind(2)
+ NONE = 0
+ LVALUE = 1
+ RVALUE = 2
class LinkageKind(BaseEnumeration):
"""Describes the kind of linkage of a cursor."""
- # The unique kind objects, indexed by id.
- _kinds = []
- _name_map = None
-
- def from_param(self):
- return self.value
-
- def __repr__(self):
- return "LinkageKind.%s" % (self.name,)
-
-
-LinkageKind.INVALID = LinkageKind(0)
-LinkageKind.NO_LINKAGE = LinkageKind(1)
-LinkageKind.INTERNAL = LinkageKind(2)
-LinkageKind.UNIQUE_EXTERNAL = LinkageKind(3)
-LinkageKind.EXTERNAL = LinkageKind(4)
+ INVALID = 0
+ NO_LINKAGE = 1
+ INTERNAL = 2
+ UNIQUE_EXTERNAL = 3
+ EXTERNAL = 4
class TLSKind(BaseEnumeration):
"""Describes the kind of thread-local storage (TLS) of a cursor."""
- # The unique kind objects, indexed by id.
- _kinds = []
- _name_map = None
-
- def from_param(self):
- return self.value
-
- def __repr__(self):
- return "TLSKind.%s" % (self.name,)
-
-
-TLSKind.NONE = TLSKind(0)
-TLSKind.DYNAMIC = TLSKind(1)
-TLSKind.STATIC = TLSKind(2)
+ NONE = 0
+ DYNAMIC = 1
+ STATIC = 2
class Type(Structure):
diff --git a/clang/bindings/python/tests/cindex/test_enums.py b/clang/bindings/python/tests/cindex/test_enums.py
index 6fc0e5ed77e3e..1c01d472d630d 100644
--- a/clang/bindings/python/tests/cindex/test_enums.py
+++ b/clang/bindings/python/tests/cindex/test_enums.py
@@ -31,17 +31,9 @@ class TestCursorKind(unittest.TestCase):
def test_from_id(self):
"""Check that kinds can be constructed from valid IDs"""
for enum in self.enums:
- self.assertEqual(enum.from_id(2), enum._kinds[2])
+ self.assertEqual(enum.from_id(2), enum(2))
+ max_value = max([variant.value for variant in enum])
with self.assertRaises(ValueError):
- enum.from_id(len(enum._kinds))
+ enum.from_id(max_value + 1)
with self.assertRaises(ValueError):
enum.from_id(-1)
-
- def test_unique_kinds(self):
- """Check that no kind name has been used multiple times"""
- for enum in self.enums:
- for id in range(len(enum._kinds)):
- try:
- enum.from_id(id).name
- except ValueError:
- pass
>From a587d753b79720ea0549e60a4aed20ce778fce28 Mon Sep 17 00:00:00 2001
From: Jannick Kremer <jannick.kremer at mailbox.org>
Date: Mon, 24 Jun 2024 17:45:44 +0100
Subject: [PATCH 2/5] [libclang/python] Refactor TokenKind usage
Unify TokenKind implementation with other enums
---
clang/bindings/python/clang/cindex.py | 61 +++++--------------
clang/bindings/python/clang/enumerations.py | 33 ----------
.../python/tests/cindex/test_enums.py | 2 +
.../python/tests/cindex/test_token_kind.py | 20 ------
4 files changed, 17 insertions(+), 99 deletions(-)
delete mode 100644 clang/bindings/python/clang/enumerations.py
diff --git a/clang/bindings/python/clang/cindex.py b/clang/bindings/python/clang/cindex.py
index aacfc333723c4..207ccb2883f99 100644
--- a/clang/bindings/python/clang/cindex.py
+++ b/clang/bindings/python/clang/cindex.py
@@ -64,8 +64,6 @@
from ctypes import *
-import clang.enumerations
-
import collections.abc
import os
from enum import Enum
@@ -573,44 +571,6 @@ def get_tokens(tu, extent):
yield token
-class TokenKind:
- """Describes a specific type of a Token."""
-
- _value_map = {} # int -> TokenKind
-
- def __init__(self, value, name):
- """Create a new TokenKind instance from a numeric value and a name."""
- self.value = value
- self.name = name
-
- def __repr__(self):
- return "TokenKind.%s" % (self.name,)
-
- @staticmethod
- def from_value(value):
- """Obtain a registered TokenKind instance from its value."""
- result = TokenKind._value_map.get(value, None)
-
- if result is None:
- raise ValueError("Unknown TokenKind: %d" % value)
-
- return result
-
- @staticmethod
- def register(value, name):
- """Register a new TokenKind enumeration.
-
- This should only be called at module load time by code within this
- package.
- """
- if value in TokenKind._value_map:
- raise ValueError("TokenKind already registered: %d" % value)
-
- kind = TokenKind(value, name)
- TokenKind._value_map[value] = kind
- setattr(TokenKind, name, kind)
-
-
### Cursor Kinds ###
class BaseEnumeration(Enum):
"""
@@ -635,6 +595,21 @@ def __repr__(self):
)
+class TokenKind(BaseEnumeration):
+ """Describes a specific type of a Token."""
+
+ @classmethod
+ def from_value(cls, value):
+ """Obtain a registered TokenKind instance from its value."""
+ return cls.from_id(value)
+
+ PUNCTUATION = 0
+ KEYWORD = 1
+ IDENTIFIER = 2
+ LITERAL = 3
+ COMMENT = 4
+
+
class CursorKind(BaseEnumeration):
"""
A CursorKind describes the kind of entity that a cursor points to.
@@ -4040,13 +4015,7 @@ def function_exists(self, name):
return True
-def register_enumerations():
- for name, value in clang.enumerations.TokenKinds:
- TokenKind.register(value, name)
-
-
conf = Config()
-register_enumerations()
__all__ = [
"AvailabilityKind",
diff --git a/clang/bindings/python/clang/enumerations.py b/clang/bindings/python/clang/enumerations.py
deleted file mode 100644
index b1013c7372043..0000000000000
--- a/clang/bindings/python/clang/enumerations.py
+++ /dev/null
@@ -1,33 +0,0 @@
-# ===- enumerations.py - Python Enumerations ------------------*- python -*--===#
-#
-# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-# See https://llvm.org/LICENSE.txt for license information.
-# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-#
-# ===------------------------------------------------------------------------===#
-
-"""
-Clang Enumerations
-==================
-
-This module provides static definitions of enumerations that exist in libclang.
-
-Enumerations are typically defined as a list of tuples. The exported values are
-typically munged into other types or classes at module load time.
-
-All enumerations are centrally defined in this file so they are all grouped
-together and easier to audit. And, maybe even one day this file will be
-automatically generated by scanning the libclang headers!
-"""
-
-# Maps to CXTokenKind. Note that libclang maintains a separate set of token
-# enumerations from the C++ API.
-TokenKinds = [
- ("PUNCTUATION", 0),
- ("KEYWORD", 1),
- ("IDENTIFIER", 2),
- ("LITERAL", 3),
- ("COMMENT", 4),
-]
-
-__all__ = ["TokenKinds"]
diff --git a/clang/bindings/python/tests/cindex/test_enums.py b/clang/bindings/python/tests/cindex/test_enums.py
index 1c01d472d630d..5449db6f7b460 100644
--- a/clang/bindings/python/tests/cindex/test_enums.py
+++ b/clang/bindings/python/tests/cindex/test_enums.py
@@ -1,6 +1,7 @@
import unittest
from clang.cindex import (
+ TokenKind,
CursorKind,
TemplateArgumentKind,
ExceptionSpecificationKind,
@@ -16,6 +17,7 @@
class TestCursorKind(unittest.TestCase):
enums = [
+ TokenKind,
CursorKind,
TemplateArgumentKind,
ExceptionSpecificationKind,
diff --git a/clang/bindings/python/tests/cindex/test_token_kind.py b/clang/bindings/python/tests/cindex/test_token_kind.py
index 07200abad0909..747d328a577dc 100644
--- a/clang/bindings/python/tests/cindex/test_token_kind.py
+++ b/clang/bindings/python/tests/cindex/test_token_kind.py
@@ -10,26 +10,6 @@
class TestTokenKind(unittest.TestCase):
- def test_constructor(self):
- """Ensure TokenKind constructor works as expected."""
-
- t = TokenKind(5, "foo")
-
- self.assertEqual(t.value, 5)
- self.assertEqual(t.name, "foo")
-
- def test_bad_register(self):
- """Ensure a duplicate value is rejected for registration."""
-
- with self.assertRaises(ValueError):
- TokenKind.register(2, "foo")
-
- def test_unknown_value(self):
- """Ensure trying to fetch an unknown value raises."""
-
- with self.assertRaises(ValueError):
- TokenKind.from_value(-1)
-
def test_registration(self):
"""Ensure that items registered appear as class attributes."""
self.assertTrue(hasattr(TokenKind, "LITERAL"))
>From 28571e0c651ef61bc4dc377f034785cd5bfdd150 Mon Sep 17 00:00:00 2001
From: Jannick Kremer <jannick.kremer at mailbox.org>
Date: Mon, 1 Jul 2024 14:24:41 +0100
Subject: [PATCH 3/5] [libclang/python] Add test to check uniqueness of enum
variant ids
---
clang/bindings/python/tests/cindex/test_enums.py | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/clang/bindings/python/tests/cindex/test_enums.py b/clang/bindings/python/tests/cindex/test_enums.py
index 5449db6f7b460..d75052954820c 100644
--- a/clang/bindings/python/tests/cindex/test_enums.py
+++ b/clang/bindings/python/tests/cindex/test_enums.py
@@ -15,7 +15,7 @@
)
-class TestCursorKind(unittest.TestCase):
+class TestEnums(unittest.TestCase):
enums = [
TokenKind,
CursorKind,
@@ -39,3 +39,11 @@ def test_from_id(self):
enum.from_id(max_value + 1)
with self.assertRaises(ValueError):
enum.from_id(-1)
+
+ def test_duplicate_ids(self):
+ """Check that no two kinds have the same id"""
+ # for enum in self.enums:
+ for enum in self.enums:
+ num_declared_variants = len(enum._member_map_.keys())
+ num_unique_variants = len(list(enum))
+ self.assertEqual(num_declared_variants, num_unique_variants)
>From 4ee7f75c2b20b53b77f804bd96bd14f25c7cd605 Mon Sep 17 00:00:00 2001
From: Jannick Kremer <jannick.kremer at mailbox.org>
Date: Thu, 11 Jul 2024 11:21:31 +0100
Subject: [PATCH 4/5] [libclang/python] Simplify error raising in
BaseEnumeration
---
clang/bindings/python/clang/cindex.py | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/clang/bindings/python/clang/cindex.py b/clang/bindings/python/clang/cindex.py
index 207ccb2883f99..1d3ab89190407 100644
--- a/clang/bindings/python/clang/cindex.py
+++ b/clang/bindings/python/clang/cindex.py
@@ -583,10 +583,7 @@ def from_param(self):
@classmethod
def from_id(cls, id):
- try:
- return cls(id)
- except ValueError:
- raise ValueError("Unknown %s %d" % (cls.__name__, id)) from None
+ return cls(id)
def __repr__(self):
return "%s.%s" % (
>From c4aa2938bb6485e9bd032fbb542b37e33b32a0b1 Mon Sep 17 00:00:00 2001
From: Jannick Kremer <jannick.kremer at mailbox.org>
Date: Thu, 11 Jul 2024 16:23:00 +0100
Subject: [PATCH 5/5] [libclang/python] Add release note for enum refactoring
---
clang/docs/ReleaseNotes.rst | 1 +
1 file changed, 1 insertion(+)
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 36efeb8c70cca..c34f24b8400a4 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -142,6 +142,7 @@ Clang Python Bindings Potentially Breaking Changes
of variant 271.
- Renamed ``TypeKind`` variant 162 from ``OBJCCLASS`` to ``OBJCTYPEPARAM``.
The previous name was incorrect, it was a duplicate of variant 28.
+- Refactored enum usage, switching to the standard library `Enum` type
What's New in Clang |release|?
==============================
More information about the cfe-commits
mailing list