<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Sat, Mar 1, 2014 at 9:30 AM, JJ Allaire <span dir="ltr"><<a href="mailto:jj.allaire@gmail.com" target="_blank">jj.allaire@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr">Gabor,<div><br></div><div>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.</div>
</div></blockquote><div><br></div><div>Yes, I guess it could be translated to a character vector. This is what I am doing currently as a hack:</div><div><br></div><div><a href="https://github.com/gaborcsardi/Rcpp/commit/028f9ac9ab032c8eb196005f0a481f0562387397">https://github.com/gaborcsardi/Rcpp/commit/028f9ac9ab032c8eb196005f0a481f0562387397</a><br>
</div><div><br></div><div>I don't see how std::string could be a good solution, because I have separate enums and want to create as<> conversions for them, so if all of them are std::string, then they cannot have separate as<> conversions.</div>
<div><br></div><div>It would be great to use the R convention, e.g.</div><div><br></div><div>myfun <- function(enum=c("foo", "bar", "foobar")) {</div><div>  enum <- match.arg(enum)</div>
<div>  .Call(...)</div><div>}</div><div><br></div><div>but I guess this is hard to do, because the code generator in attributes.cpp does not have type information. So every "solution" is necessarily hacky. If you have other ideas, please let me know.</div>
<div><br></div><div>Best,</div><div>Gabor</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div dir="ltr">
<div><br></div><div>J.J.</div></div><div class="gmail_extra"><br><br><div class="gmail_quote"><div><div class="h5">On Fri, Feb 28, 2014 at 11:32 PM, Gábor Csárdi <span dir="ltr"><<a href="mailto:csardi.gabor@gmail.com" target="_blank">csardi.gabor@gmail.com</a>></span> wrote:<br>

</div></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div><div class="h5"><div dir="ltr">Hi All, <div>
<br></div><div>it seems that this is currently not supported. </div><div><br></div><div>For this:</div>
<div><br></div><div><div>// [[Rcpp::export("L_tree")]]</div><div>NumericMatrix rogdf_tree_layout(GraphAttributes graph,</div>
<div><span style="white-space:pre-wrap">  </span> double siblingDistance=20, double subtreeDistance=20,</div><div><span style="white-space:pre-wrap">   </span> double levelDistance=50, double treeDistance=50,</div><div>
<span style="white-space:pre-wrap">     </span> bool orthogonalLayout=false,</div><div><span style="white-space:pre-wrap">    </span> Orientation orientation=topToBottom,</div><div><span style="white-space:pre-wrap">    </span> TreeLayout::RootSelectionType selectRoot=TreeLayout::rootIsSource) {</div>


</div><div>...</div><div><br></div><div>where the last two arguments are enums, I get:</div><div><br></div><div><div>Warning messages:</div><div>1: Unable to parse C++ default value 'topToBottom' for argument orientation of function rogdf_tree_layout </div>


</div><div><div>2: Unable to parse C++ default value 'TreeLayout::rootIsSource' for argument selectRoot of function rogdf_tree_layout </div></div><div><br></div><div>and there are no default values in the generated R code.</div>


<div><br></div><div>Is there a workaround? Any chance of adding support for it? How hard do you think it is to support it?</div><div><br></div><div>Thanks, Best,</div><div>Gabor</div><div><br></div></div>
<br></div></div>_______________________________________________<br>
Rcpp-devel mailing list<br>
<a href="mailto:Rcpp-devel@lists.r-forge.r-project.org" target="_blank">Rcpp-devel@lists.r-forge.r-project.org</a><br>
<a href="https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel" target="_blank">https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel</a><br></blockquote></div><br></div>
</blockquote></div><br></div></div>