summaryrefslogtreecommitdiff
path: root/modules/api_scilab/tests
diff options
context:
space:
mode:
authorShashank2017-05-29 12:40:26 +0530
committerShashank2017-05-29 12:40:26 +0530
commit0345245e860375a32c9a437c4a9d9cae807134e9 (patch)
treead51ecbfa7bcd3cc5f09834f1bb8c08feaa526a4 /modules/api_scilab/tests
downloadscilab_for_xcos_on_cloud-0345245e860375a32c9a437c4a9d9cae807134e9.tar.gz
scilab_for_xcos_on_cloud-0345245e860375a32c9a437c4a9d9cae807134e9.tar.bz2
scilab_for_xcos_on_cloud-0345245e860375a32c9a437c4a9d9cae807134e9.zip
CMSCOPE changed
Diffstat (limited to 'modules/api_scilab/tests')
-rwxr-xr-xmodules/api_scilab/tests/nonreg_tests/bug_11046.c14
-rwxr-xr-xmodules/api_scilab/tests/nonreg_tests/bug_11046.dia.ref43
-rwxr-xr-xmodules/api_scilab/tests/nonreg_tests/bug_11046.tst44
-rwxr-xr-xmodules/api_scilab/tests/nonreg_tests/bug_11093.c43
-rwxr-xr-xmodules/api_scilab/tests/nonreg_tests/bug_11093.dia.ref32
-rwxr-xr-xmodules/api_scilab/tests/nonreg_tests/bug_11093.tst37
-rwxr-xr-xmodules/api_scilab/tests/nonreg_tests/bug_11106.c63
-rwxr-xr-xmodules/api_scilab/tests/nonreg_tests/bug_11106.dia.ref38
-rwxr-xr-xmodules/api_scilab/tests/nonreg_tests/bug_11106.tst45
-rwxr-xr-xmodules/api_scilab/tests/nonreg_tests/bug_11461.dia.ref25
-rwxr-xr-xmodules/api_scilab/tests/nonreg_tests/bug_11461.tst27
-rwxr-xr-xmodules/api_scilab/tests/nonreg_tests/bug_11538.c49
-rwxr-xr-xmodules/api_scilab/tests/nonreg_tests/bug_11538.dia.ref31
-rwxr-xr-xmodules/api_scilab/tests/nonreg_tests/bug_11538.tst33
-rwxr-xr-xmodules/api_scilab/tests/nonreg_tests/bug_12426.tst40
-rwxr-xr-xmodules/api_scilab/tests/nonreg_tests/bug_7242.dia.ref21
-rwxr-xr-xmodules/api_scilab/tests/nonreg_tests/bug_7242.tst26
-rwxr-xr-xmodules/api_scilab/tests/nonreg_tests/bug_7409.dia.ref34
-rwxr-xr-xmodules/api_scilab/tests/nonreg_tests/bug_7409.tst36
-rwxr-xr-xmodules/api_scilab/tests/nonreg_tests/bug_8587.c49
-rwxr-xr-xmodules/api_scilab/tests/nonreg_tests/bug_8587.dia.ref32
-rwxr-xr-xmodules/api_scilab/tests/nonreg_tests/bug_8587.tst33
-rwxr-xr-xmodules/api_scilab/tests/nonreg_tests/bug_8688.c40
-rwxr-xr-xmodules/api_scilab/tests/nonreg_tests/bug_8688.dia.ref29
-rwxr-xr-xmodules/api_scilab/tests/nonreg_tests/bug_8688.tst31
-rwxr-xr-xmodules/api_scilab/tests/nonreg_tests/bug_9264.c90
-rwxr-xr-xmodules/api_scilab/tests/nonreg_tests/bug_9264.dia.ref32
-rwxr-xr-xmodules/api_scilab/tests/nonreg_tests/bug_9264.tst33
-rwxr-xr-xmodules/api_scilab/tests/nonreg_tests/bug_9707.c84
-rwxr-xr-xmodules/api_scilab/tests/nonreg_tests/bug_9707.dia.ref41
-rwxr-xr-xmodules/api_scilab/tests/nonreg_tests/bug_9707.tst44
-rwxr-xr-xmodules/api_scilab/tests/nonreg_tests/bug_9708.c30
-rwxr-xr-xmodules/api_scilab/tests/nonreg_tests/bug_9708.dia.ref31
-rwxr-xr-xmodules/api_scilab/tests/nonreg_tests/bug_9708.tst33
-rwxr-xr-xmodules/api_scilab/tests/nonreg_tests/build_bug_12426_gateway.sce59
-rwxr-xr-xmodules/api_scilab/tests/nonreg_tests/sci_addErrorMessage.c55
-rwxr-xr-xmodules/api_scilab/tests/nonreg_tests/sci_empty_test.cpp62
-rwxr-xr-xmodules/api_scilab/tests/unit_tests/booleanExample.c81
-rwxr-xr-xmodules/api_scilab/tests/unit_tests/booleanExample.dia.ref22
-rwxr-xr-xmodules/api_scilab/tests/unit_tests/booleanExample.tst24
-rwxr-xr-xmodules/api_scilab/tests/unit_tests/booleanSparseExample.c63
-rwxr-xr-xmodules/api_scilab/tests/unit_tests/booleanSparseExample.dia.ref16
-rwxr-xr-xmodules/api_scilab/tests/unit_tests/booleanSparseExample.tst18
-rwxr-xr-xmodules/api_scilab/tests/unit_tests/boolean_writing_api.c104
-rwxr-xr-xmodules/api_scilab/tests/unit_tests/boolean_writing_api.dia.ref24
-rwxr-xr-xmodules/api_scilab/tests/unit_tests/boolean_writing_api.tst28
-rwxr-xr-xmodules/api_scilab/tests/unit_tests/calloverloadfunction_api.c22
-rwxr-xr-xmodules/api_scilab/tests/unit_tests/calloverloadfunction_api.dia.ref26
-rwxr-xr-xmodules/api_scilab/tests/unit_tests/calloverloadfunction_api.tst32
-rwxr-xr-xmodules/api_scilab/tests/unit_tests/check_matrix_dimension.c69
-rwxr-xr-xmodules/api_scilab/tests/unit_tests/check_matrix_dimension.dia.ref32
-rwxr-xr-xmodules/api_scilab/tests/unit_tests/check_matrix_dimension.tst24
-rwxr-xr-xmodules/api_scilab/tests/unit_tests/common_function.dia.ref45
-rwxr-xr-xmodules/api_scilab/tests/unit_tests/common_function.tst23
-rwxr-xr-xmodules/api_scilab/tests/unit_tests/common_function_api.c161
-rwxr-xr-xmodules/api_scilab/tests/unit_tests/common_list_api.c108
-rwxr-xr-xmodules/api_scilab/tests/unit_tests/common_list_api.tst28
-rwxr-xr-xmodules/api_scilab/tests/unit_tests/common_read_api.c612
-rwxr-xr-xmodules/api_scilab/tests/unit_tests/common_read_api.tst36
-rwxr-xr-xmodules/api_scilab/tests/unit_tests/deleteNamedVariable.c47
-rwxr-xr-xmodules/api_scilab/tests/unit_tests/deleteNamedVariable.dia.ref30
-rwxr-xr-xmodules/api_scilab/tests/unit_tests/deleteNamedVariable.tst33
-rwxr-xr-xmodules/api_scilab/tests/unit_tests/doubleExample.c127
-rwxr-xr-xmodules/api_scilab/tests/unit_tests/doubleExample.dia.ref22
-rwxr-xr-xmodules/api_scilab/tests/unit_tests/doubleExample.tst24
-rwxr-xr-xmodules/api_scilab/tests/unit_tests/double_reading_api.c100
-rwxr-xr-xmodules/api_scilab/tests/unit_tests/double_reading_api.dia.ref25
-rwxr-xr-xmodules/api_scilab/tests/unit_tests/double_reading_api.tst27
-rwxr-xr-xmodules/api_scilab/tests/unit_tests/double_writing_api.c107
-rwxr-xr-xmodules/api_scilab/tests/unit_tests/double_writing_api.dia.ref24
-rwxr-xr-xmodules/api_scilab/tests/unit_tests/double_writing_api.tst26
-rwxr-xr-xmodules/api_scilab/tests/unit_tests/hypermatExample.c90
-rwxr-xr-xmodules/api_scilab/tests/unit_tests/hypermatExample.dia.ref18
-rwxr-xr-xmodules/api_scilab/tests/unit_tests/hypermatExample.tst21
-rwxr-xr-xmodules/api_scilab/tests/unit_tests/hypermatIntExample.c174
-rwxr-xr-xmodules/api_scilab/tests/unit_tests/hypermatIntExample.dia.ref26
-rwxr-xr-xmodules/api_scilab/tests/unit_tests/hypermatIntExample.tst29
-rwxr-xr-xmodules/api_scilab/tests/unit_tests/integer_reading_api.c277
-rwxr-xr-xmodules/api_scilab/tests/unit_tests/integer_reading_api.dia.ref39
-rwxr-xr-xmodules/api_scilab/tests/unit_tests/integer_reading_api.tst41
-rwxr-xr-xmodules/api_scilab/tests/unit_tests/integer_writing_api.c277
-rwxr-xr-xmodules/api_scilab/tests/unit_tests/integer_writing_api.dia.ref39
-rwxr-xr-xmodules/api_scilab/tests/unit_tests/integer_writing_api.tst41
-rwxr-xr-xmodules/api_scilab/tests/unit_tests/list_createlist_api.c134
-rwxr-xr-xmodules/api_scilab/tests/unit_tests/list_createlist_api.dia.ref23
-rwxr-xr-xmodules/api_scilab/tests/unit_tests/list_createlist_api.tst25
-rwxr-xr-xmodules/api_scilab/tests/unit_tests/pointer_reading_api.c69
-rwxr-xr-xmodules/api_scilab/tests/unit_tests/pointer_reading_api.dia.ref18
-rwxr-xr-xmodules/api_scilab/tests/unit_tests/pointer_reading_api.tst20
-rwxr-xr-xmodules/api_scilab/tests/unit_tests/polyExample.c148
-rwxr-xr-xmodules/api_scilab/tests/unit_tests/polyExample.dia.ref22
-rwxr-xr-xmodules/api_scilab/tests/unit_tests/polyExample.tst24
-rwxr-xr-xmodules/api_scilab/tests/unit_tests/poly_reading_api.c161
-rwxr-xr-xmodules/api_scilab/tests/unit_tests/poly_reading_api.dia.ref38
-rwxr-xr-xmodules/api_scilab/tests/unit_tests/poly_reading_api.tst40
-rwxr-xr-xmodules/api_scilab/tests/unit_tests/poly_writing_api.c56
-rwxr-xr-xmodules/api_scilab/tests/unit_tests/poly_writing_api.dia.ref19
-rwxr-xr-xmodules/api_scilab/tests/unit_tests/poly_writing_api.tst21
-rwxr-xr-xmodules/api_scilab/tests/unit_tests/read_write_boolean_api.c64
-rwxr-xr-xmodules/api_scilab/tests/unit_tests/read_write_boolean_api.dia.ref18
-rwxr-xr-xmodules/api_scilab/tests/unit_tests/read_write_boolean_api.tst20
-rwxr-xr-xmodules/api_scilab/tests/unit_tests/read_write_bsparse_api.c97
-rwxr-xr-xmodules/api_scilab/tests/unit_tests/read_write_bsparse_api.dia.ref18
-rwxr-xr-xmodules/api_scilab/tests/unit_tests/read_write_bsparse_api.tst20
-rwxr-xr-xmodules/api_scilab/tests/unit_tests/sparseExample.c91
-rwxr-xr-xmodules/api_scilab/tests/unit_tests/sparseExample.dia.ref18
-rwxr-xr-xmodules/api_scilab/tests/unit_tests/sparseExample.tst20
-rwxr-xr-xmodules/api_scilab/tests/unit_tests/sparse_reading_api.c77
-rwxr-xr-xmodules/api_scilab/tests/unit_tests/sparse_reading_api.dia.ref20
-rwxr-xr-xmodules/api_scilab/tests/unit_tests/sparse_reading_api.tst18
-rwxr-xr-xmodules/api_scilab/tests/unit_tests/sparse_writing_api.c37
-rwxr-xr-xmodules/api_scilab/tests/unit_tests/sparse_writing_api.dia.ref17
-rwxr-xr-xmodules/api_scilab/tests/unit_tests/sparse_writing_api.tst19
-rwxr-xr-xmodules/api_scilab/tests/unit_tests/stringExample.c89
-rwxr-xr-xmodules/api_scilab/tests/unit_tests/stringExample.dia.ref18
-rwxr-xr-xmodules/api_scilab/tests/unit_tests/stringExample.tst20
-rwxr-xr-xmodules/api_scilab/tests/unit_tests/string_reading_api.c124
-rwxr-xr-xmodules/api_scilab/tests/unit_tests/string_reading_api.dia.ref18
-rwxr-xr-xmodules/api_scilab/tests/unit_tests/string_reading_api.tst20
-rwxr-xr-xmodules/api_scilab/tests/unit_tests/string_writing_api.c56
-rwxr-xr-xmodules/api_scilab/tests/unit_tests/string_writing_api.dia.ref24
-rwxr-xr-xmodules/api_scilab/tests/unit_tests/string_writing_api.tst26
122 files changed, 6518 insertions, 0 deletions
diff --git a/modules/api_scilab/tests/nonreg_tests/bug_11046.c b/modules/api_scilab/tests/nonreg_tests/bug_11046.c
new file mode 100755
index 000000000..189c044e2
--- /dev/null
+++ b/modules/api_scilab/tests/nonreg_tests/bug_11046.c
@@ -0,0 +1,14 @@
+#include "api_scilab.h"
+#if API_SCILAB_VERSION < 3
+#include "stack-c.h"
+#endif
+#include "localization.h"
+#include "Scierror.h"
+
+int sci_bug_11046(char *fname)
+{
+ CheckRhs(0, 0);
+ sciprint("Overload call macro\n"); // %_myscifun
+ OverLoad(0);
+ return 0;
+}
diff --git a/modules/api_scilab/tests/nonreg_tests/bug_11046.dia.ref b/modules/api_scilab/tests/nonreg_tests/bug_11046.dia.ref
new file mode 100755
index 000000000..2096f178e
--- /dev/null
+++ b/modules/api_scilab/tests/nonreg_tests/bug_11046.dia.ref
@@ -0,0 +1,43 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2012 - Scilab Enterprises - Antoine ELIAS
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- ENGLISH IMPOSED -->
+//
+// <-- CLI SHELL MODE -->
+//
+// <-- Non-regression test for bug 11046 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/11046
+//
+// <-- Short Description -->
+// Sometimes, OverLoad(0) did not call %_xxx but %x_xxx overload
+ilib_verbose(0);
+mkdir(pathconvert(TMPDIR+"/bug_11046"));
+cd(pathconvert(TMPDIR+"/bug_11046"));
+copyfile(SCI+"/modules/api_scilab/tests/nonreg_tests/bug_11046.c",pathconvert(TMPDIR+"/bug_11046/bug_11046.c",%F));
+ilib_build("gw_bug_11046", ["bug_11046", "sci_bug_11046"], "bug_11046.c", []);
+exec("loader.sce");
+function %_bug_11046()
+ disp('OK default overload called.')
+endfunction
+//call %_myscifun
+bug_11046();
+Overload call macro
+
+ OK default overload called.
+function [x] = call_overload(a, b)
+ bug_11046();
+ x = 2;
+endfunction
+function call_overload2(a, b)
+endfunction
+//try to call %s_bug_11046
+call_overload2(1, call_overload(1,2));
+Overload call macro
+
+ OK default overload called.
diff --git a/modules/api_scilab/tests/nonreg_tests/bug_11046.tst b/modules/api_scilab/tests/nonreg_tests/bug_11046.tst
new file mode 100755
index 000000000..bd5294aca
--- /dev/null
+++ b/modules/api_scilab/tests/nonreg_tests/bug_11046.tst
@@ -0,0 +1,44 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2012 - Scilab Enterprises - Antoine ELIAS
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- ENGLISH IMPOSED -->
+//
+// <-- CLI SHELL MODE -->
+//
+// <-- Non-regression test for bug 11046 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/11046
+//
+// <-- Short Description -->
+// Sometimes, OverLoad(0) did not call %_xxx but %x_xxx overload
+
+ilib_verbose(0);
+mkdir(pathconvert(TMPDIR+"/bug_11046"));
+cd(pathconvert(TMPDIR+"/bug_11046"));
+copyfile(SCI+"/modules/api_scilab/tests/nonreg_tests/bug_11046.c",pathconvert(TMPDIR+"/bug_11046/bug_11046.c",%F));
+ilib_build("gw_bug_11046", ["bug_11046", "sci_bug_11046"], "bug_11046.c", []);
+exec("loader.sce");
+
+function %_bug_11046()
+ disp('OK default overload called.')
+endfunction
+
+//call %_myscifun
+bug_11046();
+
+
+function [x] = call_overload(a, b)
+ bug_11046();
+ x = 2;
+endfunction
+
+function call_overload2(a, b)
+endfunction
+
+//try to call %s_bug_11046
+call_overload2(1, call_overload(1,2));
diff --git a/modules/api_scilab/tests/nonreg_tests/bug_11093.c b/modules/api_scilab/tests/nonreg_tests/bug_11093.c
new file mode 100755
index 000000000..dc373c6e4
--- /dev/null
+++ b/modules/api_scilab/tests/nonreg_tests/bug_11093.c
@@ -0,0 +1,43 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2011 - DIGITEO - Allan CORNET
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+#include <stdlib.h>
+#include <api_scilab.h>
+#include <Scierror.h>
+#include <MALLOC.h>
+#include <localization.h>
+// =============================================================================
+int sci_bug_11093(char *fname)
+{
+ SciErr sciErr;
+ int* piAddr = NULL;
+ char* pstName = NULL;
+ int iRet = 0;
+
+ checkInputArgument(pvApiCtx, 1, 1);
+
+ sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddr);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 1;
+ }
+
+
+ if (getAllocatedSingleString(pvApiCtx, piAddr, &pstName))
+ {
+ return 1;
+ }
+
+ iRet = isNamedVarExist(pvApiCtx, pstName);
+ FREE(pstName);
+
+ createScalarBoolean(pvApiCtx, Rhs + 1, iRet);
+ LhsVar(1) = Rhs + 1;
+ return 0;
+}
+// =============================================================================
diff --git a/modules/api_scilab/tests/nonreg_tests/bug_11093.dia.ref b/modules/api_scilab/tests/nonreg_tests/bug_11093.dia.ref
new file mode 100755
index 000000000..843279430
--- /dev/null
+++ b/modules/api_scilab/tests/nonreg_tests/bug_11093.dia.ref
@@ -0,0 +1,32 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2012 - DIGITEO - Antoine ELIAS
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- CLI SHELL MODE -->
+// <-- Non-regression test for bug 7242 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=7242
+//
+// <-- Short Description -->
+// Check name is already used by a variable
+// or un function ( built-in or macro )
+BUGNAME = "bug_11093";
+ilib_verbose(0);
+if haveacompiler() then
+ cd TMPDIR;
+ mkdir(BUGNAME);
+ cd(BUGNAME);
+ DEST = TMPDIR + "/" + BUGNAME + "/" + BUGNAME + ".c";
+ copyfile(SCI + "/modules/api_scilab/tests/nonreg_tests/" + BUGNAME + ".c", DEST);
+ assert_checkequal(isfile(DEST), %T);
+ gw_functions = [BUGNAME, "sci_" + BUGNAME];
+ ilib_build("lib" + BUGNAME, gw_functions, BUGNAME + ".c", []);
+ exec loader.sce;
+ execstr("a = " + BUGNAME + "(""cos"")", "errcatch");
+ assert_checktrue(a);
+ execstr("b = " + BUGNAME + "(""myFunctionThatNotExist"")", "errcatch");
+ assert_checkfalse(b);
+end
diff --git a/modules/api_scilab/tests/nonreg_tests/bug_11093.tst b/modules/api_scilab/tests/nonreg_tests/bug_11093.tst
new file mode 100755
index 000000000..17c2ae1f4
--- /dev/null
+++ b/modules/api_scilab/tests/nonreg_tests/bug_11093.tst
@@ -0,0 +1,37 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2012 - DIGITEO - Antoine ELIAS
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- CLI SHELL MODE -->
+
+// <-- Non-regression test for bug 7242 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=7242
+//
+// <-- Short Description -->
+// Check name is already used by a variable
+// or un function ( built-in or macro )
+
+BUGNAME = "bug_11093";
+ilib_verbose(0);
+if haveacompiler() then
+ cd TMPDIR;
+ mkdir(BUGNAME);
+ cd(BUGNAME);
+ DEST = TMPDIR + "/" + BUGNAME + "/" + BUGNAME + ".c";
+ copyfile(SCI + "/modules/api_scilab/tests/nonreg_tests/" + BUGNAME + ".c", DEST);
+ assert_checkequal(isfile(DEST), %T);
+
+ gw_functions = [BUGNAME, "sci_" + BUGNAME];
+
+ ilib_build("lib" + BUGNAME, gw_functions, BUGNAME + ".c", []);
+ exec loader.sce;
+ execstr("a = " + BUGNAME + "(""cos"")", "errcatch");
+ assert_checktrue(a);
+ execstr("b = " + BUGNAME + "(""myFunctionThatNotExist"")", "errcatch");
+ assert_checkfalse(b);
+end \ No newline at end of file
diff --git a/modules/api_scilab/tests/nonreg_tests/bug_11106.c b/modules/api_scilab/tests/nonreg_tests/bug_11106.c
new file mode 100755
index 000000000..2fb1fe9ba
--- /dev/null
+++ b/modules/api_scilab/tests/nonreg_tests/bug_11106.c
@@ -0,0 +1,63 @@
+/* ========================================================================== */
+/* bug 8587 */
+/* Allan CORNET - 2010 - DIGITEO */
+/* ========================================================================== */
+#include <api_scilab.h>
+#include <Scierror.h>
+#include <MALLOC.h>
+/* ========================================================================== */
+int sci_bug_11106(char *fname)
+{
+ int* piAddr = NULL;
+ char pstRet[64];
+
+ getVarAddressFromPosition(pvApiCtx, 1, &piAddr);
+
+ if (isStringType(pvApiCtx, piAddr))
+ {
+ //named check
+ char* pstVar = NULL;
+ getAllocatedSingleString(pvApiCtx, piAddr, &pstVar);
+
+ if (isNamedListType(pvApiCtx, pstVar))
+ {
+ sprintf(pstRet, "%s", "isNamedList");
+ }
+ else if (isNamedTListType(pvApiCtx, pstVar))
+ {
+ sprintf(pstRet, "%s", "isNamedTList");
+ }
+ else if (isNamedMListType(pvApiCtx, pstVar))
+ {
+ sprintf(pstRet, "%s", "isNamedMList");
+ }
+ else
+ {
+ sprintf(pstRet, "%s", "unmanaged named type");
+ }
+ FREE(pstVar);
+ }
+ else
+ {
+ if (isListType(pvApiCtx, piAddr))
+ {
+ sprintf(pstRet, "%s", "isList");
+ }
+ else if (isTListType(pvApiCtx, piAddr))
+ {
+ sprintf(pstRet, "%s", "isTList");
+ }
+ else if (isMListType(pvApiCtx, piAddr))
+ {
+ sprintf(pstRet, "%s", "isMList");
+ }
+ else
+ {
+ sprintf(pstRet, "%s", "unmanaged type");
+ }
+ }
+ createSingleString(pvApiCtx, Rhs + 1, pstRet);
+ LhsVar(1) = Rhs + 1;
+ return 0;
+}
+/* ========================================================================== */
diff --git a/modules/api_scilab/tests/nonreg_tests/bug_11106.dia.ref b/modules/api_scilab/tests/nonreg_tests/bug_11106.dia.ref
new file mode 100755
index 000000000..f084a72c2
--- /dev/null
+++ b/modules/api_scilab/tests/nonreg_tests/bug_11106.dia.ref
@@ -0,0 +1,38 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2012 - DIGITEO - Antoine ELIAS
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- CLI SHELL MODE -->
+//
+// <-- Non-regression test for bug 11106 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=11106
+//
+// <-- Short Description -->
+ilib_verbose(0);
+test_path = get_absolute_file_path('bug_11106.tst');
+currentpath = pwd();
+cd TMPDIR;
+mkdir('bug_11106');
+cd('bug_11106');
+copyfile(SCI+'/modules/api_scilab/tests/nonreg_tests/bug_11106.c' , 'bug_11106.c');
+files = ['bug_11106.c'];
+ilib_build('lib_bug_11106', ['bug_11106', 'sci_bug_11106'], files, []);
+exec loader.sce;
+chdir(currentpath);
+a = list();
+b = tlist("test");
+c = mlist("test");
+d = 1;
+assert_checkequal(bug_11106(a), "isList");
+assert_checkequal(bug_11106(b), "isTList");
+assert_checkequal(bug_11106(c), "isMList");
+assert_checkequal(bug_11106(d), "unmanaged type");
+assert_checkequal(bug_11106("a"), "isNamedList");
+assert_checkequal(bug_11106("b"), "isNamedTList");
+assert_checkequal(bug_11106("c"), "isNamedMList");
+assert_checkequal(bug_11106("d"), "unmanaged named type");
diff --git a/modules/api_scilab/tests/nonreg_tests/bug_11106.tst b/modules/api_scilab/tests/nonreg_tests/bug_11106.tst
new file mode 100755
index 000000000..6dd8590fa
--- /dev/null
+++ b/modules/api_scilab/tests/nonreg_tests/bug_11106.tst
@@ -0,0 +1,45 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2012 - DIGITEO - Antoine ELIAS
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- CLI SHELL MODE -->
+//
+// <-- Non-regression test for bug 11106 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=11106
+//
+// <-- Short Description -->
+
+ilib_verbose(0);
+test_path = get_absolute_file_path('bug_11106.tst');
+currentpath = pwd();
+cd TMPDIR;
+mkdir('bug_11106');
+cd('bug_11106');
+copyfile(SCI+'/modules/api_scilab/tests/nonreg_tests/bug_11106.c' , 'bug_11106.c');
+
+files = ['bug_11106.c'];
+ilib_build('lib_bug_11106', ['bug_11106', 'sci_bug_11106'], files, []);
+exec loader.sce;
+chdir(currentpath);
+
+a = list();
+b = tlist("test");
+c = mlist("test");
+d = 1;
+
+assert_checkequal(bug_11106(a), "isList");
+assert_checkequal(bug_11106(b), "isTList");
+assert_checkequal(bug_11106(c), "isMList");
+assert_checkequal(bug_11106(d), "unmanaged type");
+
+assert_checkequal(bug_11106("a"), "isNamedList");
+assert_checkequal(bug_11106("b"), "isNamedTList");
+assert_checkequal(bug_11106("c"), "isNamedMList");
+assert_checkequal(bug_11106("d"), "unmanaged named type");
+
+
diff --git a/modules/api_scilab/tests/nonreg_tests/bug_11461.dia.ref b/modules/api_scilab/tests/nonreg_tests/bug_11461.dia.ref
new file mode 100755
index 000000000..50fc0ef5f
--- /dev/null
+++ b/modules/api_scilab/tests/nonreg_tests/bug_11461.dia.ref
@@ -0,0 +1,25 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2012 - Scilab Enterprises - Antoine ELIAS
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- CLI SHELL MODE -->
+//
+// <-- Non-regression test for bug 11461 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=11461
+//
+// <-- Short Description -->
+//
+// api_list was not able to create lists and sub lists with undefined items
+listRef = list();
+listRef(1) = 1;
+listRef(4) = list(1,2,3);
+listRef(5) = 1;
+myList = listRef;
+export_to_hdf5(TMPDIR + "/test.sod", "myList");
+clear myList;
+import_from_hdf5(TMPDIR + "/test.sod");
+assert_checkequal(listRef, myList);
diff --git a/modules/api_scilab/tests/nonreg_tests/bug_11461.tst b/modules/api_scilab/tests/nonreg_tests/bug_11461.tst
new file mode 100755
index 000000000..e2c5c9d70
--- /dev/null
+++ b/modules/api_scilab/tests/nonreg_tests/bug_11461.tst
@@ -0,0 +1,27 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2012 - Scilab Enterprises - Antoine ELIAS
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- CLI SHELL MODE -->
+//
+// <-- Non-regression test for bug 11461 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=11461
+//
+// <-- Short Description -->
+//
+// api_list was not able to create lists and sub lists with undefined items
+
+listRef = list();
+listRef(1) = 1;
+listRef(4) = list(1,2,3);
+listRef(5) = 1;
+myList = listRef;
+export_to_hdf5(TMPDIR + "/test.sod", "myList");
+clear myList;
+import_from_hdf5(TMPDIR + "/test.sod");
+assert_checkequal(listRef, myList);
+
diff --git a/modules/api_scilab/tests/nonreg_tests/bug_11538.c b/modules/api_scilab/tests/nonreg_tests/bug_11538.c
new file mode 100755
index 000000000..6eee1eb6b
--- /dev/null
+++ b/modules/api_scilab/tests/nonreg_tests/bug_11538.c
@@ -0,0 +1,49 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2012 - Scilab Enterprises - Antoine ELIAS
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+ *
+ * Please note that piece of code will be rewrited for the Scilab 6 family
+ * However, the API (profile of the functions in the header files) will be
+ * still available and supported in Scilab 6.
+ */
+
+#include "api_scilab.h"
+
+int sci_bug_11538(char* fname, int length)
+{
+ SciErr sciErr;
+ int* piAddr = NULL;
+ wchar_t* pwstData = NULL;
+ char* pstData = NULL;
+
+ CheckRhs(1, 1);
+ CheckLhs(1, 1);
+
+ sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddr);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 1;
+ }
+
+ if (getAllocatedSingleString(pvApiCtx, piAddr, &pstData))
+ {
+ Scierror(999, "Failed to get data as ascii string");
+ return 1;
+ }
+
+ if (getAllocatedSingleWideString(pvApiCtx, piAddr, &pwstData))
+ {
+ Scierror(999, "Failed to get data as wide string");
+ return 1;
+ }
+
+ LhsVar(0) = 1;
+ return 0;
+}
diff --git a/modules/api_scilab/tests/nonreg_tests/bug_11538.dia.ref b/modules/api_scilab/tests/nonreg_tests/bug_11538.dia.ref
new file mode 100755
index 000000000..ee4b190d1
--- /dev/null
+++ b/modules/api_scilab/tests/nonreg_tests/bug_11538.dia.ref
@@ -0,0 +1,31 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2012 - Scilab Enterprises - Antoine ELIAS
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- CLI SHELL MODE -->
+//
+// <-- Non-regression test for bug 11538 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/11538
+//
+// <-- Short Description -->
+// check failed of to_wide_string function in WideString functions
+// The conversion does not fail under Windows do we can not check that we have an error
+if getos() <> "Windows" then
+ ilib_verbose(0);
+ test_path = get_absolute_file_path('bug_11538.tst');
+ currentpath = pwd();
+ cd TMPDIR;
+ mkdir('bug_11538');
+ cd('bug_11538');
+ copyfile(SCI+'/modules/api_scilab/tests/nonreg_tests/bug_11538.c' , 'bug_11538.c');
+ ilib_build('gw_bug_11538', ['bug_11538', 'sci_bug_11538'], 'bug_11538.c', []);
+ exec loader.sce;
+ ierr = execstr("bug_11538(""abs"")", "errcatch");
+ assert_checktrue(ierr == 0);
+ ierr = execstr("bug_11538(ascii(190:210))", "errcatch");
+ assert_checkfalse(ierr == 0);
+end
diff --git a/modules/api_scilab/tests/nonreg_tests/bug_11538.tst b/modules/api_scilab/tests/nonreg_tests/bug_11538.tst
new file mode 100755
index 000000000..3566d7333
--- /dev/null
+++ b/modules/api_scilab/tests/nonreg_tests/bug_11538.tst
@@ -0,0 +1,33 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2012 - Scilab Enterprises - Antoine ELIAS
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- CLI SHELL MODE -->
+//
+// <-- Non-regression test for bug 11538 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/11538
+//
+// <-- Short Description -->
+// check failed of to_wide_string function in WideString functions
+
+// The conversion does not fail under Windows do we can not check that we have an error
+if getos() <> "Windows" then
+ ilib_verbose(0);
+ test_path = get_absolute_file_path('bug_11538.tst');
+ currentpath = pwd();
+ cd TMPDIR;
+ mkdir('bug_11538');
+ cd('bug_11538');
+ copyfile(SCI+'/modules/api_scilab/tests/nonreg_tests/bug_11538.c' , 'bug_11538.c');
+ ilib_build('gw_bug_11538', ['bug_11538', 'sci_bug_11538'], 'bug_11538.c', []);
+ exec loader.sce;
+
+ ierr = execstr("bug_11538(""abs"")", "errcatch");
+ assert_checktrue(ierr == 0);
+ ierr = execstr("bug_11538(ascii(190:210))", "errcatch");
+ assert_checkfalse(ierr == 0);
+end
diff --git a/modules/api_scilab/tests/nonreg_tests/bug_12426.tst b/modules/api_scilab/tests/nonreg_tests/bug_12426.tst
new file mode 100755
index 000000000..8d2df4131
--- /dev/null
+++ b/modules/api_scilab/tests/nonreg_tests/bug_12426.tst
@@ -0,0 +1,40 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2013 - Scilab Enterprises - Simon MARCHETTO
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- CLI SHELL MODE -->
+//
+// <-- INTERACTIVE TEST -->
+//
+// <-- Non-regression test for bug 12426 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=12426
+//
+// <-- Short Description -->
+// By using addErrorMessage, random string error can be displayed.
+
+// exec SCI/modules/api_scilab/tests/nonreg_tests/bug_12426.tst
+ilib_verbose(0);
+directory = get_absolute_file_path("bug_12426.tst");
+exec(directory + "/build_bug_12426_gateway.sce");
+exec(TMPDIR + "/bug_12426_gateway/loader.sce");
+
+n = int32(1);
+disp("add 1 error message");
+addErrorMessage(n);
+
+n = int32(4);
+disp("add 4 error messages");
+addErrorMessage(n);
+
+n = int32(5);
+disp("add 5 error messages");
+addErrorMessage(n);
+
+n = int32(6);
+disp("add 6 error messages");
+addErrorMessage(n);
diff --git a/modules/api_scilab/tests/nonreg_tests/bug_7242.dia.ref b/modules/api_scilab/tests/nonreg_tests/bug_7242.dia.ref
new file mode 100755
index 000000000..ab98adb74
--- /dev/null
+++ b/modules/api_scilab/tests/nonreg_tests/bug_7242.dia.ref
@@ -0,0 +1,21 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2010 - DIGITEO - Antoine ELIAS
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- CLI SHELL MODE -->
+// <-- Non-regression test for bug 7242 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=7242
+//
+// <-- Short Description -->
+// API was unable to retrieve named variable address
+// when variable name is passed in argument of function
+function result = myExport(data, filepath)
+ result = export_to_hdf5(filepath, "data");
+endfunction
+myData = "blam";
+myFile = TMPDIR + "/myFile.sod";
+if ~myExport(myData, myFile) then bugmes();quit;end
diff --git a/modules/api_scilab/tests/nonreg_tests/bug_7242.tst b/modules/api_scilab/tests/nonreg_tests/bug_7242.tst
new file mode 100755
index 000000000..e051c2c65
--- /dev/null
+++ b/modules/api_scilab/tests/nonreg_tests/bug_7242.tst
@@ -0,0 +1,26 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2010 - DIGITEO - Antoine ELIAS
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- CLI SHELL MODE -->
+
+// <-- Non-regression test for bug 7242 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=7242
+//
+// <-- Short Description -->
+// API was unable to retrieve named variable address
+// when variable name is passed in argument of function
+
+function result = myExport(data, filepath)
+ result = export_to_hdf5(filepath, "data");
+endfunction
+
+myData = "blam";
+myFile = TMPDIR + "/myFile.sod";
+
+if ~myExport(myData, myFile) then pause,end
diff --git a/modules/api_scilab/tests/nonreg_tests/bug_7409.dia.ref b/modules/api_scilab/tests/nonreg_tests/bug_7409.dia.ref
new file mode 100755
index 000000000..60dc3b4b7
--- /dev/null
+++ b/modules/api_scilab/tests/nonreg_tests/bug_7409.dia.ref
@@ -0,0 +1,34 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2010 - Artem GLEBOV
+// Copyright (C) 2011 - DIGITEO - Sylvestre Ledru
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- ENGLISH IMPOSED -->
+//
+// <-- CLI SHELL MODE -->
+//
+// <-- Non-regression test for bug 7409 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/7409
+//
+// <-- Short Description -->
+//
+BUGNAME = "sci_empty_test";
+ilib_verbose(0);
+if haveacompiler() then
+ cd TMPDIR;
+ mkdir(BUGNAME);
+ cd(BUGNAME);
+ DEST = TMPDIR + "/" + BUGNAME + "/" + BUGNAME + ".cpp";
+ copyfile(SCI + "/modules/api_scilab/tests/nonreg_tests/" + BUGNAME + ".cpp", DEST);
+ assert_checkequal(isfile(DEST), %T);
+ ilib_build("lib" + BUGNAME,[BUGNAME, BUGNAME], BUGNAME + ".cpp", []);
+ exec loader.sce;
+ [a,b]=sci_empty_test();
+ assert_checkequal(a,[]);
+ assert_checkequal(b,[]);
+end
diff --git a/modules/api_scilab/tests/nonreg_tests/bug_7409.tst b/modules/api_scilab/tests/nonreg_tests/bug_7409.tst
new file mode 100755
index 000000000..dab8063e9
--- /dev/null
+++ b/modules/api_scilab/tests/nonreg_tests/bug_7409.tst
@@ -0,0 +1,36 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2010 - Artem GLEBOV
+// Copyright (C) 2011 - DIGITEO - Sylvestre Ledru
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- ENGLISH IMPOSED -->
+//
+// <-- CLI SHELL MODE -->
+//
+// <-- Non-regression test for bug 7409 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/7409
+//
+// <-- Short Description -->
+//
+
+BUGNAME = "sci_empty_test";
+ilib_verbose(0);
+if haveacompiler() then
+ cd TMPDIR;
+ mkdir(BUGNAME);
+ cd(BUGNAME);
+ DEST = TMPDIR + "/" + BUGNAME + "/" + BUGNAME + ".cpp";
+ copyfile(SCI + "/modules/api_scilab/tests/nonreg_tests/" + BUGNAME + ".cpp", DEST);
+ assert_checkequal(isfile(DEST), %T);
+ ilib_build("lib" + BUGNAME,[BUGNAME, BUGNAME], BUGNAME + ".cpp", []);
+ exec loader.sce;
+ [a,b]=sci_empty_test();
+ assert_checkequal(a,[]);
+ assert_checkequal(b,[]);
+end
+
diff --git a/modules/api_scilab/tests/nonreg_tests/bug_8587.c b/modules/api_scilab/tests/nonreg_tests/bug_8587.c
new file mode 100755
index 000000000..18c327cc6
--- /dev/null
+++ b/modules/api_scilab/tests/nonreg_tests/bug_8587.c
@@ -0,0 +1,49 @@
+/* ========================================================================== */
+/* bug 8587 */
+/* Allan CORNET - 2010 - DIGITEO */
+/* ========================================================================== */
+#include <api_scilab.h>
+#include <BOOL.h>
+#include <Scierror.h>
+#include <MALLOC.h>
+/* ========================================================================== */
+int sci_readDoubles(char *fname)
+{
+#define NAME_MATRIX_TO_READ "REF_TEST_MATRIX"
+#define REF_SIZE_COLS 3
+#define REF_SIZE_ROWS 2
+ SciErr sciErr;
+ int nbRow = 0;
+ int nbCol = 0;
+ double * matrixOfDouble = NULL;
+
+ sciErr = readNamedMatrixOfDouble(pvApiCtx, NAME_MATRIX_TO_READ, &nbRow, &nbCol , NULL);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ }
+
+ if ((nbRow != REF_SIZE_ROWS) || (nbCol != REF_SIZE_COLS))
+ {
+ Scierror(999, "%s: Wrong size for input argument #%s.\n", fname, NAME_MATRIX_TO_READ);
+ return 0;
+ }
+
+ matrixOfDouble = (double*)MALLOC((nbRow * nbCol) * sizeof(double));
+
+ sciErr = readNamedMatrixOfDouble(pvApiCtx, NAME_MATRIX_TO_READ, &nbRow, &nbCol, matrixOfDouble);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ }
+
+ sciErr = createMatrixOfDouble(pvApiCtx, Rhs + 1, nbRow, nbCol, matrixOfDouble);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ }
+
+ LhsVar(1) = Rhs + 1;
+ return 0;
+}
+/* ========================================================================== */
diff --git a/modules/api_scilab/tests/nonreg_tests/bug_8587.dia.ref b/modules/api_scilab/tests/nonreg_tests/bug_8587.dia.ref
new file mode 100755
index 000000000..231101745
--- /dev/null
+++ b/modules/api_scilab/tests/nonreg_tests/bug_8587.dia.ref
@@ -0,0 +1,32 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2010 - DIGITEO - Allan CORNET
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- CLI SHELL MODE -->
+//
+// <-- Non-regression test for bug 8587 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=8587
+//
+// <-- Short Description -->
+// readNamedMatrixOfDouble (readCommonNamedMatrixOfDouble) returned wrong values
+ilib_verbose(0);
+currentpath = pwd();
+cd TMPDIR;
+mkdir('bug_8587');
+TEST_DIR = TMPDIR + filesep() + 'bug_8587';
+copyfile(SCI+'/modules/api_scilab/tests/nonreg_tests/bug_8587.c' , TEST_DIR + filesep() + 'bug_8587.c');
+chdir(TEST_DIR);
+files = ['bug_8587.c'];
+ilib_build('lib_bug_8587', ['readDoubles', 'sci_readDoubles'], files, []);
+exec loader.sce;
+chdir(currentpath);
+REF_TEST_MATRIX = [1 2 3; 4 5 6];
+REF_TEST_MATRIX_COPY = [1 2 3; 4 5 6];
+if execstr("result = readDoubles()", "errcatch") <> 0 then bugmes();quit;end
+if ~or(REF_TEST_MATRIX_COPY == REF_TEST_MATRIX) then bugmes();quit;end
+if ~or(result == REF_TEST_MATRIX) then bugmes();quit;end
diff --git a/modules/api_scilab/tests/nonreg_tests/bug_8587.tst b/modules/api_scilab/tests/nonreg_tests/bug_8587.tst
new file mode 100755
index 000000000..3e60a1aae
--- /dev/null
+++ b/modules/api_scilab/tests/nonreg_tests/bug_8587.tst
@@ -0,0 +1,33 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2010 - DIGITEO - Allan CORNET
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- CLI SHELL MODE -->
+//
+// <-- Non-regression test for bug 8587 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=8587
+//
+// <-- Short Description -->
+// readNamedMatrixOfDouble (readCommonNamedMatrixOfDouble) returned wrong values
+
+ilib_verbose(0);
+currentpath = pwd();
+cd TMPDIR;
+mkdir('bug_8587');
+TEST_DIR = TMPDIR + filesep() + 'bug_8587';
+copyfile(SCI+'/modules/api_scilab/tests/nonreg_tests/bug_8587.c' , TEST_DIR + filesep() + 'bug_8587.c');
+chdir(TEST_DIR);
+files = ['bug_8587.c'];
+ilib_build('lib_bug_8587', ['readDoubles', 'sci_readDoubles'], files, []);
+exec loader.sce;
+chdir(currentpath);
+REF_TEST_MATRIX = [1 2 3; 4 5 6];
+REF_TEST_MATRIX_COPY = [1 2 3; 4 5 6];
+if execstr("result = readDoubles()", "errcatch") <> 0 then pause, end
+if ~or(REF_TEST_MATRIX_COPY == REF_TEST_MATRIX) then pause, end
+if ~or(result == REF_TEST_MATRIX) then pause, end
diff --git a/modules/api_scilab/tests/nonreg_tests/bug_8688.c b/modules/api_scilab/tests/nonreg_tests/bug_8688.c
new file mode 100755
index 000000000..57e5018f5
--- /dev/null
+++ b/modules/api_scilab/tests/nonreg_tests/bug_8688.c
@@ -0,0 +1,40 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2011 - DIGITEO - Allan CORNET
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+#include <stdlib.h>
+#include <api_scilab.h>
+#include <Scierror.h>
+#include <MALLOC.h>
+#include <localization.h>
+
+int sci_bug_8688(char *fname)
+{
+ SciErr sciErr;
+ int N = 20000000;
+ char **ptrStrs = (char **)MALLOC(sizeof(char*) * N);
+ int i = 0;
+
+ if (ptrStrs == NULL)
+ {
+ Scierror(999, "memory allocation error");
+ }
+
+ for (i = 0; i < N; i++)
+ {
+ ptrStrs[i] = strdup("TEST BUG 8688.");
+ }
+
+ sciErr = createMatrixOfString(pvApiCtx, Rhs + 1, 1, N, ptrStrs);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+ LhsVar(1) = 1;
+ return 0;
+}
+// =============================================================================
diff --git a/modules/api_scilab/tests/nonreg_tests/bug_8688.dia.ref b/modules/api_scilab/tests/nonreg_tests/bug_8688.dia.ref
new file mode 100755
index 000000000..fc69e603d
--- /dev/null
+++ b/modules/api_scilab/tests/nonreg_tests/bug_8688.dia.ref
@@ -0,0 +1,29 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2011 - DIGITEO - Allan CORNET
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- CLI SHELL MODE -->
+//
+// <-- Non-regression test for bug 8688 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/8688
+//
+// <-- Short Description -->
+// fillMatrixOfString did not check available memory on stack.
+BUGNAME = "bug_8688";
+ilib_verbose(0);
+if haveacompiler() then
+ cd TMPDIR;
+ mkdir(BUGNAME);
+ cd(BUGNAME);
+ DEST = TMPDIR + "/" + BUGNAME + "/" + BUGNAME + ".c";
+ copyfile(SCI + "/modules/api_scilab/tests/nonreg_tests/" + BUGNAME + ".c", DEST);
+ assert_checkequal(isfile(DEST), %T);
+ ilib_build("lib" + BUGNAME,[BUGNAME,"sci_" + BUGNAME], BUGNAME + ".c", []);
+ exec loader.sce;
+ assert_checkequal(execstr("bug_8688()", "errcatch"), 0);
+end
diff --git a/modules/api_scilab/tests/nonreg_tests/bug_8688.tst b/modules/api_scilab/tests/nonreg_tests/bug_8688.tst
new file mode 100755
index 000000000..568a26982
--- /dev/null
+++ b/modules/api_scilab/tests/nonreg_tests/bug_8688.tst
@@ -0,0 +1,31 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2011 - DIGITEO - Allan CORNET
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- CLI SHELL MODE -->
+//
+// <-- Non-regression test for bug 8688 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/8688
+//
+// <-- Short Description -->
+// fillMatrixOfString did not check available memory on stack.
+
+BUGNAME = "bug_8688";
+ilib_verbose(0);
+if haveacompiler() then
+ cd TMPDIR;
+ mkdir(BUGNAME);
+ cd(BUGNAME);
+ DEST = TMPDIR + "/" + BUGNAME + "/" + BUGNAME + ".c";
+ copyfile(SCI + "/modules/api_scilab/tests/nonreg_tests/" + BUGNAME + ".c", DEST);
+ assert_checkequal(isfile(DEST), %T);
+ ilib_build("lib" + BUGNAME,[BUGNAME,"sci_" + BUGNAME], BUGNAME + ".c", []);
+ exec loader.sce;
+ assert_checkequal(execstr("bug_8688()", "errcatch"), 0);
+end
+
diff --git a/modules/api_scilab/tests/nonreg_tests/bug_9264.c b/modules/api_scilab/tests/nonreg_tests/bug_9264.c
new file mode 100755
index 000000000..a590346b8
--- /dev/null
+++ b/modules/api_scilab/tests/nonreg_tests/bug_9264.c
@@ -0,0 +1,90 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2011 - Calixte DENIZET
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+#include <stdlib.h>
+#include "api_scilab.h"
+#include "Scierror.h"
+#include "MALLOC.h"
+#include "localization.h"
+
+// =============================================================================
+// The aim of this function is just to retrieve from the stack an array of strings
+// to test the speed of the function getMatrixOfString.
+// =============================================================================
+int sci_bug9264(char *fname)
+{
+ SciErr err;
+ int *piAddressVarOne = NULL;
+ int rows = 0, cols = 0;
+
+ CheckInputArgument(pvApiCtx, 1, 1);
+ CheckOutputArgument(pvApiCtx, 1, 1);
+
+ err = getVarAddressFromPosition(pvApiCtx, 1, &piAddressVarOne);
+ if (err.iErr)
+ {
+ printError(&err, 0);
+ return 0;
+ }
+
+ if (isStringType(pvApiCtx, piAddressVarOne))
+ {
+ int i = 0;
+ int size = 0;
+ int* lengths = NULL;
+ char **str = NULL;
+
+ err = getVarDimension(pvApiCtx, piAddressVarOne, &rows, &cols);
+ if (err.iErr)
+ {
+ printError(&err, 0);
+ return -1;
+ }
+
+ if (rows < 1 || cols < 1)
+ {
+ Scierror(999, _("%s: Wrong size for input argument #%d.\n"), fname, 1);
+ return 0;
+ }
+
+ size = rows * cols;
+ lengths = (int*)MALLOC(sizeof(int) * size);
+ if (!lengths)
+ {
+ Scierror(999, _("%s: No more memory.\n"), fname);
+ return 0;
+ }
+
+ err = getMatrixOfString(pvApiCtx, piAddressVarOne, &rows, &cols, lengths, NULL);
+ if (err.iErr)
+ {
+ FREE(lengths);
+ printError(&err, 0);
+ return 0;
+ }
+
+ str = (char**)MALLOC(sizeof(char*) * size);
+ for (; i < size; i++)
+ {
+ str[i] = (char*)MALLOC(sizeof(char) * (lengths[i] + 1));
+ if (str[i] == NULL)
+ {
+ freeArrayOfString(str, i);
+ Scierror(999, _("%s: No more memory.\n"), fname);
+ return 0;
+ }
+ }
+
+ err = getMatrixOfString(pvApiCtx, piAddressVarOne, &rows, &cols, lengths, str);
+
+ FREE(lengths);
+ freeArrayOfString(str, size);
+ }
+
+ AssignOutputVariable(pvApiCtx, 1) = 0;
+ return 0;
+}
diff --git a/modules/api_scilab/tests/nonreg_tests/bug_9264.dia.ref b/modules/api_scilab/tests/nonreg_tests/bug_9264.dia.ref
new file mode 100755
index 000000000..ba151f161
--- /dev/null
+++ b/modules/api_scilab/tests/nonreg_tests/bug_9264.dia.ref
@@ -0,0 +1,32 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2011 - Calixte DENIZET
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- CLI SHELL MODE -->
+//
+// <-- Non-regression test for bug 9264 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/9264
+//
+// <-- Short Description -->
+// Big loss of performance on mputl
+ilib_verbose(0);
+if haveacompiler() then
+ cd TMPDIR;
+ mkdir("bug_9264");
+ cd("bug_9264");
+ copyfile(SCI + "/modules/api_scilab/tests/nonreg_tests/bug_9264.c", TMPDIR + "/bug_9264/bug_9264.c");
+ if ~isfile(TMPDIR + "/bug_9264/bug_9264.c") then bugmes();quit;end
+ ilib_build("build_c",["bug9264","sci_bug9264"], "bug_9264.c", []);
+ exec loader.sce;
+ M = string(rand(200,1000));
+ tic();
+ bug9264(M);
+ T = toc();
+ // More than 2 seconds to read a matrix is not normal
+ if T > 2 then bugmes();quit;end
+end
diff --git a/modules/api_scilab/tests/nonreg_tests/bug_9264.tst b/modules/api_scilab/tests/nonreg_tests/bug_9264.tst
new file mode 100755
index 000000000..07cb81758
--- /dev/null
+++ b/modules/api_scilab/tests/nonreg_tests/bug_9264.tst
@@ -0,0 +1,33 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2011 - Calixte DENIZET
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- CLI SHELL MODE -->
+//
+// <-- Non-regression test for bug 9264 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/9264
+//
+// <-- Short Description -->
+// Big loss of performance on mputl
+
+ilib_verbose(0);
+if haveacompiler() then
+ cd TMPDIR;
+ mkdir("bug_9264");
+ cd("bug_9264");
+ copyfile(SCI + "/modules/api_scilab/tests/nonreg_tests/bug_9264.c", TMPDIR + "/bug_9264/bug_9264.c");
+ if ~isfile(TMPDIR + "/bug_9264/bug_9264.c") then pause, end
+ ilib_build("build_c",["bug9264","sci_bug9264"], "bug_9264.c", []);
+ exec loader.sce;
+
+ M = string(rand(200,1000));
+ tic();
+ bug9264(M);
+ T = toc();
+ // More than 2 seconds to read a matrix is not normal
+ if T > 2 then pause, end
+end
diff --git a/modules/api_scilab/tests/nonreg_tests/bug_9707.c b/modules/api_scilab/tests/nonreg_tests/bug_9707.c
new file mode 100755
index 000000000..988e5f5f7
--- /dev/null
+++ b/modules/api_scilab/tests/nonreg_tests/bug_9707.c
@@ -0,0 +1,84 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2011 - DIGITEO - Allan CORNET
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+#include <stdlib.h>
+#include <api_scilab.h>
+#include <Scierror.h>
+#include <MALLOC.h>
+#include <localization.h>
+// =============================================================================
+int sci_bug_9707_1(char *fname)
+{
+ SciErr sciErr;
+ const char varname[] = "1";
+
+
+ sciErr = createNamedMatrixOfString(pvApiCtx, varname, 1, 1, &fname);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ Scierror(999, _("%s: Invalid variable name.\n"), fname);
+ }
+ return 0;
+}
+// =============================================================================
+int sci_bug_9707_2(char *fname)
+{
+ SciErr sciErr;
+ const char varname[] = "";
+
+ sciErr = createNamedMatrixOfString(pvApiCtx, varname, 1, 1, &fname);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ Scierror(999, _("%s: Invalid variable name.\n"), fname);
+ }
+ return 0;
+}
+// =============================================================================
+int sci_bug_9707_3(char *fname)
+{
+ SciErr sciErr;
+ const char varname[] = " ";
+
+ sciErr = createNamedMatrixOfString(pvApiCtx, varname, 1, 1, &fname);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ Scierror(999, _("%s: Invalid variable name.\n"), fname);
+ }
+ return 0;
+}
+// =============================================================================
+int sci_bug_9707_4(char *fname)
+{
+ SciErr sciErr;
+ const char varname[] = "Scilab Variable";
+
+ sciErr = createNamedMatrixOfString(pvApiCtx, varname, 1, 1, &fname);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ Scierror(999, _("%s: Invalid variable name.\n"), fname);
+ }
+ return 0;
+}
+// =============================================================================
+int sci_bug_9707_OK(char *fname)
+{
+ SciErr sciErr;
+ const char varname[] = "VAR_9707";
+
+ sciErr = createNamedMatrixOfString(pvApiCtx, varname, 1, 1, &fname);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ Scierror(999, _("%s: Invalid variable name.\n"), fname);
+ }
+ return 0;
+}
+// =============================================================================
diff --git a/modules/api_scilab/tests/nonreg_tests/bug_9707.dia.ref b/modules/api_scilab/tests/nonreg_tests/bug_9707.dia.ref
new file mode 100755
index 000000000..ed0ea865d
--- /dev/null
+++ b/modules/api_scilab/tests/nonreg_tests/bug_9707.dia.ref
@@ -0,0 +1,41 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2011 - DIGITEO - Allan CORNET
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- ENGLISH IMPOSED -->
+//
+// <-- CLI SHELL MODE -->
+//
+// <-- Non-regression test for bug 9707 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/9707
+//
+// <-- Short Description -->
+// createNamedXXX did not check variable name
+BUGNAME = "bug_9707";
+ilib_verbose(0);
+if haveacompiler() then
+ cd TMPDIR;
+ mkdir(BUGNAME);
+ cd(BUGNAME);
+ DEST = TMPDIR + "/" + BUGNAME + "/" + BUGNAME + ".c";
+ copyfile(SCI + "/modules/api_scilab/tests/nonreg_tests/" + BUGNAME + ".c", DEST);
+ assert_checkequal(isfile(DEST), %T);
+ gw_functions = [BUGNAME+ "_1","sci_" + BUGNAME + "_1";
+ BUGNAME+ "_2","sci_" + BUGNAME + "_2";
+ BUGNAME+ "_3","sci_" + BUGNAME + "_3";
+ BUGNAME+ "_4","sci_" + BUGNAME + "_4";
+ BUGNAME+ "_OK","sci_" + BUGNAME + "_OK"];
+ ilib_build("lib" + BUGNAME, gw_functions, BUGNAME + ".c", []);
+ exec loader.sce;
+ assert_checkequal(execstr("bug_9707_1()", "errcatch"), 999);
+ assert_checkequal(execstr("bug_9707_2()", "errcatch"), 999);
+ assert_checkequal(execstr("bug_9707_3()", "errcatch"), 999);
+ assert_checkequal(execstr("bug_9707_4()", "errcatch"), 999);
+ assert_checkequal(execstr("bug_9707_OK()", "errcatch"), 0);
+ assert_checkequal(VAR_9707 == "bug_9707_OK", %t);
+end
diff --git a/modules/api_scilab/tests/nonreg_tests/bug_9707.tst b/modules/api_scilab/tests/nonreg_tests/bug_9707.tst
new file mode 100755
index 000000000..1a08a0fe0
--- /dev/null
+++ b/modules/api_scilab/tests/nonreg_tests/bug_9707.tst
@@ -0,0 +1,44 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2011 - DIGITEO - Allan CORNET
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- ENGLISH IMPOSED -->
+//
+// <-- CLI SHELL MODE -->
+//
+// <-- Non-regression test for bug 9707 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/9707
+//
+// <-- Short Description -->
+// createNamedXXX did not check variable name
+
+BUGNAME = "bug_9707";
+ilib_verbose(0);
+if haveacompiler() then
+ cd TMPDIR;
+ mkdir(BUGNAME);
+ cd(BUGNAME);
+ DEST = TMPDIR + "/" + BUGNAME + "/" + BUGNAME + ".c";
+ copyfile(SCI + "/modules/api_scilab/tests/nonreg_tests/" + BUGNAME + ".c", DEST);
+ assert_checkequal(isfile(DEST), %T);
+
+ gw_functions = [BUGNAME+ "_1","sci_" + BUGNAME + "_1";
+ BUGNAME+ "_2","sci_" + BUGNAME + "_2";
+ BUGNAME+ "_3","sci_" + BUGNAME + "_3";
+ BUGNAME+ "_4","sci_" + BUGNAME + "_4";
+ BUGNAME+ "_OK","sci_" + BUGNAME + "_OK"];
+
+ ilib_build("lib" + BUGNAME, gw_functions, BUGNAME + ".c", []);
+ exec loader.sce;
+ assert_checkequal(execstr("bug_9707_1()", "errcatch"), 999);
+ assert_checkequal(execstr("bug_9707_2()", "errcatch"), 999);
+ assert_checkequal(execstr("bug_9707_3()", "errcatch"), 999);
+ assert_checkequal(execstr("bug_9707_4()", "errcatch"), 999);
+ assert_checkequal(execstr("bug_9707_OK()", "errcatch"), 0);
+ assert_checkequal(VAR_9707 == "bug_9707_OK", %t);
+end
diff --git a/modules/api_scilab/tests/nonreg_tests/bug_9708.c b/modules/api_scilab/tests/nonreg_tests/bug_9708.c
new file mode 100755
index 000000000..52e73ee0f
--- /dev/null
+++ b/modules/api_scilab/tests/nonreg_tests/bug_9708.c
@@ -0,0 +1,30 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2011 - DIGITEO - Allan CORNET
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+#include <stdlib.h>
+#include <api_scilab.h>
+#include <Scierror.h>
+#include <MALLOC.h>
+#include <localization.h>
+
+int sci_bug_9708(char *fname)
+{
+ SciErr sciErr;
+ const char varname[] = "iputhereavariabletoolongforscilabandthereisnoerror";
+
+ sciErr = createNamedMatrixOfString(pvApiCtx, varname, 1, 1, &varname);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ Scierror(999, _("%s: Invalid variable name.\n"), fname);
+ return 0;
+ }
+
+ LhsVar(1) = 1;
+ return 0;
+}
+// =============================================================================
diff --git a/modules/api_scilab/tests/nonreg_tests/bug_9708.dia.ref b/modules/api_scilab/tests/nonreg_tests/bug_9708.dia.ref
new file mode 100755
index 000000000..03f8f020b
--- /dev/null
+++ b/modules/api_scilab/tests/nonreg_tests/bug_9708.dia.ref
@@ -0,0 +1,31 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2011 - DIGITEO - Allan CORNET
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- ENGLISH IMPOSED -->
+//
+// <-- CLI SHELL MODE -->
+//
+// <-- Non-regression test for bug 9708 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/9708
+//
+// <-- Short Description -->
+// createNamedXXX did not check length of variable name
+BUGNAME = "bug_9708";
+ilib_verbose(0);
+if haveacompiler() then
+ cd TMPDIR;
+ mkdir(BUGNAME);
+ cd(BUGNAME);
+ DEST = TMPDIR + "/" + BUGNAME + "/" + BUGNAME + ".c";
+ copyfile(SCI + "/modules/api_scilab/tests/nonreg_tests/" + BUGNAME + ".c", DEST);
+ assert_checkequal(isfile(DEST), %T);
+ ilib_build("lib" + BUGNAME,[BUGNAME,"sci_" + BUGNAME], BUGNAME + ".c", []);
+ exec loader.sce;
+ assert_checkequal(execstr("bug_9708()", "errcatch"), 999);
+end
diff --git a/modules/api_scilab/tests/nonreg_tests/bug_9708.tst b/modules/api_scilab/tests/nonreg_tests/bug_9708.tst
new file mode 100755
index 000000000..d2548e174
--- /dev/null
+++ b/modules/api_scilab/tests/nonreg_tests/bug_9708.tst
@@ -0,0 +1,33 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2011 - DIGITEO - Allan CORNET
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- ENGLISH IMPOSED -->
+//
+// <-- CLI SHELL MODE -->
+//
+// <-- Non-regression test for bug 9708 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/9708
+//
+// <-- Short Description -->
+// createNamedXXX did not check length of variable name
+
+BUGNAME = "bug_9708";
+ilib_verbose(0);
+if haveacompiler() then
+ cd TMPDIR;
+ mkdir(BUGNAME);
+ cd(BUGNAME);
+ DEST = TMPDIR + "/" + BUGNAME + "/" + BUGNAME + ".c";
+ copyfile(SCI + "/modules/api_scilab/tests/nonreg_tests/" + BUGNAME + ".c", DEST);
+ assert_checkequal(isfile(DEST), %T);
+ ilib_build("lib" + BUGNAME,[BUGNAME,"sci_" + BUGNAME], BUGNAME + ".c", []);
+ exec loader.sce;
+ assert_checkequal(execstr("bug_9708()", "errcatch"), 999);
+end
+
diff --git a/modules/api_scilab/tests/nonreg_tests/build_bug_12426_gateway.sce b/modules/api_scilab/tests/nonreg_tests/build_bug_12426_gateway.sce
new file mode 100755
index 000000000..01a8f34c6
--- /dev/null
+++ b/modules/api_scilab/tests/nonreg_tests/build_bug_12426_gateway.sce
@@ -0,0 +1,59 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2013 - Scilab Enterprises - Simon MARCHETTO
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+
+gatewayName = "bug_12426_gateway";
+lib1 = "api_scilab";
+lib1include = SCI + "/modules/" + lib1 + "/includes";
+func1 = "addErrorMessage";
+
+previous_dir = pwd();
+cd(get_absolute_file_path("build_" + gatewayName + ".sce"));
+current_dir = pwd();
+mkdir(TMPDIR + "/" + gatewayName);
+cd(TMPDIR + "/" + gatewayName);
+
+ilib_name = gatewayName;
+files = ["sci_" + func1 + ".c"];
+
+for i = 1 : size(files, "*")
+ copyfile(current_dir + "/" + files(i), TMPDIR + "/" + gatewayName);
+end
+
+if getos() == "Windows" then
+ libs = SCI + "/bin/" + lib1;
+ cflags = "-I " + lib1include;
+
+elseif isdir(lib1include)
+ // Unix source version
+ libs = SCI + "/modules/" + lib1 + "/.libs/libsci" + lib1;
+ cflags = "-I " + lib1include;
+else
+ // Unix binary version
+ SCI_LIB = strsubst(SCI,"/share\/scilab$/", "lib/scilab", "r");
+ SCI_INCLUDE = strsubst(SCI,"/share\/scilab$/", "include/scilab", "r");
+ libs = SCI_LIB + "/libscilab-cli";
+ cflags = "-I " + SCI_INCLUDE;
+end
+
+// name known in scilab, C function called
+table = [func1, "sci_" + func1];
+
+ilib_build(ilib_name, table, files, libs, [], "", cflags);
+
+cd(previous_dir);
+
+clear ilib_build;
+clear table;
+clear libs;
+clear files;
+clear ilib_name;
+clear previous_dir;
+clear gateway_c_dir;
+clear SCI_LIB;
+clear SCI_INCLUDE;
diff --git a/modules/api_scilab/tests/nonreg_tests/sci_addErrorMessage.c b/modules/api_scilab/tests/nonreg_tests/sci_addErrorMessage.c
new file mode 100755
index 000000000..c9ca6809a
--- /dev/null
+++ b/modules/api_scilab/tests/nonreg_tests/sci_addErrorMessage.c
@@ -0,0 +1,55 @@
+/*
+* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+* Copyright (C) Scilab Enterprises - 2013 - Simon MARCHETTO
+*
+* This file must be used under the terms of the CeCILL.
+* This source file is licensed as described in the file COPYING, which
+* you should have received as part of this distribution. The terms
+* are also available at
+* http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+*
+*/
+
+#include <stdio.h>
+#include "api_scilab.h"
+#include "api_int.h"
+
+/*--------------------------------------------------------------------------*/
+int sci_addErrorMessage(char *fname, unsigned long fname_len)
+{
+ SciErr sciErr;
+ int *piAddressVarOne = NULL;
+ int errorMessageCount = 0;
+ sciErr.iMsgCount = 0;
+
+ CheckInputArgument(pvApiCtx, 1, 1);
+ sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddressVarOne);
+ if (!sciErr.iErr)
+ {
+ if (isIntegerType(pvApiCtx, piAddressVarOne))
+ {
+ if (!getScalarInteger32(pvApiCtx, piAddressVarOne,
+ &errorMessageCount))
+ {
+ ;
+ }
+ {
+ SciErr sciErr;
+ char errMsg[100];
+ int i = 0;
+ sciErr.iMsgCount = 0;
+
+ for (i = 1; i <= errorMessageCount; i++)
+ {
+ sprintf(errMsg, "Error %d", i);
+ addErrorMessage(&sciErr, 999, errMsg);
+ }
+ printError(&sciErr, 0);
+
+ return -1;
+ }
+ }
+ }
+ return -1;
+}
+/*--------------------------------------------------------------------------*/
diff --git a/modules/api_scilab/tests/nonreg_tests/sci_empty_test.cpp b/modules/api_scilab/tests/nonreg_tests/sci_empty_test.cpp
new file mode 100755
index 000000000..4cb54645f
--- /dev/null
+++ b/modules/api_scilab/tests/nonreg_tests/sci_empty_test.cpp
@@ -0,0 +1,62 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2010 - Artem GLEBOV <aglebov@acm.org>
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+ *
+ */
+
+/* ==================================================================== */
+extern "C"
+{
+#include "api_scilab.h"
+#include "Scierror.h"
+
+ /**
+ * The gateway function for soap_servers()
+ * @param[in] fname the name of the file for the error messages
+ * @return 0 if successful, a negative value otherwise
+ */
+ int sci_empty_test(char *fname)
+ {
+ SciErr sciErr;
+
+ // allocate memory for values
+ double dOut = 0;
+ char *cOut = "zero";
+
+ // this function does not take input arguments
+ CheckInputArgument(pvApiCtx, 0, 0);
+
+ // the number of output arguments must be 2
+ CheckOutputArgument(pvApiCtx, 2, 2);
+
+ // create results on stack
+ sciErr = createMatrixOfDouble(pvApiCtx, nbInputArgument(pvApiCtx) + 1, 0, 0, &dOut);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ sciErr = createMatrixOfString(pvApiCtx, nbInputArgument(pvApiCtx) + 2, 0, 0, &cOut);
+
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1;
+ AssignOutputVariable(pvApiCtx, 2) = nbInputArgument(pvApiCtx) + 2;
+
+ return 0;
+ }
+ /* ==================================================================== */
+} /* extern "C" */
+
+/* ==================================================================== */
diff --git a/modules/api_scilab/tests/unit_tests/booleanExample.c b/modules/api_scilab/tests/unit_tests/booleanExample.c
new file mode 100755
index 000000000..7d6d060f4
--- /dev/null
+++ b/modules/api_scilab/tests/unit_tests/booleanExample.c
@@ -0,0 +1,81 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2009-2010 - DIGITEO
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+ *
+ */
+
+#include "api_scilab.h"
+#include "MALLOC.h"
+
+int booleanExample(char *fname, unsigned long fname_len)
+{
+ SciErr sciErr;
+ int* piAddr = NULL;
+ int iType = 0;
+ int iRet = 0;
+
+ //CheckInputArgument(pvApiCtx, 1, 1);
+ //CheckOutputArgument(pvApiCtx, 0, 1);
+ CheckRhs(1, 1);
+ CheckLhs(0, 1);
+
+ sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddr);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+ if (isBooleanType(pvApiCtx, piAddr))
+ {
+ if (isScalar(pvApiCtx, piAddr))
+ {
+ int iBool = 0;
+ iRet = getScalarBoolean(pvApiCtx, piAddr, &iBool);
+ if (iRet)
+ {
+ return 0;
+ }
+ iRet = createScalarBoolean(pvApiCtx, Rhs + 1, iBool);
+ //iRet = createScalarBoolean(pvApiCtx, nbInputArgument + 1, iBool);
+ if (iRet)
+ {
+ return 0;
+ }
+ }
+ else
+ {
+ int iRows = 0;
+ int iCols = 0;
+ int *piBool = NULL;
+
+ sciErr = getMatrixOfBoolean(pvApiCtx, piAddr, &iRows, &iCols, &piBool);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ sciErr = createMatrixOfBoolean(pvApiCtx, Rhs + 1, iRows, iCols, piBool);
+ //sciErr = createMatrixOfBoolean(pvApiCtx, nbInputArgument + 1, iRows, iCols, piBool);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+ }
+ LhsVar(1) = Rhs + 1;
+ //AssignOutputVariable(1) = nbInputArgument + 1;
+ }
+ else
+ {
+ LhsVar(1) = 0;
+ //AssignOutputVariable(1) = 0;
+ }
+ return 0;
+}
diff --git a/modules/api_scilab/tests/unit_tests/booleanExample.dia.ref b/modules/api_scilab/tests/unit_tests/booleanExample.dia.ref
new file mode 100755
index 000000000..9f5e9782f
--- /dev/null
+++ b/modules/api_scilab/tests/unit_tests/booleanExample.dia.ref
@@ -0,0 +1,22 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2009-2010 - DIGITEO
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- CLI SHELL MODE -->
+ilib_verbose(0);
+mkdir(pathconvert(TMPDIR+"/booleanExample"));
+cd(pathconvert(TMPDIR+"/booleanExample"));
+copyfile(SCI+"/modules/api_scilab/tests/unit_tests/booleanExample.c",pathconvert(TMPDIR+"/booleanExample/booleanExample.c",%F));
+cflags = "-I"+SCI+"/modules/localization/includes";
+ilib_build("gw_booleanExample", ["booleanExample", "booleanExample"], "booleanExample.c", [], "", "", cflags);
+exec("loader.sce");
+a = %t;
+b = %f;
+c = [a,b;b,a;a,b;b,a];
+d = c';
+assert_checkequal(booleanExample(a), a);
+assert_checkequal(booleanExample(b), b);
+assert_checkequal(booleanExample(c), c);
+assert_checkequal(booleanExample(d), d);
diff --git a/modules/api_scilab/tests/unit_tests/booleanExample.tst b/modules/api_scilab/tests/unit_tests/booleanExample.tst
new file mode 100755
index 000000000..8fc007610
--- /dev/null
+++ b/modules/api_scilab/tests/unit_tests/booleanExample.tst
@@ -0,0 +1,24 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2009-2010 - DIGITEO
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- CLI SHELL MODE -->
+ilib_verbose(0);
+mkdir(pathconvert(TMPDIR+"/booleanExample"));
+cd(pathconvert(TMPDIR+"/booleanExample"));
+copyfile(SCI+"/modules/api_scilab/tests/unit_tests/booleanExample.c",pathconvert(TMPDIR+"/booleanExample/booleanExample.c",%F));
+cflags = "-I"+SCI+"/modules/localization/includes";
+ilib_build("gw_booleanExample", ["booleanExample", "booleanExample"], "booleanExample.c", [], "", "", cflags);
+exec("loader.sce");
+
+a = %t;
+b = %f;
+c = [a,b;b,a;a,b;b,a];
+d = c';
+assert_checkequal(booleanExample(a), a);
+assert_checkequal(booleanExample(b), b);
+assert_checkequal(booleanExample(c), c);
+assert_checkequal(booleanExample(d), d);
diff --git a/modules/api_scilab/tests/unit_tests/booleanSparseExample.c b/modules/api_scilab/tests/unit_tests/booleanSparseExample.c
new file mode 100755
index 000000000..8135fc770
--- /dev/null
+++ b/modules/api_scilab/tests/unit_tests/booleanSparseExample.c
@@ -0,0 +1,63 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2009-2010 - DIGITEO
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+ *
+ */
+
+#include "api_scilab.h"
+#include "Scierror.h"
+#include "localization.h"
+#include "sciprint.h"
+#include "MALLOC.h"
+
+int booleanSparseExample(char *fname, unsigned long fname_len)
+{
+ SciErr sciErr;
+ int* piAddr = NULL;
+ int iType = 0;
+ int iRet = 0;
+
+ CheckInputArgument(pvApiCtx, 1, 1);
+ CheckOutputArgument(pvApiCtx, 0, 1);
+
+ sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddr);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ if (isBooleanSparseType(pvApiCtx, piAddr))
+ {
+ int iRows = 0;
+ int iCols = 0;
+ int iNbItem = 0;
+ int* piNbItemRow = NULL;
+ int* piColPos = NULL;
+
+ iRet = getAllocatedBooleanSparseMatrix(pvApiCtx, piAddr, &iRows, &iCols, &iNbItem, &piNbItemRow, &piColPos);
+ if (iRet)
+ {
+ freeAllocatedBooleanSparse(piNbItemRow, piColPos);
+ return iRet;
+ }
+
+ sciErr = createBooleanSparseMatrix(pvApiCtx, nbInputArgument(pvApiCtx) + 1, iRows, iCols, iNbItem, piNbItemRow, piColPos);
+ if (sciErr.iErr)
+ {
+ freeAllocatedBooleanSparse(piNbItemRow, piColPos);
+ printError(&sciErr, 0);
+ return sciErr.iErr;
+ }
+
+ freeAllocatedBooleanSparse(piNbItemRow, piColPos);
+ AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1;
+ }
+ return 0;
+}
diff --git a/modules/api_scilab/tests/unit_tests/booleanSparseExample.dia.ref b/modules/api_scilab/tests/unit_tests/booleanSparseExample.dia.ref
new file mode 100755
index 000000000..4a495d27a
--- /dev/null
+++ b/modules/api_scilab/tests/unit_tests/booleanSparseExample.dia.ref
@@ -0,0 +1,16 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2009-2010 - DIGITEO
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- CLI SHELL MODE -->
+ilib_verbose(0);
+mkdir(pathconvert(TMPDIR+"/booleanSparseExample"));
+cd(pathconvert(TMPDIR+"/booleanSparseExample"));
+copyfile(SCI+"/modules/api_scilab/tests/unit_tests/booleanSparseExample.c",pathconvert(TMPDIR+"/booleanSparseExample/booleanSparseExample.c",%F));
+cflags = "-I"+SCI+"/modules/localization/includes";
+ilib_build("gw_booleanSparseExample",["booleanSparseExample","booleanSparseExample"],"booleanSparseExample.c",[],"","",cflags);
+exec("loader.sce");
+bsp = sparse([1,1;2,2;3,3],[%t,%t,%t]);
+assert_checkequal(booleanSparseExample(bsp), bsp);
diff --git a/modules/api_scilab/tests/unit_tests/booleanSparseExample.tst b/modules/api_scilab/tests/unit_tests/booleanSparseExample.tst
new file mode 100755
index 000000000..3417c9058
--- /dev/null
+++ b/modules/api_scilab/tests/unit_tests/booleanSparseExample.tst
@@ -0,0 +1,18 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2009-2010 - DIGITEO
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- CLI SHELL MODE -->
+ilib_verbose(0);
+mkdir(pathconvert(TMPDIR+"/booleanSparseExample"));
+cd(pathconvert(TMPDIR+"/booleanSparseExample"));
+copyfile(SCI+"/modules/api_scilab/tests/unit_tests/booleanSparseExample.c",pathconvert(TMPDIR+"/booleanSparseExample/booleanSparseExample.c",%F));
+cflags = "-I"+SCI+"/modules/localization/includes";
+ilib_build("gw_booleanSparseExample",["booleanSparseExample","booleanSparseExample"],"booleanSparseExample.c",[],"","",cflags);
+exec("loader.sce");
+
+bsp = sparse([1,1;2,2;3,3],[%t,%t,%t]);
+assert_checkequal(booleanSparseExample(bsp), bsp);
diff --git a/modules/api_scilab/tests/unit_tests/boolean_writing_api.c b/modules/api_scilab/tests/unit_tests/boolean_writing_api.c
new file mode 100755
index 000000000..857f02945
--- /dev/null
+++ b/modules/api_scilab/tests/unit_tests/boolean_writing_api.c
@@ -0,0 +1,104 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2009-2010 - DIGITEO
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+ *
+ */
+
+#include "api_scilab.h"
+#include "Scierror.h"
+#include "localization.h"
+#include "sciprint.h"
+#include "MALLOC.h"
+
+int write_boolean(char *fname, unsigned long fname_len)
+{
+ SciErr sciErr;
+ int i, j;
+ //first variable info : boolean matrix of boolean 3 x 4
+ int iRows1 = 3;
+ int iCols1 = 4;
+ int* pboolOutput1 = NULL;
+ //second variable info : boolean matrix of boolean 4 x 6
+ int iRows2 = 4;
+ int iCols2 = 6;
+ int* pboolOutput2 = NULL;
+
+ /************************
+ * First variable *
+ ************************/
+
+ //alloc array of data in OS memory
+ pboolOutput1 = (int*)malloc(sizeof(int) * iRows1 * iCols1);
+ //fill array with incremental values
+ //[ %t %f %t %f
+ // %t %f %t %f
+ // %t %f %t %f ]
+ for (i = 0 ; i < iRows1 ; i++)
+ {
+ for (j = 0 ; j < iCols1 ; j++)
+ {
+ pboolOutput1[i + iRows1 * j] = (i * iCols1 + j) % 2 == FALSE;
+ }
+ }
+
+ //can be written in a single loop
+ //for(i = 0 ; i < iRows1 * iCols1; i++)
+ //{
+ // pboolOutput1[i] = i % 2 == FALSE;
+ //}
+ //create a variable from a existing data array
+
+ sciErr = createMatrixOfBoolean(pvApiCtx, nbInputArgument(pvApiCtx) + 1, iRows1, iCols1, pboolOutput1);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+ //after creation, we can free memory.
+ free(pboolOutput1);
+
+
+ /*************************
+ * Second variable *
+ *************************/
+
+ //reserve space in scilab memory and fill it
+ sciErr = allocMatrixOfBoolean(pvApiCtx, nbInputArgument(pvApiCtx) + 2, iRows2, iCols2, &pboolOutput2);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ //fill array with incremental values
+ //[ %f %t %f %t %f %t
+ // %f %t %f %t %f %t
+ // %f %t %f %t %f %t
+ // %f %t %f %t %f %t ]
+ for (i = 0 ; i < iRows2 ; i++)
+ {
+ for (j = 0 ; j < iCols2 ; j++)
+ {
+ pboolOutput2[i + iRows2 * j] = (i * iCols2 + j) % 2 == TRUE;
+ }
+ }
+
+ //can be written in a single loop
+ //for(i = 0 ; i < iRows2 * iCols2; i++)
+ //{
+ // pboolOutput2[i] = i % 2 == TRUE;
+ //}
+ // /!\ DO NOT FREE MEMORY, in this case, it's the Scilab memory
+ //assign allocated variables to Lhs position
+
+ AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1;
+ AssignOutputVariable(pvApiCtx, 2) = nbInputArgument(pvApiCtx) + 2;
+
+ return 0;
+}
diff --git a/modules/api_scilab/tests/unit_tests/boolean_writing_api.dia.ref b/modules/api_scilab/tests/unit_tests/boolean_writing_api.dia.ref
new file mode 100755
index 000000000..a41858c25
--- /dev/null
+++ b/modules/api_scilab/tests/unit_tests/boolean_writing_api.dia.ref
@@ -0,0 +1,24 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2009-2010 - DIGITEO
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- CLI SHELL MODE -->
+ilib_verbose(0);
+mkdir(pathconvert(TMPDIR+"/boolean_writing_api"));
+cd(pathconvert(TMPDIR+"/boolean_writing_api"));
+copyfile(SCI+"/modules/api_scilab/tests/unit_tests/boolean_writing_api.c",pathconvert(TMPDIR+"/boolean_writing_api/boolean_writing_api.c",%F));
+cflags = "-I"+SCI+"/modules/localization/includes";
+ilib_build("boolean_writing",["write_boolean","write_boolean"],"boolean_writing_api.c",[],"","",cflags);
+exec("loader.sce");
+a_ref = [ %t %f %t %f
+ %t %f %t %f
+ %t %f %t %f ];
+b_ref = [ %f %t %f %t %f %t
+ %f %t %f %t %f %t
+ %f %t %f %t %f %t
+ %f %t %f %t %f %t ];
+[a,b] = write_boolean();
+if or(a <> a_ref) then bugmes();quit;end
+if or(b <> b_ref) then bugmes();quit;end
diff --git a/modules/api_scilab/tests/unit_tests/boolean_writing_api.tst b/modules/api_scilab/tests/unit_tests/boolean_writing_api.tst
new file mode 100755
index 000000000..e0599a87e
--- /dev/null
+++ b/modules/api_scilab/tests/unit_tests/boolean_writing_api.tst
@@ -0,0 +1,28 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2009-2010 - DIGITEO
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- CLI SHELL MODE -->
+ilib_verbose(0);
+mkdir(pathconvert(TMPDIR+"/boolean_writing_api"));
+cd(pathconvert(TMPDIR+"/boolean_writing_api"));
+copyfile(SCI+"/modules/api_scilab/tests/unit_tests/boolean_writing_api.c",pathconvert(TMPDIR+"/boolean_writing_api/boolean_writing_api.c",%F));
+cflags = "-I"+SCI+"/modules/localization/includes";
+ilib_build("boolean_writing",["write_boolean","write_boolean"],"boolean_writing_api.c",[],"","",cflags);
+exec("loader.sce");
+
+a_ref = [ %t %f %t %f
+ %t %f %t %f
+ %t %f %t %f ];
+
+b_ref = [ %f %t %f %t %f %t
+ %f %t %f %t %f %t
+ %f %t %f %t %f %t
+ %f %t %f %t %f %t ];
+
+[a,b] = write_boolean();
+if or(a <> a_ref) then pause;end
+if or(b <> b_ref) then pause;end
diff --git a/modules/api_scilab/tests/unit_tests/calloverloadfunction_api.c b/modules/api_scilab/tests/unit_tests/calloverloadfunction_api.c
new file mode 100755
index 000000000..865791b2c
--- /dev/null
+++ b/modules/api_scilab/tests/unit_tests/calloverloadfunction_api.c
@@ -0,0 +1,22 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2009-2010 - DIGITEO
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+ *
+ */
+
+#include "api_scilab.h"
+
+int callOverload(char *fname, unsigned long fname_len)
+{
+ CheckRhs(1, 1);
+ CheckLhs(0, 1);
+
+ CallOverloadFunction(1);
+ return 0;
+}
diff --git a/modules/api_scilab/tests/unit_tests/calloverloadfunction_api.dia.ref b/modules/api_scilab/tests/unit_tests/calloverloadfunction_api.dia.ref
new file mode 100755
index 000000000..7a002bdb6
--- /dev/null
+++ b/modules/api_scilab/tests/unit_tests/calloverloadfunction_api.dia.ref
@@ -0,0 +1,26 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2009-2010 - DIGITEO
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- CLI SHELL MODE -->
+ilib_verbose(0);
+mkdir(pathconvert(TMPDIR+"/calloverloadfunction_api"));
+cd(pathconvert(TMPDIR+"/calloverloadfunction_api"));
+copyfile(SCI+"/modules/api_scilab/tests/unit_tests/calloverloadfunction_api.c",pathconvert(TMPDIR+"/calloverloadfunction_api/calloverloadfunction_api.c",%F));
+cflags = "-I"+SCI+"/modules/localization/includes";
+ilib_build("callOverload", ["getSize", "callOverload"], "calloverloadfunction_api.c", [], "", "", cflags);
+exec("loader.sce");
+function x = %c_getSize(a)
+ x = length(a);
+endfunction
+function x = %s_getSize(a)
+ x = size(a);
+endfunction
+a = [1,2;3,4];
+a_ref = [2,2];
+assert_checkequal(getSize(a), a_ref);
+b = ["May","the","puffin";"be","with","you"];
+b_ref = [3,3,6;2,4,3];
+assert_checkequal(getSize(b), b_ref);
diff --git a/modules/api_scilab/tests/unit_tests/calloverloadfunction_api.tst b/modules/api_scilab/tests/unit_tests/calloverloadfunction_api.tst
new file mode 100755
index 000000000..06f421c4f
--- /dev/null
+++ b/modules/api_scilab/tests/unit_tests/calloverloadfunction_api.tst
@@ -0,0 +1,32 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2009-2010 - DIGITEO
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- CLI SHELL MODE -->
+ilib_verbose(0);
+mkdir(pathconvert(TMPDIR+"/calloverloadfunction_api"));
+cd(pathconvert(TMPDIR+"/calloverloadfunction_api"));
+copyfile(SCI+"/modules/api_scilab/tests/unit_tests/calloverloadfunction_api.c",pathconvert(TMPDIR+"/calloverloadfunction_api/calloverloadfunction_api.c",%F));
+cflags = "-I"+SCI+"/modules/localization/includes";
+ilib_build("callOverload", ["getSize", "callOverload"], "calloverloadfunction_api.c", [], "", "", cflags);
+exec("loader.sce");
+
+function x = %c_getSize(a)
+ x = length(a);
+endfunction
+
+function x = %s_getSize(a)
+ x = size(a);
+endfunction
+
+
+a = [1,2;3,4];
+a_ref = [2,2];
+assert_checkequal(getSize(a), a_ref);
+
+b = ["May","the","puffin";"be","with","you"];
+b_ref = [3,3,6;2,4,3];
+assert_checkequal(getSize(b), b_ref);
diff --git a/modules/api_scilab/tests/unit_tests/check_matrix_dimension.c b/modules/api_scilab/tests/unit_tests/check_matrix_dimension.c
new file mode 100755
index 000000000..a9ceb332b
--- /dev/null
+++ b/modules/api_scilab/tests/unit_tests/check_matrix_dimension.c
@@ -0,0 +1,69 @@
+#include "api_scilab.h"
+#include "sciprint.h"
+
+int check_matrix_dimension(char * fname)
+{
+ SciErr sciErr;
+ int* piAddr = NULL;
+ int iRows = 0;
+ int iCols = 0;
+
+ CheckInputArgument(pvApiCtx, 1, 1);
+
+ sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddr);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 1;
+ }
+
+ sciErr = getVarDimension(pvApiCtx, piAddr, &iRows, &iCols);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 1;
+ }
+
+ if (checkVarDimension(pvApiCtx, piAddr, iCols, iRows))
+ {
+ sciprint("checkVarDimension returns false\n");
+ }
+ else
+ {
+ sciprint("checkVarDimension returns true\n");
+ }
+
+ if (isRowVector(pvApiCtx, piAddr))
+ {
+ sciprint("isRowVector\n");
+ }
+
+ if (isColumnVector(pvApiCtx, piAddr))
+ {
+ sciprint("isColumnVector\n");
+ }
+
+ if (isVector(pvApiCtx, piAddr))
+ {
+ sciprint("isVector\n");
+ }
+
+ if (isScalar(pvApiCtx, piAddr))
+ {
+ sciprint("isScalar\n");
+ }
+
+ if (isSquareMatrix(pvApiCtx, piAddr))
+ {
+ sciprint("isSquareMatrix\n");
+ }
+
+ if (isEmptyMatrix(pvApiCtx, piAddr))
+ {
+ sciprint("isEmptyMatrix\n");
+ }
+
+ //no return value
+ AssignOutputVariable(pvApiCtx, 0) = 1;
+ return 0;
+}
diff --git a/modules/api_scilab/tests/unit_tests/check_matrix_dimension.dia.ref b/modules/api_scilab/tests/unit_tests/check_matrix_dimension.dia.ref
new file mode 100755
index 000000000..ea7f70cb4
--- /dev/null
+++ b/modules/api_scilab/tests/unit_tests/check_matrix_dimension.dia.ref
@@ -0,0 +1,32 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2009-2010 - DIGITEO
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- CLI SHELL MODE -->
+ilib_verbose(0);
+mkdir(pathconvert(TMPDIR+"/check_matrix_dimension"));
+cd(pathconvert(TMPDIR+"/check_matrix_dimension"));
+copyfile(SCI+"/modules/api_scilab/tests/unit_tests/check_matrix_dimension.c",pathconvert(TMPDIR+"/check_matrix_dimension/check_matrix_dimension.c",%F));
+ilib_build("gw_check_matrix_dimension",["check_matrix_dimension","check_matrix_dimension"],"check_matrix_dimension.c",[]);
+exec("loader.sce");
+check_matrix_dimension([1,2,3;4,5,6]);
+checkVarDimension returns true
+check_matrix_dimension([1,2,3]);
+checkVarDimension returns true
+isRowVector
+isVector
+check_matrix_dimension([1;2;3]);
+checkVarDimension returns true
+isColumnVector
+isVector
+check_matrix_dimension([1]);
+checkVarDimension returns false
+isScalar
+check_matrix_dimension([1,2;3,4]);
+checkVarDimension returns false
+isSquareMatrix
+check_matrix_dimension([]);
+checkVarDimension returns false
+isEmptyMatrix
diff --git a/modules/api_scilab/tests/unit_tests/check_matrix_dimension.tst b/modules/api_scilab/tests/unit_tests/check_matrix_dimension.tst
new file mode 100755
index 000000000..76024bbf8
--- /dev/null
+++ b/modules/api_scilab/tests/unit_tests/check_matrix_dimension.tst
@@ -0,0 +1,24 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2009-2010 - DIGITEO
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- CLI SHELL MODE -->
+ilib_verbose(0);
+mkdir(pathconvert(TMPDIR+"/check_matrix_dimension"));
+cd(pathconvert(TMPDIR+"/check_matrix_dimension"));
+copyfile(SCI+"/modules/api_scilab/tests/unit_tests/check_matrix_dimension.c",pathconvert(TMPDIR+"/check_matrix_dimension/check_matrix_dimension.c",%F));
+ilib_build("gw_check_matrix_dimension",["check_matrix_dimension","check_matrix_dimension"],"check_matrix_dimension.c",[]);
+exec("loader.sce");
+
+
+check_matrix_dimension([1,2,3;4,5,6]);
+check_matrix_dimension([1,2,3]);
+check_matrix_dimension([1;2;3]);
+check_matrix_dimension([1]);
+check_matrix_dimension([1,2;3,4]);
+check_matrix_dimension([]);
+
+
diff --git a/modules/api_scilab/tests/unit_tests/common_function.dia.ref b/modules/api_scilab/tests/unit_tests/common_function.dia.ref
new file mode 100755
index 000000000..7b3103f22
--- /dev/null
+++ b/modules/api_scilab/tests/unit_tests/common_function.dia.ref
@@ -0,0 +1,45 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2009-2010 - DIGITEO
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- CLI SHELL MODE -->
+ilib_verbose(0);
+mkdir(pathconvert(TMPDIR+"/common_function"));
+cd(pathconvert(TMPDIR+"/common_function"));
+copyfile(SCI+"/modules/api_scilab/tests/unit_tests/common_function_api.c",pathconvert(TMPDIR+"/common_function/common_function_api.c",%F));
+cflags = "-I"+SCI+"/modules/localization/includes";
+ilib_build("common_function",["common_function","common_function"],"common_function_api.c",[],"","",cflags);
+exec("loader.sce");
+l1 = [1,2*%i,3;%i,2,3*%i];
+l2 = ["may","the";"puffin","be";"with","you"];
+l3 = int8([1,2,3]);
+l4 = uint16([1000,2000,3000]);
+l5 = list(l1,l2,l3);
+l = list(l1,l2,l3,l4,l5);
+common_function(l(1:$))
+Variable 1 information:
+ Type: double
+ Complex: Yes
+ Dimensions: 2 x 3
+
+Variable 2 information:
+ Type: strings
+ Dimensions: 3 x 2
+
+Variable 3 information:
+ Type: signed integer 8 bits
+ Dimensions: 1 x 3
+
+Variable 4 information:
+ Type: unsigned integer 16 bits
+ Dimensions: 1 x 3
+
+Variable 5 information:
+ Type: list
+ Dimensions: 3
+
+ ans =
+
+ T
diff --git a/modules/api_scilab/tests/unit_tests/common_function.tst b/modules/api_scilab/tests/unit_tests/common_function.tst
new file mode 100755
index 000000000..03a62d53c
--- /dev/null
+++ b/modules/api_scilab/tests/unit_tests/common_function.tst
@@ -0,0 +1,23 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2009-2010 - DIGITEO
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- CLI SHELL MODE -->
+ilib_verbose(0);
+mkdir(pathconvert(TMPDIR+"/common_function"));
+cd(pathconvert(TMPDIR+"/common_function"));
+copyfile(SCI+"/modules/api_scilab/tests/unit_tests/common_function_api.c",pathconvert(TMPDIR+"/common_function/common_function_api.c",%F));
+cflags = "-I"+SCI+"/modules/localization/includes";
+ilib_build("common_function",["common_function","common_function"],"common_function_api.c",[],"","",cflags);
+exec("loader.sce");
+
+l1 = [1,2*%i,3;%i,2,3*%i];
+l2 = ["may","the";"puffin","be";"with","you"];
+l3 = int8([1,2,3]);
+l4 = uint16([1000,2000,3000]);
+l5 = list(l1,l2,l3);
+l = list(l1,l2,l3,l4,l5);
+common_function(l(1:$))
diff --git a/modules/api_scilab/tests/unit_tests/common_function_api.c b/modules/api_scilab/tests/unit_tests/common_function_api.c
new file mode 100755
index 000000000..52d742ad7
--- /dev/null
+++ b/modules/api_scilab/tests/unit_tests/common_function_api.c
@@ -0,0 +1,161 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2009-2010 - DIGITEO
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+ *
+ */
+
+#include "api_scilab.h"
+#include "Scierror.h"
+#include "localization.h"
+#include "sciprint.h"
+#include "MALLOC.h"
+
+SciErr printf_info(void* _pvCtx, int _iVar);
+
+int common_function(char *fname, unsigned long fname_len)
+{
+ SciErr sciErr;
+ int i;
+ int *piAddr1 = NULL;
+ int iBool = 0;
+
+ for (i = 0 ; i < nbInputArgument(pvApiCtx) ; i++)
+ {
+ sciErr = printf_info(pvApiCtx, i + 1);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ break;
+ }
+ sciprint("\n\n");
+ }
+
+ //1 for true, 0 for false
+ iBool = sciErr.iErr == 0 ? 1 : 0;
+
+ sciErr = createMatrixOfBoolean(pvApiCtx, nbInputArgument(pvApiCtx) + 1, 1, 1, &iBool);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ //assign allocated variables to Lhs position
+ AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1;
+ return 0;
+}
+
+SciErr printf_info(void* _pvCtx, int _iVar)
+{
+ SciErr sciErr;
+ int* piAddr = NULL;
+ int iType = 0;
+ int iRows = 0;
+ int iCols = 0;
+ int iItem = 0;
+ int iComplex = 0;
+
+ sciErr = getVarAddressFromPosition(_pvCtx, _iVar, &piAddr);
+ if (sciErr.iErr)
+ {
+ return sciErr;
+ }
+
+ sciprint("Variable %d information:\n", _iVar);
+
+ sciErr = getVarType(_pvCtx, piAddr, &iType);
+ if (sciErr.iErr)
+ {
+ return sciErr;
+ }
+
+ sciprint("\tType: ");
+ switch (iType)
+ {
+ case sci_matrix :
+ sciprint("double\n");
+ break;
+ case sci_poly :
+ sciprint("polynomial\n");
+ break;
+ case sci_boolean :
+ sciprint("boolean\n");
+ break;
+ case sci_sparse :
+ sciprint("sparse\n");
+ break;
+ case sci_boolean_sparse :
+ sciprint("boolean_sparse\n");
+ break;
+ case sci_ints :
+ {
+ char pstSigned[] = "signed";
+ char pstUnsigned[] = "unsigned";
+ char* pstSign = pstSigned;
+ int iPrec = 0;
+
+ sciErr = getMatrixOfIntegerPrecision(_pvCtx, piAddr, &iPrec);
+ if (sciErr.iErr)
+ {
+ return sciErr;
+ }
+
+ if (iPrec > 10)
+ {
+ pstSign = pstUnsigned;
+ }
+
+ sciprint("%s integer %d bits\n", pstSign, (iPrec % 10) * 8);
+ }
+ break;
+ case sci_strings :
+ sciprint("strings\n");
+ break;
+ case sci_list :
+ sciprint("list\n");
+ break;
+ case sci_tlist :
+ sciprint("tlist\n");
+ break;
+ case sci_mlist :
+ sciprint("mlist\n");
+ break;
+ default :
+ sciprint("Not manage by this function\n");
+ return sciErr;
+ }
+
+ if (isVarComplex(_pvCtx, piAddr))
+ {
+ sciprint("\tComplex: Yes\n");
+ }
+
+ sciprint("\tDimensions: ");
+ if (isVarMatrixType(_pvCtx, piAddr))
+ {
+ sciErr = getVarDimension(_pvCtx, piAddr, &iRows, &iCols);
+ if (sciErr.iErr)
+ {
+ return sciErr;
+ }
+
+ sciprint("%d x %d", iRows, iCols);
+ }
+ else
+ {
+ sciErr = getListItemNumber(_pvCtx, piAddr, &iItem);
+ if (sciErr.iErr)
+ {
+ return sciErr;
+ }
+
+ sciprint("%d", iItem);
+ }
+ return sciErr;
+}
diff --git a/modules/api_scilab/tests/unit_tests/common_list_api.c b/modules/api_scilab/tests/unit_tests/common_list_api.c
new file mode 100755
index 000000000..54203b851
--- /dev/null
+++ b/modules/api_scilab/tests/unit_tests/common_list_api.c
@@ -0,0 +1,108 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2009-2010 - DIGITEO
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+ *
+ */
+
+#include "api_scilab.h"
+#include "Scierror.h"
+#include "localization.h"
+#include "sciprint.h"
+#include "MALLOC.h"
+
+int get_list_info(void* _pvCtx, int* _piAddress);
+void insert_indent(void);
+
+static int iLocalTab = 1;
+
+int common_list(char *fname, unsigned long fname_len)
+{
+ SciErr sciErr;
+ int *piAddr = NULL;
+
+ CheckInputArgument(pvApiCtx, 1, 1);
+
+ sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddr);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ get_list_info(pvApiCtx, piAddr);
+ AssignOutputVariable(pvApiCtx, 1) = 0;
+ return 0;
+}
+int get_list_info(void* _pvCtx, int* _piAddress)
+{
+ SciErr sciErr;
+ int i = 0;
+ int iRet = 0;
+ int iItem = 0;
+
+ //get list item number, failed if variable is not a kind of list
+ sciErr = getListItemNumber(_pvCtx, _piAddress, &iItem);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ sciprint("This variable is not a list");
+ return 0;
+ }
+
+ sciprint("List (%d items) -> address : 0x%08X) : \n", iItem, _piAddress);
+
+ for (i = 0 ; i < iItem ; i++)
+ {
+ int iType = 0;
+ int* piAddrChild = NULL;
+
+ sciErr = getListItemAddress(_pvCtx, _piAddress, i + 1, &piAddrChild);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ sciErr = getVarType(_pvCtx, piAddrChild, &iType);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ if (iType == sci_list || iType == sci_tlist || iType == sci_mlist)
+ {
+ insert_indent();
+ sciprint("Child %d -> ", i + 1);
+ iLocalTab++;
+ iRet = get_list_info(_pvCtx, piAddrChild);
+ iLocalTab--;
+
+ if (iRet)
+ {
+ return 1;
+ }
+ }
+ else
+ {
+ insert_indent();
+ sciprint("Child %d -> address : 0x%08X\n", i + 1, piAddrChild);
+ }
+ }
+
+ return 0;
+}
+void insert_indent(void)
+{
+ int i = 0;
+ for (i = 0 ; i < iLocalTab ; i++)
+ {
+ sciprint("\t");
+ }
+}
diff --git a/modules/api_scilab/tests/unit_tests/common_list_api.tst b/modules/api_scilab/tests/unit_tests/common_list_api.tst
new file mode 100755
index 000000000..f9a9b1c02
--- /dev/null
+++ b/modules/api_scilab/tests/unit_tests/common_list_api.tst
@@ -0,0 +1,28 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2009-2010 - DIGITEO
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- CLI SHELL MODE -->
+// <-- NO CHECK REF -->
+ilib_verbose(0);
+mkdir(pathconvert(TMPDIR+"/common_list_api"));
+cd(pathconvert(TMPDIR+"/common_list_api"));
+copyfile(SCI+"/modules/api_scilab/tests/unit_tests/common_list_api.c",pathconvert(TMPDIR+"/common_list_api/common_list_api.c",%F));
+cflags = "-I"+SCI+"/modules/localization/includes";
+ilib_build("common_list",["common_list","common_list"],"common_list_api.c",[],"","",cflags);
+exec("loader.sce");
+
+
+l1 = [1,2*%i,3;%i,2,3*%i];
+l2 = ["may","the";"puffin","be";"with","you"];
+l3 = int8([1,2,3]);
+l5 = list(l1,l2,l3);
+l4 = list(l5, list(l5,l5));
+l6 = uint16([1000,2000,3000]);
+l = list(l1,l2,l3,l6,l4,l5);
+common_list(l)
+
+
diff --git a/modules/api_scilab/tests/unit_tests/common_read_api.c b/modules/api_scilab/tests/unit_tests/common_read_api.c
new file mode 100755
index 000000000..59c7fceca
--- /dev/null
+++ b/modules/api_scilab/tests/unit_tests/common_read_api.c
@@ -0,0 +1,612 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2009-2010 - DIGITEO
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+ *
+ */
+
+#include "api_scilab.h"
+#include "Scierror.h"
+#include "localization.h"
+#include "sciprint.h"
+#include "MALLOC.h"
+
+static int iTab = 0;
+void insert_indent(void)
+{
+ int i = 0;
+ for (i = 0 ; i < iTab ; i++)
+ {
+ sciprint("\t");
+ }
+}
+
+int get_info(void* _pvCtx, int _iRhs, int* _piParent, int *_piAddr, int _iItemPos);
+int get_list_info(void* _pvCtx, int _iRhs, int* _piParent, int *_piAddr, int _iItemPos);
+int get_double_info(void* _pvCtx, int _iRhs, int* _piParent, int *_piAddr, int _iItemPos);
+int get_poly_info(void* _pvCtx, int _iRhs, int* _piParent, int *_piAddr, int _iItemPos);
+int get_boolean_info(void* _pvCtx, int _iRhs, int* _piParent, int *_piAddr, int _iItemPos);
+int get_sparse_info(void* _pvCtx, int _iRhs, int* _piParent, int *_piAddr, int _iItemPos);
+int get_bsparse_info(void* _pvCtx, int _iRhs, int* _piParent, int *_piAddr, int _iItemPos);
+int get_integer_info(void* _pvCtx, int _iRhs, int* _piParent, int *_piAddr, int _iItemPos);
+int get_string_info(void* _pvCtx, int _iRhs, int* _piParent, int *_piAddr, int _iItemPos);
+int get_pointer_info(void* _pvCtx, int _iRhs, int* _piParent, int *_piAddr, int _iItemPos);
+
+int common_read(char *fname, unsigned long fname_len)
+{
+ SciErr sciErr;
+ int iItem = 0;
+ int iRet = 0;
+ int *piAddr = NULL;
+
+ CheckInputArgument(pvApiCtx, 1, 1);
+
+ sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddr);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ get_info(pvApiCtx, 1, NULL, piAddr, 0);
+ AssignOutputVariable(pvApiCtx, 1) = 0;
+ return 0;
+}
+
+int get_info(void* _pvCtx, int _iRhs, int* _piParent, int *_piAddr, int _iItemPos)
+{
+ SciErr sciErr;
+ int iRet = 0;
+ int iType = 0;
+
+ sciErr = getVarType(_pvCtx, _piAddr, &iType);
+ switch (iType)
+ {
+ case sci_matrix :
+ iRet = get_double_info(_pvCtx, _iRhs, _piParent, _piAddr, _iItemPos);
+ break;
+ case sci_poly :
+ iRet = get_poly_info(_pvCtx, _iRhs, _piParent, _piAddr, _iItemPos);
+ break;
+ case sci_boolean :
+ iRet = get_boolean_info(_pvCtx, _iRhs, _piParent, _piAddr, _iItemPos);
+ break;
+ case sci_sparse :
+ iRet = get_sparse_info(_pvCtx, _iRhs, _piParent, _piAddr, _iItemPos);
+ break;
+ case sci_boolean_sparse :
+ iRet = get_bsparse_info(_pvCtx, _iRhs, _piParent, _piAddr, _iItemPos);
+ break;
+ case sci_ints :
+ iRet = get_integer_info(_pvCtx, _iRhs, _piParent, _piAddr, _iItemPos);
+ break;
+ case sci_strings :
+ iRet = get_string_info(_pvCtx, _iRhs, _piParent, _piAddr, _iItemPos);
+ break;
+ case sci_list :
+ insert_indent();
+ sciprint("List ");
+ iRet = get_list_info(_pvCtx, _iRhs, _piParent, _piAddr, _iItemPos);
+ break;
+ case sci_tlist :
+ insert_indent();
+ sciprint("TList ");
+ iRet = get_list_info(_pvCtx, _iRhs, _piParent, _piAddr, _iItemPos);
+ break;
+ case sci_mlist :
+ insert_indent();
+ sciprint("MList ");
+ iRet = get_list_info(_pvCtx, _iRhs, _piParent, _piAddr, _iItemPos);
+ break;
+ case sci_pointer :
+ iRet = get_pointer_info(_pvCtx, _iRhs, _piParent, _piAddr, _iItemPos);
+ break;
+ default :
+ insert_indent();
+ sciprint("Unknown type\n");
+ return 1;
+ }
+ return iRet;
+}
+
+int get_list_info(void* _pvCtx, int _iRhs, int* _piParent, int *_piAddr, int _iItemPos)
+{
+ SciErr sciErr;
+ int i;
+ int iRet = 0;
+ int iItem = 0;
+ int* piChild = NULL;
+
+ sciErr = getListItemNumber(_pvCtx, _piAddr, &iItem);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ sciprint("(%d)\n", iItem);
+ for (i = 0 ; i < iItem ; i++)
+ {
+ sciErr = getListItemAddress(_pvCtx, _piAddr, i + 1, &piChild);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ iTab++;
+ iRet = get_info(_pvCtx, _iRhs, _piAddr, piChild, i + 1);
+ iTab--;
+ }
+ return 0;;
+}
+
+int get_double_info(void* _pvCtx, int _iRhs, int* _piParent, int *_piAddr, int _iItemPos)
+{
+ SciErr sciErr;
+ int iRows = 0;
+ int iCols = 0;
+ double* pdblReal = NULL;
+ double* pdblImg = NULL;
+
+ if (_iItemPos == 0)
+ {
+ //not in list
+ if (isVarComplex(_pvCtx, _piAddr))
+ {
+ sciErr = getComplexMatrixOfDouble(_pvCtx, _piAddr, &iRows, &iCols, &pdblReal, &pdblImg);
+ }
+ else
+ {
+ sciErr = getMatrixOfDouble(_pvCtx, _piAddr, &iRows, &iCols, &pdblReal);
+ }
+ }
+ else
+ {
+ if (isVarComplex(_pvCtx, _piAddr))
+ {
+ sciErr = getComplexMatrixOfDoubleInList(_pvCtx, _piParent, _iItemPos, &iRows, &iCols, &pdblReal, &pdblImg);
+ }
+ else
+ {
+ sciErr = getMatrixOfDoubleInList(_pvCtx, _piParent, _iItemPos, &iRows, &iCols, &pdblReal);
+ }
+ }
+
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ insert_indent();
+ sciprint("Double (%d x %d)\n", iRows, iCols);
+ return 0;;
+}
+
+int get_poly_info(void* _pvCtx, int _iRhs, int* _piParent, int *_piAddr, int _iItemPos)
+{
+ SciErr sciErr;
+ int i;
+ int iLen = 0;
+ int iRows = 0;
+ int iCols = 0;
+ char pstVar[16];
+ int* piCoeff = NULL;
+ double** pdblReal = NULL;
+ double** pdblImg = NULL;
+
+ sciErr = getPolyVariableName(_pvCtx, _piAddr, pstVar, &iLen);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ if (_iItemPos == 0)
+ {
+ //not in list
+ sciErr = getMatrixOfPoly(_pvCtx, _piAddr, &iRows, &iCols, NULL, NULL);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ piCoeff = (int*)malloc(sizeof(int) * iRows * iCols);
+ sciErr = getMatrixOfPoly(_pvCtx, _piAddr, &iRows, &iCols, piCoeff, NULL);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ pdblReal = (double**)malloc(sizeof(double*) * iRows * iCols);
+ pdblImg = (double**)malloc(sizeof(double*) * iRows * iCols);
+
+ for (i = 0 ; i < iRows * iCols ; i++)
+ {
+ pdblReal[i] = (double*)malloc(sizeof(double) * piCoeff[i]);
+ pdblImg[i] = (double*)malloc(sizeof(double) * piCoeff[i]);
+ }
+
+ if (isVarComplex(_pvCtx, _piAddr))
+ {
+ sciErr = getComplexMatrixOfPoly(_pvCtx, _piAddr, &iRows, &iCols, piCoeff, pdblReal, pdblImg);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+ }
+ else
+ {
+ sciErr = getMatrixOfPoly(_pvCtx, _piAddr, &iRows, &iCols, piCoeff, pdblReal);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+ }
+ }
+ else
+ {
+ sciErr = getMatrixOfPolyInList(_pvCtx, _piParent, _iItemPos, &iRows, &iCols, NULL, NULL);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ piCoeff = (int*)malloc(sizeof(int) * iRows * iCols);
+
+ sciErr = getMatrixOfPolyInList(_pvCtx, _piParent, _iItemPos, &iRows, &iCols, piCoeff, NULL);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ pdblReal = (double**)malloc(sizeof(double*) * iRows * iCols);
+ pdblImg = (double**)malloc(sizeof(double*) * iRows * iCols);
+
+ for (i = 0 ; i < iRows * iCols ; i++)
+ {
+ pdblReal[i] = (double*)malloc(sizeof(double) * piCoeff[i]);
+ pdblImg[i] = (double*)malloc(sizeof(double) * piCoeff[i]);
+ }
+
+ if (isVarComplex(_pvCtx, _piAddr))
+ {
+ sciErr = getComplexMatrixOfPolyInList(_pvCtx, _piParent, _iItemPos, &iRows, &iCols, piCoeff, pdblReal, pdblImg);
+ }
+ else
+ {
+ sciErr = getMatrixOfPolyInList(_pvCtx, _piParent, _iItemPos, &iRows, &iCols, piCoeff, pdblReal);
+ }
+ }
+
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ insert_indent();
+ sciprint("Poly (%d x %d), varname : \'%s\'\n", iRows, iCols, pstVar);
+
+ for (i = 0 ; i < iRows * iCols ; i++)
+ {
+ free(pdblReal[i]);
+ free(pdblImg[i]);
+ }
+
+ free(pdblReal);
+ free(pdblImg);
+ free(piCoeff);
+ return 0;;
+}
+int get_boolean_info(void* _pvCtx, int _iRhs, int* _piParent, int *_piAddr, int _iItemPos)
+{
+ SciErr sciErr;
+ int iRows = 0;
+ int iCols = 0;
+ int* piBool = NULL;
+
+ if (_iItemPos == 0)
+ {
+ sciErr = getMatrixOfBoolean(_pvCtx, _piAddr, &iRows, &iCols, &piBool);
+ }
+ else
+ {
+ sciErr = getMatrixOfBooleanInList(_pvCtx, _piParent, _iItemPos, &iRows, &iCols, &piBool);
+ }
+
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ insert_indent();
+ sciprint("Boolean (%d x %d)\n", iRows, iCols);
+ return 0;
+}
+int get_sparse_info(void* _pvCtx, int _iRhs, int* _piParent, int *_piAddr, int _iItemPos)
+{
+ SciErr sciErr;
+ int iRows = 0;
+ int iCols = 0;
+ int iItem = 0;
+ int* piNbRow = NULL;
+ int* piColPos = NULL;
+ double* pdblReal = NULL;
+ double* pdblImg = NULL;
+
+ if (_iItemPos == 0)
+ {
+ //Not in list
+ if (isVarComplex(_pvCtx, _piAddr))
+ {
+ sciErr = getComplexSparseMatrix(_pvCtx, _piAddr, &iRows, &iCols, &iItem, &piNbRow, &piColPos, &pdblReal, &pdblImg);
+ }
+ else
+ {
+ sciErr = getSparseMatrix(_pvCtx, _piAddr, &iRows, &iCols, &iItem, &piNbRow, &piColPos, &pdblReal);
+ }
+ }
+ else
+ {
+ if (isVarComplex(_pvCtx, _piAddr))
+ {
+ sciErr = getComplexSparseMatrixInList(_pvCtx, _piParent, _iItemPos, &iRows, &iCols, &iItem, &piNbRow, &piColPos, &pdblReal, &pdblImg);
+ }
+ else
+ {
+ sciErr = getSparseMatrixInList(_pvCtx, _piParent, _iItemPos, &iRows, &iCols, &iItem, &piNbRow, &piColPos, &pdblReal);
+ }
+ }
+
+ insert_indent();
+ sciprint("Sparse (%d x %d), Item(s) : %d \n", iRows, iCols, iItem);
+ return 0;;
+}
+
+int get_bsparse_info(void* _pvCtx, int _iRhs, int* _piParent, int *_piAddr, int _iItemPos)
+{
+ SciErr sciErr;
+ int iRows = 0;
+ int iCols = 0;
+ int iItem = 0;
+ int* piNbRow = NULL;
+ int* piColPos = NULL;
+
+ if (_iItemPos == 0)
+ {
+ //Not in list
+ sciErr = getBooleanSparseMatrix(_pvCtx, _piAddr, &iRows, &iCols, &iItem, &piNbRow, &piColPos);
+ }
+ else
+ {
+ sciErr = getBooleanSparseMatrixInList(_pvCtx, _piParent, _iItemPos, &iRows, &iCols, &iItem, &piNbRow, &piColPos);
+ }
+
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ insert_indent();
+ sciprint("Boolean Sparse (%d x %d), Item(s) : %d \n", iRows, iCols, iItem);
+ return 0;;
+}
+int get_integer_info(void* _pvCtx, int _iRhs, int* _piParent, int *_piAddr, int _iItemPos)
+{
+ SciErr sciErr;
+ int iPrec = 0;
+ int iRows = 0;
+ int iCols = 0;
+ char* pcData = NULL;
+ short* psData = NULL;
+ int* piData = NULL;
+ unsigned char* pucData = NULL;
+ unsigned short* pusData = NULL;
+ unsigned int* puiData = NULL;
+
+ if (_iItemPos == 0)
+ {
+ //Not in list
+ sciErr = getMatrixOfIntegerPrecision(_pvCtx, _piAddr, &iPrec);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ switch (iPrec)
+ {
+ case SCI_INT8 :
+ sciErr = getMatrixOfInteger8(_pvCtx, _piAddr, &iRows, &iCols, &pcData);
+ break;
+ case SCI_INT16 :
+ sciErr = getMatrixOfInteger16(_pvCtx, _piAddr, &iRows, &iCols, &psData);
+ break;
+ case SCI_INT32 :
+ sciErr = getMatrixOfInteger32(_pvCtx, _piAddr, &iRows, &iCols, &piData);
+ break;
+ case SCI_UINT8 :
+ sciErr = getMatrixOfUnsignedInteger8(_pvCtx, _piAddr, &iRows, &iCols, &pucData);
+ break;
+ case SCI_UINT16 :
+ sciErr = getMatrixOfUnsignedInteger16(_pvCtx, _piAddr, &iRows, &iCols, &pusData);
+ break;
+ case SCI_UINT32 :
+ sciErr = getMatrixOfUnsignedInteger32(_pvCtx, _piAddr, &iRows, &iCols, &puiData);
+ break;
+ default :
+ return 1;
+ }
+ }
+ else
+ {
+ sciErr = getMatrixOfIntegerPrecision(_pvCtx, _piAddr, &iPrec);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ switch (iPrec)
+ {
+ case SCI_INT8 :
+ sciErr = getMatrixOfInteger8InList(_pvCtx, _piParent, _iItemPos, &iRows, &iCols, &pcData);
+ break;
+ case SCI_INT16 :
+ sciErr = getMatrixOfInteger16InList(_pvCtx, _piParent, _iItemPos, &iRows, &iCols, &psData);
+ break;
+ case SCI_INT32 :
+ sciErr = getMatrixOfInteger32InList(_pvCtx, _piParent, _iItemPos, &iRows, &iCols, &piData);
+ break;
+ case SCI_UINT8 :
+ sciErr = getMatrixOfUnsignedInteger8InList(_pvCtx, _piParent, _iItemPos, &iRows, &iCols, &pucData);
+ break;
+ case SCI_UINT16 :
+ sciErr = getMatrixOfUnsignedInteger16InList(_pvCtx, _piParent, _iItemPos, &iRows, &iCols, &pusData);
+ break;
+ case SCI_UINT32 :
+ sciErr = getMatrixOfUnsignedInteger32InList(_pvCtx, _piParent, _iItemPos, &iRows, &iCols, &puiData);
+ break;
+ default :
+ return 1;
+ }
+ }
+
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ insert_indent();
+
+ if (iPrec > 10)
+ {
+ sciprint("Unsigned ");
+ }
+
+ sciprint("Integer %d bits (%d x %d)\n", (iPrec % 10) * 8, iRows, iCols);
+ return 0;;
+}
+int get_string_info(void* _pvCtx, int _iRhs, int* _piParent, int *_piAddr, int _iItemPos)
+{
+ SciErr sciErr;
+ int i;
+ int iRows = 0;
+ int iCols = 0;
+ int* piLen = NULL;
+ char **pstData = NULL;
+
+ if (_iItemPos == 0)
+ {
+ //Not in list
+ sciErr = getMatrixOfString(_pvCtx, _piAddr, &iRows, &iCols, NULL, NULL);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ piLen = (int*)malloc(sizeof(int) * iRows * iCols);
+ sciErr = getMatrixOfString(_pvCtx, _piAddr, &iRows, &iCols, piLen, NULL);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ pstData = (char**)malloc(sizeof(char*) * iRows * iCols);
+
+ for (i = 0 ; i < iRows * iCols ; i++)
+ {
+ pstData[i] = (char*)malloc(sizeof(char) * (piLen[i] + 1));//+ 1 for null termination
+ }
+
+ sciErr = getMatrixOfString(_pvCtx, _piAddr, &iRows, &iCols, piLen, pstData);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+ }
+ else
+ {
+ sciErr = getMatrixOfStringInList(_pvCtx, _piParent, _iItemPos, &iRows, &iCols, NULL, NULL);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ piLen = (int*)malloc(sizeof(int) * iRows * iCols);
+
+ sciErr = getMatrixOfStringInList(_pvCtx, _piParent, _iItemPos, &iRows, &iCols, piLen, NULL);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ pstData = (char**)malloc(sizeof(char*) * iRows * iCols);
+
+ for (i = 0 ; i < iRows * iCols ; i++)
+ {
+ pstData[i] = (char*)malloc(sizeof(char) * (piLen[i] + 1));//+ 1 for null termination
+ }
+
+ sciErr = getMatrixOfStringInList(_pvCtx, _piParent, _iItemPos, &iRows, &iCols, piLen, pstData);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+ }
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ insert_indent();
+ sciprint("Strings (%d x %d)\n", iRows, iCols);
+ return 0;;
+}
+int get_pointer_info(void* _pvCtx, int _iRhs, int* _piParent, int *_piAddr, int _iItemPos)
+{
+ SciErr sciErr;
+ void* pvPtr = NULL;
+
+ if (_iItemPos == 0)
+ {
+ sciErr = getPointer(_pvCtx, _piAddr, &pvPtr);
+ }
+ else
+ {
+ sciErr = getPointerInList(_pvCtx, _piParent, _iItemPos, &pvPtr);
+ }
+
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ insert_indent();
+ sciprint("Pointer : 0x%08X\n", pvPtr);
+ return 0;
+}
diff --git a/modules/api_scilab/tests/unit_tests/common_read_api.tst b/modules/api_scilab/tests/unit_tests/common_read_api.tst
new file mode 100755
index 000000000..399f7ff80
--- /dev/null
+++ b/modules/api_scilab/tests/unit_tests/common_read_api.tst
@@ -0,0 +1,36 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2009-2010 - DIGITEO
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- CLI SHELL MODE -->
+// <-- NO CHECK REF -->
+ilib_verbose(0);
+mkdir(pathconvert(TMPDIR+"/common_read_api"));
+cd(pathconvert(TMPDIR+"/common_read_api"));
+copyfile(SCI+"/modules/api_scilab/tests/unit_tests/common_read_api.c",pathconvert(TMPDIR+"/common_read_api/common_read_api.c",%F));
+cflags = "-I"+SCI+"/modules/localization/includes";
+ilib_build("common_read",["common_read","common_read"],"common_read_api.c",[],"","",cflags);
+exec("loader.sce");
+
+
+function read_all()
+d = [1,2,3;4,5,6;7,8,9];common_read(d);
+s=poly(0,"x");p=1+s+2*s^2;p = [(p * 2),(p * s + 3);(p * 2 * s ** 2 - 6),(12 - 4 * p * (- s) ** 2)];common_read(p);
+b = [%t,%f;%t,%f;%f,%t];common_read(b);
+sp=sparse([2,-1,0,0,0;-1,2,-1,0,0;0,-1,2,-1,0;0,0,-1,2,-1;0,0,0,-1,2]);common_read(sp);
+bsp=sparse([1,2;4,5;3,10],[%t,%t,%t]);common_read(bsp);
+i8 = int8([1,2,3]);common_read(i8);
+ui32 = uint32([3;2;1]);common_read(ui32);
+str = ["may", "the", "puffin"; "be", "with","you"];common_read(str);
+if with_module('umfpack') then
+ Cp = taucs_chfact(sp);
+ l = list(list(d, p, list(b, sp)), list(i8, bsp), list(ui32, str), Cp);
+else
+ l = list(list(d, p, list(b, sp)), list(i8, bsp), list(ui32, str));
+end
+common_read(l)
+endfunction
+read_all;
diff --git a/modules/api_scilab/tests/unit_tests/deleteNamedVariable.c b/modules/api_scilab/tests/unit_tests/deleteNamedVariable.c
new file mode 100755
index 000000000..2b78811c9
--- /dev/null
+++ b/modules/api_scilab/tests/unit_tests/deleteNamedVariable.c
@@ -0,0 +1,47 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2009-2010 - DIGITEO
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+ *
+ */
+
+#include "api_scilab.h"
+#include "MALLOC.h"
+
+int sci_deleteNamedVariable(char *fname, unsigned long fname_len)
+{
+ SciErr sciErr;
+ int iRet = 0;
+ int* piAddr = NULL;
+ char* pstVarName = NULL;
+
+ CheckRhs(1, 1);
+ CheckLhs(1, 1);
+
+ sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddr);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 1;
+ }
+
+ if (getAllocatedSingleString(pvApiCtx, piAddr, &pstVarName))
+ {
+ //error
+ return 1;
+ }
+
+ if (isNamedVarExist(pvApiCtx, pstVarName))
+ {
+ iRet = deleteNamedVariable(pvApiCtx, pstVarName);
+ }
+
+ createScalarBoolean(pvApiCtx, Rhs + 1, iRet);
+ AssignOutputVariable(pvApiCtx, 1) = Rhs + 1;
+ return 0;
+}
diff --git a/modules/api_scilab/tests/unit_tests/deleteNamedVariable.dia.ref b/modules/api_scilab/tests/unit_tests/deleteNamedVariable.dia.ref
new file mode 100755
index 000000000..39e74479f
--- /dev/null
+++ b/modules/api_scilab/tests/unit_tests/deleteNamedVariable.dia.ref
@@ -0,0 +1,30 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2009-2010 - DIGITEO
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- CLI SHELL MODE -->
+//
+ilib_verbose(0);
+mkdir(pathconvert(TMPDIR+"/deleteNamedVariable"));
+cd(pathconvert(TMPDIR+"/deleteNamedVariable"));
+copyfile(SCI+"/modules/api_scilab/tests/unit_tests/deleteNamedVariable.c",pathconvert(TMPDIR+"/deleteNamedVariable/deleteNamedVariable.c",%F));
+cflags = "-I"+SCI+"/modules/localization/includes";
+setenv('DEBUG_SCILAB_DYNAMIC_LINK','YES');
+ilib_build("gw_deleteNamedVariable", ["deleteNamedVariable", "sci_deleteNamedVariable"], "deleteNamedVariable.c", [], "", "", cflags);
+exec("loader.sce");
+function test()
+ assert_checkequal(exists("a"), 1);
+ assert_checkequal(a, 1);
+ a = 2;
+ assert_checkequal(a, 2);
+ assert_checktrue(deleteNamedVariable("a"));
+ assert_checkequal(exists("a"), 1);
+ assert_checkequal(a, 1);
+endfunction
+a = 1;
+test();
+assert_checkequal(a, 1);
+deleteNamedVariable("a");
+assert_checkequal(exists("a"), 0);
diff --git a/modules/api_scilab/tests/unit_tests/deleteNamedVariable.tst b/modules/api_scilab/tests/unit_tests/deleteNamedVariable.tst
new file mode 100755
index 000000000..9a958ab45
--- /dev/null
+++ b/modules/api_scilab/tests/unit_tests/deleteNamedVariable.tst
@@ -0,0 +1,33 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2009-2010 - DIGITEO
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- CLI SHELL MODE -->
+//exec SCI/modules\api_scilab\tests\unit_tests\deleteNamedVariable.tst
+ilib_verbose(0);
+mkdir(pathconvert(TMPDIR+"/deleteNamedVariable"));
+cd(pathconvert(TMPDIR+"/deleteNamedVariable"));
+copyfile(SCI+"/modules/api_scilab/tests/unit_tests/deleteNamedVariable.c",pathconvert(TMPDIR+"/deleteNamedVariable/deleteNamedVariable.c",%F));
+cflags = "-I"+SCI+"/modules/localization/includes";
+setenv('DEBUG_SCILAB_DYNAMIC_LINK','YES');
+ilib_build("gw_deleteNamedVariable", ["deleteNamedVariable", "sci_deleteNamedVariable"], "deleteNamedVariable.c", [], "", "", cflags);
+exec("loader.sce");
+
+function test()
+ assert_checkequal(exists("a"), 1);
+ assert_checkequal(a, 1);
+ a = 2;
+ assert_checkequal(a, 2);
+ assert_checktrue(deleteNamedVariable("a"));
+ assert_checkequal(exists("a"), 1);
+ assert_checkequal(a, 1);
+endfunction
+
+a = 1;
+test();
+assert_checkequal(a, 1);
+deleteNamedVariable("a");
+assert_checkequal(exists("a"), 0);
diff --git a/modules/api_scilab/tests/unit_tests/doubleExample.c b/modules/api_scilab/tests/unit_tests/doubleExample.c
new file mode 100755
index 000000000..8cfee6a50
--- /dev/null
+++ b/modules/api_scilab/tests/unit_tests/doubleExample.c
@@ -0,0 +1,127 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2009-2010 - DIGITEO
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+ *
+ */
+
+#include "api_scilab.h"
+#include "Scierror.h"
+#include "localization.h"
+#include "sciprint.h"
+#include "MALLOC.h"
+
+int doubleExample(char *fname, unsigned long fname_len)
+{
+ SciErr sciErr;
+ int* piAddr = NULL;
+ int iType = 0;
+ int iRet = 0;
+
+ CheckInputArgument(pvApiCtx, 1, 1);
+ CheckOutputArgument(pvApiCtx, 0, 1);
+
+ sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddr);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ if (isEmptyMatrix(pvApiCtx, piAddr))
+ {
+ iRet = createEmptyMatrix(pvApiCtx, nbInputArgument(pvApiCtx) + 1);
+ if (iRet)
+ {
+ return iRet;
+ }
+
+ AssignOutputVariable(pvApiCtx, 1) = 0;
+ }
+ else if (isDoubleType(pvApiCtx, piAddr))
+ {
+ if (isScalar(pvApiCtx, piAddr))
+ {
+ double dblReal = 0;
+ double dblImg = 0;
+
+ if (isVarComplex(pvApiCtx, piAddr))
+ {
+ iRet = getScalarComplexDouble(pvApiCtx, piAddr, &dblReal, &dblImg);
+ if (iRet)
+ {
+ return iRet;
+ }
+
+ iRet = createScalarComplexDouble(pvApiCtx, nbInputArgument(pvApiCtx) + 1, dblReal, dblImg);
+ if (iRet)
+ {
+ return iRet;
+ }
+ }
+ else
+ {
+ iRet = getScalarDouble(pvApiCtx, piAddr, &dblReal);
+ if (iRet)
+ {
+ return iRet;
+ }
+
+ iRet = createScalarDouble(pvApiCtx, nbInputArgument(pvApiCtx) + 1, dblReal);
+ if (iRet)
+ {
+ return iRet;
+ }
+ }
+ }
+ else
+ {
+ int iRows = 0;
+ int iCols = 0;
+ double* pdblReal = NULL;
+ double* pdblImg = NULL;
+
+ if (isVarComplex(pvApiCtx, piAddr))
+ {
+ sciErr = getComplexMatrixOfDouble(pvApiCtx, piAddr, &iRows, &iCols, &pdblReal, &pdblImg);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return sciErr.iErr;
+ }
+
+ sciErr = createComplexMatrixOfDouble(pvApiCtx, nbInputArgument(pvApiCtx) + 1, iRows, iCols, pdblReal, pdblImg);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return sciErr.iErr;
+ }
+ }
+ else
+ {
+ sciErr = getMatrixOfDouble(pvApiCtx, piAddr, &iRows, &iCols, &pdblReal);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return sciErr.iErr;
+ }
+
+ sciErr = createMatrixOfDouble(pvApiCtx, nbInputArgument(pvApiCtx) + 1, iRows, iCols, pdblReal);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return sciErr.iErr;
+ }
+ }
+ }
+
+ AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1;
+ }
+
+ return 0;
+}
diff --git a/modules/api_scilab/tests/unit_tests/doubleExample.dia.ref b/modules/api_scilab/tests/unit_tests/doubleExample.dia.ref
new file mode 100755
index 000000000..3d15243e2
--- /dev/null
+++ b/modules/api_scilab/tests/unit_tests/doubleExample.dia.ref
@@ -0,0 +1,22 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2009-2010 - DIGITEO
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- CLI SHELL MODE -->
+ilib_verbose(0);
+mkdir(pathconvert(TMPDIR+"/doubleExample"));
+cd(pathconvert(TMPDIR+"/doubleExample"));
+copyfile(SCI+"/modules/api_scilab/tests/unit_tests/doubleExample.c",pathconvert(TMPDIR+"/doubleExample/doubleExample.c",%F));
+cflags = "-I"+SCI+"/modules/localization/includes";
+ilib_build("gw_doubleExample",["doubleExample","doubleExample"],"doubleExample.c",[],"","",cflags);
+exec("loader.sce");
+a = 1;
+b = %i;
+c = [1,2,3;4,5,6];
+d = c(1:$) + c($:-1:1) * %i;
+assert_checkequal(doubleExample(a), a);
+assert_checkequal(doubleExample(b), b);
+assert_checkequal(doubleExample(c), c);
+assert_checkequal(doubleExample(d), d);
diff --git a/modules/api_scilab/tests/unit_tests/doubleExample.tst b/modules/api_scilab/tests/unit_tests/doubleExample.tst
new file mode 100755
index 000000000..90a445c08
--- /dev/null
+++ b/modules/api_scilab/tests/unit_tests/doubleExample.tst
@@ -0,0 +1,24 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2009-2010 - DIGITEO
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- CLI SHELL MODE -->
+ilib_verbose(0);
+mkdir(pathconvert(TMPDIR+"/doubleExample"));
+cd(pathconvert(TMPDIR+"/doubleExample"));
+copyfile(SCI+"/modules/api_scilab/tests/unit_tests/doubleExample.c",pathconvert(TMPDIR+"/doubleExample/doubleExample.c",%F));
+cflags = "-I"+SCI+"/modules/localization/includes";
+ilib_build("gw_doubleExample",["doubleExample","doubleExample"],"doubleExample.c",[],"","",cflags);
+exec("loader.sce");
+
+a = 1;
+b = %i;
+c = [1,2,3;4,5,6];
+d = c(1:$) + c($:-1:1) * %i;
+assert_checkequal(doubleExample(a), a);
+assert_checkequal(doubleExample(b), b);
+assert_checkequal(doubleExample(c), c);
+assert_checkequal(doubleExample(d), d);
diff --git a/modules/api_scilab/tests/unit_tests/double_reading_api.c b/modules/api_scilab/tests/unit_tests/double_reading_api.c
new file mode 100755
index 000000000..582dd77c2
--- /dev/null
+++ b/modules/api_scilab/tests/unit_tests/double_reading_api.c
@@ -0,0 +1,100 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2009-2010 - DIGITEO
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+ *
+ */
+
+#include "api_scilab.h"
+#include "Scierror.h"
+#include "localization.h"
+#include "sciprint.h"
+#include "MALLOC.h"
+
+int read_double(char *fname, unsigned long fname_len)
+{
+ SciErr sciErr;
+ int i;
+ //first variable info : real matrix of double
+ int iType = 0;
+ int iRows = 0;
+ int iCols = 0;
+ int iComplex = 0;
+ int *piAddr = NULL;
+ double* pdblReal = NULL;
+ double* pdblImg = NULL;
+
+ //check input and output arguments
+ CheckInputArgument(pvApiCtx, 1, 1);
+ CheckOutputArgument(pvApiCtx, 1, 1);
+
+ /************************
+ * First variable *
+ ************************/
+
+ //get variable address of the first input argument
+ sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddr);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ //check type
+ sciErr = getVarType(pvApiCtx, piAddr, &iType);
+ if (sciErr.iErr || iType != sci_matrix)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ //get complexity
+ iComplex = isVarComplex(pvApiCtx, piAddr);
+
+ //check complexity
+ if (iComplex)
+ {
+ //get size and data from Scilab memory
+ sciErr = getComplexMatrixOfDouble(pvApiCtx, piAddr, &iRows, &iCols, &pdblReal, &pdblImg);
+ }
+ else
+ {
+ //get size and data from Scilab memory
+ sciErr = getMatrixOfDouble(pvApiCtx, piAddr, &iRows, &iCols, &pdblReal);
+ }
+
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ //Do something with data
+ //if variable is complex, switch real part and imaginary part otherwise multiply by -1
+ if (iComplex)
+ {
+ sciErr = createComplexMatrixOfDouble(pvApiCtx, nbInputArgument(pvApiCtx) + 1, iRows, iCols, pdblImg, pdblReal);
+ }
+ else
+ {
+ for (i = 0 ; i < iRows * iCols ; i++)
+ {
+ pdblReal[i] = pdblReal[i] * -1;
+ }
+ sciErr = createMatrixOfDouble(pvApiCtx, nbInputArgument(pvApiCtx) + 1, iRows, iCols, pdblReal);
+ }
+
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1;
+ return 0;
+}
diff --git a/modules/api_scilab/tests/unit_tests/double_reading_api.dia.ref b/modules/api_scilab/tests/unit_tests/double_reading_api.dia.ref
new file mode 100755
index 000000000..26261e8af
--- /dev/null
+++ b/modules/api_scilab/tests/unit_tests/double_reading_api.dia.ref
@@ -0,0 +1,25 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2009-2010 - DIGITEO
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- CLI SHELL MODE -->
+ilib_verbose(0);
+mkdir(pathconvert(TMPDIR+"/double_reading_api"));
+cd(pathconvert(TMPDIR+"/double_reading_api"));
+copyfile(SCI+"/modules/api_scilab/tests/unit_tests/double_reading_api.c",pathconvert(TMPDIR+"/double_reading_api/double_reading_api.c",%F));
+cflags = "-I"+SCI+"/modules/localization/includes";
+ilib_build("double_reading",["read_double","read_double"],"double_reading_api.c",[],"","",cflags);
+exec("loader.sce");
+a = [ 0 1 2 3; ..
+ 4 5 6 7; ..
+ 8 9 10 11];
+b = [ 23*%i, 1+22*%i, 2+21*%i, 3+20*%i, 4+19*%i, 5+18*%i; ..
+ 6+17*%i, 7+16*%i, 8+15*%i, 9+14*%i, 10+13*%i, 11+12*%i; ..
+ 12+11*%i, 13+10*%i, 14+9*%i, 15+8*%i, 16+7*%i, 17+6*%i; ..
+ 18+5*%i, 19+4*%i, 20+3*%i, 21+2*%i, 22+1*%i, 23];
+a2 = read_double(a);
+b2 = read_double(b);
+if or(a2 <> a * -1) then bugmes();quit;end
+if or(b2 <> (imag(b) + real(b) * %i)) then bugmes();quit;end
diff --git a/modules/api_scilab/tests/unit_tests/double_reading_api.tst b/modules/api_scilab/tests/unit_tests/double_reading_api.tst
new file mode 100755
index 000000000..decadf8ff
--- /dev/null
+++ b/modules/api_scilab/tests/unit_tests/double_reading_api.tst
@@ -0,0 +1,27 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2009-2010 - DIGITEO
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- CLI SHELL MODE -->
+ilib_verbose(0);
+mkdir(pathconvert(TMPDIR+"/double_reading_api"));
+cd(pathconvert(TMPDIR+"/double_reading_api"));
+copyfile(SCI+"/modules/api_scilab/tests/unit_tests/double_reading_api.c",pathconvert(TMPDIR+"/double_reading_api/double_reading_api.c",%F));
+cflags = "-I"+SCI+"/modules/localization/includes";
+ilib_build("double_reading",["read_double","read_double"],"double_reading_api.c",[],"","",cflags);
+exec("loader.sce");
+
+a = [ 0 1 2 3; ..
+ 4 5 6 7; ..
+ 8 9 10 11];
+b = [ 23*%i, 1+22*%i, 2+21*%i, 3+20*%i, 4+19*%i, 5+18*%i; ..
+ 6+17*%i, 7+16*%i, 8+15*%i, 9+14*%i, 10+13*%i, 11+12*%i; ..
+ 12+11*%i, 13+10*%i, 14+9*%i, 15+8*%i, 16+7*%i, 17+6*%i; ..
+ 18+5*%i, 19+4*%i, 20+3*%i, 21+2*%i, 22+1*%i, 23];
+a2 = read_double(a);
+b2 = read_double(b);
+if or(a2 <> a * -1) then pause;end
+if or(b2 <> (imag(b) + real(b) * %i)) then pause;end
diff --git a/modules/api_scilab/tests/unit_tests/double_writing_api.c b/modules/api_scilab/tests/unit_tests/double_writing_api.c
new file mode 100755
index 000000000..d8bcc62b5
--- /dev/null
+++ b/modules/api_scilab/tests/unit_tests/double_writing_api.c
@@ -0,0 +1,107 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2009-2010 - DIGITEO
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+ *
+ */
+
+#include "api_scilab.h"
+#include "Scierror.h"
+#include "localization.h"
+#include "sciprint.h"
+#include "MALLOC.h"
+
+int write_double(char *fname, unsigned long fname_len)
+{
+ SciErr sciErr;
+ int i, j;
+ //first variable info : real matrix of double 3 x 4
+ int iRows1 = 3;
+ int iCols1 = 4;
+ double* pdblReal1 = NULL;
+ //second variable info : complex matrix of double 4 x 6
+ int iRows2 = 4;
+ int iCols2 = 6;
+ double* pdblReal2 = NULL;
+ double* pdblImg2 = NULL;
+
+ /************************
+ * First variable *
+ ************************/
+
+ //alloc array of data in OS memory
+ pdblReal1 = (double*)malloc(sizeof(double) * iRows1 * iCols1);
+ //fill array with incremental values
+ //[ 0 1 2 3
+ // 4 5 6 7
+ // 8 9 10 11]
+ for (i = 0 ; i < iRows1 ; i++)
+ {
+ for (j = 0 ; j < iCols1 ; j++)
+ {
+ pdblReal1[i + iRows1 * j] = i * iCols1 + j;
+ }
+ }
+
+ //can be written in a single loop
+ //for(i = 0 ; i < iRows1 * iCols1; i++)
+ //{
+ // pdblReal1[i] = i;
+ //}
+ //create a variable from a existing data array
+
+ sciErr = createMatrixOfDouble(pvApiCtx, nbInputArgument(pvApiCtx) + 1, iRows1, iCols1, pdblReal1);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+ //after creation, we can free memory.
+ free(pdblReal1);
+
+
+ /*************************
+ * Second variable *
+ *************************/
+
+ //reserve space in scilab memory and fill it
+ sciErr = allocComplexMatrixOfDouble(pvApiCtx, nbInputArgument(pvApiCtx) + 2, iRows2, iCols2, &pdblReal2, &pdblImg2);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ //fill array with incremental values for real part and decremental for imaginary part
+ //[ 23i 1+22i 2+21i 3+20i 4+19i 5+18i
+ // 6+17i 7+16i 8+15i 9+14i 10+13i 11+12i
+ // 12+11i 13+10i 14+9i 15+8i 16+7i 17+6i
+ // 18+5i 19+4i 20+3i 21+2i 22+1i 23 ]
+ for (i = 0 ; i < iRows2 ; i++)
+ {
+ for (j = 0 ; j < iCols2 ; j++)
+ {
+ pdblReal2[i + iRows2 * j] = i * iCols2 + j;
+ pdblImg2 [i + iRows2 * j] = (iRows2 * iCols2 - 1) - (i * iCols2 + j);
+ }
+ }
+
+ //can be written in a single loop
+ //for(i = 0 ; i < iRows2 * iCols2; i++)
+ //{
+ // pdblReal2[i] = i;
+ // pdblImg2 [i] = (iRows2 * iCols2 - 1) - i;
+ //}
+ // /!\ DO NOT FREE MEMORY, in this case, it's the Scilab memory
+ //assign allocated variables to Lhs position
+
+ AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1;
+ AssignOutputVariable(pvApiCtx, 2) = nbInputArgument(pvApiCtx) + 2;
+
+ return 0;
+}
diff --git a/modules/api_scilab/tests/unit_tests/double_writing_api.dia.ref b/modules/api_scilab/tests/unit_tests/double_writing_api.dia.ref
new file mode 100755
index 000000000..6035abcb1
--- /dev/null
+++ b/modules/api_scilab/tests/unit_tests/double_writing_api.dia.ref
@@ -0,0 +1,24 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2009-2010 - DIGITEO
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- CLI SHELL MODE -->
+ilib_verbose(0);
+mkdir(pathconvert(TMPDIR+"/double_writing_api"));
+cd(pathconvert(TMPDIR+"/double_writing_api"));
+copyfile(SCI+"/modules/api_scilab/tests/unit_tests/double_writing_api.c",pathconvert(TMPDIR+"/double_writing_api/double_writing_api.c",%F));
+cflags = "-I"+SCI+"/modules/localization/includes";
+ilib_build("double_writing",["write_double","write_double"],"double_writing_api.c",[],"","",cflags);
+exec("loader.sce");
+a_ref = [ 0 1 2 3; ..
+ 4 5 6 7; ..
+ 8 9 10 11];
+b_ref = [ 23*%i, 1+22*%i, 2+21*%i, 3+20*%i, 4+19*%i, 5+18*%i; ..
+ 6+17*%i, 7+16*%i, 8+15*%i, 9+14*%i, 10+13*%i, 11+12*%i; ..
+ 12+11*%i, 13+10*%i, 14+9*%i, 15+8*%i, 16+7*%i, 17+6*%i; ..
+ 18+5*%i, 19+4*%i, 20+3*%i, 21+2*%i, 22+1*%i, 23];
+[a,b] = write_double();
+if or(a <> a_ref) then bugmes();quit;end
+if or(b <> b_ref) then bugmes();quit;end
diff --git a/modules/api_scilab/tests/unit_tests/double_writing_api.tst b/modules/api_scilab/tests/unit_tests/double_writing_api.tst
new file mode 100755
index 000000000..c65a4f661
--- /dev/null
+++ b/modules/api_scilab/tests/unit_tests/double_writing_api.tst
@@ -0,0 +1,26 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2009-2010 - DIGITEO
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- CLI SHELL MODE -->
+ilib_verbose(0);
+mkdir(pathconvert(TMPDIR+"/double_writing_api"));
+cd(pathconvert(TMPDIR+"/double_writing_api"));
+copyfile(SCI+"/modules/api_scilab/tests/unit_tests/double_writing_api.c",pathconvert(TMPDIR+"/double_writing_api/double_writing_api.c",%F));
+cflags = "-I"+SCI+"/modules/localization/includes";
+ilib_build("double_writing",["write_double","write_double"],"double_writing_api.c",[],"","",cflags);
+exec("loader.sce");
+
+a_ref = [ 0 1 2 3; ..
+ 4 5 6 7; ..
+ 8 9 10 11];
+b_ref = [ 23*%i, 1+22*%i, 2+21*%i, 3+20*%i, 4+19*%i, 5+18*%i; ..
+ 6+17*%i, 7+16*%i, 8+15*%i, 9+14*%i, 10+13*%i, 11+12*%i; ..
+ 12+11*%i, 13+10*%i, 14+9*%i, 15+8*%i, 16+7*%i, 17+6*%i; ..
+ 18+5*%i, 19+4*%i, 20+3*%i, 21+2*%i, 22+1*%i, 23];
+[a,b] = write_double();
+if or(a <> a_ref) then pause;end
+if or(b <> b_ref) then pause;end
diff --git a/modules/api_scilab/tests/unit_tests/hypermatExample.c b/modules/api_scilab/tests/unit_tests/hypermatExample.c
new file mode 100755
index 000000000..bc11b3277
--- /dev/null
+++ b/modules/api_scilab/tests/unit_tests/hypermatExample.c
@@ -0,0 +1,90 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2013 - Scilab Enterprises
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+ *
+ */
+
+#include "api_scilab.h"
+#include "Scierror.h"
+#include "localization.h"
+#include "sciprint.h"
+#include "MALLOC.h"
+
+int hypermatExample(char *fname, unsigned long fname_len)
+{
+ SciErr sciErr;
+ int* piAddr = NULL;
+ int iType = 0;
+ int iRet = 0;
+
+ CheckInputArgument(pvApiCtx, 1, 1);
+ CheckOutputArgument(pvApiCtx, 0, 1);
+
+ sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddr);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ if (isEmptyMatrix(pvApiCtx, piAddr))
+ {
+ iRet = createEmptyMatrix(pvApiCtx, nbInputArgument(pvApiCtx) + 1);
+ if (iRet)
+ {
+ return iRet;
+ }
+
+ AssignOutputVariable(pvApiCtx, 1) = 0;
+ }
+ else if (isHypermatType(pvApiCtx, piAddr))
+ {
+ int * dims = NULL;
+ int ndims;
+ double* pdblReal = NULL;
+ double* pdblImg = NULL;
+
+ if (isHypermatComplex(pvApiCtx, piAddr))
+ {
+ sciErr = getComplexHypermatOfDouble(pvApiCtx, piAddr, &dims, &ndims, &pdblReal, &pdblImg);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return sciErr.iErr;
+ }
+
+ sciErr = createComplexHypermatOfDouble(pvApiCtx, nbInputArgument(pvApiCtx) + 1, dims, ndims, pdblReal, pdblImg);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return sciErr.iErr;
+ }
+ }
+ else
+ {
+ sciErr = getHypermatOfDouble(pvApiCtx, piAddr, &dims, &ndims, &pdblReal);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return sciErr.iErr;
+ }
+
+ sciErr = createHypermatOfDouble(pvApiCtx, nbInputArgument(pvApiCtx) + 1, dims, ndims, pdblReal);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return sciErr.iErr;
+ }
+ }
+
+ AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1;
+ }
+
+ return 0;
+}
diff --git a/modules/api_scilab/tests/unit_tests/hypermatExample.dia.ref b/modules/api_scilab/tests/unit_tests/hypermatExample.dia.ref
new file mode 100755
index 000000000..e18c6c38e
--- /dev/null
+++ b/modules/api_scilab/tests/unit_tests/hypermatExample.dia.ref
@@ -0,0 +1,18 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2013 - Scilab Enterprises
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- CLI SHELL MODE -->
+ilib_verbose(0);
+mkdir(pathconvert(TMPDIR+"/hypermatExample"));
+cd(pathconvert(TMPDIR+"/hypermatExample"));
+copyfile(SCI+"/modules/api_scilab/tests/unit_tests/hypermatExample.c",pathconvert(TMPDIR+"/hypermatExample/hypermatExample.c",%F));
+cflags = "-I"+SCI+"/modules/localization/includes";
+ilib_build("gw_hypermatExample",["hypermatExample","hypermatExample"],"hypermatExample.c",[],"","",cflags);
+exec("loader.sce");
+a = hypermat([1 2 3], ones(1,6));
+b = a + %i*hypermat([1 2 3], 1:6);
+assert_checkequal(hypermatExample(a), a);
+assert_checkequal(hypermatExample(b), b);
diff --git a/modules/api_scilab/tests/unit_tests/hypermatExample.tst b/modules/api_scilab/tests/unit_tests/hypermatExample.tst
new file mode 100755
index 000000000..fb4d19567
--- /dev/null
+++ b/modules/api_scilab/tests/unit_tests/hypermatExample.tst
@@ -0,0 +1,21 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2013 - Scilab Enterprises
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- CLI SHELL MODE -->
+ilib_verbose(0);
+mkdir(pathconvert(TMPDIR+"/hypermatExample"));
+cd(pathconvert(TMPDIR+"/hypermatExample"));
+copyfile(SCI+"/modules/api_scilab/tests/unit_tests/hypermatExample.c",pathconvert(TMPDIR+"/hypermatExample/hypermatExample.c",%F));
+cflags = "-I"+SCI+"/modules/localization/includes";
+ilib_build("gw_hypermatExample",["hypermatExample","hypermatExample"],"hypermatExample.c",[],"","",cflags);
+exec("loader.sce");
+
+a = hypermat([1 2 3], ones(1,6));
+b = a + %i*hypermat([1 2 3], 1:6);
+
+assert_checkequal(hypermatExample(a), a);
+assert_checkequal(hypermatExample(b), b);
diff --git a/modules/api_scilab/tests/unit_tests/hypermatIntExample.c b/modules/api_scilab/tests/unit_tests/hypermatIntExample.c
new file mode 100755
index 000000000..089b5f9a1
--- /dev/null
+++ b/modules/api_scilab/tests/unit_tests/hypermatIntExample.c
@@ -0,0 +1,174 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2013 - Scilab Enterprises
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+ *
+ */
+
+#include "api_scilab.h"
+#include "Scierror.h"
+#include "localization.h"
+#include "sciprint.h"
+#include "MALLOC.h"
+
+int hypermatIntExample(char *fname, unsigned long fname_len)
+{
+ SciErr sciErr;
+ int* piAddr = NULL;
+ int iType = 0;
+ int iRet = 0;
+
+ CheckInputArgument(pvApiCtx, 1, 1);
+ CheckOutputArgument(pvApiCtx, 0, 1);
+
+ sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddr);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ if (isEmptyMatrix(pvApiCtx, piAddr))
+ {
+ iRet = createEmptyMatrix(pvApiCtx, nbInputArgument(pvApiCtx) + 1);
+ if (iRet)
+ {
+ return iRet;
+ }
+
+ AssignOutputVariable(pvApiCtx, 1) = 0;
+ }
+ else if (isHypermatType(pvApiCtx, piAddr))
+ {
+ int * dims = NULL;
+ int ndims;
+ void * data = NULL;
+ int htype = 0;
+ int precision;
+
+ sciErr = getHypermatType(pvApiCtx, piAddr, &htype);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return sciErr.iErr;
+ }
+
+ if (htype == sci_ints)
+ {
+ sciErr = getHypermatOfIntegerPrecision(pvApiCtx, piAddr, &precision);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return sciErr.iErr;
+ }
+
+ switch (precision)
+ {
+ case SCI_INT8:
+ sciErr = getHypermatOfInteger8(pvApiCtx, piAddr, &dims, &ndims, (char*)&data);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return sciErr.iErr;
+ }
+
+ sciErr = createHypermatOfInteger8(pvApiCtx, nbInputArgument(pvApiCtx) + 1, dims, ndims, (const char*)data);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return sciErr.iErr;
+ }
+ break;
+ case SCI_UINT8:
+ sciErr = getHypermatOfUnsignedInteger8(pvApiCtx, piAddr, &dims, &ndims, (unsigned char*)&data);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return sciErr.iErr;
+ }
+
+ sciErr = createHypermatOfUnsignedInteger8(pvApiCtx, nbInputArgument(pvApiCtx) + 1, dims, ndims, (const unsigned char*)data);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return sciErr.iErr;
+ }
+ break;
+ case SCI_INT16:
+ sciErr = getHypermatOfInteger16(pvApiCtx, piAddr, &dims, &ndims, (short*)&data);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return sciErr.iErr;
+ }
+
+ sciErr = createHypermatOfInteger16(pvApiCtx, nbInputArgument(pvApiCtx) + 1, dims, ndims, (const short*)data);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return sciErr.iErr;
+ }
+ break;
+ case SCI_UINT16:
+ sciErr = getHypermatOfUnsignedInteger16(pvApiCtx, piAddr, &dims, &ndims, (unsigned short*)&data);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return sciErr.iErr;
+ }
+
+ sciErr = createHypermatOfUnsignedInteger16(pvApiCtx, nbInputArgument(pvApiCtx) + 1, dims, ndims, (const unsigned short*)data);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return sciErr.iErr;
+ }
+ break;
+ case SCI_INT32:
+ sciErr = getHypermatOfInteger32(pvApiCtx, piAddr, &dims, &ndims, (int*)&data);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return sciErr.iErr;
+ }
+
+ sciErr = createHypermatOfInteger32(pvApiCtx, nbInputArgument(pvApiCtx) + 1, dims, ndims, (const int*)data);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return sciErr.iErr;
+ }
+ break;
+ case SCI_UINT32:
+ sciErr = getHypermatOfUnsignedInteger32(pvApiCtx, piAddr, &dims, &ndims, (unsigned int*)&data);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return sciErr.iErr;
+ }
+
+ sciErr = createHypermatOfUnsignedInteger32(pvApiCtx, nbInputArgument(pvApiCtx) + 1, dims, ndims, (const unsigned int*)data);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return sciErr.iErr;
+ }
+ break;
+ }
+ }
+ else
+ {
+ Scierror(999, _("%s: Wrong type for input argument #%d: An integer expected.\n"), fname, 1);
+ return 1;
+ }
+
+ AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1;
+ }
+
+ return 0;
+}
diff --git a/modules/api_scilab/tests/unit_tests/hypermatIntExample.dia.ref b/modules/api_scilab/tests/unit_tests/hypermatIntExample.dia.ref
new file mode 100755
index 000000000..5446f8952
--- /dev/null
+++ b/modules/api_scilab/tests/unit_tests/hypermatIntExample.dia.ref
@@ -0,0 +1,26 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2013 - Scilab Enterprises
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- CLI SHELL MODE -->
+ilib_verbose(0);
+mkdir(pathconvert(TMPDIR+"/hypermatIntExample"));
+cd(pathconvert(TMPDIR+"/hypermatIntExample"));
+copyfile(SCI+"/modules/api_scilab/tests/unit_tests/hypermatIntExample.c",pathconvert(TMPDIR+"/hypermatIntExample/hypermatIntExample.c",%F));
+cflags = "-I"+SCI+"/modules/localization/includes";
+ilib_build("gw_hypermatIntExample",["hypermatIntExample","hypermatIntExample"],"hypermatIntExample.c",[],"","",cflags);
+exec("loader.sce");
+a = hypermat([1 2 3], int8(1:6));
+b = hypermat([1 2 3], uint8(1:6));
+c = hypermat([1 2 3], int16(1:6));
+d = hypermat([1 2 3], uint16(1:6));
+e = hypermat([1 2 3], int32(1:6));
+f = hypermat([1 2 3], uint32(1:6));
+assert_checkequal(hypermatIntExample(a), a);
+assert_checkequal(hypermatIntExample(b), b);
+assert_checkequal(hypermatIntExample(c), c);
+assert_checkequal(hypermatIntExample(d), d);
+assert_checkequal(hypermatIntExample(e), e);
+assert_checkequal(hypermatIntExample(f), f);
diff --git a/modules/api_scilab/tests/unit_tests/hypermatIntExample.tst b/modules/api_scilab/tests/unit_tests/hypermatIntExample.tst
new file mode 100755
index 000000000..abb142134
--- /dev/null
+++ b/modules/api_scilab/tests/unit_tests/hypermatIntExample.tst
@@ -0,0 +1,29 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2013 - Scilab Enterprises
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- CLI SHELL MODE -->
+ilib_verbose(0);
+mkdir(pathconvert(TMPDIR+"/hypermatIntExample"));
+cd(pathconvert(TMPDIR+"/hypermatIntExample"));
+copyfile(SCI+"/modules/api_scilab/tests/unit_tests/hypermatIntExample.c",pathconvert(TMPDIR+"/hypermatIntExample/hypermatIntExample.c",%F));
+cflags = "-I"+SCI+"/modules/localization/includes";
+ilib_build("gw_hypermatIntExample",["hypermatIntExample","hypermatIntExample"],"hypermatIntExample.c",[],"","",cflags);
+exec("loader.sce");
+
+a = hypermat([1 2 3], int8(1:6));
+b = hypermat([1 2 3], uint8(1:6));
+c = hypermat([1 2 3], int16(1:6));
+d = hypermat([1 2 3], uint16(1:6));
+e = hypermat([1 2 3], int32(1:6));
+f = hypermat([1 2 3], uint32(1:6));
+
+assert_checkequal(hypermatIntExample(a), a);
+assert_checkequal(hypermatIntExample(b), b);
+assert_checkequal(hypermatIntExample(c), c);
+assert_checkequal(hypermatIntExample(d), d);
+assert_checkequal(hypermatIntExample(e), e);
+assert_checkequal(hypermatIntExample(f), f);
diff --git a/modules/api_scilab/tests/unit_tests/integer_reading_api.c b/modules/api_scilab/tests/unit_tests/integer_reading_api.c
new file mode 100755
index 000000000..bb8a964c1
--- /dev/null
+++ b/modules/api_scilab/tests/unit_tests/integer_reading_api.c
@@ -0,0 +1,277 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2009-2010 - DIGITEO
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+ *
+ */
+
+#include "api_scilab.h"
+#include "Scierror.h"
+#include "localization.h"
+#include "sciprint.h"
+#include "MALLOC.h"
+
+void* create_output(int _iCoeff, int _iSize, int _iRows, int _iCols, void* _pvDataIn);
+
+int read_integer(char *fname, unsigned long fname_len)
+{
+ SciErr sciErr;
+ //output variable info
+ int iRows8 = 0;
+ int iCols8 = 0;
+ int iRows16 = 0;
+ int iCols16 = 0;
+ int iRows32 = 0;
+ int iCols32 = 0;
+ int iRowsu8 = 0;
+ int iColsu8 = 0;
+ int iRowsu16 = 0;
+ int iColsu16 = 0;
+ int iRowsu32 = 0;
+ int iColsu32 = 0;
+ int iPrec = 0;
+ int* piAddr8 = NULL;
+ int* piAddr16 = NULL;
+ int* piAddr32 = NULL;
+ int* piAddru8 = NULL;
+ int* piAddru16 = NULL;
+ int* piAddru32 = NULL;
+ char* pcData = NULL;
+ short* psData = NULL;
+ int* piData = NULL;
+ unsigned char* pucData = NULL;
+ unsigned short* pusData = NULL;
+ unsigned int* puiData = NULL;
+ char* pcDataOut = NULL;
+ short* psDataOut = NULL;
+ int* piDataOut = NULL;
+ unsigned char* pucDataOut = NULL;
+ unsigned short* pusDataOut = NULL;
+ unsigned int* puiDataOut = NULL;
+
+ //check input/output arguments count
+ CheckInputArgument(pvApiCtx, 6, 6);
+ CheckOutputArgument(pvApiCtx, 6, 6);
+
+ //get varialbe address
+ sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddr8);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ sciErr = getVarAddressFromPosition(pvApiCtx, 2, &piAddru8);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ sciErr = getVarAddressFromPosition(pvApiCtx, 3, &piAddr16);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ sciErr = getVarAddressFromPosition(pvApiCtx, 4, &piAddru16);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ sciErr = getVarAddressFromPosition(pvApiCtx, 5, &piAddr32);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ sciErr = getVarAddressFromPosition(pvApiCtx, 6, &piAddru32);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ //check variable precision
+ sciErr = getMatrixOfIntegerPrecision(pvApiCtx, piAddr8, &iPrec);
+ if (sciErr.iErr || iPrec != SCI_INT8)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ //check variable precision
+ sciErr = getMatrixOfIntegerPrecision(pvApiCtx, piAddru8, &iPrec);
+ if (sciErr.iErr || iPrec != SCI_UINT8)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ //check variable precision
+ sciErr = getMatrixOfIntegerPrecision(pvApiCtx, piAddr16, &iPrec);
+ if (sciErr.iErr || iPrec != SCI_INT16)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ //check variable precision
+ sciErr = getMatrixOfIntegerPrecision(pvApiCtx, piAddru16, &iPrec);
+ if (sciErr.iErr || iPrec != SCI_UINT16)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+ //check variable precision
+ sciErr = getMatrixOfIntegerPrecision(pvApiCtx, piAddr32, &iPrec);
+ if (sciErr.iErr || iPrec != SCI_INT32)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ //check variable precision
+ sciErr = getMatrixOfIntegerPrecision(pvApiCtx, piAddru32, &iPrec);
+ if (sciErr.iErr || iPrec != SCI_UINT32)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ //retrieve dimensions and data
+ sciErr = getMatrixOfInteger8(pvApiCtx, piAddr8, &iRows8, &iCols8, &pcData);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ //retrieve dimensions and data
+ sciErr = getMatrixOfUnsignedInteger8(pvApiCtx, piAddru8, &iRowsu8, &iColsu8, &pucData);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ //retrieve dimensions and data
+ sciErr = getMatrixOfInteger16(pvApiCtx, piAddr16, &iRows16, &iCols16, &psData);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ //retrieve dimensions and data
+ sciErr = getMatrixOfUnsignedInteger16(pvApiCtx, piAddru16, &iRowsu16, &iColsu16, &pusData);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ //retrieve dimensions and data
+ sciErr = getMatrixOfInteger32(pvApiCtx, piAddr32, &iRows32, &iCols32, &piData);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ //retrieve dimensions and data
+ sciErr = getMatrixOfUnsignedInteger32(pvApiCtx, piAddru32, &iRowsu32, &iColsu32, &puiData);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ //alloc and fill new variable
+ pcDataOut = (char*)create_output(2, 1, iRows8, iCols8, (void*)pcData);
+ pucDataOut = (unsigned char*)create_output(4, 1, iRowsu8, iColsu8, (void*)pucData);
+ psDataOut = (short*)create_output(8, 2, iRows16, iCols16, (void*)psData);
+ pusDataOut = (unsigned short*)create_output(16, 2, iRowsu16, iColsu16, (void*)pusData);
+ piDataOut = (int*)create_output(32, 4, iRows32, iCols32, (void*)piData);
+ puiDataOut = (unsigned int*)create_output(64, 4, iRowsu32, iColsu32, (void*)puiData);
+
+ //create new variable
+ sciErr = createMatrixOfInteger8(pvApiCtx, nbInputArgument(pvApiCtx) + 1, iRows8, iCols8, pcDataOut);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ //create new variable
+ sciErr = createMatrixOfUnsignedInteger8(pvApiCtx, nbInputArgument(pvApiCtx) + 2, iRowsu8, iColsu8, pucDataOut);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ //create new variable
+ sciErr = createMatrixOfInteger16(pvApiCtx, nbInputArgument(pvApiCtx) + 3, iRows16, iCols16, psDataOut);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ //create new variable
+ sciErr = createMatrixOfUnsignedInteger16(pvApiCtx, nbInputArgument(pvApiCtx) + 4, iRowsu16, iColsu16, pusDataOut);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ //create new variable
+ sciErr = createMatrixOfInteger32(pvApiCtx, nbInputArgument(pvApiCtx) + 5, iRows32, iCols32, piDataOut);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ //create new variable
+ sciErr = createMatrixOfUnsignedInteger32(pvApiCtx, nbInputArgument(pvApiCtx) + 6, iRowsu32, iColsu32, puiDataOut);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ //assign allocated variables to Lhs position
+ AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1;
+ AssignOutputVariable(pvApiCtx, 2) = nbInputArgument(pvApiCtx) + 2;
+ AssignOutputVariable(pvApiCtx, 3) = nbInputArgument(pvApiCtx) + 3;
+ AssignOutputVariable(pvApiCtx, 4) = nbInputArgument(pvApiCtx) + 4;
+ AssignOutputVariable(pvApiCtx, 5) = nbInputArgument(pvApiCtx) + 5;
+ AssignOutputVariable(pvApiCtx, 6) = nbInputArgument(pvApiCtx) + 6;
+ return 0;
+}
+
+void* create_output(int _iCoeff, int _iSize, int _iRows, int _iCols, void* _pvDataIn)
+{
+ int i = 0;
+ void* pvDataOut = (void*)malloc(_iSize * _iRows * _iCols);
+ for (i = 0 ; i < _iRows * _iCols ; i++)
+ {
+ int iVal = 0;
+ memcpy(&iVal, (char*)_pvDataIn + i * _iSize, _iSize);
+ iVal *= _iCoeff;
+ memcpy((char*)pvDataOut + i * _iSize, &iVal, _iSize);
+ }
+ return pvDataOut;
+}
diff --git a/modules/api_scilab/tests/unit_tests/integer_reading_api.dia.ref b/modules/api_scilab/tests/unit_tests/integer_reading_api.dia.ref
new file mode 100755
index 000000000..256a72888
--- /dev/null
+++ b/modules/api_scilab/tests/unit_tests/integer_reading_api.dia.ref
@@ -0,0 +1,39 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2009-2010 - DIGITEO
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- CLI SHELL MODE -->
+ilib_verbose(0);
+mkdir(pathconvert(TMPDIR+"/integer_reading_api"));
+cd(pathconvert(TMPDIR+"/integer_reading_api"));
+copyfile(SCI+"/modules/api_scilab/tests/unit_tests/integer_reading_api.c",pathconvert(TMPDIR+"/integer_reading_api/integer_reading_api.c",%F));
+cflags = "-I"+SCI+"/modules/localization/includes";
+ilib_build("integer_reading",["read_integer","read_integer"],"integer_reading_api.c",[],"","",cflags);
+exec("loader.sce");
+a8 = int8([ 1 -2 3 -4 5; ..
+ -6 7 -8 9 -10; ..
+ 11 -12 13 -14 15]);
+au8 = uint8([ 1 2 3 4 5; ..
+ 6 7 8 9 10; ..
+ 11 12 13 14 15]);
+a16 = int16([ 1 -2 3 -4 5; ..
+ -6 7 -8 9 -10; ..
+ 11 -12 13 -14 15]);
+au16 = uint16([ 1 2 3 4 5; ..
+ 6 7 8 9 10; ..
+ 11 12 13 14 15]);
+a32 = int32([ 1 -2 3 -4 5; ..
+ -6 7 -8 9 -10; ..
+ 11 -12 13 -14 15]);
+au32 = uint32([ 1 2 3 4 5; ..
+ 6 7 8 9 10; ..
+ 11 12 13 14 15]);
+[c8, cu8, c16, cu16, c32, cu32] = read_integer(a8, au8, a16, au16, a32, au32);
+if or(c8 <> a8 * 2) then bugmes();quit;end
+if or(cu8 <> au8 * 4) then bugmes();quit;end
+if or(c16 <> a16 * 8) then bugmes();quit;end
+if or(cu16 <> au16 * 16) then bugmes();quit;end
+if or(c32 <> a32 * 32) then bugmes();quit;end
+if or(cu32 <> au32 * 64) then bugmes();quit;end
diff --git a/modules/api_scilab/tests/unit_tests/integer_reading_api.tst b/modules/api_scilab/tests/unit_tests/integer_reading_api.tst
new file mode 100755
index 000000000..1eef39a6a
--- /dev/null
+++ b/modules/api_scilab/tests/unit_tests/integer_reading_api.tst
@@ -0,0 +1,41 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2009-2010 - DIGITEO
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- CLI SHELL MODE -->
+ilib_verbose(0);
+mkdir(pathconvert(TMPDIR+"/integer_reading_api"));
+cd(pathconvert(TMPDIR+"/integer_reading_api"));
+copyfile(SCI+"/modules/api_scilab/tests/unit_tests/integer_reading_api.c",pathconvert(TMPDIR+"/integer_reading_api/integer_reading_api.c",%F));
+cflags = "-I"+SCI+"/modules/localization/includes";
+ilib_build("integer_reading",["read_integer","read_integer"],"integer_reading_api.c",[],"","",cflags);
+exec("loader.sce");
+
+a8 = int8([ 1 -2 3 -4 5; ..
+ -6 7 -8 9 -10; ..
+ 11 -12 13 -14 15]);
+au8 = uint8([ 1 2 3 4 5; ..
+ 6 7 8 9 10; ..
+ 11 12 13 14 15]);
+a16 = int16([ 1 -2 3 -4 5; ..
+ -6 7 -8 9 -10; ..
+ 11 -12 13 -14 15]);
+au16 = uint16([ 1 2 3 4 5; ..
+ 6 7 8 9 10; ..
+ 11 12 13 14 15]);
+a32 = int32([ 1 -2 3 -4 5; ..
+ -6 7 -8 9 -10; ..
+ 11 -12 13 -14 15]);
+au32 = uint32([ 1 2 3 4 5; ..
+ 6 7 8 9 10; ..
+ 11 12 13 14 15]);
+[c8, cu8, c16, cu16, c32, cu32] = read_integer(a8, au8, a16, au16, a32, au32);
+if or(c8 <> a8 * 2) then pause;end
+if or(cu8 <> au8 * 4) then pause;end
+if or(c16 <> a16 * 8) then pause;end
+if or(cu16 <> au16 * 16) then pause;end
+if or(c32 <> a32 * 32) then pause;end
+if or(cu32 <> au32 * 64) then pause;end
diff --git a/modules/api_scilab/tests/unit_tests/integer_writing_api.c b/modules/api_scilab/tests/unit_tests/integer_writing_api.c
new file mode 100755
index 000000000..f24466d90
--- /dev/null
+++ b/modules/api_scilab/tests/unit_tests/integer_writing_api.c
@@ -0,0 +1,277 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2009-2010 - DIGITEO
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+ *
+ */
+
+#include "api_scilab.h"
+#include "Scierror.h"
+#include "localization.h"
+#include "sciprint.h"
+#include "MALLOC.h"
+
+void* create_output(int _iCoeff, int _iSize, int _iRows, int _iCols, void* _pvDataIn);
+int read_integer(char *fname, unsigned long fname_len)
+{
+ SciErr sciErr;
+ //output variable info
+ int iRows8 = 0;
+ int iCols8 = 0;
+ int iRows16 = 0;
+ int iCols16 = 0;
+ int iRows32 = 0;
+ int iCols32 = 0;
+ int iRowsu8 = 0;
+ int iColsu8 = 0;
+ int iRowsu16 = 0;
+ int iColsu16 = 0;
+ int iRowsu32 = 0;
+ int iColsu32 = 0;
+ int iPrec = 0;
+ int* piAddr8 = NULL;
+ int* piAddr16 = NULL;
+ int* piAddr32 = NULL;
+ int* piAddru8 = NULL;
+ int* piAddru16 = NULL;
+ int* piAddru32 = NULL;
+ char* pcData = NULL;
+ short* psData = NULL;
+ int* piData = NULL;
+ unsigned char* pucData = NULL;
+ unsigned short* pusData = NULL;
+ unsigned int* puiData = NULL;
+ char* pcDataOut = NULL;
+ short* psDataOut = NULL;
+ int* piDataOut = NULL;
+ unsigned char* pucDataOut = NULL;
+ unsigned short* pusDataOut = NULL;
+ unsigned int* puiDataOut = NULL;
+
+ //check input/output arguments count
+ CheckInputArgument(pvApiCtx, 6, 6);
+ CheckOutputArgument(pvApiCtx, 6, 6);
+
+ //get varialbe address
+ sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddr8);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ sciErr = getVarAddressFromPosition(pvApiCtx, 2, &piAddru8);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ sciErr = getVarAddressFromPosition(pvApiCtx, 3, &piAddr16);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ sciErr = getVarAddressFromPosition(pvApiCtx, 4, &piAddru16);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ sciErr = getVarAddressFromPosition(pvApiCtx, 5, &piAddr32);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ sciErr = getVarAddressFromPosition(pvApiCtx, 6, &piAddru32);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ //check variable precision
+ sciErr = getMatrixOfIntegerPrecision(pvApiCtx, piAddr8, &iPrec);
+ if (sciErr.iErr || iPrec != SCI_INT8)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ //check variable precision
+ sciErr = getMatrixOfIntegerPrecision(pvApiCtx, piAddru8, &iPrec);
+ if (sciErr.iErr || iPrec != SCI_UINT8)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ //check variable precision
+ sciErr = getMatrixOfIntegerPrecision(pvApiCtx, piAddr16, &iPrec);
+ if (sciErr.iErr || iPrec != SCI_INT16)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ //check variable precision
+ sciErr = getMatrixOfIntegerPrecision(pvApiCtx, piAddru16, &iPrec);
+ if (sciErr.iErr || iPrec != SCI_UINT16)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ //check variable precision
+ sciErr = getMatrixOfIntegerPrecision(pvApiCtx, piAddr32, &iPrec);
+ if (sciErr.iErr || iPrec != SCI_INT32)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ //check variable precision
+ sciErr = getMatrixOfIntegerPrecision(pvApiCtx, piAddru32, &iPrec);
+ if (sciErr.iErr || iPrec != SCI_UINT32)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ //retrieve dimensions and data
+ sciErr = getMatrixOfInteger8(pvApiCtx, piAddr8, &iRows8, &iCols8, &pcData);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ //retrieve dimensions and data
+ sciErr = getMatrixOfUnsignedInteger8(pvApiCtx, piAddru8, &iRowsu8, &iColsu8, &pucData);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ //retrieve dimensions and data
+ sciErr = getMatrixOfInteger16(pvApiCtx, piAddr16, &iRows16, &iCols16, &psData);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ //retrieve dimensions and data
+ sciErr = getMatrixOfUnsignedInteger16(pvApiCtx, piAddru16, &iRowsu16, &iColsu16, &pusData);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ //retrieve dimensions and data
+ sciErr = getMatrixOfInteger32(pvApiCtx, piAddr32, &iRows32, &iCols32, &piData);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ //retrieve dimensions and data
+ sciErr = getMatrixOfUnsignedInteger32(pvApiCtx, piAddru32, &iRowsu32, &iColsu32, &puiData);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ //alloc and fill new variable
+ pcDataOut = (char*)create_output(2, 1, iRows8, iCols8, (void*)pcData);
+ pucDataOut = (unsigned char*)create_output(4, 1, iRowsu8, iColsu8, (void*)pucData);
+ psDataOut = (short*)create_output(8, 2, iRows16, iCols16, (void*)psData);
+ pusDataOut = (unsigned short*)create_output(16, 2, iRowsu16, iColsu16, (void*)pusData);
+ piDataOut = (int*)create_output(32, 4, iRows32, iCols32, (void*)piData);
+ puiDataOut = (unsigned int*)create_output(64, 4, iRowsu32, iColsu32, (void*)puiData);
+
+ //create new variable
+ sciErr = createMatrixOfInteger8(pvApiCtx, nbInputArgument(pvApiCtx) + 1, iRows8, iCols8, pcDataOut);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ //create new variable
+ sciErr = createMatrixOfUnsignedInteger8(pvApiCtx, nbInputArgument(pvApiCtx) + 2, iRowsu8, iColsu8, pucDataOut);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ //create new variable
+ sciErr = createMatrixOfInteger16(pvApiCtx, nbInputArgument(pvApiCtx) + 3, iRows16, iCols16, psDataOut);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ //create new variable
+ sciErr = createMatrixOfUnsignedInteger16(pvApiCtx, nbInputArgument(pvApiCtx) + 4, iRowsu16, iColsu16, pusDataOut);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ //create new variable
+ sciErr = createMatrixOfInteger32(pvApiCtx, nbInputArgument(pvApiCtx) + 5, iRows32, iCols32, piDataOut);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ //create new variable
+ sciErr = createMatrixOfUnsignedInteger32(pvApiCtx, nbInputArgument(pvApiCtx) + 6, iRowsu32, iColsu32, puiDataOut);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ //assign allocated variables to Lhs position
+ AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1;
+ AssignOutputVariable(pvApiCtx, 2) = nbInputArgument(pvApiCtx) + 2;
+ AssignOutputVariable(pvApiCtx, 3) = nbInputArgument(pvApiCtx) + 3;
+ AssignOutputVariable(pvApiCtx, 4) = nbInputArgument(pvApiCtx) + 4;
+ AssignOutputVariable(pvApiCtx, 5) = nbInputArgument(pvApiCtx) + 5;
+ AssignOutputVariable(pvApiCtx, 6) = nbInputArgument(pvApiCtx) + 6;
+ return 0;
+}
+
+void* create_output(int _iCoeff, int _iSize, int _iRows, int _iCols, void* _pvDataIn)
+{
+ int i = 0;
+ void* pvDataOut = (void*)malloc(_iSize * _iRows * _iCols);
+ for (i = 0 ; i < _iRows * _iCols ; i++)
+ {
+ int iVal = 0;
+ memcpy(&iVal, (char*)_pvDataIn + i * _iSize, _iSize);
+ iVal *= _iCoeff;
+ memcpy((char*)pvDataOut + i * _iSize, &iVal, _iSize);
+ }
+ return pvDataOut;
+}
diff --git a/modules/api_scilab/tests/unit_tests/integer_writing_api.dia.ref b/modules/api_scilab/tests/unit_tests/integer_writing_api.dia.ref
new file mode 100755
index 000000000..bc553ddb7
--- /dev/null
+++ b/modules/api_scilab/tests/unit_tests/integer_writing_api.dia.ref
@@ -0,0 +1,39 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2009-2010 - DIGITEO
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- CLI SHELL MODE -->
+ilib_verbose(0);
+mkdir(pathconvert(TMPDIR+"/integer_writing_api"));
+cd(pathconvert(TMPDIR+"/integer_writing_api"));
+copyfile(SCI+"/modules/api_scilab/tests/unit_tests/integer_writing_api.c",pathconvert(TMPDIR+"/integer_writing_api/integer_writing_api.c",%F));
+cflags = "-I"+SCI+"/modules/localization/includes";
+ilib_build("integer_writing",["read_integer","read_integer"],"integer_writing_api.c",[],"","",cflags);
+exec("loader.sce");
+a8 = int8([ 1 -2 3 -4 5; ..
+ -6 7 -8 9 -10; ..
+ 11 -12 13 -14 15]);
+au8 = uint8([ 1 2 3 4 5; ..
+ 6 7 8 9 10; ..
+ 11 12 13 14 15]);
+a16 = int16([ 1 -2 3 -4 5; ..
+ -6 7 -8 9 -10; ..
+ 11 -12 13 -14 15]);
+au16 = uint16([ 1 2 3 4 5; ..
+ 6 7 8 9 10; ..
+ 11 12 13 14 15]);
+a32 = int32([ 1 -2 3 -4 5; ..
+ -6 7 -8 9 -10; ..
+ 11 -12 13 -14 15]);
+au32 = uint32([ 1 2 3 4 5; ..
+ 6 7 8 9 10; ..
+ 11 12 13 14 15]);
+[c8, cu8, c16, cu16, c32, cu32] = read_integer(a8, au8, a16, au16, a32, au32);
+if or(c8 <> a8 * 2) then bugmes();quit;end
+if or(cu8 <> au8 * 4) then bugmes();quit;end
+if or(c16 <> a16 * 8) then bugmes();quit;end
+if or(cu16 <> au16 * 16) then bugmes();quit;end
+if or(c32 <> a32 * 32) then bugmes();quit;end
+if or(cu32 <> au32 * 64) then bugmes();quit;end
diff --git a/modules/api_scilab/tests/unit_tests/integer_writing_api.tst b/modules/api_scilab/tests/unit_tests/integer_writing_api.tst
new file mode 100755
index 000000000..ee2388e97
--- /dev/null
+++ b/modules/api_scilab/tests/unit_tests/integer_writing_api.tst
@@ -0,0 +1,41 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2009-2010 - DIGITEO
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- CLI SHELL MODE -->
+ilib_verbose(0);
+mkdir(pathconvert(TMPDIR+"/integer_writing_api"));
+cd(pathconvert(TMPDIR+"/integer_writing_api"));
+copyfile(SCI+"/modules/api_scilab/tests/unit_tests/integer_writing_api.c",pathconvert(TMPDIR+"/integer_writing_api/integer_writing_api.c",%F));
+cflags = "-I"+SCI+"/modules/localization/includes";
+ilib_build("integer_writing",["read_integer","read_integer"],"integer_writing_api.c",[],"","",cflags);
+exec("loader.sce");
+
+a8 = int8([ 1 -2 3 -4 5; ..
+ -6 7 -8 9 -10; ..
+ 11 -12 13 -14 15]);
+au8 = uint8([ 1 2 3 4 5; ..
+ 6 7 8 9 10; ..
+ 11 12 13 14 15]);
+a16 = int16([ 1 -2 3 -4 5; ..
+ -6 7 -8 9 -10; ..
+ 11 -12 13 -14 15]);
+au16 = uint16([ 1 2 3 4 5; ..
+ 6 7 8 9 10; ..
+ 11 12 13 14 15]);
+a32 = int32([ 1 -2 3 -4 5; ..
+ -6 7 -8 9 -10; ..
+ 11 -12 13 -14 15]);
+au32 = uint32([ 1 2 3 4 5; ..
+ 6 7 8 9 10; ..
+ 11 12 13 14 15]);
+[c8, cu8, c16, cu16, c32, cu32] = read_integer(a8, au8, a16, au16, a32, au32);
+if or(c8 <> a8 * 2) then pause;end
+if or(cu8 <> au8 * 4) then pause;end
+if or(c16 <> a16 * 8) then pause;end
+if or(cu16 <> au16 * 16) then pause;end
+if or(c32 <> a32 * 32) then pause;end
+if or(cu32 <> au32 * 64) then pause;end
diff --git a/modules/api_scilab/tests/unit_tests/list_createlist_api.c b/modules/api_scilab/tests/unit_tests/list_createlist_api.c
new file mode 100755
index 000000000..cf3c72a23
--- /dev/null
+++ b/modules/api_scilab/tests/unit_tests/list_createlist_api.c
@@ -0,0 +1,134 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2009-2010 - DIGITEO
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+ *
+ */
+
+#include "api_scilab.h"
+#include "Scierror.h"
+#include "localization.h"
+#include "sciprint.h"
+#include "MALLOC.h"
+
+int list_createlist(char *fname, unsigned long fname_len)
+{
+ SciErr sciErr;
+ int *piAddr = NULL;
+ int* piChild = NULL;
+ double pdblData1[] = {1, 3, 5, 2, 4, 6};
+ double pdblData2[] = {6, 4, 2, 5, 3, 1};
+ char *pstData[] = {"may", "be", "the", "with", "puffin", "you"};
+ short psData[] = {1, 4, 2, 5, 3, 6};
+ double pdblPoly1[] = {1};
+ double pdblPoly2[] = { -2, -1};
+ double pdblPoly3[] = {1, 2, 3};
+ double pdblPoly4[] = { -4, -3, -2, -1};
+ double pdblPoly5[] = {1, 2, 3, 4, 5};
+ double pdblPoly6[] = { -6, -5, -4, -3, -2, -1};
+ double *pdblPoly[] = {pdblPoly1, pdblPoly3, pdblPoly5, pdblPoly2, pdblPoly4, pdblPoly6};
+ int piCoef[] = {1, 3, 5, 2, 4, 6};
+ int piNbItemRow[] = {1, 2, 1};
+ int piColPos[] = {8, 4, 7, 2};
+ double pdblSReal[] = {1, 2, 3, 4};
+ double pdblSImg[] = {4, 3, 2, 1};
+ int piBool[] = {1, 0, 1, 0, 1, 0, 1, 0, 1};
+ double* pdblDataPtr = NULL;
+
+ sciErr = createList(pvApiCtx, nbInputArgument(pvApiCtx) + 1, 8, &piAddr);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ sciErr = createComplexMatrixOfDoubleInList(pvApiCtx, nbInputArgument(pvApiCtx) + 1, piAddr, 1, 3, 2, pdblData1, pdblData2);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ sciErr = createMatrixOfStringInList(pvApiCtx, nbInputArgument(pvApiCtx) + 1, piAddr, 2, 2, 3, pstData);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ sciErr = createMatrixOfInteger16InList(pvApiCtx, nbInputArgument(pvApiCtx) + 1, piAddr, 3, 2, 3, psData);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ sciErr = createMatrixOfPolyInList(pvApiCtx, nbInputArgument(pvApiCtx) + 1, piAddr, 4, "x", 3, 2, piCoef, pdblPoly);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+ sciErr = createComplexSparseMatrixInList(pvApiCtx, nbInputArgument(pvApiCtx) + 1, piAddr, 5, 3, 10, 4, piNbItemRow, piColPos, pdblSReal, pdblSImg);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ sciErr = createMatrixOfBooleanInList(pvApiCtx, nbInputArgument(pvApiCtx) + 1, piAddr, 6, 3, 3, piBool);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+ sciErr = createBooleanSparseMatrixInList(pvApiCtx, nbInputArgument(pvApiCtx) + 1, piAddr, 7, 3, 10, 4, piNbItemRow, piColPos);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ //add list in list
+ sciErr = createListInList(pvApiCtx, nbInputArgument(pvApiCtx) + 1, piAddr, 8, 3, &piChild);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ sciErr = createMatrixOfDoubleInList(pvApiCtx, nbInputArgument(pvApiCtx) + 1, piChild, 1, 3, 2, pdblData1);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ sciErr = createSparseMatrixInList(pvApiCtx, nbInputArgument(pvApiCtx) + 1, piChild, 2, 3, 10, 4, piNbItemRow, piColPos, pdblSReal);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ pdblDataPtr = (double*)malloc(sizeof(double) * 4);
+ pdblDataPtr[0] = 1;
+ pdblDataPtr[1] = 2;
+ pdblDataPtr[2] = 3;
+ pdblDataPtr[3] = 4;
+
+ sciErr = createPointerInList(pvApiCtx, nbInputArgument(pvApiCtx) + 1, piChild, 3, pdblDataPtr);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1;
+ return 0;
+}
diff --git a/modules/api_scilab/tests/unit_tests/list_createlist_api.dia.ref b/modules/api_scilab/tests/unit_tests/list_createlist_api.dia.ref
new file mode 100755
index 000000000..f3b0936fd
--- /dev/null
+++ b/modules/api_scilab/tests/unit_tests/list_createlist_api.dia.ref
@@ -0,0 +1,23 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2009-2010 - DIGITEO
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- CLI SHELL MODE -->
+ilib_verbose(0);
+mkdir(pathconvert(TMPDIR+"/list_createlist_api"));
+cd(pathconvert(TMPDIR+"/list_createlist_api"));
+copyfile(SCI+"/modules/api_scilab/tests/unit_tests/list_createlist_api.c",pathconvert(TMPDIR+"/list_createlist_api/list_createlist_api.c",%F));
+cflags = "-I"+SCI+"/modules/localization/includes";
+ilib_build("list_createlist",["list_createlist","list_createlist"],"list_createlist_api.c",[],"","",cflags);
+exec("loader.sce");
+size_ref = 8;
+type_ref = ["constant","string","int16","polynomial", "sparse", "boolean", "boolean sparse", "list"];
+dim_ref = list([3,2],[2,3],[2,3],[3,2],[3,10],[3,3],[3,10],3);
+l = list_createlist();
+if size(l) <> size_ref then bugmes();quit;end
+for i = 1 : size_ref
+ if typeof(l(i)) <> type_ref(i) then bugmes();quit;end
+ if size(l(i)) <> dim_ref(i) then bugmes();quit;end
+end
diff --git a/modules/api_scilab/tests/unit_tests/list_createlist_api.tst b/modules/api_scilab/tests/unit_tests/list_createlist_api.tst
new file mode 100755
index 000000000..bce05ab68
--- /dev/null
+++ b/modules/api_scilab/tests/unit_tests/list_createlist_api.tst
@@ -0,0 +1,25 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2009-2010 - DIGITEO
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- CLI SHELL MODE -->
+ilib_verbose(0);
+mkdir(pathconvert(TMPDIR+"/list_createlist_api"));
+cd(pathconvert(TMPDIR+"/list_createlist_api"));
+copyfile(SCI+"/modules/api_scilab/tests/unit_tests/list_createlist_api.c",pathconvert(TMPDIR+"/list_createlist_api/list_createlist_api.c",%F));
+cflags = "-I"+SCI+"/modules/localization/includes";
+ilib_build("list_createlist",["list_createlist","list_createlist"],"list_createlist_api.c",[],"","",cflags);
+exec("loader.sce");
+
+size_ref = 8;
+type_ref = ["constant","string","int16","polynomial", "sparse", "boolean", "boolean sparse", "list"];
+dim_ref = list([3,2],[2,3],[2,3],[3,2],[3,10],[3,3],[3,10],3);
+l = list_createlist();
+if size(l) <> size_ref then pause;end
+for i = 1 : size_ref
+ if typeof(l(i)) <> type_ref(i) then pause;end
+ if size(l(i)) <> dim_ref(i) then pause;end
+end
diff --git a/modules/api_scilab/tests/unit_tests/pointer_reading_api.c b/modules/api_scilab/tests/unit_tests/pointer_reading_api.c
new file mode 100755
index 000000000..8bea9503c
--- /dev/null
+++ b/modules/api_scilab/tests/unit_tests/pointer_reading_api.c
@@ -0,0 +1,69 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2009-2010 - DIGITEO
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+ *
+ */
+#include <stdlib.h>
+#include "api_scilab.h"
+#include "Scierror.h"
+#include "localization.h"
+#include "sciprint.h"
+#include "MALLOC.h"
+
+int read_pointer(char *fname, unsigned long fname_len)
+{
+ SciErr sciErr;
+
+ CheckInputArgument(pvApiCtx, 0, 1);
+ CheckOutputArgument(pvApiCtx, 1, 1);
+
+ if (nbInputArgument(pvApiCtx) == 0)
+ {
+ //create mode
+ double* pdblData = (double*)malloc(sizeof(double) * 2 * 2);
+ pdblData[0] = 1;
+ pdblData[1] = 3;
+ pdblData[2] = 2;
+ pdblData[3] = 4;
+ sciErr = createPointer(pvApiCtx, nbInputArgument(pvApiCtx) + 1, (void*)pdblData);
+ }
+ else if (nbInputArgument(pvApiCtx) == 1)
+ {
+ //read mode
+ int iType = 0;
+ int* piAddr = NULL;
+ void* pvPtr = NULL;
+ double* pdblData = NULL;
+ sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddr);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+ sciErr = getPointer(pvApiCtx, piAddr, &pvPtr);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+ pdblData = (double*)pvPtr;
+ sciErr = createMatrixOfDouble(pvApiCtx, nbInputArgument(pvApiCtx) + 1, 2, 2, pdblData);
+ }
+ else
+ {
+ return 0;
+ }
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+ AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1;
+ return 0;
+}
diff --git a/modules/api_scilab/tests/unit_tests/pointer_reading_api.dia.ref b/modules/api_scilab/tests/unit_tests/pointer_reading_api.dia.ref
new file mode 100755
index 000000000..19789235c
--- /dev/null
+++ b/modules/api_scilab/tests/unit_tests/pointer_reading_api.dia.ref
@@ -0,0 +1,18 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2009-2010 - DIGITEO
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- CLI SHELL MODE -->
+ilib_verbose(0);
+mkdir(pathconvert(TMPDIR+"/pointer_reading_api"));
+cd(pathconvert(TMPDIR+"/pointer_reading_api"));
+copyfile(SCI+"/modules/api_scilab/tests/unit_tests/pointer_reading_api.c",pathconvert(TMPDIR+"/pointer_reading_api/pointer_reading_api.c",%F));
+cflags = "-I"+SCI+"/modules/localization/includes";
+ilib_build("pointer_reading",["read_pointer","read_pointer"],"pointer_reading_api.c",[],"","",cflags);
+exec("loader.sce");
+b_ref = [1,2;3,4];
+a = read_pointer();
+b = read_pointer(a);
+if or(b <> b_ref) then bugmes();quit;end
diff --git a/modules/api_scilab/tests/unit_tests/pointer_reading_api.tst b/modules/api_scilab/tests/unit_tests/pointer_reading_api.tst
new file mode 100755
index 000000000..731ddcf60
--- /dev/null
+++ b/modules/api_scilab/tests/unit_tests/pointer_reading_api.tst
@@ -0,0 +1,20 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2009-2010 - DIGITEO
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- CLI SHELL MODE -->
+ilib_verbose(0);
+mkdir(pathconvert(TMPDIR+"/pointer_reading_api"));
+cd(pathconvert(TMPDIR+"/pointer_reading_api"));
+copyfile(SCI+"/modules/api_scilab/tests/unit_tests/pointer_reading_api.c",pathconvert(TMPDIR+"/pointer_reading_api/pointer_reading_api.c",%F));
+cflags = "-I"+SCI+"/modules/localization/includes";
+ilib_build("pointer_reading",["read_pointer","read_pointer"],"pointer_reading_api.c",[],"","",cflags);
+exec("loader.sce");
+
+b_ref = [1,2;3,4];
+a = read_pointer();
+b = read_pointer(a);
+if or(b <> b_ref) then pause;end
diff --git a/modules/api_scilab/tests/unit_tests/polyExample.c b/modules/api_scilab/tests/unit_tests/polyExample.c
new file mode 100755
index 000000000..aab37c356
--- /dev/null
+++ b/modules/api_scilab/tests/unit_tests/polyExample.c
@@ -0,0 +1,148 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2009-2010 - DIGITEO
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+ *
+ */
+
+#include "api_scilab.h"
+#include "Scierror.h"
+#include "localization.h"
+#include "sciprint.h"
+#include "MALLOC.h"
+
+int polyExample(char *fname, unsigned long fname_len)
+{
+ SciErr sciErr;
+ int* piAddr = NULL;
+ int iType = 0;
+ int iRet = 0;
+
+ CheckInputArgument(pvApiCtx, 1, 1);
+ CheckOutputArgument(pvApiCtx, 0, 1);
+
+ sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddr);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ if (isPolyType(pvApiCtx, piAddr))
+ {
+ char pstVarName[64];
+ int iLen = 0;
+
+ sciErr = getPolyVariableName(pvApiCtx, piAddr, pstVarName, &iLen);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return sciErr.iErr;
+ }
+
+ if (isScalar(pvApiCtx, piAddr))
+ {
+ int iNbCoef = 0;
+ double* pdblReal = NULL;
+ double* pdblImg = NULL;
+
+ if (isVarComplex(pvApiCtx, piAddr))
+ {
+ iRet = getAllocatedSingleComplexPoly(pvApiCtx, piAddr, &iNbCoef, &pdblReal, &pdblImg);
+ if (iRet)
+ {
+ freeAllocatedSingleComplexPoly(pdblReal, pdblImg);
+ return iRet;
+ }
+
+ sciErr = createComplexMatrixOfPoly(pvApiCtx, nbInputArgument(pvApiCtx) + 1, pstVarName, 1, 1, &iNbCoef, &pdblReal, &pdblImg);
+ if (sciErr.iErr)
+ {
+ freeAllocatedSingleComplexPoly(pdblReal, pdblImg);
+ printError(&sciErr, 0);
+ return sciErr.iErr;
+ }
+
+ freeAllocatedSingleComplexPoly(pdblReal, pdblImg);
+ }
+ else
+ {
+ iRet = getAllocatedSinglePoly(pvApiCtx, piAddr, &iNbCoef, &pdblReal);
+ if (iRet)
+ {
+ freeAllocatedSinglePoly(pdblReal);
+ return iRet;
+ }
+
+ sciErr = createMatrixOfPoly(pvApiCtx, nbInputArgument(pvApiCtx) + 1, pstVarName, 1, 1, &iNbCoef, &pdblReal);
+ if (sciErr.iErr)
+ {
+ freeAllocatedSinglePoly(pdblReal);
+ printError(&sciErr, 0);
+ return sciErr.iErr;
+ }
+
+ freeAllocatedSinglePoly(pdblReal);
+ }
+ }
+ else
+ {
+ int iRows = 0;
+ int iCols = 0;
+ int* piNbCoef = NULL;
+ double** pdblReal = NULL;
+ double** pdblImg = NULL;
+
+ if (isVarComplex(pvApiCtx, piAddr))
+ {
+ iRet = getAllocatedMatrixOfComplexPoly(pvApiCtx, piAddr, &iRows, &iCols, &piNbCoef, &pdblReal, &pdblImg);
+ if (iRet)
+ {
+ freeAllocatedMatrixOfComplexPoly(iRows, iCols, piNbCoef, pdblReal, pdblImg);
+ return iRet;
+ }
+
+ sciErr = createComplexMatrixOfPoly(pvApiCtx, nbInputArgument(pvApiCtx) + 1, pstVarName, iRows, iCols, piNbCoef, pdblReal, pdblImg);
+ if (sciErr.iErr)
+ {
+ freeAllocatedMatrixOfComplexPoly(iRows, iCols, piNbCoef, pdblReal, pdblImg);
+ printError(&sciErr, 0);
+ return sciErr.iErr;
+ }
+
+ freeAllocatedMatrixOfComplexPoly(iRows, iCols, piNbCoef, pdblReal, pdblImg);
+ }
+ else
+ {
+ iRet = getAllocatedMatrixOfPoly(pvApiCtx, piAddr, &iRows, &iCols, &piNbCoef, &pdblReal);
+ if (iRet)
+ {
+ freeAllocatedMatrixOfPoly(iRows, iCols, piNbCoef, pdblReal);
+ return iRet;
+ }
+
+ sciErr = createMatrixOfPoly(pvApiCtx, nbInputArgument(pvApiCtx) + 1, pstVarName, iRows, iCols, piNbCoef, pdblReal);
+ if (sciErr.iErr)
+ {
+ freeAllocatedMatrixOfPoly(iRows, iCols, piNbCoef, pdblReal);
+ printError(&sciErr, 0);
+ return sciErr.iErr;
+ }
+
+ freeAllocatedMatrixOfPoly(iRows, iCols, piNbCoef, pdblReal);
+ }
+ }
+
+ AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1;
+ }
+ else
+ {
+ AssignOutputVariable(pvApiCtx, 1) = 0;
+ }
+ return 0;
+}
diff --git a/modules/api_scilab/tests/unit_tests/polyExample.dia.ref b/modules/api_scilab/tests/unit_tests/polyExample.dia.ref
new file mode 100755
index 000000000..be6076309
--- /dev/null
+++ b/modules/api_scilab/tests/unit_tests/polyExample.dia.ref
@@ -0,0 +1,22 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2009-2010 - DIGITEO
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- CLI SHELL MODE -->
+ilib_verbose(0);
+mkdir(pathconvert(TMPDIR+"/polyExample"));
+cd(pathconvert(TMPDIR+"/polyExample"));
+copyfile(SCI+"/modules/api_scilab/tests/unit_tests/polyExample.c",pathconvert(TMPDIR+"/polyExample/polyExample.c",%F));
+cflags = "-I"+SCI+"/modules/localization/includes";
+ilib_build("gw_polyExample",["polyExample","polyExample"],"polyExample.c",[],"","",cflags);
+exec("loader.sce");
+a = %s;
+b = (2 + 3*%i) * %s;
+c = [a, 2*a, 3*a;4*a, 5*a, 6*a];
+d = [c + c * %i];
+assert_checkequal(polyExample(a), a);
+assert_checkequal(polyExample(b), b);
+assert_checkequal(polyExample(c), c);
+assert_checkequal(polyExample(d), d);
diff --git a/modules/api_scilab/tests/unit_tests/polyExample.tst b/modules/api_scilab/tests/unit_tests/polyExample.tst
new file mode 100755
index 000000000..732e8a3f2
--- /dev/null
+++ b/modules/api_scilab/tests/unit_tests/polyExample.tst
@@ -0,0 +1,24 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2009-2010 - DIGITEO
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- CLI SHELL MODE -->
+ilib_verbose(0);
+mkdir(pathconvert(TMPDIR+"/polyExample"));
+cd(pathconvert(TMPDIR+"/polyExample"));
+copyfile(SCI+"/modules/api_scilab/tests/unit_tests/polyExample.c",pathconvert(TMPDIR+"/polyExample/polyExample.c",%F));
+cflags = "-I"+SCI+"/modules/localization/includes";
+ilib_build("gw_polyExample",["polyExample","polyExample"],"polyExample.c",[],"","",cflags);
+exec("loader.sce");
+
+a = %s;
+b = (2 + 3*%i) * %s;
+c = [a, 2*a, 3*a;4*a, 5*a, 6*a];
+d = [c + c * %i];
+assert_checkequal(polyExample(a), a);
+assert_checkequal(polyExample(b), b);
+assert_checkequal(polyExample(c), c);
+assert_checkequal(polyExample(d), d);
diff --git a/modules/api_scilab/tests/unit_tests/poly_reading_api.c b/modules/api_scilab/tests/unit_tests/poly_reading_api.c
new file mode 100755
index 000000000..1217ead61
--- /dev/null
+++ b/modules/api_scilab/tests/unit_tests/poly_reading_api.c
@@ -0,0 +1,161 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2009-2010 - DIGITEO
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+ *
+ */
+
+#include "api_scilab.h"
+#include "Scierror.h"
+#include "localization.h"
+#include "sciprint.h"
+#include "MALLOC.h"
+
+int read_poly(char *fname, unsigned long fname_len)
+{
+ SciErr sciErr;
+ int i, j;
+ //variable info
+ int iRows = 0;
+ int iCols = 0;
+ int iVarLen = 0;
+ int* piAddr = NULL;
+ int* piNbCoef = NULL;
+ double** pdblReal = NULL;
+ double** pdblImg = NULL;
+ char* pstVarname = NULL;
+
+ //check input and output arguments
+ CheckInputArgument(pvApiCtx, 1, 1);
+ CheckOutputArgument(pvApiCtx, 1, 1);
+
+ sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddr);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ if (isVarComplex(pvApiCtx, piAddr) == FALSE)
+ {
+ //Error
+ return 0;
+ }
+
+ //get variable name length
+ sciErr = getPolyVariableName(pvApiCtx, piAddr, NULL, &iVarLen);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ //alloc buff to receive variable name
+ pstVarname = (char*)malloc(sizeof(char) * (iVarLen + 1));//1 for null termination
+
+ //get variable name
+ sciErr = getPolyVariableName(pvApiCtx, piAddr, pstVarname, &iVarLen);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ //First call: retrieve dimmension
+ sciErr = getComplexMatrixOfPoly(pvApiCtx, piAddr, &iRows, &iCols, NULL, NULL, NULL);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ //alloc array of coefficient
+ piNbCoef = (int*)malloc(sizeof(int) * iRows * iCols);
+
+ //Second call: retrieve coefficient
+ sciErr = getComplexMatrixOfPoly(pvApiCtx, piAddr, &iRows, &iCols, piNbCoef, NULL, NULL);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ //alloc arrays of data
+ pdblReal = (double**)malloc(sizeof(double*) * iRows * iCols);
+ pdblImg = (double**)malloc(sizeof(double*) * iRows * iCols);
+
+ for (i = 0 ; i < iRows * iCols ; i++)
+ {
+ pdblReal[i] = (double*)malloc(sizeof(double) * piNbCoef[i]);
+ pdblImg[i] = (double*)malloc(sizeof(double) * piNbCoef[i]);
+ }
+
+ //Third call: retrieve data
+ sciErr = getComplexMatrixOfPoly(pvApiCtx, piAddr, &iRows, &iCols, piNbCoef, pdblReal, pdblImg);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ //Do something with Data
+ //Invert polynomials in the matrix and invert coefficients
+ for (i = 0 ; i < (iRows * iCols) / 2 ; i++)
+ {
+ int iPos1 = iRows * iCols - 1 - i;
+ double* pdblSave = NULL;
+ int iNbCoefSave = 0;
+ //switch array of coefficient
+ pdblSave = pdblReal[i];
+ pdblReal[i] = pdblReal[iPos1];
+ pdblReal[iPos1] = pdblSave;
+ pdblSave = pdblImg[i];
+ pdblImg[i] = pdblImg[iPos1];
+ pdblImg[iPos1] = pdblSave;
+ //switch number of coefficient
+ iNbCoefSave = piNbCoef[i];
+ piNbCoef[i] = piNbCoef[iPos1];
+ piNbCoef[iPos1] = iNbCoefSave;
+ }
+
+ //switch coefficient
+ for (i = 0 ; i < iRows * iCols ; i++)
+ {
+ for (j = 0 ; j < piNbCoef[i] / 2 ; j++)
+ {
+ int iPos2 = piNbCoef[i] - 1 - j;
+ double dblVal = pdblReal[i][j];
+ pdblReal[i][j] = pdblReal[i][iPos2];
+ pdblReal[i][iPos2] = dblVal;
+ dblVal = pdblImg[i][j];
+ pdblImg[i][j] = pdblImg[i][iPos2];
+ pdblImg[i][iPos2] = dblVal;
+ }
+ }
+
+ sciErr = createComplexMatrixOfPoly(pvApiCtx, nbInputArgument(pvApiCtx) + 1, pstVarname, iRows, iCols, piNbCoef, pdblReal, pdblImg);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ //free OS memory
+ free(pstVarname);
+ free(piNbCoef);
+ for (i = 0 ; i < iRows * iCols ; i++)
+ {
+ free(pdblReal[i]);
+ free(pdblImg[i]);
+ }
+ free(pdblReal);
+ free(pdblImg);
+ //assign allocated variables to Lhs position
+ AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1;
+ return 0;
+}
diff --git a/modules/api_scilab/tests/unit_tests/poly_reading_api.dia.ref b/modules/api_scilab/tests/unit_tests/poly_reading_api.dia.ref
new file mode 100755
index 000000000..3fbd8e478
--- /dev/null
+++ b/modules/api_scilab/tests/unit_tests/poly_reading_api.dia.ref
@@ -0,0 +1,38 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2009-2010 - DIGITEO
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- CLI SHELL MODE -->
+ilib_verbose(0);
+mkdir(pathconvert(TMPDIR+"/poly_reading_api"));
+cd(pathconvert(TMPDIR+"/poly_reading_api"));
+copyfile(SCI+"/modules/api_scilab/tests/unit_tests/poly_reading_api.c",pathconvert(TMPDIR+"/poly_reading_api/poly_reading_api.c",%F));
+cflags = "-I"+SCI+"/modules/localization/includes";
+ilib_build("poly_reading",["read_poly","read_poly"],"poly_reading_api.c",[],"","",cflags);
+exec("loader.sce");
+coeff1 = [ ..
+29*%i,22*%i,16*%i,11*%i,7*%i,30,23,17,12,8,-31*%i,-24*%i,-18*%i,-13*%i,-9*%i,32,25,19,14,10,-33*%i,-26*%i,-20*%i,-15*%i,0,34,27,21,0,0,0,-28*%i,0,0,0,36-35*%i,0,0,0,0; ..
+4*%i,2*%i,%i,22,16,5,-3,0,-23*%i,-17*%i,-6*%i,0,0,24,18,0,0,0,-25*%i,-19*%i,0,0,0,26,20,0,0,0,-27*%i,-21*%i,0,0,0,28,0,0,0,0,0,0; ..
+11,7,4,2,1,-12*%i,-8*%i,-5*%i,3*%i,0,13,9,6,0,0,-14*%i,-10*%i,0,0,0,15,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
+x = poly(0, "x");
+p1 = 1;
+p2 = 2 * x + 3 * %i;
+p3 = 4 * x**2 - 5 * %i * x + 6;
+p4 = 7 * x**3 - 8 * %i * x**2 + 9 * x - 10 * %i;
+p5 = 11 * x**4 - 12 * %i * x**3 + 13 * x**2 - 14 * %i * x + 15;
+p6 = 16 * x**5 - 17 * %i * x**4 + 18 * x**3 - 19 * %i * x**2 + 20 * x - 21 * %i;
+p7 = 22 * x**6 - 23 * %i * x**5 + 24 * x**4 - 25 * %i * x**3 + 26 * x**2 - 27 * %i * x + 28;
+p8 = %i;
+p9 = 2 * %i * x - 3;
+p10 = 4 * %i * x**2 + 5 * x - 6 * %i;
+p11 = 7 * %i * x**3 + 8 * x**2 - 9 * %i * x + 10;
+p12 = 11 * %i * x**4 + 12 * x**3 - 13 * %i * x**2 + 14 * x - 15 * %i;
+p13 = 16 * %i * x**5 + 17 * x**4 - 18 * %i * x**3 + 19 * x**2 - 20 * %i * x + 21;
+p14 = 22 * %i * x**6 + 23 * x**5 - 24 * %i * x**4 + 25 * x**3 - 26 * %i * x**2 + 27 * x - 28 * %i;
+p15 = 29 * %i * x**7 + 30 * x**6 - 31 * %i * x**5 + 32 * x**4 - 33 * %i * x**3 + 34 * x**2 - 35 * %i + 36;
+p = [p1, p2, p3, p4, p5 ; p6, p7, p8, p9 ,p10 ; p11, p12, p13, p14, p15];
+p1 = read_poly(p);
+coeff2 = coeff(p1);
+if or(coeff2 <> coeff1) then bugmes();quit;end
diff --git a/modules/api_scilab/tests/unit_tests/poly_reading_api.tst b/modules/api_scilab/tests/unit_tests/poly_reading_api.tst
new file mode 100755
index 000000000..2e6a0230b
--- /dev/null
+++ b/modules/api_scilab/tests/unit_tests/poly_reading_api.tst
@@ -0,0 +1,40 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2009-2010 - DIGITEO
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- CLI SHELL MODE -->
+ilib_verbose(0);
+mkdir(pathconvert(TMPDIR+"/poly_reading_api"));
+cd(pathconvert(TMPDIR+"/poly_reading_api"));
+copyfile(SCI+"/modules/api_scilab/tests/unit_tests/poly_reading_api.c",pathconvert(TMPDIR+"/poly_reading_api/poly_reading_api.c",%F));
+cflags = "-I"+SCI+"/modules/localization/includes";
+ilib_build("poly_reading",["read_poly","read_poly"],"poly_reading_api.c",[],"","",cflags);
+exec("loader.sce");
+
+coeff1 = [ ..
+29*%i,22*%i,16*%i,11*%i,7*%i,30,23,17,12,8,-31*%i,-24*%i,-18*%i,-13*%i,-9*%i,32,25,19,14,10,-33*%i,-26*%i,-20*%i,-15*%i,0,34,27,21,0,0,0,-28*%i,0,0,0,36-35*%i,0,0,0,0; ..
+4*%i,2*%i,%i,22,16,5,-3,0,-23*%i,-17*%i,-6*%i,0,0,24,18,0,0,0,-25*%i,-19*%i,0,0,0,26,20,0,0,0,-27*%i,-21*%i,0,0,0,28,0,0,0,0,0,0; ..
+11,7,4,2,1,-12*%i,-8*%i,-5*%i,3*%i,0,13,9,6,0,0,-14*%i,-10*%i,0,0,0,15,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
+x = poly(0, "x");
+p1 = 1;
+p2 = 2 * x + 3 * %i;
+p3 = 4 * x**2 - 5 * %i * x + 6;
+p4 = 7 * x**3 - 8 * %i * x**2 + 9 * x - 10 * %i;
+p5 = 11 * x**4 - 12 * %i * x**3 + 13 * x**2 - 14 * %i * x + 15;
+p6 = 16 * x**5 - 17 * %i * x**4 + 18 * x**3 - 19 * %i * x**2 + 20 * x - 21 * %i;
+p7 = 22 * x**6 - 23 * %i * x**5 + 24 * x**4 - 25 * %i * x**3 + 26 * x**2 - 27 * %i * x + 28;
+p8 = %i;
+p9 = 2 * %i * x - 3;
+p10 = 4 * %i * x**2 + 5 * x - 6 * %i;
+p11 = 7 * %i * x**3 + 8 * x**2 - 9 * %i * x + 10;
+p12 = 11 * %i * x**4 + 12 * x**3 - 13 * %i * x**2 + 14 * x - 15 * %i;
+p13 = 16 * %i * x**5 + 17 * x**4 - 18 * %i * x**3 + 19 * x**2 - 20 * %i * x + 21;
+p14 = 22 * %i * x**6 + 23 * x**5 - 24 * %i * x**4 + 25 * x**3 - 26 * %i * x**2 + 27 * x - 28 * %i;
+p15 = 29 * %i * x**7 + 30 * x**6 - 31 * %i * x**5 + 32 * x**4 - 33 * %i * x**3 + 34 * x**2 - 35 * %i + 36;
+p = [p1, p2, p3, p4, p5 ; p6, p7, p8, p9 ,p10 ; p11, p12, p13, p14, p15];
+p1 = read_poly(p);
+coeff2 = coeff(p1);
+if or(coeff2 <> coeff1) then pause;end
diff --git a/modules/api_scilab/tests/unit_tests/poly_writing_api.c b/modules/api_scilab/tests/unit_tests/poly_writing_api.c
new file mode 100755
index 000000000..4c919f6c7
--- /dev/null
+++ b/modules/api_scilab/tests/unit_tests/poly_writing_api.c
@@ -0,0 +1,56 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2009-2010 - DIGITEO
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+ *
+ */
+
+#include "api_scilab.h"
+#include "Scierror.h"
+#include "localization.h"
+#include "sciprint.h"
+#include "MALLOC.h"
+
+int write_poly(char *fname, unsigned long fname_len)
+{
+ SciErr sciErr;
+ //output variable info : polinomial matrix 2 x 4
+ //[ x + 2 x^2 - 4x + 5 4x^3 - 14x^2 + 18 ;
+ // 2x^3 - 12x^2 + 64 1 8x^5 + 32x^3]
+ int iRows = 2;
+ int iCols = 3;
+ //varname "x"
+ char pstVarName[2] = {"x"};
+ //coeficient array
+ int piNbCoef[6] = {2, 4, 3, 1, 4, 6};
+ //data array
+ double *pdblReal[6] = {0};
+ double pdblPoly0[2] = {2, 1};
+ double pdblPoly1[4] = {64, 0, -12, 2};
+ double pdblPoly2[3] = {5, -4, 1};
+ double pdblPoly3[1] = {1};
+ double pdblPoly4[4] = {18, 0, -14, 4};
+ double pdblPoly5[6] = {0, 0, 0, 32, 0, 8};
+ pdblReal[0] = pdblPoly0;
+ pdblReal[1] = pdblPoly1;
+ pdblReal[2] = pdblPoly2;
+ pdblReal[3] = pdblPoly3;
+ pdblReal[4] = pdblPoly4;
+ pdblReal[5] = pdblPoly5;
+
+ sciErr = createMatrixOfPoly(pvApiCtx, nbInputArgument(pvApiCtx) + 1, pstVarName, iRows, iCols, piNbCoef, pdblReal);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ //assign allocated variables to Lhs position
+ AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1;
+ return 0;
+}
diff --git a/modules/api_scilab/tests/unit_tests/poly_writing_api.dia.ref b/modules/api_scilab/tests/unit_tests/poly_writing_api.dia.ref
new file mode 100755
index 000000000..b9fc726e1
--- /dev/null
+++ b/modules/api_scilab/tests/unit_tests/poly_writing_api.dia.ref
@@ -0,0 +1,19 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2009-2010 - DIGITEO
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- CLI SHELL MODE -->
+ilib_verbose(0);
+mkdir(pathconvert(TMPDIR+"/poly_writing_api"));
+cd(pathconvert(TMPDIR+"/poly_writing_api"));
+copyfile(SCI+"/modules/api_scilab/tests/unit_tests/poly_writing_api.c",pathconvert(TMPDIR+"/poly_writing_api/poly_writing_api.c",%F));
+cflags = "-I"+SCI+"/modules/localization/includes";
+ilib_build("poly_writing",["write_poly","write_poly"],"poly_writing_api.c",[],"","",cflags);
+exec("loader.sce");
+p_ref = [2 5 18 1 -4 0 0 1 -14 0 0 4 0 0 0 0 0 0;64 1 0 0 0 0 -12 0 0 2 0 32 0 0 0 0 0 8];
+l = list();
+a = write_poly();
+p = coeff(a);
+if or(p <> p_ref) then bugmes();quit;end
diff --git a/modules/api_scilab/tests/unit_tests/poly_writing_api.tst b/modules/api_scilab/tests/unit_tests/poly_writing_api.tst
new file mode 100755
index 000000000..da6dd90a0
--- /dev/null
+++ b/modules/api_scilab/tests/unit_tests/poly_writing_api.tst
@@ -0,0 +1,21 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2009-2010 - DIGITEO
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- CLI SHELL MODE -->
+ilib_verbose(0);
+mkdir(pathconvert(TMPDIR+"/poly_writing_api"));
+cd(pathconvert(TMPDIR+"/poly_writing_api"));
+copyfile(SCI+"/modules/api_scilab/tests/unit_tests/poly_writing_api.c",pathconvert(TMPDIR+"/poly_writing_api/poly_writing_api.c",%F));
+cflags = "-I"+SCI+"/modules/localization/includes";
+ilib_build("poly_writing",["write_poly","write_poly"],"poly_writing_api.c",[],"","",cflags);
+exec("loader.sce");
+
+p_ref = [2 5 18 1 -4 0 0 1 -14 0 0 4 0 0 0 0 0 0;64 1 0 0 0 0 -12 0 0 2 0 32 0 0 0 0 0 8];
+l = list();
+a = write_poly();
+p = coeff(a);
+if or(p <> p_ref) then pause;end
diff --git a/modules/api_scilab/tests/unit_tests/read_write_boolean_api.c b/modules/api_scilab/tests/unit_tests/read_write_boolean_api.c
new file mode 100755
index 000000000..e657efcf1
--- /dev/null
+++ b/modules/api_scilab/tests/unit_tests/read_write_boolean_api.c
@@ -0,0 +1,64 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2009-2010 - DIGITEO
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+ *
+ */
+
+#include "api_scilab.h"
+#include "Scierror.h"
+#include "localization.h"
+#include "sciprint.h"
+#include "MALLOC.h"
+
+int read_write_boolean(char *fname, unsigned long fname_len)
+{
+ SciErr sciErr;
+ int i;
+ //first variable info : real matrix of double
+ int iRows = 0;
+ int iCols = 0;
+ int *piAddr = NULL;
+ int* piBool = NULL;
+
+ //check input and output arguments
+ CheckInputArgument(pvApiCtx, 1, 1);
+ CheckOutputArgument(pvApiCtx, 1, 1);
+
+ //get variable address of the first input argument
+ sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddr);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ //get size and data from Scilab memory
+ sciErr = getMatrixOfBoolean(pvApiCtx, piAddr, &iRows, &iCols, &piBool);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ //Do something with data
+ for (i = 0 ; i < iRows * iCols ; i++)
+ {
+ piBool[i] = piBool[i] == 0 ? 1 : 0;
+ }
+
+ sciErr = createMatrixOfBoolean(pvApiCtx, nbInputArgument(pvApiCtx) + 1, iRows, iCols, piBool);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1;
+ return 0;
+}
diff --git a/modules/api_scilab/tests/unit_tests/read_write_boolean_api.dia.ref b/modules/api_scilab/tests/unit_tests/read_write_boolean_api.dia.ref
new file mode 100755
index 000000000..9eae33690
--- /dev/null
+++ b/modules/api_scilab/tests/unit_tests/read_write_boolean_api.dia.ref
@@ -0,0 +1,18 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2009-2010 - DIGITEO
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- CLI SHELL MODE -->
+ilib_verbose(0);
+mkdir(pathconvert(TMPDIR+"/read_write_boolean_api"));
+cd(pathconvert(TMPDIR+"/read_write_boolean_api"));
+copyfile(SCI+"/modules/api_scilab/tests/unit_tests/read_write_boolean_api.c",pathconvert(TMPDIR+"/read_write_boolean_api/read_write_boolean_api.c",%F));
+cflags = "-I"+SCI+"/modules/localization/includes";
+ilib_build("read_write_boolean",["read_write_boolean","read_write_boolean"],"read_write_boolean_api.c",[],"","",cflags);
+exec("loader.sce");
+a = [%t, %f, %t ; %f, %t, %f ; %t, %f, %t];
+a_ref = [%f, %t, %f ; %t, %f, %t ; %f, %t, %f];
+b = read_write_boolean(a);
+if or(b <> a_ref) then bugmes();quit;end
diff --git a/modules/api_scilab/tests/unit_tests/read_write_boolean_api.tst b/modules/api_scilab/tests/unit_tests/read_write_boolean_api.tst
new file mode 100755
index 000000000..ec4913dc2
--- /dev/null
+++ b/modules/api_scilab/tests/unit_tests/read_write_boolean_api.tst
@@ -0,0 +1,20 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2009-2010 - DIGITEO
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- CLI SHELL MODE -->
+ilib_verbose(0);
+mkdir(pathconvert(TMPDIR+"/read_write_boolean_api"));
+cd(pathconvert(TMPDIR+"/read_write_boolean_api"));
+copyfile(SCI+"/modules/api_scilab/tests/unit_tests/read_write_boolean_api.c",pathconvert(TMPDIR+"/read_write_boolean_api/read_write_boolean_api.c",%F));
+cflags = "-I"+SCI+"/modules/localization/includes";
+ilib_build("read_write_boolean",["read_write_boolean","read_write_boolean"],"read_write_boolean_api.c",[],"","",cflags);
+exec("loader.sce");
+
+a = [%t, %f, %t ; %f, %t, %f ; %t, %f, %t];
+a_ref = [%f, %t, %f ; %t, %f, %t ; %f, %t, %f];
+b = read_write_boolean(a);
+if or(b <> a_ref) then pause;end
diff --git a/modules/api_scilab/tests/unit_tests/read_write_bsparse_api.c b/modules/api_scilab/tests/unit_tests/read_write_bsparse_api.c
new file mode 100755
index 000000000..44abd1536
--- /dev/null
+++ b/modules/api_scilab/tests/unit_tests/read_write_bsparse_api.c
@@ -0,0 +1,97 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2009-2010 - DIGITEO
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+ *
+ */
+
+#include "api_scilab.h"
+#include "Scierror.h"
+#include "localization.h"
+#include "sciprint.h"
+#include "MALLOC.h"
+
+int read_write_bsparse(char *fname, unsigned long fname_len)
+{
+ SciErr sciErr;
+ int i = 0;
+ int j = 0;
+ int k = 0;
+ //first variable info : real matrix of double
+ int iRows = 0;
+ int iCols = 0;
+ int *piAddr = NULL;
+ int iNbItem = 0;
+ int* piNbItemRow = NULL;
+ int* piColPos = NULL;
+ int iCol = 0;
+ int iNewCol = 0;
+ int iNewItem = 0;
+ int* piNewRow = NULL;
+ int* piNewCol = NULL;
+
+ //check input and output arguments
+ CheckInputArgument(pvApiCtx, 1, 1);
+ CheckOutputArgument(pvApiCtx, 1, 1);
+
+ //get variable address of the first input argument
+ sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddr);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ //get size and data from Scilab memory
+ sciErr = getBooleanSparseMatrix(pvApiCtx, piAddr, &iRows, &iCols, &iNbItem, &piNbItemRow, &piColPos);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ //Do something with data
+ //convert %T -> %F and %F -> %T
+ iNewItem = (iRows * iCols) - iNbItem;
+ piNewRow = (int*)MALLOC(sizeof(int) * iRows);
+ piNewCol = (int*)MALLOC(sizeof(int) * iNewItem);
+
+ for (i = 0 ; i < iRows ; i++)
+ {
+ piNewRow[i] = iCols - piNbItemRow[i];
+ for (j = 0 ; j < iCols ; j++)
+ {
+ int iFind = 0;
+ for (k = 0 ; k < piNbItemRow[i] ; k++)
+ {
+ if (piColPos[iCol + k] == (j + 1))
+ {
+ iFind = 1;
+ break;
+ }
+ }
+
+ if (iFind == 0)
+ {
+ piNewCol[iNewCol++] = (j + 1);
+ }
+ }
+
+ iCol += piNbItemRow[i];
+ }
+
+ sciErr = createBooleanSparseMatrix(pvApiCtx, nbInputArgument(pvApiCtx) + 1, iRows, iCols, iNewItem, piNewRow, piNewCol);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1;
+ return 0;
+}
diff --git a/modules/api_scilab/tests/unit_tests/read_write_bsparse_api.dia.ref b/modules/api_scilab/tests/unit_tests/read_write_bsparse_api.dia.ref
new file mode 100755
index 000000000..a42c55f92
--- /dev/null
+++ b/modules/api_scilab/tests/unit_tests/read_write_bsparse_api.dia.ref
@@ -0,0 +1,18 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2009-2010 - DIGITEO
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- CLI SHELL MODE -->
+ilib_verbose(0);
+mkdir(pathconvert(TMPDIR+"/read_write_bsparse_api"));
+cd(pathconvert(TMPDIR+"/read_write_bsparse_api"));
+copyfile(SCI+"/modules/api_scilab/tests/unit_tests/read_write_bsparse_api.c",pathconvert(TMPDIR+"/read_write_bsparse_api/read_write_bsparse_api.c",%F));
+cflags = "-I"+SCI+"/modules/localization/includes";
+ilib_build("read_write_bsparse",["read_write_bsparse","read_write_bsparse"],"read_write_bsparse_api.c",[],"","",cflags);
+exec("loader.sce");
+a = sparse([%t, %f, %t ; %f, %t, %f ; %t, %f, %t]);
+a_ref = sparse([%f, %t, %f ; %t, %f, %t ; %f, %t, %f]);
+b = read_write_bsparse(a);
+if or(b <> a_ref) then bugmes();quit;end
diff --git a/modules/api_scilab/tests/unit_tests/read_write_bsparse_api.tst b/modules/api_scilab/tests/unit_tests/read_write_bsparse_api.tst
new file mode 100755
index 000000000..804c13a4d
--- /dev/null
+++ b/modules/api_scilab/tests/unit_tests/read_write_bsparse_api.tst
@@ -0,0 +1,20 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2009-2010 - DIGITEO
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- CLI SHELL MODE -->
+ilib_verbose(0);
+mkdir(pathconvert(TMPDIR+"/read_write_bsparse_api"));
+cd(pathconvert(TMPDIR+"/read_write_bsparse_api"));
+copyfile(SCI+"/modules/api_scilab/tests/unit_tests/read_write_bsparse_api.c",pathconvert(TMPDIR+"/read_write_bsparse_api/read_write_bsparse_api.c",%F));
+cflags = "-I"+SCI+"/modules/localization/includes";
+ilib_build("read_write_bsparse",["read_write_bsparse","read_write_bsparse"],"read_write_bsparse_api.c",[],"","",cflags);
+exec("loader.sce");
+
+a = sparse([%t, %f, %t ; %f, %t, %f ; %t, %f, %t]);
+a_ref = sparse([%f, %t, %f ; %t, %f, %t ; %f, %t, %f]);
+b = read_write_bsparse(a);
+if or(b <> a_ref) then pause;end
diff --git a/modules/api_scilab/tests/unit_tests/sparseExample.c b/modules/api_scilab/tests/unit_tests/sparseExample.c
new file mode 100755
index 000000000..e1858058d
--- /dev/null
+++ b/modules/api_scilab/tests/unit_tests/sparseExample.c
@@ -0,0 +1,91 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2009-2010 - DIGITEO
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+ *
+ */
+
+#include "api_scilab.h"
+#include "Scierror.h"
+#include "localization.h"
+#include "sciprint.h"
+#include "MALLOC.h"
+
+int sparseExample(char *fname, unsigned long fname_len)
+{
+ SciErr sciErr;
+ int* piAddr = NULL;
+ int iType = 0;
+ int iRet = 0;
+
+ CheckInputArgument(pvApiCtx, 1, 1);
+ CheckOutputArgument(pvApiCtx, 0, 1);
+
+ sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddr);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ if (isSparseType(pvApiCtx, piAddr))
+ {
+ int iRows = 0;
+ int iCols = 0;
+ int iNbItem = 0;
+ int* piNbItemRow = NULL;
+ int* piColPos = NULL;
+ double* pdblReal = NULL;
+ double* pdblImg = NULL;
+
+ if (isVarComplex(pvApiCtx, piAddr))
+ {
+ iRet = getAllocatedComplexSparseMatrix(pvApiCtx, piAddr, &iRows, &iCols, &iNbItem, &piNbItemRow, &piColPos, &pdblReal, &pdblImg);
+ if (iRet)
+ {
+ freeAllocatedComplexSparseMatrix(piNbItemRow, piColPos, pdblReal, pdblImg);
+ return iRet;
+ }
+
+ sciErr = createComplexSparseMatrix(pvApiCtx, nbInputArgument(pvApiCtx) + 1, iRows, iCols, iNbItem, piNbItemRow, piColPos, pdblReal, pdblImg);
+ if (sciErr.iErr)
+ {
+ freeAllocatedComplexSparseMatrix(piNbItemRow, piColPos, pdblReal, pdblImg);
+ printError(&sciErr, 0);
+ return sciErr.iErr;
+ }
+
+ freeAllocatedComplexSparseMatrix(piNbItemRow, piColPos, pdblReal, pdblImg);
+ }
+ else
+ {
+ iRet = getAllocatedSparseMatrix(pvApiCtx, piAddr, &iRows, &iCols, &iNbItem, &piNbItemRow, &piColPos, &pdblReal);
+ if (iRet)
+ {
+ freeAllocatedSparseMatrix(piNbItemRow, piColPos, pdblReal);
+ return iRet;
+ }
+
+ sciErr = createSparseMatrix(pvApiCtx, nbInputArgument(pvApiCtx) + 1, iRows, iCols, iNbItem, piNbItemRow, piColPos, pdblReal);
+ if (sciErr.iErr)
+ {
+ freeAllocatedSparseMatrix(piNbItemRow, piColPos, pdblReal);
+ printError(&sciErr, 0);
+ return sciErr.iErr;
+ }
+
+ freeAllocatedSparseMatrix(piNbItemRow, piColPos, pdblReal);
+ }
+ AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1;
+ }
+ else
+ {
+ AssignOutputVariable(pvApiCtx, 1) = 0;
+ }
+ return 0;
+}
diff --git a/modules/api_scilab/tests/unit_tests/sparseExample.dia.ref b/modules/api_scilab/tests/unit_tests/sparseExample.dia.ref
new file mode 100755
index 000000000..a62678f12
--- /dev/null
+++ b/modules/api_scilab/tests/unit_tests/sparseExample.dia.ref
@@ -0,0 +1,18 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2009-2010 - DIGITEO
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- CLI SHELL MODE -->
+ilib_verbose(0);
+mkdir(pathconvert(TMPDIR+"/sparseExample"));
+cd(pathconvert(TMPDIR+"/sparseExample"));
+copyfile(SCI+"/modules/api_scilab/tests/unit_tests/sparseExample.c",pathconvert(TMPDIR+"/sparseExample/sparseExample.c",%F));
+cflags = "-I"+SCI+"/modules/localization/includes";
+ilib_build("gwsparseExample",["sparseExample","sparseExample"],"sparseExample.c",[],"","",cflags);
+exec("loader.sce");
+a = sparse([1,1;2,2;3,3], [1, 2, 3]);
+b = sparse([1,1;2,2;3,3], [1 + 2 * %i, 3 , -4 * %i]);
+assert_checkequal(sparseExample(a), a);
+assert_checkequal(sparseExample(b), b);
diff --git a/modules/api_scilab/tests/unit_tests/sparseExample.tst b/modules/api_scilab/tests/unit_tests/sparseExample.tst
new file mode 100755
index 000000000..6de647673
--- /dev/null
+++ b/modules/api_scilab/tests/unit_tests/sparseExample.tst
@@ -0,0 +1,20 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2009-2010 - DIGITEO
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- CLI SHELL MODE -->
+ilib_verbose(0);
+mkdir(pathconvert(TMPDIR+"/sparseExample"));
+cd(pathconvert(TMPDIR+"/sparseExample"));
+copyfile(SCI+"/modules/api_scilab/tests/unit_tests/sparseExample.c",pathconvert(TMPDIR+"/sparseExample/sparseExample.c",%F));
+cflags = "-I"+SCI+"/modules/localization/includes";
+ilib_build("gwsparseExample",["sparseExample","sparseExample"],"sparseExample.c",[],"","",cflags);
+exec("loader.sce");
+
+a = sparse([1,1;2,2;3,3], [1, 2, 3]);
+b = sparse([1,1;2,2;3,3], [1 + 2 * %i, 3 , -4 * %i]);
+assert_checkequal(sparseExample(a), a);
+assert_checkequal(sparseExample(b), b);
diff --git a/modules/api_scilab/tests/unit_tests/sparse_reading_api.c b/modules/api_scilab/tests/unit_tests/sparse_reading_api.c
new file mode 100755
index 000000000..f7f66ff73
--- /dev/null
+++ b/modules/api_scilab/tests/unit_tests/sparse_reading_api.c
@@ -0,0 +1,77 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2009-2010 - DIGITEO
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+ *
+ */
+
+#include "api_scilab.h"
+#include "Scierror.h"
+#include "localization.h"
+#include "sciprint.h"
+#include "MALLOC.h"
+
+int read_sparse(char *fname, unsigned long fname_len)
+{
+ SciErr sciErr;
+ int i, j, k;
+ int* piAddr = NULL;
+ int iRows = 0;
+ int iCols = 0;
+ int iNbItem = 0;
+ int* piNbItemRow = NULL;
+ int* piColPos = NULL;
+ double* pdblReal = NULL;
+ double* pdblImg = NULL;
+
+ CheckInputArgument(pvApiCtx, 1, 1);
+
+ sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddr);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ if (isVarComplex(pvApiCtx, piAddr))
+ {
+ sciErr = getComplexSparseMatrix(pvApiCtx, piAddr, &iRows, &iCols, &iNbItem, &piNbItemRow, &piColPos, &pdblReal, &pdblImg);
+ }
+ else
+ {
+ sciErr = getSparseMatrix(pvApiCtx, piAddr, &iRows, &iCols, &iNbItem, &piNbItemRow, &piColPos, &pdblReal);
+ }
+
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ sciprint("Sparse %d item(s)\n", iNbItem);
+ k = 0;
+
+ for (i = 0 ; i < iRows ; i++)
+ {
+ for (j = 0 ; j < piNbItemRow[i] ; j++)
+ {
+ sciprint("(%d,%d) = %f", i + 1, piColPos[k], pdblReal[k]);
+ if (isVarComplex(pvApiCtx, piAddr))
+ {
+ sciprint(" %+fi", pdblImg[k]);
+ }
+
+ sciprint("\n");
+ k++;
+ }
+ }
+
+ //assign allocated variables to Lhs position
+ AssignOutputVariable(pvApiCtx, 1) = 0;
+ return 0;
+}
diff --git a/modules/api_scilab/tests/unit_tests/sparse_reading_api.dia.ref b/modules/api_scilab/tests/unit_tests/sparse_reading_api.dia.ref
new file mode 100755
index 000000000..0fa69642e
--- /dev/null
+++ b/modules/api_scilab/tests/unit_tests/sparse_reading_api.dia.ref
@@ -0,0 +1,20 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2009-2010 - DIGITEO
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- CLI SHELL MODE -->
+ilib_verbose(0);
+mkdir(pathconvert(TMPDIR+"/sparse_reading_api"));
+cd(pathconvert(TMPDIR+"/sparse_reading_api"));
+copyfile(SCI+"/modules/api_scilab/tests/unit_tests/sparse_reading_api.c",pathconvert(TMPDIR+"/sparse_reading_api/sparse_reading_api.c",%F));
+cflags = "-I"+SCI+"/modules/localization/includes";
+ilib_build("sparse_reading",["read_sparse","read_sparse"],"sparse_reading_api.c",[],"","",cflags);
+exec("loader.sce");
+sp=sparse([1,2;4,5;3,10],[1 + 2*%i,2 - 3*%i,-3 + 4*%i]);
+read_sparse(sp);
+Sparse 3 item(s)
+(1,2) = 1.000000 +2.000000i
+(3,10) = -3.000000 +4.000000i
+(4,5) = 2.000000 -3.000000i
diff --git a/modules/api_scilab/tests/unit_tests/sparse_reading_api.tst b/modules/api_scilab/tests/unit_tests/sparse_reading_api.tst
new file mode 100755
index 000000000..2f034d68c
--- /dev/null
+++ b/modules/api_scilab/tests/unit_tests/sparse_reading_api.tst
@@ -0,0 +1,18 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2009-2010 - DIGITEO
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- CLI SHELL MODE -->
+ilib_verbose(0);
+mkdir(pathconvert(TMPDIR+"/sparse_reading_api"));
+cd(pathconvert(TMPDIR+"/sparse_reading_api"));
+copyfile(SCI+"/modules/api_scilab/tests/unit_tests/sparse_reading_api.c",pathconvert(TMPDIR+"/sparse_reading_api/sparse_reading_api.c",%F));
+cflags = "-I"+SCI+"/modules/localization/includes";
+ilib_build("sparse_reading",["read_sparse","read_sparse"],"sparse_reading_api.c",[],"","",cflags);
+exec("loader.sce");
+
+sp=sparse([1,2;4,5;3,10],[1 + 2*%i,2 - 3*%i,-3 + 4*%i]);
+read_sparse(sp);
diff --git a/modules/api_scilab/tests/unit_tests/sparse_writing_api.c b/modules/api_scilab/tests/unit_tests/sparse_writing_api.c
new file mode 100755
index 000000000..a6d42e412
--- /dev/null
+++ b/modules/api_scilab/tests/unit_tests/sparse_writing_api.c
@@ -0,0 +1,37 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2009-2010 - DIGITEO
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+ *
+ */
+
+#include "api_scilab.h"
+#include "Scierror.h"
+#include "localization.h"
+#include "sciprint.h"
+#include "MALLOC.h"
+
+int write_sparse(char *fname, unsigned long fname_len)
+{
+ SciErr sciErr;
+ int piNbItemRow[] = {1, 2, 1};
+ int piColPos[] = {8, 4, 7, 2};
+ double pdblSReal[] = {1, 2, 3, 4};
+ double pdblSImg[] = {4, 3, 2, 1};
+ int iNbItem = 4;
+
+ sciErr = createComplexSparseMatrix(pvApiCtx, nbInputArgument(pvApiCtx) + 1, 3, 10, iNbItem, piNbItemRow, piColPos, pdblSReal, pdblSImg);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1;
+ return 0;
+}
diff --git a/modules/api_scilab/tests/unit_tests/sparse_writing_api.dia.ref b/modules/api_scilab/tests/unit_tests/sparse_writing_api.dia.ref
new file mode 100755
index 000000000..dbc1a5646
--- /dev/null
+++ b/modules/api_scilab/tests/unit_tests/sparse_writing_api.dia.ref
@@ -0,0 +1,17 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2009-2010 - DIGITEO
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- CLI SHELL MODE -->
+ilib_verbose(0);
+mkdir(pathconvert(TMPDIR+"/sparse_writing_api"));
+cd(pathconvert(TMPDIR+"/sparse_writing_api"));
+copyfile(SCI+"/modules/api_scilab/tests/unit_tests/sparse_writing_api.c",pathconvert(TMPDIR+"/sparse_writing_api/sparse_writing_api.c",%F));
+cflags = "-I"+SCI+"/modules/localization/includes";
+ilib_build("sparse_writing",["write_sparse","write_sparse"],"sparse_writing_api.c",[],"","",cflags);
+exec("loader.sce");
+sp_ref = sparse([1,8;2,4;2,7;3,2],[1+4*%i,2+3*%i,3+2*%i,4+%i], [3,10]);
+sp = write_sparse();
+if or(sp <> sp_ref) then bugmes();quit;end
diff --git a/modules/api_scilab/tests/unit_tests/sparse_writing_api.tst b/modules/api_scilab/tests/unit_tests/sparse_writing_api.tst
new file mode 100755
index 000000000..c6ebbca6a
--- /dev/null
+++ b/modules/api_scilab/tests/unit_tests/sparse_writing_api.tst
@@ -0,0 +1,19 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2009-2010 - DIGITEO
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- CLI SHELL MODE -->
+ilib_verbose(0);
+mkdir(pathconvert(TMPDIR+"/sparse_writing_api"));
+cd(pathconvert(TMPDIR+"/sparse_writing_api"));
+copyfile(SCI+"/modules/api_scilab/tests/unit_tests/sparse_writing_api.c",pathconvert(TMPDIR+"/sparse_writing_api/sparse_writing_api.c",%F));
+cflags = "-I"+SCI+"/modules/localization/includes";
+ilib_build("sparse_writing",["write_sparse","write_sparse"],"sparse_writing_api.c",[],"","",cflags);
+exec("loader.sce");
+
+sp_ref = sparse([1,8;2,4;2,7;3,2],[1+4*%i,2+3*%i,3+2*%i,4+%i], [3,10]);
+sp = write_sparse();
+if or(sp <> sp_ref) then pause;end
diff --git a/modules/api_scilab/tests/unit_tests/stringExample.c b/modules/api_scilab/tests/unit_tests/stringExample.c
new file mode 100755
index 000000000..c20239551
--- /dev/null
+++ b/modules/api_scilab/tests/unit_tests/stringExample.c
@@ -0,0 +1,89 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2009-2010 - DIGITEO
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+ *
+ */
+
+#include "api_scilab.h"
+#include "Scierror.h"
+#include "localization.h"
+#include "sciprint.h"
+#include "MALLOC.h"
+
+int stringExample(char *fname, unsigned long fname_len)
+{
+ SciErr sciErr;
+ int* piAddr = NULL;
+ int iType = 0;
+ int iRet = 0;
+
+ CheckInputArgument(pvApiCtx, 1, 1);
+ CheckOutputArgument(pvApiCtx, 0, 1);
+
+ sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddr);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ if (isStringType(pvApiCtx, piAddr))
+ {
+ if (isScalar(pvApiCtx, piAddr))
+ {
+ char* pstData = NULL;
+
+ iRet = getAllocatedSingleString(pvApiCtx, piAddr, &pstData);
+ if (iRet)
+ {
+ freeAllocatedSingleString(pstData);
+ return iRet;
+ }
+
+ iRet = createSingleString(pvApiCtx, nbInputArgument(pvApiCtx) + 1, pstData);
+ if (iRet)
+ {
+ freeAllocatedSingleString(pstData);
+ return iRet;
+ }
+
+ freeAllocatedSingleString(pstData);
+ }
+ else
+ {
+ int iRows = 0;
+ int iCols = 0;
+ char** pstData = NULL;
+
+ iRet = getAllocatedMatrixOfString(pvApiCtx, piAddr, &iRows, &iCols, &pstData);
+ if (iRet)
+ {
+ freeAllocatedMatrixOfString(iRows, iCols, pstData);
+ return iRet;
+ }
+
+ sciErr = createMatrixOfString(pvApiCtx, nbInputArgument(pvApiCtx) + 1, iRows, iCols, pstData);
+ if (sciErr.iErr)
+ {
+ freeAllocatedMatrixOfString(iRows, iCols, pstData);
+ printError(&sciErr, 0);
+ return sciErr.iErr;
+ }
+
+ freeAllocatedMatrixOfString(iRows, iCols, pstData);
+ }
+
+ AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1;
+ }
+ else
+ {
+ AssignOutputVariable(pvApiCtx, 1) = 0;
+ }
+ return 0;
+}
diff --git a/modules/api_scilab/tests/unit_tests/stringExample.dia.ref b/modules/api_scilab/tests/unit_tests/stringExample.dia.ref
new file mode 100755
index 000000000..de70b26d9
--- /dev/null
+++ b/modules/api_scilab/tests/unit_tests/stringExample.dia.ref
@@ -0,0 +1,18 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2009-2010 - DIGITEO
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- CLI SHELL MODE -->
+ilib_verbose(0);
+mkdir(pathconvert(TMPDIR+"/stringExample"));
+cd(pathconvert(TMPDIR+"/stringExample"));
+copyfile(SCI+"/modules/api_scilab/tests/unit_tests/stringExample.c",pathconvert(TMPDIR+"/stringExample/stringExample.c",%F));
+cflags = "-I"+SCI+"/modules/localization/includes";
+ilib_build("gw_stringExample",["stringExample","stringExample"],"stringExample.c",[],"","",cflags);
+exec("loader.sce");
+a = "Scilab";
+b = ["New","Scilab";"API","functions"];
+assert_checkequal(stringExample(a), a);
+assert_checkequal(stringExample(b), b);
diff --git a/modules/api_scilab/tests/unit_tests/stringExample.tst b/modules/api_scilab/tests/unit_tests/stringExample.tst
new file mode 100755
index 000000000..5e7093b34
--- /dev/null
+++ b/modules/api_scilab/tests/unit_tests/stringExample.tst
@@ -0,0 +1,20 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2009-2010 - DIGITEO
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- CLI SHELL MODE -->
+ilib_verbose(0);
+mkdir(pathconvert(TMPDIR+"/stringExample"));
+cd(pathconvert(TMPDIR+"/stringExample"));
+copyfile(SCI+"/modules/api_scilab/tests/unit_tests/stringExample.c",pathconvert(TMPDIR+"/stringExample/stringExample.c",%F));
+cflags = "-I"+SCI+"/modules/localization/includes";
+ilib_build("gw_stringExample",["stringExample","stringExample"],"stringExample.c",[],"","",cflags);
+exec("loader.sce");
+
+a = "Scilab";
+b = ["New","Scilab";"API","functions"];
+assert_checkequal(stringExample(a), a);
+assert_checkequal(stringExample(b), b);
diff --git a/modules/api_scilab/tests/unit_tests/string_reading_api.c b/modules/api_scilab/tests/unit_tests/string_reading_api.c
new file mode 100755
index 000000000..53ec28c9a
--- /dev/null
+++ b/modules/api_scilab/tests/unit_tests/string_reading_api.c
@@ -0,0 +1,124 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2009-2010 - DIGITEO
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+ *
+ */
+
+#include "api_scilab.h"
+#include "Scierror.h"
+#include "localization.h"
+#include "sciprint.h"
+#include "MALLOC.h"
+
+int read_string(char *fname, unsigned long fname_len)
+{
+ SciErr sciErr;
+ int i, j;
+ int iLen = 0;
+ //variable info
+ int iRows = 0;
+ int iCols = 0;
+ int* piAddr = NULL;
+ int* piLen = NULL;
+ char** pstData = NULL;
+ //output variable
+ int iRowsOut = 1;
+ int iColsOut = 1;
+ char* pstOut = NULL;
+ //check input and output arguments
+
+ CheckInputArgument(pvApiCtx, 1, 1);
+ CheckOutputArgument(pvApiCtx, 1, 1);
+
+ //get variable address
+ sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddr);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ //first call to retrieve dimensions
+ sciErr = getMatrixOfString(pvApiCtx, piAddr, &iRows, &iCols, NULL, NULL);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ piLen = (int*)malloc(sizeof(int) * iRows * iCols);
+
+ //second call to retrieve length of each string
+ sciErr = getMatrixOfString(pvApiCtx, piAddr, &iRows, &iCols, piLen, NULL);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ pstData = (char**)malloc(sizeof(char*) * iRows * iCols);
+ for (i = 0 ; i < iRows * iCols ; i++)
+ {
+ pstData[i] = (char*)malloc(sizeof(char) * (piLen[i] + 1));//+ 1 for null termination
+ }
+
+ //third call to retrieve data
+ sciErr = getMatrixOfString(pvApiCtx, piAddr, &iRows, &iCols, piLen, pstData);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ //computer length of all strings
+ for (i = 0 ; i < iRows * iCols ; i++)
+ {
+ iLen += piLen[i];
+ }
+
+ //alloc output variable
+ pstOut = (char*)malloc(sizeof(char) * (iLen + iRows * iCols));
+ //initialize string to 0x00
+ memset(pstOut, 0x00, sizeof(char) * (iLen + iRows * iCols));
+
+ //concat input strings in output string
+ for (i = 0 ; i < iRows ; i++)
+ {
+ for (j = 0 ; j < iCols ; j++)
+ {
+ int iCurLen = strlen(pstOut);
+ if (iCurLen)
+ {
+ strcat(pstOut, " ");
+ }
+ strcpy(pstOut + strlen(pstOut), pstData[j * iRows + i]);
+ }
+ }
+
+ //create new variable
+ sciErr = createMatrixOfString(pvApiCtx, nbInputArgument(pvApiCtx) + 1, iRowsOut, iColsOut, &pstOut);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ //free memory
+ free(piLen);
+
+ for (i = 0 ; i < iRows * iCols ; i++)
+ {
+ free(pstData[i]);
+ }
+
+ free(pstData);
+ free(pstOut);
+ AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1;
+ return 0;
+}
diff --git a/modules/api_scilab/tests/unit_tests/string_reading_api.dia.ref b/modules/api_scilab/tests/unit_tests/string_reading_api.dia.ref
new file mode 100755
index 000000000..37ed5796f
--- /dev/null
+++ b/modules/api_scilab/tests/unit_tests/string_reading_api.dia.ref
@@ -0,0 +1,18 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2009-2010 - DIGITEO
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- CLI SHELL MODE -->
+ilib_verbose(0);
+mkdir(pathconvert(TMPDIR+"/string_reading_api"));
+cd(pathconvert(TMPDIR+"/string_reading_api"));
+copyfile(SCI+"/modules/api_scilab/tests/unit_tests/string_reading_api.c",pathconvert(TMPDIR+"/string_reading_api/string_reading_api.c",%F));
+cflags = "-I"+SCI+"/modules/localization/includes";
+ilib_build("string_reading",["read_string","read_string"],"string_reading_api.c",[],"","",cflags);
+exec("loader.sce");
+a_ref = ["may the puffin be with you"];
+a = ["may", "the", "puffin"; "be","with","you"];
+b = read_string(a);
+if a_ref <> b then bugmes();quit;end
diff --git a/modules/api_scilab/tests/unit_tests/string_reading_api.tst b/modules/api_scilab/tests/unit_tests/string_reading_api.tst
new file mode 100755
index 000000000..ec98ca81b
--- /dev/null
+++ b/modules/api_scilab/tests/unit_tests/string_reading_api.tst
@@ -0,0 +1,20 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2009-2010 - DIGITEO
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- CLI SHELL MODE -->
+ilib_verbose(0);
+mkdir(pathconvert(TMPDIR+"/string_reading_api"));
+cd(pathconvert(TMPDIR+"/string_reading_api"));
+copyfile(SCI+"/modules/api_scilab/tests/unit_tests/string_reading_api.c",pathconvert(TMPDIR+"/string_reading_api/string_reading_api.c",%F));
+cflags = "-I"+SCI+"/modules/localization/includes";
+ilib_build("string_reading",["read_string","read_string"],"string_reading_api.c",[],"","",cflags);
+exec("loader.sce");
+
+a_ref = ["may the puffin be with you"];
+a = ["may", "the", "puffin"; "be","with","you"];
+b = read_string(a);
+if a_ref <> b then pause;end
diff --git a/modules/api_scilab/tests/unit_tests/string_writing_api.c b/modules/api_scilab/tests/unit_tests/string_writing_api.c
new file mode 100755
index 000000000..f1fec6968
--- /dev/null
+++ b/modules/api_scilab/tests/unit_tests/string_writing_api.c
@@ -0,0 +1,56 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2009-2010 - DIGITEO
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+ *
+ */
+
+#include "api_scilab.h"
+#include "Scierror.h"
+#include "localization.h"
+#include "sciprint.h"
+#include "MALLOC.h"
+
+int write_string(char *fname, unsigned long fname_len)
+{
+ SciErr sciErr;
+ //variable info : matrix of string 2 x 3
+ int iRows = 2;
+ int iCols = 3;
+ char** pstData = NULL;
+ //data to put in the new variable
+ char string11[] = "may";
+ char string21[] = "be";
+ char string12[] = "the";
+ char string22[] = "with";
+ char string13[] = "puffin";
+ char string23[] = "you";
+ //alloc new array
+ pstData = (char**)malloc(sizeof(char*) * iRows * iCols);
+ //copy data address to the "main" array
+ pstData[0] = string11;
+ pstData[1] = string21;
+ pstData[2] = string12;
+ pstData[3] = string22;
+ pstData[4] = string13;
+ pstData[5] = string23;
+
+ //create the variable
+ sciErr = createMatrixOfString(pvApiCtx, nbInputArgument(pvApiCtx) + 1, iRows, iCols, pstData);
+ if (sciErr.iErr)
+ {
+ printError(&sciErr, 0);
+ return 0;
+ }
+
+ //free container
+ free(pstData);
+ //assign allocated variables to Lhs position
+ AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1;
+ return 0;
+}
diff --git a/modules/api_scilab/tests/unit_tests/string_writing_api.dia.ref b/modules/api_scilab/tests/unit_tests/string_writing_api.dia.ref
new file mode 100755
index 000000000..d4505706f
--- /dev/null
+++ b/modules/api_scilab/tests/unit_tests/string_writing_api.dia.ref
@@ -0,0 +1,24 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2009-2010 - DIGITEO
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- CLI SHELL MODE -->
+ilib_verbose(0);
+mkdir(pathconvert(TMPDIR+"/string_writing_api"));
+cd(pathconvert(TMPDIR+"/string_writing_api"));
+copyfile(SCI+"/modules/api_scilab/tests/unit_tests/string_writing_api.c",pathconvert(TMPDIR+"/string_writing_api/string_writing_api.c",%F));
+cflags = "-I"+SCI+"/modules/localization/includes";
+ilib_build("string_writing",["write_string","write_string"],"string_writing_api.c",[],"","",cflags);
+exec("loader.sce");
+a_ref = "may the puffin be with you ";
+b = [];
+a = write_string();
+for i=1:size(a,"r")
+ for j=1:size(a,"c")
+ b = b + a(i,j);
+ b = b + " ";
+ end
+end
+if b <> a_ref then bugmes();quit;end
diff --git a/modules/api_scilab/tests/unit_tests/string_writing_api.tst b/modules/api_scilab/tests/unit_tests/string_writing_api.tst
new file mode 100755
index 000000000..5f399e22d
--- /dev/null
+++ b/modules/api_scilab/tests/unit_tests/string_writing_api.tst
@@ -0,0 +1,26 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2009-2010 - DIGITEO
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- CLI SHELL MODE -->
+ilib_verbose(0);
+mkdir(pathconvert(TMPDIR+"/string_writing_api"));
+cd(pathconvert(TMPDIR+"/string_writing_api"));
+copyfile(SCI+"/modules/api_scilab/tests/unit_tests/string_writing_api.c",pathconvert(TMPDIR+"/string_writing_api/string_writing_api.c",%F));
+cflags = "-I"+SCI+"/modules/localization/includes";
+ilib_build("string_writing",["write_string","write_string"],"string_writing_api.c",[],"","",cflags);
+exec("loader.sce");
+
+a_ref = "may the puffin be with you ";
+b = [];
+a = write_string();
+for i=1:size(a,"r")
+ for j=1:size(a,"c")
+ b = b + a(i,j);
+ b = b + " ";
+ end
+end
+if b <> a_ref then pause;end