[Rcpp-devel] [Rcpp-commits] r221 - in pkg: inst src
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Tue Dec 29 11:05:08 CET 2009
Author: romain
Date: 2009-12-29 11:05:07 +0100 (Tue, 29 Dec 2009)
New Revision: 221
Modified:
pkg/inst/ChangeLog
pkg/src/RcppSexp.cpp
pkg/src/RcppSexp.h
pkg/src/RcppXPtr.h
Log:
added operator SEXP()
Modified: pkg/inst/ChangeLog
===================================================================
--- pkg/inst/ChangeLog 2009-12-29 09:30:12 UTC (rev 220)
+++ pkg/inst/ChangeLog 2009-12-29 10:05:07 UTC (rev 221)
@@ -1,5 +1,15 @@
2009-12-29 Romain Francois <francoisromain at free.fr>
+ * src/RcppXPtr.h: added operator SEXP() to class
+ RcppXPtr to ease implicit conversion from RcppXPtr to SEXP.
+ This means we can directly return the RcppXPtr object to R when the
+ return type of the function is SEXP. (no need to explicitely call
+ asSexp anymore)
+
+ * src/RcppSexp.{h,cpp} : idem
+
+2009-12-29 Romain Francois <francoisromain at free.fr>
+
* src/RcppXPtr.h: new smart external pointer wrapper. The RcppXPtr
template can be used to wrap a external pointer (SEXP) so that it
looks like the dumb pointer it is wrapping (as far as the * and ->
Modified: pkg/src/RcppSexp.cpp
===================================================================
--- pkg/src/RcppSexp.cpp 2009-12-29 09:30:12 UTC (rev 220)
+++ pkg/src/RcppSexp.cpp 2009-12-29 10:05:07 UTC (rev 221)
@@ -376,3 +376,7 @@
return m_sexp == R_NilValue ;
}
+RcppSexp::operator SEXP() const{
+ return m_sexp ;
+}
+
Modified: pkg/src/RcppSexp.h
===================================================================
--- pkg/src/RcppSexp.h 2009-12-29 09:30:12 UTC (rev 220)
+++ pkg/src/RcppSexp.h 2009-12-29 10:05:07 UTC (rev 221)
@@ -48,7 +48,12 @@
RcppSexp(const std::set<Rbyte> & v);
~RcppSexp();
-
+
+ /**
+ * implicit conversion to SEXP
+ */
+ operator SEXP() const ;
+
bool asBool() const;
double asDouble() const;
int asInt() const;
Modified: pkg/src/RcppXPtr.h
===================================================================
--- pkg/src/RcppXPtr.h 2009-12-29 09:30:12 UTC (rev 220)
+++ pkg/src/RcppXPtr.h 2009-12-29 10:05:07 UTC (rev 221)
@@ -106,6 +106,12 @@
*/
SEXP asSexp();
+ /**
+ * implicit conversion to SEXP. So that we can return these
+ * objects to the R side directly
+ */
+ operator SEXP() const ;
+
private:
/**
@@ -176,4 +182,9 @@
return m_sexp ;
}
+template<typename T>
+RcppXPtr<T>::operator SEXP() const {
+ return m_sexp ;
+}
+
#endif
_______________________________________________
Rcpp-commits mailing list
Rcpp-commits at lists.r-forge.r-project.org
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-commits
More information about the Rcpp-devel
mailing list