[cfe-commits] r94386 - /cfe/trunk/bindings/python/clang/cindex.py
Daniel Dunbar
daniel at zuster.org
Sun Jan 24 13:20:13 PST 2010
Author: ddunbar
Date: Sun Jan 24 15:20:13 2010
New Revision: 94386
URL: http://llvm.org/viewvc/llvm-project?rev=94386&view=rev
Log:
cindex/Python: Add Cursor.get_usr().
Also, change Cursor.spelling to return None for non-decls, for consistency with get_usr().
Modified:
cfe/trunk/bindings/python/clang/cindex.py
Modified: cfe/trunk/bindings/python/clang/cindex.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/clang/cindex.py?rev=94386&r1=94385&r2=94386&view=diff
==============================================================================
--- cfe/trunk/bindings/python/clang/cindex.py (original)
+++ cfe/trunk/bindings/python/clang/cindex.py Sun Jan 24 15:20:13 2010
@@ -174,12 +174,24 @@
# 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.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]
More information about the cfe-commits
mailing list