add R garbage collection and newfree

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12023 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Joseph Wang 2010-05-12 04:12:42 +00:00
commit 70c557e8e3
2 changed files with 24 additions and 4 deletions

View file

@ -1,6 +1,10 @@
Version 2.0.0 (in progress)
============================
2010-05-12: drjoe
[R] Add two more changes from Wil Nolan. Get garbage
collection to work. Implement newfree
2010-05-09: drjoe
Fix bug reported by Wil Nolan change creation of string so
that R 2.7.0+ can use char hashes

View file

@ -1673,7 +1673,7 @@ int R::functionWrapper(Node *n) {
}
p = nextSibling(p);
}
String *unresolved_return_type =
Copy(type);
if (expandTypedef(type) &&
@ -1731,7 +1731,7 @@ int R::functionWrapper(Node *n) {
Wrapper *f = NewWrapper();
Wrapper *sfun = NewWrapper();
int isVoidReturnType = (Strcmp(type, "void") == 0);
// Need to use the unresolved return type since
// typedef resolution removes the const which causes a
@ -2036,7 +2036,13 @@ int R::functionWrapper(Node *n) {
Printv(f->code, cleanup, NIL);
Delete(cleanup);
/* Look to see if there is any newfree cleanup code */
if (GetFlag(n, "feature:new")) {
if ((tm = Swig_typemap_lookup("newfree", n, "result", 0))) {
Replaceall(tm, "$source", "result"); /* deprecated */
Printf(f->code, "%s\n", tm);
}
}
Printv(f->code, UnProtectWrapupCode, NIL);
@ -2053,7 +2059,17 @@ int R::functionWrapper(Node *n) {
Printv(sfun->code, ";", (Len(tm) ? "ans = " : ""), ".Call('", wname,
"', ", sargs, "PACKAGE='", Rpackage, "');\n", NIL);
if(Len(tm))
Printf(sfun->code, "%s\n\nans;\n", tm);
{
Printf(sfun->code, "%s\n\n", tm);
if (constructor)
{
String *finalizer = NewString(iname);
Replace(finalizer, "new_", "", DOH_REPLACE_FIRST);
Printf(sfun->code, "reg.finalizer(ans, delete_%s)\n", finalizer);
}
Printf(sfun->code, "ans\n");
}
if (destructor)
Printv(f->code, "R_ClearExternalPtr(self);\n", NIL);