[Rcpp-devel] Rcpp attributes, default values for enums

JJ Allaire jj.allaire at gmail.com
Sat Mar 1 15:30:09 CET 2014


Gabor,

The issue is that we don't know how to translate C++ enums into R (since R
has no enum construct). Since R typically uses a character vector for
enumerated values, another way to approach this would be use a std::string
and then just convert it to enum within the C++ implementation.

J.J.


On Fri, Feb 28, 2014 at 11:32 PM, Gábor Csárdi <csardi.gabor at gmail.com>wrote:

> Hi All,
>
> it seems that this is currently not supported.
>
> For this:
>
> // [[Rcpp::export("L_tree")]]
> NumericMatrix rogdf_tree_layout(GraphAttributes graph,
>  double siblingDistance=20, double subtreeDistance=20,
>  double levelDistance=50, double treeDistance=50,
>  bool orthogonalLayout=false,
>  Orientation orientation=topToBottom,
>  TreeLayout::RootSelectionType selectRoot=TreeLayout::rootIsSource) {
> ...
>
> where the last two arguments are enums, I get:
>
> Warning messages:
> 1: Unable to parse C++ default value 'topToBottom' for argument
> orientation of function rogdf_tree_layout
> 2: Unable to parse C++ default value 'TreeLayout::rootIsSource' for
> argument selectRoot of function rogdf_tree_layout
>
> and there are no default values in the generated R code.
>
> Is there a workaround? Any chance of adding support for it? How hard do
> you think it is to support it?
>
> Thanks, Best,
> Gabor
>
>
> _______________________________________________
> Rcpp-devel mailing list
> Rcpp-devel at lists.r-forge.r-project.org
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20140301/1308f7be/attachment.html>


More information about the Rcpp-devel mailing list