summaryrefslogtreecommitdiff
path: root/bindings/python/clang/cindex.py
diff options
context:
space:
mode:
Diffstat (limited to 'bindings/python/clang/cindex.py')
-rw-r--r--bindings/python/clang/cindex.py101
1 files changed, 101 insertions, 0 deletions
diff --git a/bindings/python/clang/cindex.py b/bindings/python/clang/cindex.py
index 4069ab8650d60..b53661a4d0ae9 100644
--- a/bindings/python/clang/cindex.py
+++ b/bindings/python/clang/cindex.py
@@ -94,6 +94,9 @@ if sys.version_info[0] == 3:
return cls(param)
if isinstance(param, bytes):
return cls(param)
+ if param is None:
+ # Support passing null to C functions expecting char arrays
+ return None
raise TypeError("Cannot convert '{}' to '{}'".format(type(param).__name__, cls.__name__))
@staticmethod
@@ -1476,6 +1479,12 @@ class Cursor(Structure):
"""
return conf.lib.clang_CXXMethod_isVirtual(self)
+ def is_abstract_record(self):
+ """Returns True if the cursor refers to a C++ record declaration
+ that has pure virtual member functions.
+ """
+ return conf.lib.clang_CXXRecord_isAbstract(self)
+
def is_scoped_enum(self):
"""Returns True if the cursor refers to a scoped enum declaration.
"""
@@ -1549,6 +1558,22 @@ class Cursor(Structure):
return self._loc
@property
+ def linkage(self):
+ """Return the linkage of this cursor."""
+ if not hasattr(self, '_linkage'):
+ self._linkage = conf.lib.clang_getCursorLinkage(self)
+
+ return LinkageKind.from_id(self._linkage)
+
+ @property
+ def tls_kind(self):
+ """Return the thread-local storage (TLS) kind of this cursor."""
+ if not hasattr(self, '_tls_kind'):
+ self._tls_kind = conf.lib.clang_getCursorTLSKind(self)
+
+ return TLSKind.from_id(self._tls_kind)
+
+ @property
def extent(self):
"""
Return the source range (the range of text) occupied by the entity
@@ -1571,6 +1596,16 @@ class Cursor(Structure):
return StorageClass.from_id(self._storage_class)
@property
+ def availability(self):
+ """
+ Retrieves the availability of the entity pointed at by the cursor.
+ """
+ if not hasattr(self, '_availability'):
+ self._availability = conf.lib.clang_getCursorAvailability(self)
+
+ return AvailabilityKind.from_id(self._availability)
+
+ @property
def access_specifier(self):
"""
Retrieves the access specifier (if any) of the entity pointed at by the
@@ -1907,6 +1942,24 @@ StorageClass.OPENCLWORKGROUPLOCAL = StorageClass(5)
StorageClass.AUTO = StorageClass(6)
StorageClass.REGISTER = StorageClass(7)
+### Availability Kinds ###
+
+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)
### C++ access specifiers ###
@@ -2061,6 +2114,42 @@ RefQualifierKind.NONE = RefQualifierKind(0)
RefQualifierKind.LVALUE = RefQualifierKind(1)
RefQualifierKind.RVALUE = RefQualifierKind(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)
+
+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)
+
class Type(Structure):
"""
The type of an element in the abstract syntax tree.
@@ -3191,6 +3280,7 @@ class Token(Structure):
def cursor(self):
"""The Cursor this Token corresponds to."""
cursor = Cursor()
+ cursor._tu = self._tu
conf.lib.clang_annotateTokens(self._tu, byref(self), 1, byref(cursor))
@@ -3317,6 +3407,10 @@ functionList = [
[Cursor],
bool),
+ ("clang_CXXRecord_isAbstract",
+ [Cursor],
+ bool),
+
("clang_EnumDecl_isScoped",
[Cursor],
bool),
@@ -3438,6 +3532,10 @@ functionList = [
[TranslationUnit, SourceLocation],
Cursor),
+ ("clang_getCursorAvailability",
+ [Cursor],
+ c_int),
+
("clang_getCursorDefinition",
[Cursor],
Cursor,
@@ -4053,6 +4151,7 @@ conf = Config()
register_enumerations()
__all__ = [
+ 'AvailabilityKind',
'Config',
'CodeCompletionResults',
'CompilationDatabase',
@@ -4064,8 +4163,10 @@ __all__ = [
'File',
'FixIt',
'Index',
+ 'LinkageKind',
'SourceLocation',
'SourceRange',
+ 'TLSKind',
'TokenKind',
'Token',
'TranslationUnitLoadError',