createClassBindings: Generate R and C/C++ code bindings for a C++ class.

Description Usage Arguments Note Author(s) References See Also

Description

This function is used to generate code that provides an R-language interface to a C++ class. Currently, it generates code to access the instances of the class as references. This makes sense for C++ classes.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
createClassBindings(def, nodes, className = rdef@name, # rdef computed in function from def.
                    types = DefinitionContainer(nodes),
                    polymorphicNames = unique(names(mm)[duplicated(names(mm))]),
                    abstract = isAbstractClass(mm, nodes),
                    resolvedMethods = resolveType(getClassMethods(def), nodes, types),
                    typeMap = list(),
                    generateOverloaded = TRUE, ifdef = character(),
                    helperInfo = NULL, access = "public",
                    dynamicCast = list(),
                    otherClassMethods = NULL, useClassNameMethod = FALSE,
                    signatures = list(),
                    useSignatureParameters = TRUE,
                    dispatchInfo = data.frame(),
                    defaultBaseClass = if(useClassNameMethod)
                                          "RC++ReferenceUseName"
                                       else
                                          "RC++Reference",
                    classDefs = NULL, ...)

Arguments

def

the node giving the class definition. In the future, we will allow this object to be a fully resolved description of the class, i.e. with the methods and types resolved.

nodes

the TU parser returned from parseTU which is an array of the tu nodes.

className

the name of the C++ class being processed

types

the collection of resolved data types, routines, etc. typically a DefinitionContainer.

polymorphicNames

a character vector giving the names of the methods that are overloaded, typically just within this class.

abstract

a logical value indicating if this class is an abstract class for which there can be no C++-level instances.

resolvedMethods

a list of the fully resolved methods, typically obtained from a call to resolveType on the methods returned by getClassMethods. This can be either a list of all the resolved methods

typeMap

a user-specifiable list of "hints" for mapping particular data types in the generated code, i.e. for converting between R and C/C++ and coercing in R functions to the appropriate type for the C/C++ method.

...

additional arguments that are passed on to createMethodBinding.

generateOverloaded

a logical value XXX

ifdef

a character string which, if non-empty, is used to enclose the entire generated code within and #ifdef string ... #endif block. This allows one to generate code that is conditionally compiled, e.g. for specific platforms.

helperInfo

passed on to each call to createMethodBinding.

access

a character vector containing one or more of public, protected, private to indicate which methods should be processed. For each method, we compare its accessability value to this vector and only process it if there is a corresponding entry in this vector. Thus, a value of c("public", "protected") will process both the public and protected methods.

dynamicCast

a logical value or a list that controls how dynamic casting code is generated.

otherClassMethods

methods from other classes

useClassNameMethod

prefix methods, etc. with the name of hte class rather than using translation unit-wide overloading

signatures

a list of the signatures of all functions/methods in the translation unit.

dispatchInfo

a data frame. This is passed to and from the different helper functions and builds up information about the number of possible arguments for different methods.

useSignatureParameters

a logical controlling whether to use the parameters from the local definition or the centralized overloaded method.

defaultBaseClass

the name of the base C++ class to use for defining a new class.

classDefs

a collection of the resolved type descriptions of the classes in the translation unit.

Note

For regular C/C++ structures, we can access the fields and work with instances rather than references to instances, passing such objects between R and C/C++ representations by explicitly copying the fields.

Author(s)

Duncan Temple Lang <duncan@wald.ucdavis.edu>

References

http://www.omegahat.org/RGCCTranslationUnit

See Also

writeCode parseTU


omegahat/RGCCTranslationUnit documentation built on May 24, 2019, 1:53 p.m.