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:
parent
3cf41050b5
commit
70c557e8e3
2 changed files with 24 additions and 4 deletions
|
|
@ -1,6 +1,10 @@
|
||||||
Version 2.0.0 (in progress)
|
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
|
2010-05-09: drjoe
|
||||||
Fix bug reported by Wil Nolan change creation of string so
|
Fix bug reported by Wil Nolan change creation of string so
|
||||||
that R 2.7.0+ can use char hashes
|
that R 2.7.0+ can use char hashes
|
||||||
|
|
|
||||||
|
|
@ -2036,7 +2036,13 @@ int R::functionWrapper(Node *n) {
|
||||||
Printv(f->code, cleanup, NIL);
|
Printv(f->code, cleanup, NIL);
|
||||||
Delete(cleanup);
|
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);
|
Printv(f->code, UnProtectWrapupCode, NIL);
|
||||||
|
|
||||||
|
|
@ -2053,7 +2059,17 @@ int R::functionWrapper(Node *n) {
|
||||||
Printv(sfun->code, ";", (Len(tm) ? "ans = " : ""), ".Call('", wname,
|
Printv(sfun->code, ";", (Len(tm) ? "ans = " : ""), ".Call('", wname,
|
||||||
"', ", sargs, "PACKAGE='", Rpackage, "');\n", NIL);
|
"', ", sargs, "PACKAGE='", Rpackage, "');\n", NIL);
|
||||||
if(Len(tm))
|
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)
|
if (destructor)
|
||||||
Printv(f->code, "R_ClearExternalPtr(self);\n", NIL);
|
Printv(f->code, "R_ClearExternalPtr(self);\n", NIL);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue