aboutsummaryrefslogtreecommitdiff
path: root/bindings/python/clang/cindex.py
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2010-01-24 21:20:13 +0000
committerDaniel Dunbar <daniel@zuster.org>2010-01-24 21:20:13 +0000
commit3d855f8d48b235eb2beb45216cced24efd3c08fa (patch)
tree745a13e3f4b81b06af2593c55fb82781750ddb09 /bindings/python/clang/cindex.py
parentfb8ae1796e7209b6dcd9ab08bae7cac55e1cec39 (diff)
cindex/Python: Add Cursor.get_usr().
Also, change Cursor.spelling to return None for non-decls, for consistency with get_usr(). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94386 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'bindings/python/clang/cindex.py')
-rw-r--r--bindings/python/clang/cindex.py20
1 files changed, 17 insertions, 3 deletions
diff --git a/bindings/python/clang/cindex.py b/bindings/python/clang/cindex.py
index 8b4ea5bc32..39239e5020 100644
--- a/bindings/python/clang/cindex.py
+++ b/bindings/python/clang/cindex.py
@@ -174,12 +174,24 @@ class Cursor(Structure):
# declaration prior to issuing the lookup.
return Cursor_def(self)
+ def get_usr(self):
+ """Return the Unified Symbol Resultion (USR) for the entity referenced
+ by the given cursor (or None).
+
+ A Unified Symbol Resolution (USR) is a string that identifies a
+ particular entity (function, class, variable, etc.) within a
+ program. USRs can be compared across translation units to determine,
+ e.g., when references in one translation refer to an entity defined in
+ another translation unit."""
+ return Cursor_usr(self)
+
@property
def spelling(self):
"""Return the spelling of the entity pointed at by the cursor."""
if not self.is_declaration():
- # FIXME: This should be documented in Index.h
- raise ValueError("Cursor does not refer to a Declaration")
+ # FIXME: clang_getCursorSpelling should be fixed to not assert on
+ # this, for consistency with clang_getCursorUSR.
+ return None
return Cursor_spelling(self)
@property
@@ -363,8 +375,10 @@ Cursor_kind = lib.clang_getCursorKind
Cursor_kind.argtypes = [Cursor]
Cursor_kind.restype = c_int
-# FIXME: Not really sure what a USR is or what this function actually does...
Cursor_usr = lib.clang_getCursorUSR
+Cursor_usr.argtypes = [Cursor]
+Cursor_usr.restype = _CXString
+Cursor_usr.errcheck = _CXString.from_result
Cursor_is_decl = lib.clang_isDeclaration
Cursor_is_decl.argtypes = [CursorKind]