diff --git a/Examples/test-suite/scilab/ret_by_value_runme.sci b/Examples/test-suite/scilab/ret_by_value_runme.sci index 2be40d62e..f4ab16226 100644 --- a/Examples/test-suite/scilab/ret_by_value_runme.sci +++ b/Examples/test-suite/scilab/ret_by_value_runme.sci @@ -6,8 +6,23 @@ catch swigtesterror(); end +// Test default values if test_myInt_get(a) <> 100 then swigtesterror(); end +if test_myShort_get(a) <> 200 then swigtesterror(); end -if test_myShort_get(a) != 200 then swigtesterror(); end +// Write new values +try + test_myInt_set(a, 42) + test_myShort_set(a, 12) +catch + swigtesterror(); +end -exec("swigtest.quit", -1); \ No newline at end of file +// Read new values +if test_myInt_get(a) <> 42 then swigtesterror(); end +if test_myShort_get(a) <> 12 then swigtesterror(); end + +// Destroy pointer +delete_test(a); + +exec("swigtest.quit", -1); diff --git a/Lib/scilab/scitypemaps.swg b/Lib/scilab/scitypemaps.swg index a5ef5a73c..c9f0e2fa4 100644 --- a/Lib/scilab/scitypemaps.swg +++ b/Lib/scilab/scitypemaps.swg @@ -1208,7 +1208,7 @@ } %typemap(out) SWIGTYPE { - sciErr = createPointer(pvApiCtx, iVarOut, (void *)&$result); + sciErr = createPointer(pvApiCtx, iVarOut, %new_copy($result, $1_ltype)); if (sciErr.iErr) { printError(&sciErr, 0); return 0;