[Rcpp-devel] wrap documentation?

Toby Hocking tdhock5 at gmail.com
Mon Apr 27 18:55:51 CEST 2020


Hi Dirk and Sokol, thanks for the responses.
Dirk I was aware that the C/C++ output type of wrap is always SEXP, but I
my question was about the R type/class.
Also thanks for the ref of the discussion in Sec 3.1 of the JSS 2011
article, which is pretty much what I was looking for, but it seems to be
incomplete. I can deduce from the example that std::vector becomes a list
in R, and std::map<string, int> becomes a named integer vector in R, but I
am looking for a list of all such conversions that have currently been
implemented.
I guess there is no such documentation, and we should instead refer to the
source code as Seugeui pointed out?
In that case I find it a bit problematic, because there are lots of
conversions that are possible, but not obvious upon inspection of wrap.h.
For example the std::vector -> R list conversion is not obvious (I don't
see any mention of std::vector in wrap.h actually).
As an Rcpp user I think it would be very helpful to have a list/table that
documents all the currently implemented conversions. Would that be very
difficult to write by hand / generate from the source code?

On Sun, Apr 26, 2020 at 12:07 AM Sokol Serguei <sokol at insa-toulouse.fr>
wrote:

> Le 26/04/2020 à 01:19, Dirk Eddelbuettel a écrit :
> > On 25 April 2020 at 16:04, Toby Hocking wrote: | Hi, can someone
> > please tell me where the return types of wrap are | documented? The
> > _return_ value of a wrap() call is by definition always SEXP. Just how
> > the _input_ for as<>() converters is always a SEXP. For wrap(), see
> > e.g. Section 3.1 of the JSS 2011 paper which ships as vignette
> > Rcpp-jss-2011.pdf
> To complete the Dirk's response, this gallery example can be of some help:
>
> https://gallery.rcpp.org/articles/custom-templated-wrap-and-as-for-seamingless-interfaces/
>
> And as always, an ultimate place to clarify the trickiest questions is
> the code itself ;) :
>
> https://github.com/sgsokol/Rcpp/blob/master/inst/include/Rcpp/internal/wrap.h
>
> Best,
> Serguei.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20200427/75d31a9f/attachment.html>


More information about the Rcpp-devel mailing list