<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Okay, so at the risk of asking another stupid question...<div><br></div><div><br><div>I'm a bit unclear about how to write the R constructor for a class being exported via the module facility.</div></div><div><br></div><div><br></div><div>class Foo{</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>public:</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>int i;</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>Foo();</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>Foo(SEXP);</div><div>}</div><div><br></div><div><br></div><div><br></div><div>int test(Foo f){</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>return f.i;</div><div>}</div><div><br></div><div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; ">RCPP_MODULE(amodule){</div></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; "><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; color: rgb(145, 24, 103); "><span style="color: #000000"><span class="Apple-tab-span" style="white-space:pre">        </span></span>using<span style="color: #000000"> </span>namespace<span style="color: #000000"> Rcpp ;</span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; color: rgb(145, 24, 103); "><span style="color: #000000"><span class="Apple-tab-span" style="white-space:pre">        </span>function("test",&amp;test);</span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; color: rgb(145, 24, 103); "><span style="color: #000000"><span class="Apple-tab-span" style="white-space:pre">        </span>class&lt;Foo&gt;("Foo");</span></div></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; ">}</div><div><br></div><div><br></div><div>I assume that I need to write Foo(SEXP) in such a way that the external pointer is extracted, and then 'i' is copied over. How does one do this?</div><div><br></div><div><br></div><div>Thanks for the help,</div><div>Ian</div></body></html>