diff options
author | William S Fulton <wsf@fultondesigns.co.uk> | 2019-02-09 22:54:43 +0000 |
---|---|---|
committer | William S Fulton <wsf@fultondesigns.co.uk> | 2019-02-09 22:54:43 +0000 |
commit | 9ab873f432c1ae33234726184e92dc4a67e89348 (patch) | |
tree | abccb0c637579498f545ff5f42c49b5f2ca320b3 /Source/Modules | |
parent | 6ec798f7ff511b677cadf640ee31b7053faf41ca (diff) | |
parent | 28a846705f10e4d1c69277ff9d288b03998cf0c5 (diff) | |
download | swig-9ab873f432c1ae33234726184e92dc4a67e89348.tar.gz |
Merge branch 'ZackerySpytz-OCaml-classDirectorMethod-CAMLreturn'
* ZackerySpytz-OCaml-classDirectorMethod-CAMLreturn:
[OCaml] Fix possible GC issues in generated director code
Conflicts:
Examples/test-suite/ocaml/director_unroll_runme.ml
Diffstat (limited to 'Source/Modules')
-rw-r--r-- | Source/Modules/ocaml.cxx | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/Source/Modules/ocaml.cxx b/Source/Modules/ocaml.cxx index a3a4756f3..417454375 100644 --- a/Source/Modules/ocaml.cxx +++ b/Source/Modules/ocaml.cxx @@ -1405,8 +1405,7 @@ public: pure_virtual = true; } } - - Wrapper_add_local(w, "swig_result", "CAMLparam0();\n" "SWIG_CAMLlocal2(swig_result,args)"); + Printf(w->locals, "CAMLparam0();\n"); /* determine if the method returns a pointer */ is_pointer = SwigType_ispointer_return(decl); @@ -1480,16 +1479,18 @@ public: if (ignored_method) { if (!pure_virtual) { - if (!is_void) - Printf(w->code, "return "); String *super_call = Swig_method_call(super, l); - Printf(w->code, "%s;\n", super_call); + if (is_void) + Printf(w->code, "%s;\n", super_call); + else + Printf(w->code, "CAMLreturn_type(%s);\n", super_call); Delete(super_call); } else { Printf(w->code, "Swig::DirectorPureVirtualException::raise(\"Attempted to invoke pure virtual method %s::%s\");\n", SwigType_namestr(c_classname), SwigType_namestr(name)); } } else { + Wrapper_add_local(w, "swig_result", "SWIG_CAMLlocal2(swig_result, args)"); /* attach typemaps to arguments (C/C++ -> Ocaml) */ String *arglist = NewString(""); @@ -1686,6 +1687,8 @@ public: Printf(w->code, "CAMLreturn_type(*c_result);\n"); } } + } else { + Printf(w->code, "CAMLreturn0;\n"); } Printf(w->code, "}\n"); |