[cfe-commits] r94353 - /cfe/trunk/bindings/python/clang/cindex.py
Daniel Dunbar
daniel at zuster.org
Sat Jan 23 20:09:24 PST 2010
Author: ddunbar
Date: Sat Jan 23 22:09:23 2010
New Revision: 94353
URL: http://llvm.org/viewvc/llvm-project?rev=94353&view=rev
Log:
cindex/Python: Make Cursor.is_... functions not properties.
Also, add ValueError check before calling Cursor_spelling.
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=94353&r1=94352&r2=94353&view=diff
==============================================================================
--- cfe/trunk/bindings/python/clang/cindex.py (original)
+++ cfe/trunk/bindings/python/clang/cindex.py Sat Jan 23 22:09:23 2010
@@ -141,37 +141,30 @@
"""Return the null cursor object."""
return Cursor_null()
- @property
def is_declaration(self):
"""Return True if the cursor points to a declaration."""
return Cursor_is_decl(self.kind)
- @property
def is_reference(self):
"""Return True if the cursor points to a refernce."""
return Cursor_is_ref(self.kind)
- @property
def is_expression(self):
"""Return True if the cursor points to an expression."""
return Cursor_is_expr(self.kind)
- @property
def is_statement(self):
"""Return True if the cursor points to a statement."""
return Cursor_is_stmt(self.kind)
- @property
def is_translation_unit(self):
"""Return True if the cursor points to a translation unit."""
return Cursor_is_tu(self.kind)
- @property
def is_invalid(self):
"""Return True if the cursor points to an invalid entity."""
return Cursor_is_inv(self.kind)
- @property
def is_definition(self):
"""
Returns true if the declaration pointed at by the cursor is also a
@@ -185,7 +178,7 @@
is a declaration, then this simpy returns the declaration. If the
cursor is a reference, then this returns the referenced declaration.
"""
- if not self.is_declaration:
+ if not self.is_declaration():
raise Exception("Cursor does not refer to a Declaration")
return Cursor_decl(self)
@@ -202,6 +195,9 @@
@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")
return Cursor_spelling(self)
@property
More information about the cfe-commits
mailing list