clone: The 'CXCursor' class

cloneR Documentation

The CXCursor class

Description

The CXCursor is one of the two primary data types in RCIndex. A cursor represents semantic information about an element of code. It might be a call expression, a binary operator, a C++ class definition, a variable declaration, a routine/function declaration/definition. Each cursor has a kind field that describes its purpose. The set of possible cursor kinds is available via the variable CXCursorKind. These are enumeration values with a symbolic name and a corresponding integer value used in C code.

Usage

clone(x, ...)
length(x)
show(x)
lapply(x, FUN, ...)
sapply(x, FUN, ..., simplify = TRUE, USE.NAMES = TRUE))
getParent(cursor, semantic = TRUE)

Arguments

x

the object to be cloned

...

additional parameters for the methods

cursor

the CXCursor whose parent is being requested

semantic

a logical value indicating either the semantic parent or alternatively the lexical parent of this cursor.

FUN

the function to be applied to each of the child cursors

simplify

a logical with the same meaning as for base::sapply, i.e., to simplify the results into a vector if possible.

USE.NAMES

a logical value with the same meaning as for base::sapply.

Value

clone returns a new object made from copying the input.

Author(s)

Duncan Temple Lang

References

libclang http://clang.llvm.org/doxygen/group__CINDEX.html

See Also

CXCursor-class

Examples

f = system.file("exampleCode", "fib.c", package = "RCIndex")
r = getRoutines(f)
r$fib
cur = as(r$fib, "CXCursor")
cur[[1]]  # the ParmDecl
cur[[2]] # the body of the routine
cur[[2]][[2]] # the return
cur[[2]][[2]][[1]][[1]] # the BinaryOperator for fib(n-1) + fib(n-2)
getCursorTokens(cur[[2]][[2]][[1]][[1]]) #

bin = cur[[2]][[2]][[1]][[1]]
# get operator
toks = getCursorTokens(bin[[1]])
toks[length(toks)]


omegahat/RClangSimple documentation built on Jan. 17, 2024, 6:27 p.m.