Displaying 1 result from an estimated 1 matches for "r_foo_init".
2005 Apr 18
3
A 'true' R-wrapper for C++ classes
...is created to convert the C++ class to some C-style
code.
(2.2) An R-wrapper wraps the C-wrapper.
Here is a rough example to demonstrate the above:
---------------------
C++ class:
class foo
{
public:
foo();
~foo();
fun();
}
---------------------
C-wrapper:
extern "C" SEXP R_foo_init()
{
foo* obj = new foo();
SEXP res;
PROTECT(res = R_MakeExternalPtr(obj, R_NilValue, R_NilValue));
UNPROTECT(1);
return res;
}
extern "C" SEXP R_foo_fun(SEXP ptr)
{
foo *ptr = Hello
I am trying to wrap some C++ classes into R.
(1) Comparing the OOP and methods packages, I...