Cool. Yes, Rcpp could make many of the routine tasks easier, thus allowing us to focus on the tough stuff.<br><br>Thanks for the info,<br>Michael<br><br><div class="gmail_quote">On Wed, Jan 20, 2010 at 2:05 AM, Romain Francois <span dir="ltr"><<a href="mailto:romain.francois@dbmail.com">romain.francois@dbmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="im"><br>
On 01/19/2010 03:34 PM, Michael Lawrence wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Thanks for passing this along. Rcpp has come a long way. It could be<br>
very useful as we add more type conversions. The inline compilation is<br>
also cool for experimentation.<br>
</blockquote>
<br></div>
Hi,<br>
<br>
Possibly. For type conversion, we have the magic "as" :<br>
<br>
template <typename T> T as( SEXP m_sexp)<br>
<br>
so that we do things like :<br>
<br>
SEXP foo ;<br>
int x = as<int>( foo ) ;<br>
<br>
the templateness gives the possibility to add other converters, so that<br>
<br>
Whatever y = as<Whatever>( foo ) ;<br>
<br>
<br>
.. and since all our RObject's implement the operator SEXP() for implicit conversion to SEXP, we can do this for free :<br>
<br>
CharacterVector x(1) ; x[0] = "foo" ;<br>
std::string y = as< std::string >( x ) ;<br>
<br>
<br>
One other thing I thought that could help (although I have not poked deeply into your code yet), is the templated external pointer class.<br>
<br>
SEXP x = ... ; /* an external pointer holding a Foo object */<br>
XPtr<Foo> p(x) ;<br>
p->bar() ; /* where bar is a method of Foo */<br>
<br>
see <a href="http://romainfrancois.blog.free.fr/index.php?post/2010/01/08/External-pointers-with-Rcpp" target="_blank">http://romainfrancois.blog.free.fr/index.php?post/2010/01/08/External-pointers-with-Rcpp</a> for details.<br>
<font color="#888888">
<br>
Romain<br>
<br>
</font><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="im">
Michael<br>
<br>
On Tue, Jan 19, 2010 at 1:50 AM, Romain Francois<br></div><div class="im">
<<a href="mailto:romain.francois@dbmail.com" target="_blank">romain.francois@dbmail.com</a> <mailto:<a href="mailto:romain.francois@dbmail.com" target="_blank">romain.francois@dbmail.com</a>>> wrote:<br>
<br>
Hello,<br>
<br>
I just wanted to draw your attention to the new version of Rcpp, that I<br>
think might be useful for qtinterfaces (maybe not).<br>
<br>
Rcpp has been completely redesigned over the holidays (while keeping the<br>
existing interface). Now we have many C++ classes that basically act as<br>
proxy classes for the SEXP they encapsulate. So that the object takes<br>
care of protection/release to the garbage collection.<br>
<br>
We cover just about every (useful) SEXP type. For example, manipulating<br>
a character vector can look like this :<br>
<br>
/* creating a character vector of two elements */<br>
Rcpp::CharacterVector x(2);<br>
x[0] = "foo" ;<br>
x[1] = "bar" ;<br>
<br>
Romain<br>
</div></blockquote><div><div></div><div class="h5">
<br>
<br>
<br>
-- <br>
Romain Francois<br>
Professional R Enthusiast<br>
+33(0) 6 28 91 30 30<br>
<a href="http://romainfrancois.blog.free.fr" target="_blank">http://romainfrancois.blog.free.fr</a><br>
|- <a href="http://tr.im/KfKn" target="_blank">http://tr.im/KfKn</a> : Rcpp 0.7.2<br>
|- <a href="http://tr.im/JOlc" target="_blank">http://tr.im/JOlc</a> : External pointers with Rcpp<br>
`- <a href="http://tr.im/JFqa" target="_blank">http://tr.im/JFqa</a> : R Journal, Volume 1/2, December 2009<br>
<br>
</div></div></blockquote></div><br>