[Rcpp-commits] r1337 - pkg/Rcpp/inst/doc
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Thu May 27 11:53:45 CEST 2010
Author: romain
Date: 2010-05-27 11:53:45 +0200 (Thu, 27 May 2010)
New Revision: 1337
Modified:
pkg/Rcpp/inst/doc/Makefile
pkg/Rcpp/inst/doc/Rcpp-modules.Rnw
Log:
using InputIfFileExists instead of input
Modified: pkg/Rcpp/inst/doc/Makefile
===================================================================
--- pkg/Rcpp/inst/doc/Makefile 2010-05-27 09:29:27 UTC (rev 1336)
+++ pkg/Rcpp/inst/doc/Makefile 2010-05-27 09:53:45 UTC (rev 1337)
@@ -34,4 +34,6 @@
R CMD Sweave Rcpp-modules.Rnw
Rscript -e "tools::texi2dvi( 'Rcpp-modules.tex', pdf = TRUE, clean = TRUE )"
rm -fr Rcpp-modules.tex
+ rm -fr snippets/*.tex
+
Modified: pkg/Rcpp/inst/doc/Rcpp-modules.Rnw
===================================================================
--- pkg/Rcpp/inst/doc/Rcpp-modules.Rnw 2010-05-27 09:29:27 UTC (rev 1336)
+++ pkg/Rcpp/inst/doc/Rcpp-modules.Rnw 2010-05-27 09:53:45 UTC (rev 1337)
@@ -95,15 +95,15 @@
Consider the \texttt{hello} function below:
-\input{snippets/hello}
+\InputIfFileExists{snippets/hello}{}{}
One can expose a such a function using \texttt{Rcpp} converters
-\input{snippets/helloexpose}
+\InputIfFileExists{snippets/helloexpose}{}{}
Or more traditionally using the R API :
-\input{snippets/helloexposerapi}
+\InputIfFileExists{snippets/helloexposerapi}{}{}
Either way requires implication from the programmer and quickly becomes an
time sink when many functions are involved. \textsl{Rcpp modules} provides a
@@ -115,7 +115,7 @@
requires writing glue code for each function that is to be exposed. Consider the
simple \texttt{World} class below:
-\input{snippets/World}
+\InputIfFileExists{snippets/World}{}{}
We might want a way to create objects of this class, and use the member
functions \texttt{greet} and \texttt{set} to alter the object. External pointers
@@ -123,11 +123,11 @@
\texttt{Rcpp:::XPtr} template from \texttt{Rcpp} we can expose the class
by exposing three functions :
-\input{snippets/WorldRcpp}
+\InputIfFileExists{snippets/WorldRcpp}{}{}
which can be used from R with some S4 glue code:
-\input{snippets/WorldRcppR}
+\InputIfFileExists{snippets/WorldRcppR}{}{}
\texttt{Rcpp} considerably simplifies the code that would be involved for using
external pointers with the traditional R API. This still involves
@@ -150,7 +150,7 @@
Consider the \texttt{hello} function from the previous section.
We can expose it to R :
-\input{snippets/helloModule}
+\InputIfFileExists{snippets/helloModule}{}{}
The code creates a module called an Rcpp module called \texttt{yada}
that exposes the \texttt{hello} function. \texttt{Rcpp} automatically
@@ -159,20 +159,20 @@
On the R side, the module is simply retrieved by using the \texttt{Module}
function from \texttt{Rcpp}:
-\input{snippets/helloModuleR}
+\InputIfFileExists{snippets/helloModuleR}{}{}
A module can contain any number of calls to \texttt{function} to register
many internal functions to R. For example, these 6 functions :
-\input{snippets/functions}
+\InputIfFileExists{snippets/functions}{}{}
can be exposed with the following minimal code:
-\input{snippets/functionsModule}
+\InputIfFileExists{snippets/functionsModule}{}{}
and used from R:
-\input{snippets/functionsModuleR}
+\InputIfFileExists{snippets/functionsModuleR}{}{}
The requirements on the functions to be exposed are:
\begin{itemize}
@@ -192,7 +192,7 @@
A class is exposed using the \texttt{class\_} class. The \texttt{World}
class may be exposed to R :
-\input{snippets/WorldModule}
+\InputIfFileExists{snippets/WorldModule}{}{}
\texttt{class\_} is templated by the c++ class or struct that is to be exposed
to R. The parameter of the \texttt{class\_<World>} constructor is the name we will
@@ -208,7 +208,7 @@
to support creation of \texttt{World} objects from R. The Rcpp module assumes
responsabilities for type conversion for input and output types.
-\input{snippets/WorldModuleR}
+\InputIfFileExists{snippets/WorldModuleR}{}{}
\section{Future extensions}
More information about the Rcpp-commits
mailing list