Description Usage Arguments Value Author(s) Examples
This function is used to create C code that one can use as a function pointer as a callback which will in turn call an R function. This allows an R programmer to provide an R function where a C routine is expected.
1 |
func |
a |
name |
the name of the new C routine being created. |
functionVar |
a string the provides C code which is used to obtain
the R function to call. This might be to cast an argument of the routine,
access a global variable, or a call to a C routine which will return a |
preamble |
additional code that is inserted into the generated C routine at the end of the declarations but before the calls. |
typeMap |
mappings from C types to converters between R and C and providing corresponding variable types in the different languages. |
a CRoutineDefinition
object containing the generated C routine code.
Duncan Temple Lang
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | #
# Create the description of a C routine that returns an integer
# and accepts 2 parameters - an integer and a double.
#
funDef = new("FunctionPointer",
returnType = new("intType"),
parameters = list(new("Parameter", name = "a", type = new("intType")),
new("Parameter", name = "b", type = new("doubleType"))))
funDef
# now create the proxy routine that would call an R function.
code = createProxyRCall(funDef, "foo")
print(code)
## Not run:
#XXX correct the name of the doubleType for the pointer in the createNativeReference.
funDef = new("FunctionPointer",
returnType = new("intType"),
parameters = list(new("Parameter", name = "a", type = new("intType")),
new("Parameter", name = "b", type = new("PointerType", type = new("doubleType", name = "double")))))
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.