summaryrefslogtreecommitdiffstats
path: root/clang/bindings/python
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2010-01-24 04:09:23 +0000
committerDaniel Dunbar <daniel@zuster.org>2010-01-24 04:09:23 +0000
commit3cdcfe03bf382f3c1d295ac8be8b4b98a435c21e (patch)
treedcad4c677b3bf38c97241c9591b33fe8f02202dd /clang/bindings/python
parentaecc45cb3c836d2dd2b6cc0df517b213f385c75d (diff)
downloadbcm5719-llvm-3cdcfe03bf382f3c1d295ac8be8b4b98a435c21e.tar.gz
bcm5719-llvm-3cdcfe03bf382f3c1d295ac8be8b4b98a435c21e.zip
cindex/Python: Make Cursor.is_... functions not properties.
Also, add ValueError check before calling Cursor_spelling. llvm-svn: 94353
Diffstat (limited to 'clang/bindings/python')
-rw-r--r--clang/bindings/python/clang/cindex.py12
1 files changed, 4 insertions, 8 deletions
diff --git a/clang/bindings/python/clang/cindex.py b/clang/bindings/python/clang/cindex.py
index a571145f35f..fd6714e602e 100644
--- a/clang/bindings/python/clang/cindex.py
+++ b/clang/bindings/python/clang/cindex.py
@@ -141,37 +141,30 @@ class Cursor(Structure):
"""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 @@ class Cursor(Structure):
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 @@ class Cursor(Structure):
@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
OpenPOWER on IntegriCloud