diff --git a/Lib/r/rrun.swg b/Lib/r/rrun.swg index 63b7ecc70..bec981546 100644 --- a/Lib/r/rrun.swg +++ b/Lib/r/rrun.swg @@ -213,17 +213,15 @@ R_SWIG_ReferenceFinalizer(SEXP el) return; } -typedef enum {R_SWIG_EXTERNAL, R_SWIG_OWNER } R_SWIG_Owner; - SWIGRUNTIME SEXP -SWIG_MakePtr(void *ptr, const char *typeName, R_SWIG_Owner owner) +SWIG_MakePtr(void *ptr, const char *typeName, int flags) { SEXP external, r_obj; Rf_protect(external = R_MakeExternalPtr(ptr, Rf_install(typeName), R_NilValue)); Rf_protect(r_obj = NEW_OBJECT(MAKE_CLASS((char *) typeName))); - if(owner) + if (flags & SWIG_POINTER_OWN) R_RegisterCFinalizer(external, R_SWIG_ReferenceFinalizer); r_obj = SET_SLOT(r_obj, Rf_mkString((char *) "ref"), external); diff --git a/Source/Modules/r.cxx b/Source/Modules/r.cxx index bd3395a73..0fe730c83 100644 --- a/Source/Modules/r.cxx +++ b/Source/Modules/r.cxx @@ -637,7 +637,7 @@ String * R::createFunctionPointerHandler(SwigType *t, Node *n, int *numArgs) { Replaceall(tm, "$1", name); Replaceall(tm, "$result", "r_tmp"); replaceRClass(tm, Getattr(p,"type")); - Replaceall(tm,"$owner", "R_SWIG_EXTERNAL"); + Replaceall(tm,"$owner", "0"); Delete(lstr); } @@ -697,7 +697,7 @@ String * R::createFunctionPointerHandler(SwigType *t, Node *n, int *numArgs) { Replaceall(tm,"$input", "r_swig_cb_data->retValue"); Replaceall(tm,"$target", Swig_cresult_name()); replaceRClass(tm, rettype); - Replaceall(tm,"$owner", "R_SWIG_EXTERNAL"); + Replaceall(tm,"$owner", "0"); Replaceall(tm,"$disown","0"); Printf(f->code, "%s\n", tm); } @@ -2062,7 +2062,7 @@ int R::functionWrapper(Node *n) { Replaceall(tm,"$n", pos); // The position into which to store the answer. Replaceall(tm,"$arg", Getattr(p, "emit:input")); Replaceall(tm,"$input", Getattr(p, "emit:input")); - Replaceall(tm,"$owner", "R_SWIG_EXTERNAL"); + Replaceall(tm,"$owner", "0"); Printf(outargs, "%s\n", tm); @@ -2087,9 +2087,9 @@ int R::functionWrapper(Node *n) { replaceRClass(tm, retType); if (GetFlag(n,"feature:new")) { - Replaceall(tm, "$owner", "R_SWIG_OWNER"); + Replaceall(tm, "$owner", "SWIG_POINTER_OWN"); } else { - Replaceall(tm,"$owner", "R_SWIG_EXTERNAL"); + Replaceall(tm,"$owner", "0"); } #if 0