Description Usage Arguments Value Note Author(s) References See Also Examples
This is the high-level function that attempts to provide a simple interface for R users to generate code to allow her or other R users to invoke C/C++ routines and work with C/C++ data strucutres. It attempts to find all or a subset of the routines in a translation unit and generate an R interface to each along with the supporting functionality for converting and working with the data structures that are inputs or outputs to these routines.
The function expects a translation unit file (or parsed translation unit) and by default creates an R interface for each C/C++ routine in that TU. One can specify the routines of interest by name to identify a subset. The function determines which data structures are needed in this interface and generates R and C/C++ code for each these also. One can specify additional data types (e.g. enumerations that are not explicitly used in the routines) for the code generation. And one can also identify the global variables of interest by name.
1 2 3 4 5 6 | generateInterface(tu, routines = character(), dataTypes = character(),
variables = getGlobalVariables(tu, files),
outfile = gsub(".[0-9]t.tu", "", basename(tu)),
includes = character(), language = NA,
omitPattern = character(), files = character(), typeMap = list(),
dllName = gsub(".R$", "", basename(outfile[1])), ...)
|
tu |
the name of the TU file, or the parsed TU object itself giving the collection of nodes in the TU. |
routines |
usually the names of the routines of interest which
are found in the |
dataTypes |
like |
variables |
the list of nodes identifying the variables we want to be able to access (query and possibly set) via our interface to the C code. |
outfile |
a character vector giving either the names of the R and C/C++ files into which the generated code will be written, or alternatively a single string which provides the base name of the file to which the appropriate prefixes will be added to generate the R and C/C++ file names. |
includes |
a character vector containing the
files to |
language |
a string giving the native language of the C/C++ code |
omitPattern |
a regular expression which is used to identify routines which are to be discarded by matching the names of the routines with this regular expression. All matching names are omitted. This provides a convenient mechanism for saying "all but these routines" rather than having to enumerate a lengthy list of those to include. |
files |
a character vector which if specified is passed to
|
typeMap |
a list of mappings for customizing the generated code. Such elements provide information, for example, about how to convert a particular C-level data structure to R or vice verse. |
dllName |
the name of the file that will be compiled, linked
and dynamically loaded into R containing the C-level interface to the
native code. This is used in the generated code in the |
... |
additional arguments passed on to |
A list with the following elements
source |
a character vector giving the names of the files to which the code was written |
routines |
the names of the routines for which code was generated |
dataTypes |
the names of all the data structures for which
interfaces were generated. This is the combination of both
structures specified by the caller (via |
This current does not process C++ classes.
This will be added later and can be done using
other functions, e.g. getClasses
and createMethodBinding
and
writeCode
.
Duncan Temple Lang
The GNU compiler suite.
parseTU
getRoutines
getDataStructures
getClasses
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | ## Not run:
generateInterface("rlimit.cc.001t.tu",
c("getrlimit", "setrlimit"),
dataTypes = "__rlimit_resource",
outfile = "rlimit",
includes = c("<sys/time.h>", "<sys/resource.h>", '"RConverters.h"'),
language = "C")
v = generateInterface("rlimit.cc.001t.tu", , ,
outfile = "bar",
includes = c("<sys/time.h>", "<sys/resource.h>", '"RConverters.h"'),
language = "C", omitPattern = "64", files = "resource.h")
v = generateInterface("tmp.c.001t.tu", , ,
outfile = "bar",
includes = c("<sys/time.h>", "<sys/resource.h>", '"RConverters.h"'),
language = "C", omitPattern = "64")
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.