From 64bb41657701e1ebb4196e59a8a846c19ec55c11 Mon Sep 17 00:00:00 2001 From: Vincent Couvert Date: Thu, 14 Oct 2010 12:38:34 +0000 Subject: [PATCH] Add new test and make it work git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2009-sploving@12268 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- .../test-suite/scilab/ret_by_value_runme.sci | 19 +++++++++++++++++-- Lib/scilab/scitypemaps.swg | 2 +- 2 files changed, 18 insertions(+), 3 deletions(-) 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;