Skip to content

Commit 8bc8790

Browse files
committed
Adds RCPP_EXPORT_AS, RCPP_EXPORT_WRAP, RCPP_EXPORT_CLASS paragraphs by MathurinD (closes #416)
1 parent b0eb4c7 commit 8bc8790

File tree

3 files changed

+45
-0
lines changed

3 files changed

+45
-0
lines changed

ChangeLog

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
2016-11-18 James J Balamuta <balamut2@illinois.edu>
2+
* vignettes/Rcpp-extending: Switched to attributes and
3+
added external class pointer macro notes by MathurinD
4+
15
2016-11-16 Dirk Eddelbuettel <edd@debian.org>
26

37
* DESCRIPTION: Release 0.12.8

inst/NEWS.Rd

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@
33
\newcommand{\ghpr}{\href{https://github.com/RcppCore/Rcpp/pull/#1}{##1}}
44
\newcommand{\ghit}{\href{https://github.com/RcppCore/Rcpp/issues/#1}{##1}}
55

6+
\section{Changes in Rcpp version 0.12.8 (2017-01-xx)}{
7+
\item Changes in Rcpp Documentation:
8+
\itemize{
9+
\item Exposed pointers macros were included in the Rcpp Extending vignette
10+
(MathurinD; James Balamuta in \ghpr{592} addressing \ghit{418}).
11+
}
12+
}
613
\section{Changes in Rcpp version 0.12.8 (2016-11-16)}{
714
\itemize{
815
\item Changes in Rcpp API:

vignettes/Rcpp-extending.Rnw

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,18 @@ It should be noted that only the declaration is required. The implementation
187187
can appear after the \texttt{Rcpp.h} file is included, and therefore take
188188
full advantage of the \pkg{Rcpp} type system.
189189

190+
Another non-intrusive option is to expose an external pointer. The macro
191+
\texttt{RCPP\_EXPORT\_WRAP} provides an easy way to expose a \proglang{C++} class
192+
to \proglang{R} as an external pointer. It can be used instead of specializing
193+
\texttt{Rcpp::wrap}, and should not be used simultaneously.
194+
195+
<<lang=cpp>>=
196+
#include RcppCommon.h
197+
#include foobar.h
198+
199+
RCPP_EXPORT_WRAP(Bar);
200+
@
201+
190202
\subsection{Templates and partial specialization}
191203

192204
It is perfectly valid to declare a partial specialization for the
@@ -263,6 +275,28 @@ namespace Rcpp {
263275
#include <Rcpp.h>
264276
@
265277

278+
Furthermore, another non-intrusive option is to opt for sharing an R
279+
external pointer. The macro \texttt{RCPP\_EXPORT\_AS} provides an easy way to
280+
extend \texttt{Rcpp::as} to expose \proglang{R} external pointers to
281+
\proglang{C++}. It can be used instead of specializing \texttt{Rcpp::as}, and
282+
should not be used simultaneously.
283+
284+
<<lang=cpp>>=
285+
#include RcppCommon.h
286+
#include foobar.h
287+
288+
RCPP_EXPORT_AS(Bar);
289+
@
290+
291+
With this being said, there is one additional macro that can be used to
292+
simultaneously define both \texttt{Rcpp::wrap} and \texttt{Rcpp::as}
293+
specialization for an external pointer. The macro \texttt{RCPP\_EXPOSED\_CLASS}
294+
can be use to transparently exchange a class between \proglang{R} and
295+
\proglang{C++} as an external pointer. Do not simultaneously use it alongside
296+
\texttt{RCPP\_EXPOSED\_AS}, \texttt{RCPP\_EXPOSED\_WRAP}, \texttt{Rcpp::wrap}, or
297+
\texttt{Rcpp::as}.
298+
299+
266300
\subsection{Templates and partial specialization}
267301

268302
The signature of \texttt{Rcpp::as} does not allow partial specialization.

0 commit comments

Comments
 (0)