[Rcpp-commits] r2532 - pkg/Rcpp/inst/doc/Rcpp-modules
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Fri Nov 26 13:18:21 CET 2010
Author: romain
Date: 2010-11-26 13:18:21 +0100 (Fri, 26 Nov 2010)
New Revision: 2532
Modified:
pkg/Rcpp/inst/doc/Rcpp-modules/Rcpp-modules.Rnw
Log:
some more
Modified: pkg/Rcpp/inst/doc/Rcpp-modules/Rcpp-modules.Rnw
===================================================================
--- pkg/Rcpp/inst/doc/Rcpp-modules/Rcpp-modules.Rnw 2010-11-26 11:57:12 UTC (rev 2531)
+++ pkg/Rcpp/inst/doc/Rcpp-modules/Rcpp-modules.Rnw 2010-11-26 12:18:21 UTC (rev 2532)
@@ -659,9 +659,12 @@
@
The validator can be used to implement dispatch to the appropriate constructor,
-when multiple constructors taking the same number of arguments are exposed.
+when multiple constructors taking the same number of arguments are exposed.
+The default validator always accepts the constructor as valid if is passed
+the appropriate number of arguments. For example, with the call above, the default
+validator accepts any call from R with two arguments.
-TODO: include example here
+TODO: include validator example here
\subsubsection{Exposing fields and properties}
@@ -853,11 +856,18 @@
or void.
\end{itemize}
-TODO: mention docstring
+\paragraph{Documenting methods}. \texttt{.method} can also include
+a short documentation of the method, after the
+method (or free function) pointer.
-TODO: mention overloading, need good example
+<<lang=cpp>>=
+ .method( "stats", &Bar::stats,
+ "vector indicating the number of times x is read and write" )
+@
+TODO: mention overloading, need good example.
+
\paragraph{Const and non-const member functions}
\texttt{method} is able to expose both \texttt{const} and \texttt{non const}
@@ -874,20 +884,25 @@
To resolve the ambiguity, it is possible to use \texttt{const\_method}
or \texttt{nonconst\_method} instead of \texttt{method} in order
-to restrict the candidate methods.
+to restrict the candidate methods.
\paragraph{Special methods}
\pkg{Rcpp} considers the methods \texttt{[[} and \texttt{[[<-} special,
and promotes them to indexing methods on the \proglang{R} side.
+\subsubsection{Object finalizers}
+The \texttt{.finalizer} member function of \texttt{class\_} can be used to
+register a finalizer. A finalizer is a free function that takes a pointer
+to the target class and return \texttt{void}. The finalizer is called
+before the destructor and so operates on a valid object of the target class.
-\subsubsection{Object finalizers}
+It can be used to perform operations, releasing resources, etc ...
-TODO: described the .finalize
+The finalizer is called automatically when the \proglang{R} object that encapsulates
+the \proglang{C++} object is garbage collected.
-
\subsubsection{S4 dispatch}
When a \proglang{C++} class is exposed by the \texttt{class\_} template,
@@ -910,6 +925,8 @@
\subsubsection{Full example}
+% TODO: maybe replace this by something from wls or RcppModels ?
+
The following example illustrates how to use Rcpp modules to expose
the class \texttt{std::vector<double>} from the STL.
More information about the Rcpp-commits
mailing list