Description Usage Arguments Value Author(s) References See Also Examples
The methods for writeCode
are responsible for writing the contents of the generated code
to a connection, or by default the console.
After we generate code based on high-level descriptions of native
routines, data structres, classes and methods, these methods take care
of writing the different pieces to different files.
We specify the generated code along with the target code type, i.e.
native or R, to output the relevant pieces of the code.
For example, we might write all the C code.
writeIncludes
is a convenience function for adding a sequence
of #include file
directives to a connection. It can be
instructed to put quotes or <> around each file name, or not!
1 |
obj |
the generated interface in different forms, for C++ classes, collection of methods, individual method interfaces, etc. |
target |
the target language, “r” or “native” at
present. This indicates the language/context for which we are generating the code.
In the future, we will add “header” for .h files to provide declarations
that are used across files, and “namespace” for declarations that appear in a
package's |
... |
additional arguments for |
file |
the connection used when |
includes |
a character vector giving the file names (with
relevant quotes or <> affixes) that will be
included via the C/C++ preprocessor when the native code is
compiled.
Tis is a convenient way to put calls to include files in the code
without explicitl calling |
The return value is of no interest. The side-effect is important to produce the content on a connection.
Duncan Temple Lang <duncan@wald.ucdavis.edu>
http://www.omegahat.org/RGCCTranslationUnit
createClassBindings
createMethodBinding
createInterface
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | library(RGCCTranslationUnit)
# Read the translation unit file for source code that defines several files.
my = parseTU(system.file("examples", "ABC.cpp.tu", package = "RGCCTranslationUnit"))
k = getClassNodes(my)
# Generate the bindings for the class named B,
# creating R and C++ code to interface to the class' methods.
z = createClassBindings(k$B, my)
# The C++ code
writeCode(z, "native")
# The R code,
writeCode(z, "r")
## Not run:
library(RGCCTranslationUnit)
tuFile = "inst/examples/ABC.cpp.tu"
my = parseTU(tuFile)
k = getClassNodes(my, "ABC")
# Generate the bindings for the class named B,
# creating R and C++ code to interface to the class' methods.
aa = createClassBindings( k$A , my)
bb = createClassBindings( k$B , my)
cc = createClassBindings( k$C , my)
f = file("inst/examples/RmyClassB.cpp"); open(f, "w")
cat('#include "RConverters.h"', "\n", file = f)
cat('\#include "ABC.h"', "\n\n\n", file = f)
# cat('extern "C" {', "\n\n\n", file = f)
writeCode(aa, "native", file = f)
writeCode(bb, "native", file = f)
writeCode(cc, "native", file = f)
# cat('}', "\n", file = f)
close(f)
f = file("inst/examples/RABC.R"); open(f, "w")
writeCode(aa, "r", file = f)
writeCode(bb, "r", file = f)
writeCode(cc, "r", file = f)
close(f)
writeCode(aa, "NAMESPACE")
writeCode(bb, "NAMESPACE")
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.