[Rcpp-devel] Rcpp version of DATAPTR

Dirk Eddelbuettel edd at debian.org
Wed Apr 11 20:42:53 CEST 2012


On 11 April 2012 at 14:16, Whit Armstrong wrote:
| I've been looking in the archives of this list for a while, so forgive
| me if I've missed it.
| 
| Does Rcpp expose a version of the DATAPTR macro?

Nothing rings an immediate bell...

| Sadly, I have a need for a void* in my code...  So I need a very old
| school C way of accessing the raw memory referenced by an SEXP.
| 
| I tried to use RAW(), but the version of RAW exposed when using Rcpp
| is from memory.c, which wraps all the calls w/ checks like this:
|     if(TYPEOF(x) != RAWSXP)
| 	error("%s() can only be applied to a '%s', not a '%s'",
| 	      "RAW", "raw", type2char(TYPEOF(x)));

Just about "everything" inherits from RObject, and RObject has the protected
'SEXP m_sexp;' you may get at.

Otherwise, you can use wrap() to turn an Rcpp object back into a SEXP after
which you have DATAPTR and all the other treasures of the R API.

Dirk

-- 
R/Finance 2012 Conference on May 11 and 12, 2012 at UIC in Chicago, IL
See agenda, registration details and more at http://www.RinFinance.com


More information about the Rcpp-devel mailing list