summaryrefslogtreecommitdiff
path: root/Source/Modules/ocaml.cxx
diff options
context:
space:
mode:
authorWilliam S Fulton <wsf@fultondesigns.co.uk>2019-02-09 22:14:10 +0000
committerWilliam S Fulton <wsf@fultondesigns.co.uk>2019-02-09 22:14:10 +0000
commitd595a7a9edefedbe4daf2e3d570b8160a9f03654 (patch)
tree186a8fb9b19777ff8b0b98b585ac5df535fe98c1 /Source/Modules/ocaml.cxx
parent827035d9cee5b49002f09d8494dc7aa6e1fce4b8 (diff)
parentbdc038b5780746d3659b8935bacd5ff89b1e4ffe (diff)
downloadswig-d595a7a9edefedbe4daf2e3d570b8160a9f03654.tar.gz
Merge branch 'ZackerySpytz-OCaml-cache-caml_named_value'
* ZackerySpytz-OCaml-cache-caml_named_value: [OCaml] Cache the result of caml_named_value() in some cases
Diffstat (limited to 'Source/Modules/ocaml.cxx')
-rw-r--r--Source/Modules/ocaml.cxx6
1 files changed, 4 insertions, 2 deletions
diff --git a/Source/Modules/ocaml.cxx b/Source/Modules/ocaml.cxx
index 1ab99705c..71dd4ec82 100644
--- a/Source/Modules/ocaml.cxx
+++ b/Source/Modules/ocaml.cxx
@@ -1605,10 +1605,12 @@ public:
/* wrap complex arguments to values */
Printv(w->code, wrap_args, NIL);
- /* pass the method call on to the Python object */
+ /* pass the method call on to the OCaml object */
Printv(w->code,
"swig_result = caml_swig_alloc(1,C_list);\n" "SWIG_Store_field(swig_result,0,args);\n" "args = swig_result;\n" "swig_result = Val_unit;\n", 0);
- Printf(w->code, "swig_result = " "caml_callback3(*caml_named_value(\"swig_runmethod\")," "swig_get_self(),caml_copy_string(\"%s\"),args);\n", Getattr(n, "name"));
+ Printf(w->code, "static CAML_VALUE *swig_ocaml_func_val = NULL;\n" "if (!swig_ocaml_func_val) {\n");
+ Printf(w->code, " swig_ocaml_func_val = caml_named_value(\"swig_runmethod\");\n }\n");
+ Printf(w->code, "swig_result = caml_callback3(*swig_ocaml_func_val,swig_get_self(),caml_copy_string(\"%s\"),args);\n", Getattr(n, "name"));
/* exception handling */
tm = Swig_typemap_lookup("director:except", n, Swig_cresult_name(), 0);
if (!tm) {