getArgType: Types of function parameter/arguments

View source: R/clang.R

getArgTypeR Documentation

Types of function parameter/arguments

Description

These functions allow us to get the types associated with parameters/arguments of routine/function types in C/C++ code. These are typically used when we have a function/routine pointer type and so have an explicit type. This is different from when we have a routine and we can access the parameters differently.

Usage

getArgType(ty, i)
getNumArgTypes(ty)
getArgsType(ty)

Arguments

ty

the CXType corresponding to the routine for getArgsType and getNumArgTypes and to the parameter itself in getArgType

i

the index of the argument, 1-based

Value

An object of class CXType or an invalid type.

Author(s)

Duncan Temple Lang

References

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

See Also

getRoutines

Examples

ds = getDataStructures(system.file("exampleCode", "funPointer.c",  package = "RCIndex"))
    # _Foo is a struct with a collection of fields. f is one of the names
    # and this is a function pointer.
    # Bob (*f)(int x, double y, Handler h, void (*p)(int, double));
    # _Foo and Foo are different - the latter is the typedef
foo = ds$`_Foo`  
    # So we get the CXType for the function type.
fun = getPointeeType(foo@fields$f)

    # get rid of any aliases.
ty = getCanonicalType(fun)

    # how many parameters are there in the function type
getNumArgTypes(ty)
    # get the types for each parameter
getArgsType(ty)

omegahat/RClangSimple documentation built on Aug. 17, 2024, 10:23 a.m.