Re: [Rcpp-devel] How to Get Pointer of Underlying Object of Rcpp Module Class

2015-10-06 Thread Tianqi Chen
Thanks to Wush Wu. I think I now find the answer to the question by using RCPP_EXPOSED_CLASS_NODECL One note is that I have to use Rcpp::internal::make_new_object to create the S4 object, instead of Rcpp::wrap. Because current wrap do copy-construct from an existing object to a new pointer. While

Re: [Rcpp-devel] How to Get Pointer of Underlying Object of Rcpp Module Class

2015-10-06 Thread Tianqi Chen
Oh, the question is not about supporting native Save/Load from R. I understand the hardness of that due to no customized loader from external pointer. The function listed here aims to write a customized function like ```save.list``` instead of R's native save/load, which is doable. The question is

Re: [Rcpp-devel] How to Get Pointer of Underlying Object of Rcpp Module Class

2015-10-06 Thread Dirk Eddelbuettel
On 6 October 2015 at 14:40, Tianqi Chen wrote: | Dear Rcpp Developers: | | ```c++ | class MyClass { | public: |    static void SaveList(SEXP list, const std::string& filename) { |           Rcpp::List data_lst(list); |           std::vector internals(data_lst[i]); |           for (size_t i = 0; i

Re: [Rcpp-devel] How to Get Pointer of Underlying Object of Rcpp Module Class

2015-10-06 Thread Tianqi Chen
Sorry about the in-complete message. I sent it earlier but did not get it posted. The question is about how to Get XPtr out from underlying Rcpp S4 object, and how to construct such object from C++ side. Tianqi On Tue, Oct 6, 2015 at 2:40 PM, Tianqi Chen wrote: > Dear Rcpp Developers: > > ```c+

[Rcpp-devel] How to Get Pointer of Underlying Object of Rcpp Module Class

2015-10-06 Thread Tianqi Chen
Dear Rcpp Developers: ```c++ class MyClass { public: static void SaveList(SEXP list, const std::string& filename) { Rcpp::List data_lst(list); std::vector internals(data_lst[i]); for (size_t i = 0; i < data_lst.size(); ++i) { SEXP obj = data_lst[i];