summaryrefslogtreecommitdiff
path: root/tools/api_scilab_trad
diff options
context:
space:
mode:
Diffstat (limited to 'tools/api_scilab_trad')
-rwxr-xr-xtools/api_scilab_trad/Bool_Matrix_Alloc.txt10
-rwxr-xr-xtools/api_scilab_trad/Bool_Matrix_Create.txt8
-rwxr-xr-xtools/api_scilab_trad/Bool_Matrix_Get.txt19
-rwxr-xr-xtools/api_scilab_trad/DoubleComplex_Matrix_Alloc.txt11
-rwxr-xr-xtools/api_scilab_trad/DoubleComplex_Matrix_AllocAsInteger.txt11
-rwxr-xr-xtools/api_scilab_trad/DoubleComplex_Matrix_Create.txt8
-rwxr-xr-xtools/api_scilab_trad/DoubleComplex_Matrix_CreateAsInteger.txt8
-rwxr-xr-xtools/api_scilab_trad/DoubleComplex_Matrix_Get.txt33
-rwxr-xr-xtools/api_scilab_trad/DoubleComplex_Matrix_GetAsInteger.txt20
-rwxr-xr-xtools/api_scilab_trad/Double_Matrix_Alloc.txt10
-rwxr-xr-xtools/api_scilab_trad/Double_Matrix_AllocAsInteger.txt10
-rwxr-xr-xtools/api_scilab_trad/Double_Matrix_Create.txt8
-rwxr-xr-xtools/api_scilab_trad/Double_Matrix_CreateAsInteger.txt8
-rwxr-xr-xtools/api_scilab_trad/Double_Matrix_Get.txt19
-rwxr-xr-xtools/api_scilab_trad/Double_Matrix_GetAsInteger.txt19
-rwxr-xr-xtools/api_scilab_trad/Handle_Matrix_Alloc.txt10
-rwxr-xr-xtools/api_scilab_trad/Handle_Matrix_Create.txt8
-rwxr-xr-xtools/api_scilab_trad/Handle_Matrix_Get.txt19
-rwxr-xr-xtools/api_scilab_trad/Pointer_Alloc.txt10
-rwxr-xr-xtools/api_scilab_trad/Pointer_Create.txt8
-rwxr-xr-xtools/api_scilab_trad/Pointer_Get.txt19
-rwxr-xr-xtools/api_scilab_trad/String_Matrix_Create.txt8
-rwxr-xr-xtools/api_scilab_trad/String_Matrix_Get.txt16
-rwxr-xr-xtools/api_scilab_trad/String_Single_Alloc.txt8
-rwxr-xr-xtools/api_scilab_trad/String_Single_Create.txt6
-rwxr-xr-xtools/api_scilab_trad/String_Single_Get.txt18
-rwxr-xr-xtools/api_scilab_trad/Tools_Check_Column.txt7
-rwxr-xr-xtools/api_scilab_trad/Tools_Check_DimProp.txt7
-rwxr-xr-xtools/api_scilab_trad/Tools_Check_Dims.txt7
-rwxr-xr-xtools/api_scilab_trad/Tools_Check_Length.txt7
-rwxr-xr-xtools/api_scilab_trad/Tools_Check_OneDim.txt7
-rwxr-xr-xtools/api_scilab_trad/Tools_Check_Row.txt7
-rwxr-xr-xtools/api_scilab_trad/Tools_Check_SameDims.txt7
-rwxr-xr-xtools/api_scilab_trad/Tools_Check_Scalar.txt7
-rwxr-xr-xtools/api_scilab_trad/Tools_Check_Square.txt7
-rwxr-xr-xtools/api_scilab_trad/Tools_Check_Vector.txt7
-rwxr-xr-xtools/api_scilab_trad/trad.sce702
37 files changed, 1104 insertions, 0 deletions
diff --git a/tools/api_scilab_trad/Bool_Matrix_Alloc.txt b/tools/api_scilab_trad/Bool_Matrix_Alloc.txt
new file mode 100755
index 000000000..d98d505ab
--- /dev/null
+++ b/tools/api_scilab_trad/Bool_Matrix_Alloc.txt
@@ -0,0 +1,10 @@
+\1int* \5 = NULL; //@MOVE@
+\1// YOU MUST REMOVE YOUR VARIABLE DECLARATION "int \5".
+\1sciErr = allocMatrixOfBoolean(pvApiCtx, \2, \3, \4, &\5);\6
+\1if(sciErr.iErr)
+\1{
+\1 printError(&sciErr, 0);
+\1 Scierror(999, _("%s: Memory allocation error.\n"), fname);
+\1 return 1;
+\1}
+
diff --git a/tools/api_scilab_trad/Bool_Matrix_Create.txt b/tools/api_scilab_trad/Bool_Matrix_Create.txt
new file mode 100755
index 000000000..82a7e3f32
--- /dev/null
+++ b/tools/api_scilab_trad/Bool_Matrix_Create.txt
@@ -0,0 +1,8 @@
+\1sciErr = createMatrixOfBoolean(pvApiCtx, \2, \3, \4, \5);\6
+\1if(sciErr.iErr)
+\1{
+\1 printError(&sciErr, 0);
+\1 Scierror(999, _("%s: Memory allocation error.\n"), fname);
+\1 return 1;
+\1}
+
diff --git a/tools/api_scilab_trad/Bool_Matrix_Get.txt b/tools/api_scilab_trad/Bool_Matrix_Get.txt
new file mode 100755
index 000000000..0a6a2e77d
--- /dev/null
+++ b/tools/api_scilab_trad/Bool_Matrix_Get.txt
@@ -0,0 +1,19 @@
+\1int* piAddr\5 = NULL; //@MOVE@
+\1int* \5 = NULL; //@MOVE@
+\1sciErr = getVarAddressFromPosition(pvApiCtx, \2, &piAddr\5);
+\1if (sciErr.iErr)
+\1{
+\1 printError(&sciErr, 0);
+\1 return 1;
+\1}
+\1
+\1// Retrieve a matrix of boolean at position \2.
+\1// YOU MUST REMOVE YOUR VARIABLE DECLARATION "int \5".
+\1sciErr = getMatrixOfBoolean(pvApiCtx, piAddr\5, &\3, &\4, &\5);\6
+\1if (sciErr.iErr)
+\1{
+\1 printError(&sciErr, 0);
+\1 Scierror(202, _("%s: Wrong type for argument %d: Boolean matrix expected.\n"), fname, \2);
+\1 return 1;
+\1}
+
diff --git a/tools/api_scilab_trad/DoubleComplex_Matrix_Alloc.txt b/tools/api_scilab_trad/DoubleComplex_Matrix_Alloc.txt
new file mode 100755
index 000000000..4f23fbffd
--- /dev/null
+++ b/tools/api_scilab_trad/DoubleComplex_Matrix_Alloc.txt
@@ -0,0 +1,11 @@
+\1double* \6 = NULL; //@MOVE@
+\1double* \7 = NULL; //@MOVE@
+\1// YOU MUST REMOVE YOUR VARIABLE DECLARATION "int \6" and "int \7".
+\1sciErr = allocComplexMatrixOfDouble(pvApiCtx, \2, \4, \5, &\6, &\7);\8
+\1if(sciErr.iErr)
+\1{
+\1 printError(&sciErr, 0);
+\1 Scierror(999, _("%s: Memory allocation error.\n"), fname);
+\1 return 1;
+\1}
+
diff --git a/tools/api_scilab_trad/DoubleComplex_Matrix_AllocAsInteger.txt b/tools/api_scilab_trad/DoubleComplex_Matrix_AllocAsInteger.txt
new file mode 100755
index 000000000..2da7e3483
--- /dev/null
+++ b/tools/api_scilab_trad/DoubleComplex_Matrix_AllocAsInteger.txt
@@ -0,0 +1,11 @@
+\1int* \6 = NULL; //@MOVE@
+\1int* \7 = NULL; //@MOVE@
+\1// YOU MUST REMOVE YOUR VARIABLE DECLARATION "int \6" and "int \7".
+\1sciErr = allocComplexMatrixOfDoubleAsInteger(pvApiCtx, \2, \4, \5, &\6, &\7);\8
+\1if(sciErr.iErr)
+\1{
+\1 printError(&sciErr, 0);
+\1 Scierror(999, _("%s: Memory allocation error.\n"), fname);
+\1 return 1;
+\1}
+
diff --git a/tools/api_scilab_trad/DoubleComplex_Matrix_Create.txt b/tools/api_scilab_trad/DoubleComplex_Matrix_Create.txt
new file mode 100755
index 000000000..2fc57987c
--- /dev/null
+++ b/tools/api_scilab_trad/DoubleComplex_Matrix_Create.txt
@@ -0,0 +1,8 @@
+\1sciErr = createComplexMatrixOfDouble(pvApiCtx, \2, \4, \5, \6, \7);\8
+\1if(sciErr.iErr)
+\1{
+\1 printError(&sciErr, 0);
+\1 Scierror(999, _("%s: Memory allocation error.\n"), fname);
+\1 return 1;
+\1}
+
diff --git a/tools/api_scilab_trad/DoubleComplex_Matrix_CreateAsInteger.txt b/tools/api_scilab_trad/DoubleComplex_Matrix_CreateAsInteger.txt
new file mode 100755
index 000000000..06063eb97
--- /dev/null
+++ b/tools/api_scilab_trad/DoubleComplex_Matrix_CreateAsInteger.txt
@@ -0,0 +1,8 @@
+\1sciErr = createComplexMatrixOfDoubleAsInteger(pvApiCtx, \2, \4, \5, \6, \7);\8
+\1if(sciErr.iErr)
+\1{
+\1 printError(&sciErr, 0);
+\1 Scierror(999, _("%s: Memory allocation error.\n"), fname);
+\1 return 1;
+\1}
+
diff --git a/tools/api_scilab_trad/DoubleComplex_Matrix_Get.txt b/tools/api_scilab_trad/DoubleComplex_Matrix_Get.txt
new file mode 100755
index 000000000..8e6bba1d1
--- /dev/null
+++ b/tools/api_scilab_trad/DoubleComplex_Matrix_Get.txt
@@ -0,0 +1,33 @@
+\1int* piAddr\5 = NULL; //@MOVE@
+\1double* \6 = NULL; //@MOVE@
+\1double* \7 = NULL; //@MOVE@
+\1sciErr = getVarAddressFromPosition(pvApiCtx, \2, &piAddr\5);
+\1if (sciErr.iErr)
+\1{
+\1 printError(&sciErr, 0);
+\1 return 1;
+\1}
+\1
+\1// Retrieve a matrix of double at position \2.
+\1// YOU MUST REMOVE YOUR VARIABLES DECLARATIONS "int \6" and "int \7".
+\1if (isVarComplex(pvApiCtx, piAddr\5))
+\1{
+\1 sciErr = getComplexMatrixOfDouble(pvApiCtx, piAddr\5, &\4, &\5, &\6, &\7);\8
+\1 \3 = 1;
+\1}
+\1else
+\1{
+\1 sciErr = getMatrixOfDouble(pvApiCtx, piAddr\5, &\4, &\5, &\6);\8
+\1 \3 = 0;
+\1}
+
+\1if (sciErr.iErr)
+\1{
+\1 printError(&sciErr, 0);
+\1 Scierror(202, _("%s: Wrong type for argument %d: Real or complex matrix expected.\n"), fname, \2);
+\1 return 1;
+\1}
+
+
+
+
diff --git a/tools/api_scilab_trad/DoubleComplex_Matrix_GetAsInteger.txt b/tools/api_scilab_trad/DoubleComplex_Matrix_GetAsInteger.txt
new file mode 100755
index 000000000..e0a40be17
--- /dev/null
+++ b/tools/api_scilab_trad/DoubleComplex_Matrix_GetAsInteger.txt
@@ -0,0 +1,20 @@
+\1int* piAddr\5 = NULL; //@MOVE@
+\1int* \6 = NULL; //@MOVE@
+\1int* \7 = NULL; //@MOVE@
+\1sciErr = getVarAddressFromPosition(pvApiCtx, \2, &piAddr\5);
+\1if (sciErr.iErr)
+\1{
+\1 printError(&sciErr, 0);
+\1 return 1;
+\1}
+\1
+\1// Retrieve a matrix of double at position \2.
+\1// YOU MUST REMOVE YOUR VARIABLES DECLARATIONS "int \6" and "int \7".
+\1sciErr = getComplexMatrixOfDoubleAsInteger(pvApiCtx, piAddr\5, &\4, &\5, &\6, &\7);\8
+\1if (sciErr.iErr)
+\1{
+\1 printError(&sciErr, 0);
+\1 Scierror(202, _("%s: Wrong type for argument %d: A real expected.\n"), fname, \2);
+\1 return 1;
+\1}
+
diff --git a/tools/api_scilab_trad/Double_Matrix_Alloc.txt b/tools/api_scilab_trad/Double_Matrix_Alloc.txt
new file mode 100755
index 000000000..948d2ac41
--- /dev/null
+++ b/tools/api_scilab_trad/Double_Matrix_Alloc.txt
@@ -0,0 +1,10 @@
+\1double* \5 = NULL; //@MOVE@
+\1// YOU MUST REMOVE YOUR VARIABLE DECLARATION "int \5".
+\1sciErr = allocMatrixOfDouble(pvApiCtx, \2, \3, \4, &\5);\6
+\1if(sciErr.iErr)
+\1{
+\1 printError(&sciErr, 0);
+\1 Scierror(999, _("%s: Memory allocation error.\n"), fname);
+\1 return 1;
+\1}
+
diff --git a/tools/api_scilab_trad/Double_Matrix_AllocAsInteger.txt b/tools/api_scilab_trad/Double_Matrix_AllocAsInteger.txt
new file mode 100755
index 000000000..c498b0dbd
--- /dev/null
+++ b/tools/api_scilab_trad/Double_Matrix_AllocAsInteger.txt
@@ -0,0 +1,10 @@
+\1int* \5 = NULL; //@MOVE@
+\1// YOU MUST REMOVE YOUR VARIABLE DECLARATION "int \5".
+\1sciErr = allocMatrixOfDoubleAsInteger(pvApiCtx, \2, \3, \4, &\5);\6
+\1if(sciErr.iErr)
+\1{
+\1 printError(&sciErr, 0);
+\1 Scierror(999, _("%s: Memory allocation error.\n"), fname);
+\1 return 1;
+\1}
+
diff --git a/tools/api_scilab_trad/Double_Matrix_Create.txt b/tools/api_scilab_trad/Double_Matrix_Create.txt
new file mode 100755
index 000000000..a2f78fdd4
--- /dev/null
+++ b/tools/api_scilab_trad/Double_Matrix_Create.txt
@@ -0,0 +1,8 @@
+\1sciErr = createMatrixOfDouble(pvApiCtx, \2, \3, \4, \5);\6
+\1if(sciErr.iErr)
+\1{
+\1 printError(&sciErr, 0);
+\1 Scierror(999, _("%s: Memory allocation error.\n"), fname);
+\1 return 1;
+\1}
+
diff --git a/tools/api_scilab_trad/Double_Matrix_CreateAsInteger.txt b/tools/api_scilab_trad/Double_Matrix_CreateAsInteger.txt
new file mode 100755
index 000000000..5e0f983f0
--- /dev/null
+++ b/tools/api_scilab_trad/Double_Matrix_CreateAsInteger.txt
@@ -0,0 +1,8 @@
+\1sciErr = createMatrixOfDoubleAsInteger(pvApiCtx, \2, \3, \4, \5);\6
+\1if(sciErr.iErr)
+\1{
+\1 printError(&sciErr, 0);
+\1 Scierror(999, _("%s: Memory allocation error.\n"), fname);
+\1 return 1;
+\1}
+
diff --git a/tools/api_scilab_trad/Double_Matrix_Get.txt b/tools/api_scilab_trad/Double_Matrix_Get.txt
new file mode 100755
index 000000000..8a832a85e
--- /dev/null
+++ b/tools/api_scilab_trad/Double_Matrix_Get.txt
@@ -0,0 +1,19 @@
+\1int* piAddr\5 = NULL; //@MOVE@
+\1double* \5 = NULL; //@MOVE@
+\1sciErr = getVarAddressFromPosition(pvApiCtx, \2, &piAddr\5);
+\1if (sciErr.iErr)
+\1{
+\1 printError(&sciErr, 0);
+\1 return 1;
+\1}
+\1
+\1// Retrieve a matrix of double at position \2.
+\1// YOU MUST REMOVE YOUR VARIABLE DECLARATION "int \5".
+\1sciErr = getMatrixOfDouble(pvApiCtx, piAddr\5, &\3, &\4, &\5);\6
+\1if (sciErr.iErr)
+\1{
+\1 printError(&sciErr, 0);
+\1 Scierror(202, _("%s: Wrong type for argument %d: A real expected.\n"), fname, \2);
+\1 return 1;
+\1}
+
diff --git a/tools/api_scilab_trad/Double_Matrix_GetAsInteger.txt b/tools/api_scilab_trad/Double_Matrix_GetAsInteger.txt
new file mode 100755
index 000000000..e88e3dcbf
--- /dev/null
+++ b/tools/api_scilab_trad/Double_Matrix_GetAsInteger.txt
@@ -0,0 +1,19 @@
+\1int* piAddr\5 = NULL; //@MOVE@
+\1int* \5 = NULL; //@MOVE@
+\1sciErr = getVarAddressFromPosition(pvApiCtx, \2, &piAddr\5);
+\1if (sciErr.iErr)
+\1{
+\1 printError(&sciErr, 0);
+\1 return 1;
+\1}
+\1
+\1// Retrieve a matrix of double at position \2.
+\1// YOU MUST REMOVE YOUR VARIABLE DECLARATION "int \5".
+\1sciErr = getMatrixOfDoubleAsInteger(pvApiCtx, piAddr\5, &\3, &\4, &\5);\6
+\1if (sciErr.iErr)
+\1{
+\1 printError(&sciErr, 0);
+\1 Scierror(202, _("%s: Wrong type for argument %d: A real expected.\n"), fname, \2);
+\1 return 1;
+\1}
+
diff --git a/tools/api_scilab_trad/Handle_Matrix_Alloc.txt b/tools/api_scilab_trad/Handle_Matrix_Alloc.txt
new file mode 100755
index 000000000..74f974c10
--- /dev/null
+++ b/tools/api_scilab_trad/Handle_Matrix_Alloc.txt
@@ -0,0 +1,10 @@
+\1long long* \5 = NULL; //@MOVE@
+\1// YOU MUST REMOVE YOUR VARIABLE DECLARATION "int \5".
+\1sciErr = allocMatrixOfHandle(pvApiCtx, \2, \3, \4, &\5);\6
+\1if(sciErr.iErr)
+\1{
+\1 printError(&sciErr, 0);
+\1 Scierror(999, _("%s: Memory allocation error.\n"), fname);
+\1 return 1;
+\1}
+
diff --git a/tools/api_scilab_trad/Handle_Matrix_Create.txt b/tools/api_scilab_trad/Handle_Matrix_Create.txt
new file mode 100755
index 000000000..053eec936
--- /dev/null
+++ b/tools/api_scilab_trad/Handle_Matrix_Create.txt
@@ -0,0 +1,8 @@
+\1sciErr = createMatrixOfHandle(pvApiCtx, \2, \3, \4, \5);\6
+\1if(sciErr.iErr)
+\1{
+\1 printError(&sciErr, 0);
+\1 Scierror(999, _("%s: Memory allocation error.\n"), fname);
+\1 return 1;
+\1}
+
diff --git a/tools/api_scilab_trad/Handle_Matrix_Get.txt b/tools/api_scilab_trad/Handle_Matrix_Get.txt
new file mode 100755
index 000000000..8c8618792
--- /dev/null
+++ b/tools/api_scilab_trad/Handle_Matrix_Get.txt
@@ -0,0 +1,19 @@
+\1int* piAddr\5 = NULL; //@MOVE@
+\1long long* \5 = NULL; //@MOVE@
+\1sciErr = getVarAddressFromPosition(pvApiCtx, \2, &piAddr\5);
+\1if (sciErr.iErr)
+\1{
+\1 printError(&sciErr, 0);
+\1 return 1;
+\1}
+\1
+\1// Retrieve a matrix of handle at position \2.
+\1// YOU MUST REMOVE YOUR VARIABLE DECLARATION "int \5".
+\1sciErr = getMatrixOfHandle(pvApiCtx, piAddr\5, &\3, &\4, &\5);\6
+\1if (sciErr.iErr)
+\1{
+\1 printError(&sciErr, 0);
+\1 Scierror(202, _("%s: Wrong type for argument %d: Handle matrix expected.\n"), fname, \2);
+\1 return 1;
+\1}
+
diff --git a/tools/api_scilab_trad/Pointer_Alloc.txt b/tools/api_scilab_trad/Pointer_Alloc.txt
new file mode 100755
index 000000000..f6b647696
--- /dev/null
+++ b/tools/api_scilab_trad/Pointer_Alloc.txt
@@ -0,0 +1,10 @@
+\1void* \5 = NULL; //@MOVE@
+\1// YOU MUST REMOVE YOUR VARIABLE DECLARATION "int \5".
+\1sciErr = allocPointer(pvApiCtx, \2, &\5);\6
+\1if(sciErr.iErr)
+\1{
+\1 printError(&sciErr, 0);
+\1 Scierror(999, _("%s: Memory allocation error.\n"), fname);
+\1 return 1;
+\1}
+
diff --git a/tools/api_scilab_trad/Pointer_Create.txt b/tools/api_scilab_trad/Pointer_Create.txt
new file mode 100755
index 000000000..3559a38df
--- /dev/null
+++ b/tools/api_scilab_trad/Pointer_Create.txt
@@ -0,0 +1,8 @@
+\1sciErr = createPointer(pvApiCtx, \2, \5);\6
+\1if(sciErr.iErr)
+\1{
+\1 printError(&sciErr, 0);
+\1 Scierror(999, _("%s: Memory allocation error.\n"), fname);
+\1 return 1;
+\1}
+
diff --git a/tools/api_scilab_trad/Pointer_Get.txt b/tools/api_scilab_trad/Pointer_Get.txt
new file mode 100755
index 000000000..a97bc1b65
--- /dev/null
+++ b/tools/api_scilab_trad/Pointer_Get.txt
@@ -0,0 +1,19 @@
+\1int* piAddr\5 = NULL; //@MOVE@
+\1void* \5 = NULL; //@MOVE@
+\1sciErr = getVarAddressFromPosition(pvApiCtx, \2, &piAddr\5);
+\1if (sciErr.iErr)
+\1{
+\1 printError(&sciErr, 0);
+\1 return 1;
+\1}
+\1
+\1// Retrieve a pointer at position \2.
+\1// YOU MUST REMOVE YOUR VARIABLE DECLARATION "int \5".
+\1sciErr = getPointer(pvApiCtx, piAddr\5, &\5);\6
+\1if (sciErr.iErr)
+\1{
+\1 printError(&sciErr, 0);
+\1 Scierror(202, _("%s: Wrong type for argument %d: Boolean matrix expected.\n"), fname, \2);
+\1 return 1;
+\1}
+
diff --git a/tools/api_scilab_trad/String_Matrix_Create.txt b/tools/api_scilab_trad/String_Matrix_Create.txt
new file mode 100755
index 000000000..6823d4b91
--- /dev/null
+++ b/tools/api_scilab_trad/String_Matrix_Create.txt
@@ -0,0 +1,8 @@
+\1sciErr = createMatrixOfString(pvApiCtx, \2, \3, \4, \5);\6
+\1if(sciErr.iErr)
+\1{
+\1 printError(&sciErr, 0);
+\1 Scierror(999, _("%s: Memory allocation error.\n"), fname);
+\1 return 1;
+\1}
+
diff --git a/tools/api_scilab_trad/String_Matrix_Get.txt b/tools/api_scilab_trad/String_Matrix_Get.txt
new file mode 100755
index 000000000..8a46149fd
--- /dev/null
+++ b/tools/api_scilab_trad/String_Matrix_Get.txt
@@ -0,0 +1,16 @@
+\1int* piAddr\5 = NULL; //@MOVE@
+\1sciErr = getVarAddressFromPosition(pvApiCtx, \2, &piAddr\5);
+\1if (sciErr.iErr)
+\1{
+\1 printError(&sciErr, 0);
+\1 return 1;
+\1}
+
+\1// Retrieve a matrix of string at position \2.
+\1// DO NOT FORGET TO RELEASE MEMORY via freeAllocatedMatrixOfString(\3, \4, \5).
+\1if (getAllocatedMatrixOfString(pvApiCtx, piAddr\5, &\3, &\4, &\5))\6
+\1{
+\1 Scierror(202, _("%s: Wrong type for argument #%d: String matrix expected.\n"), fname, \2);
+\1 return 1;
+\1}
+
diff --git a/tools/api_scilab_trad/String_Single_Alloc.txt b/tools/api_scilab_trad/String_Single_Alloc.txt
new file mode 100755
index 000000000..24e70e824
--- /dev/null
+++ b/tools/api_scilab_trad/String_Single_Alloc.txt
@@ -0,0 +1,8 @@
+\1char* \5 = NULL; //@MOVE@
+\1// YOU MUST REMOVE YOUR VARIABLE DECLARATION "int \5".
+\1if (allocSingleString(pvApiCtx, \2, \3 * \4, &\5))\6
+\1{
+\1 Scierror(999, _("%s: Memory allocation error.\n"), fname);
+\1 return 1;
+\1}
+
diff --git a/tools/api_scilab_trad/String_Single_Create.txt b/tools/api_scilab_trad/String_Single_Create.txt
new file mode 100755
index 000000000..96a322b85
--- /dev/null
+++ b/tools/api_scilab_trad/String_Single_Create.txt
@@ -0,0 +1,6 @@
+\1if (createSingleString(pvApiCtx, \2, \5))\6
+\1{
+\1 Scierror(999, _("%s: Memory allocation error.\n"), fname);
+\1 return 1;
+\1}
+
diff --git a/tools/api_scilab_trad/String_Single_Get.txt b/tools/api_scilab_trad/String_Single_Get.txt
new file mode 100755
index 000000000..f50b5754d
--- /dev/null
+++ b/tools/api_scilab_trad/String_Single_Get.txt
@@ -0,0 +1,18 @@
+\1int* piAddr\5 = NULL; //@MOVE@
+\1char* \5 = NULL; //@MOVE@
+\1sciErr = getVarAddressFromPosition(pvApiCtx, \2, &piAddr\5);
+\1if (sciErr.iErr)
+\1{
+\1 printError(&sciErr, 0);
+\1 return 1;
+\1}
+
+\1// Retrieve a matrix of double at position \2.
+\1// YOU MUST REMOVE YOUR VARIABLE DECLARATION "int \5".
+\1// DO NOT FORGET TO RELEASE MEMORY via freeAllocatedSingleString(\5).
+\1if (getAllocatedSingleString(pvApiCtx, piAddr\5, &\5))\6
+\1{
+\1 Scierror(202, _("%s: Wrong type for argument #%d: A string expected.\n"), fname, \2);
+\1 return 1;
+\1}
+
diff --git a/tools/api_scilab_trad/Tools_Check_Column.txt b/tools/api_scilab_trad/Tools_Check_Column.txt
new file mode 100755
index 000000000..0c6642f11
--- /dev/null
+++ b/tools/api_scilab_trad/Tools_Check_Column.txt
@@ -0,0 +1,7 @@
+\1//CheckColumn
+\1if (\4 != 1)
+\1{
+\1 Scierror(999, _("%s: Wrong size for input argument #%d: A column vector expected.\n"), fname, \2);
+\1 return 1;
+\1}
+
diff --git a/tools/api_scilab_trad/Tools_Check_DimProp.txt b/tools/api_scilab_trad/Tools_Check_DimProp.txt
new file mode 100755
index 000000000..7a84701b7
--- /dev/null
+++ b/tools/api_scilab_trad/Tools_Check_DimProp.txt
@@ -0,0 +1,7 @@
+\1//CheckDimProp
+\1if (\4)
+\1{
+\1 Scierror(999, _("%s: Wrong size for input arguments: Incompatible sizes.\n"), fname);
+\1 return 1;
+\1}
+
diff --git a/tools/api_scilab_trad/Tools_Check_Dims.txt b/tools/api_scilab_trad/Tools_Check_Dims.txt
new file mode 100755
index 000000000..1fd5874c0
--- /dev/null
+++ b/tools/api_scilab_trad/Tools_Check_Dims.txt
@@ -0,0 +1,7 @@
+\1//CheckDims
+\1if (\3 != \5 || \4 != \6)
+\1{
+\1 Scierror(999, _("%s: Wrong size for input argument #%d: %d-by-%d matrix expected.\n"), fname, \2, \5, \6);
+\1 return 1;
+\1}
+
diff --git a/tools/api_scilab_trad/Tools_Check_Length.txt b/tools/api_scilab_trad/Tools_Check_Length.txt
new file mode 100755
index 000000000..c6df8c2c9
--- /dev/null
+++ b/tools/api_scilab_trad/Tools_Check_Length.txt
@@ -0,0 +1,7 @@
+\1//CheckLength
+\1if (\3 != \4)
+\1{
+\1 Scierror(999, _("%s: Wrong size for input argument #%d: %d expected.\n"), fname, \2, \3);
+\1 return 1;
+\1}
+
diff --git a/tools/api_scilab_trad/Tools_Check_OneDim.txt b/tools/api_scilab_trad/Tools_Check_OneDim.txt
new file mode 100755
index 000000000..6913196df
--- /dev/null
+++ b/tools/api_scilab_trad/Tools_Check_OneDim.txt
@@ -0,0 +1,7 @@
+\1//CheckOneDim
+\1if (\4 != \5)
+\1{
+\1 Scierror(999, _("%s: Wrong size for input arguments: Incompatible sizes.\n"), fname);
+\1 return 1;
+\1}
+
diff --git a/tools/api_scilab_trad/Tools_Check_Row.txt b/tools/api_scilab_trad/Tools_Check_Row.txt
new file mode 100755
index 000000000..b9039ab50
--- /dev/null
+++ b/tools/api_scilab_trad/Tools_Check_Row.txt
@@ -0,0 +1,7 @@
+\1//CheckRow
+\1if (\3 != 1)
+\1{
+\1 Scierror(999, _("%s: Wrong size for input argument #%d: A row vector expected.\n"), fname, \2);
+\1 return 1;
+\1}
+
diff --git a/tools/api_scilab_trad/Tools_Check_SameDims.txt b/tools/api_scilab_trad/Tools_Check_SameDims.txt
new file mode 100755
index 000000000..8a46e324d
--- /dev/null
+++ b/tools/api_scilab_trad/Tools_Check_SameDims.txt
@@ -0,0 +1,7 @@
+\1//CheckSameDims
+\1if (\4 != \6 || \5 != \7)
+\1{
+\1 Scierror(999, _("%s: Wrong size for input argument #%d: %d-by-%d matrix expected.\n"), fname, \2, \4, \5);
+\1 return 1;
+\1}
+
diff --git a/tools/api_scilab_trad/Tools_Check_Scalar.txt b/tools/api_scilab_trad/Tools_Check_Scalar.txt
new file mode 100755
index 000000000..2920f836c
--- /dev/null
+++ b/tools/api_scilab_trad/Tools_Check_Scalar.txt
@@ -0,0 +1,7 @@
+\1//CheckScalar
+\1if (\3 != 1 || \4 != 1)
+\1{
+\1 Scierror(999, _("%s: Wrong size for input argument #%d: A real scalar expected.\n"), fname, \2);
+\1 return 1;
+\1}
+
diff --git a/tools/api_scilab_trad/Tools_Check_Square.txt b/tools/api_scilab_trad/Tools_Check_Square.txt
new file mode 100755
index 000000000..bdba8bb76
--- /dev/null
+++ b/tools/api_scilab_trad/Tools_Check_Square.txt
@@ -0,0 +1,7 @@
+\1//CheckSquare
+\1if (\3 != \4)
+\1{
+\1 Scierror(999, _("%s: Wrong size for input argument #%d: A square matrix expected.\n"), fname, \2);
+\1 return 1;
+\1}
+
diff --git a/tools/api_scilab_trad/Tools_Check_Vector.txt b/tools/api_scilab_trad/Tools_Check_Vector.txt
new file mode 100755
index 000000000..f2dcb4199
--- /dev/null
+++ b/tools/api_scilab_trad/Tools_Check_Vector.txt
@@ -0,0 +1,7 @@
+\1//CheckVector
+\1if (\3 != 1 && \4 != 1)
+\1{
+\1 Scierror(999, _("%s: Wrong size for input argument #%d: Vector expected.\n"), fname, \2);
+\1 return 1;
+\1}
+
diff --git a/tools/api_scilab_trad/trad.sce b/tools/api_scilab_trad/trad.sce
new file mode 100755
index 000000000..ce4644230
--- /dev/null
+++ b/tools/api_scilab_trad/trad.sce
@@ -0,0 +1,702 @@
+// 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
+
+//trad(inputFile) -> convert inputFile in place.
+//trad(inputFile, backupFile) -> convert inputFile in place and save exiting file in backupFile
+//if backupFile is empty [] or "" use inputFile with extention .old
+
+function status = trad(inputFile, backupFile)
+ if exists("backupFile") then
+ bBackup = %t;
+ if backupFile == [] | backupFile == "" then
+ [filePath, fileName, fileExt] = fileparts(inputFile);
+ backupFile = filePath + fileName + ".old";
+ end
+
+ [fd,err] = mopen(backupFile, "a");
+ if err <> 0 then
+ error(999, msprintf(gettext("%s: Unable to create backup file ""%s""\n"), "trad", backupFile));
+ end
+ mclose(fd);
+ else
+ bBachup = %f;
+ end
+ if ~isfile(inputFile) then
+ error(msprintf("file %s not find", inputFile));
+ end
+
+ printf("\nStarting convertion of ""%s""\n\n", inputFile);
+
+ if bBackup then
+ printf("Backup in ""%s""\n", backupFile);
+ copyfile(inputFile, backupFile);
+ end
+ inputFile = pathconvert(inputFile, %f);
+ //check if astyle exist on computer
+ cmd = "astyle --pad-header --suffix=none --pad-oper --indent-col1-comments --indent-switches --add-brackets --style=bsd --formatted ";
+ if getos() == "Windows" then
+ cmd = SCI + "/tools/astyle/" + cmd + inputFile;
+ else
+ cmd = cmd + inputFile;
+ end
+
+ host(cmd);
+ src = mgetl(inputFile);
+
+ result = src;
+ result = sed(result, "/CheckRhs\((.*), (.*)\)(.*)/", "CheckInputArgument(pvApiCtx, \1, \2)\3");
+ result = sed(result, "/CheckLhs\((.*), (.*)\)(.*)/", "CheckOutputArgument(pvApiCtx, \1, \2)\3");
+ result = sed(result, "/PutLhsVar\(\)(.*)/", "ReturnArguments(pvApiCtx)\1");
+
+
+ printf("Header operations");
+ //add api_scilab include
+ index = grep(result, "/#include [""<]api_scilab.h["">]/", "r");
+ if index == [] then
+ //try to replace #include "stack*.h" to #include "api_scilab.h"
+ result = sed(result, "/#include ""stack(.*).h""/", "#include ""api_scilab.h""");
+
+ //remove all #include "api_scilab.h" but one
+ index = grep(result, "/#include [""<]api_scilab.h["">]/", "r");
+ if size(index, "*") > 1 then
+ result(index(2:$)) = [];
+ end
+ end
+
+ //add localization header
+ index = grep(result, "/#include [""<]localization.h[""<]/", "r");
+ if index == [] then
+ index = grep(result, "/#include [""<]api_scilab.h["">]/", "r");
+ result = [result(1:index) ; "#include ""localization.h""" ; result((index+1):$)];
+ end
+
+ //add Scierror header
+ index = grep(result, "/#include [""<]Scierror.h[""<]/", "r");
+ if index == [] then
+ index = grep(result, "/#include [""<]api_scilab.h["">]/", "r");
+ result = [result(1:index) ; "#include ""Scierror.h""" ; result((index+1):$)];
+ end
+
+ printf(":\tOK\n");
+
+
+ //add SciErr sciErr declaration
+ index = grep(result, "SciErr sciErr;");
+ if index == [] then
+ //find gateway prototype and add declaration 2 lines lower
+ index = grep(result, "/int ([C2F\(]?.*[\)]?)\(([\s]*)char(.*), unsigned long (.*)\)/", "r");
+ if index <> [] then
+ for i = 1:size(index, "*")
+ result = [result(1 : (index(i) + 1)); " SciErr sciErr;"; result((index(i) + 2):$)];
+ end
+ else
+ error(999, msprintf(gettext("%s: unable to find gateway prototype in file %s"), "trad", inputFile));
+ end
+ end
+
+ //double
+ printf("Double operations");
+ result = GetDouble(result);
+ result = AllocDouble(result)
+ result = CreateDouble(result);
+ result = GetDoubleComplex(result);
+ result = AllocDoubleComplex(result)
+ result = CreateDoubleComplex(result);
+ printf(":\tOK\n");
+
+ //string
+ printf("String operations");
+ result = GetSingleString(result);
+ result = GetStringMatrix(result);
+ result = AllocSingleString(result);
+ result = CreateSingleString(result);
+ result = CreateStringMatrix(result);
+ printf(":\tOK\n");
+
+ //bool
+ printf("Boolean operations");
+ result = GetBoolMatrix(result);
+ result = AllocBoolMatrix(result);
+ result = CreateBoolMatrix(result);
+ printf(":\tOK\n");
+
+ //pointer
+ printf("Pointer operations");
+ result = GetPointer(result)
+ result = CreatePointer(result)
+ result = AllocPointer(result)
+ printf(":\tOK\n");
+
+ //handle
+ printf("Handle operations");
+ result = GetHandleMatrix(result)
+ result = CreateHandleMatrix(result)
+ result = AllocHandleMatrix(result)
+ printf(":\tOK\n");
+
+ //tools
+ printf("Tool operations");
+ result = replaceCheckScalar(result);
+ result = replaceCheckSquare(result);
+ result = replaceCheckVector(result);
+ result = replaceCheckRow(result);
+ result = replaceCheckColumn(result);
+ result = replaceCheckDims(result);
+ result = replaceCheckLength(result);
+ result = replaceCheckSameDims(result);
+ result = replaceCheckDimProp(result);
+ result = replaceCheckOneDim(result);
+ printf(":\tOK\n");
+
+ result = replaceVarType(result);
+ result = replaceGetType(result);
+
+ result = sed(result, "/LhsVar\((.*)\) = (.*);/", "AssignOutputVariable(pvApiCtx, \1) = \2;");
+ result = sed(result, "/ Rhs /", " nbInputArgument(pvApiCtx) ");
+ result = sed(result, "/\(Rhs([ ,])/", "(nbInputArgument(pvApiCtx)\1");
+ result = sed(result, "/ Lhs /", " nbOutputArgument(pvApiCtx) ");
+ result = sed(result, "/\(Lhs([ ,])/", "(nbOutputArgument(pvApiCtx)\1");
+
+
+ printf("Move declarations");
+
+ index = grep(result, "//@MOVE@");
+
+ dec = result(index);
+ dec = strsubst(dec, " //@MOVE@", "");
+ dec = ["";
+ "//WARNING ALL NEW DECALRATIONS ARE HERE IF YOUR HAVE MANY FUNCTIONS";
+ "//IN THE FILE YOU HAVE PROBABLY TO MOVE DECLARATIONS IN GOOD FUNCTIONS";
+ dec];
+ result(index) = [];
+
+ sciErrPos = grep(result, "SciErr sciErr;");
+ result = [result(1:sciErrPos) ; dec ; "" ; result(sciErrPos+1:$)];
+ printf("\nConvertion finished\n");
+ mputl(result, inputFile);
+
+ //call astyle again
+ host(cmd);
+
+ status = %t;
+endfunction
+
+
+function result = sed(str, findExp, replaceExp)
+
+ result = str;
+ index = grep(result, findExp, "r");
+ while index <> []
+ idx = index(1);
+ [startPos, endPos, match, captured] = regexp(result(idx), findExp);
+
+ if captured <> [] then
+ //multiple matches on the same line, YOUHOU !
+ for i=1:size(captured, "r")
+ replace = replaceExp;
+ for j = 1:size(captured, "c")
+ replace = strsubst(replace, "\" + string(j), captured(i,j));
+ end
+
+ if size(replace, "*") > 1 & (startPos <> 1 | endPos <> length(result(idx))) then
+ //replace partial line by multiline expression
+ replace(1) = part(result(idx), 1:startPos) + " " + replace(1);
+ replace($) = replace($) + " " + part(result(idx), (endPos+1):length(result(idx)));
+
+ result = [result(1:(idx-1)); replace; result((idx+1):$)];
+ elseif size(replace, "*") > 1 then
+ //replace entire line by multiline expression
+ result = [result(1:(idx-1)); replace; result((idx+1):$)];
+ else
+ //replace partial line by 1-line expression
+ result(idx) = strsubst(result(idx), match(i), replace);
+ end
+ end
+ end
+
+ //update index with new "file"
+ index = grep(result, findExp, "r");
+ end
+endfunction
+
+//double
+function result = GetDouble(str)
+ replaceExp = mgetl("SCI/tools/api_scilab_trad/Double_Matrix_Get.txt");
+ findExp = "/([\s]*)GetRhsVar\([\s]*(.*)[\s]*,[\s]*MATRIX_OF_DOUBLE_DATATYPE[\s]*,[\s]*&(.*)[\s]*,[\s]*&(.*)[\s]*,[\s]*&([\S]*)[\s]*\);(.*)/";
+
+ result = commonDouble(str, findExp, replaceExp);
+
+ replaceExp = mgetl("SCI/tools/api_scilab_trad/Double_Matrix_GetAsInteger.txt");
+ findExp = "/([\s]*)GetRhsVar\([\s]*(.*)[\s]*,[\s]*MATRIX_OF_INTEGER_DATATYPE[\s]*,[\s]*&(.*)[\s]*,[\s]*&(.*)[\s]*,[\s]*&([\S]*)[\s]*\);(.*)/";
+
+ result = commonDouble(result, findExp, replaceExp);
+endfunction
+
+function result = CreateDouble(str)
+ replaceExp = mgetl("SCI/tools/api_scilab_trad/Double_Matrix_Create.txt");
+ findExp = "/([\s]*)CreateVarFromPtr\([\s]*(.*)[\s]*,[\s]*MATRIX_OF_DOUBLE_DATATYPE[\s]*,[\s]*&(.*)[\s]*,[\s]*&(.*)[\s]*,[\s]*&([\S]*)[\s]*\);(.*)/";
+
+ result = commonDouble(str, findExp, replaceExp);
+
+ replaceExp = mgetl("SCI/tools/api_scilab_trad/Double_Matrix_CreateAsInteger.txt");
+ findExp = "/([\s]*)CreateVarFromPtr\([\s]*(.*)[\s]*,[\s]*MATRIX_OF_INTEGER_DATATYPE[\s]*,[\s]*&(.*)[\s]*,[\s]*&(.*)[\s]*,[\s]*&([\S]*)[\s]*\);(.*)/";
+
+ result = commonDouble(result, findExp, replaceExp);
+endfunction
+
+function result = AllocDouble(str)
+ replaceExp = mgetl("SCI/tools/api_scilab_trad/Double_Matrix_Alloc.txt");
+ findExp = "/([\s]*)CreateVar\([\s]*(.*)[\s]*,[\s]*MATRIX_OF_DOUBLE_DATATYPE[\s]*,[\s]*&(.*)[\s]*,[\s]*&(.*)[\s]*,[\s]*&([\S]*)[\s]*\);(.*)/";
+
+ result = commonDouble(str, findExp, replaceExp);
+
+ replaceExp = mgetl("SCI/tools/api_scilab_trad/Double_Matrix_AllocAsInteger.txt");
+ findExp = "/([\s]*)CreateVar\([\s]*(.*)[\s]*,[\s]*MATRIX_OF_INTEGER_DATATYPE[\s]*,[\s]*&(.*)[\s]*,[\s]*&(.*)[\s]*,[\s]*&([\S]*)[\s]*\);(.*)/";
+
+ result = commonDouble(result, findExp, replaceExp);
+endfunction
+
+function result = commonDouble(str, findExp, replaceExp)
+ result = str;
+ index = grep(result, findExp, "r");
+ while index <> []
+ i = index(1);
+ [start, end, match, captured] = regexp(result(i), findExp);
+ replace = replaceExp;
+
+ if size(captured, "c") >= 5 then
+ //try to replace (i)stk(\5*) by (\5*).
+ if captured(5) <> "" then
+ //hstk(\5*) -> (long long*)(\5*)
+ result = sed(result, "/hstk\(" + captured(5) + "(.*[^)]?)\)/", "(long long*)(" + captured(5) + "\1)");
+ result = sed(result, "/istk\(" + captured(5) + "(.*[^)]?)\)/", "(int*)(" + captured(5) + "\1)");
+ result = sed(result, "/[^(csz]?stk\(" + captured(5) + "(.*[^)]?)\)/", "(" + captured(5) + "\1)");
+ end
+ end
+
+ for j = 1:size(captured, "c")
+ replace = strsubst(replace, "\" + string(j), captured(j));
+ end
+
+ if size(replace, "*") > 1 then
+ result = [result(1:(i-1)); replace; result((i+1):$)];
+ else
+ result(i) = strsubst(str(i), match, replace);
+ end
+
+ index = grep(result, findExp, "r");
+end
+endfunction
+
+function result = GetDoubleComplex(str)
+ //MATRIX_OF_DOUBLE_DATATYPE
+ replaceExp = mgetl("SCI/tools/api_scilab_trad/DoubleComplex_Matrix_Get.txt");
+ findExp = "/([\s]*)GetRhsCVar\([\s]*(.*)[\s]*,[\s]*MATRIX_OF_DOUBLE_DATATYPE[\s]*,[\s]*&(.*)[\s]*,[\s]*&(.*)[\s]*,[\s]*&(.*)[\s]*,[\s]*&([\S]*)[\s]*[\s]*,[\s]*&([\S]*)[\s]*\);(.*)/";
+
+ result = commonDoubleComplex(str, findExp, replaceExp);
+
+ //MATRIX_OF_INTEGER_DATATYPE
+ replaceExp = mgetl("SCI/tools/api_scilab_trad/DoubleComplex_Matrix_GetAsInteger.txt");
+ findExp = "/([\s]*)GetRhsCVar\([\s]*(.*)[\s]*,[\s]*MATRIX_OF_INTEGER_DATATYPE[\s]*,[\s]*&(.*)[\s]*,[\s]*&(.*)[\s]*,[\s]*&(.*)[\s]*,[\s]*&([\S]*)[\s]*[\s]*,[\s]*&([\S]*)[\s]*\);(.*)/";
+
+ result = commonDoubleComplex(result, findExp, replaceExp);
+endfunction
+
+function result = CreateDoubleComplex(str)
+ replaceExp = mgetl("SCI/tools/api_scilab_trad/DoubleComplex_Matrix_Create.txt");
+ findExp = "/([\s]*)CreateCVarFromPtr\([\s]*(.*)[\s]*,[\s]*MATRIX_OF_DOUBLE_DATATYPE[\s]*,[\s]*&(.*)[\s]*,[\s]*&(.*)[\s]*,[\s]*&(.*)[\s]*,[\s]*&([\S]*)[\s]*[\s]*,[\s]*&([\S]*)[\s]*\);(.*)/";
+
+ result = commonDoubleComplex(str, findExp, replaceExp);
+
+ replaceExp = mgetl("SCI/tools/api_scilab_trad/DoubleComplex_Matrix_CreateAsInteger.txt");
+ findExp = "/([\s]*)CreateCVarFromPtr\([\s]*(.*)[\s]*,[\s]*MATRIX_OF_INTEGER_DATATYPE[\s]*,[\s]*&(.*)[\s]*,[\s]*&(.*)[\s]*,[\s]*&(.*)[\s]*,[\s]*&([\S]*)[\s]*,[\s]*&([\S]*)[\s]*\);(.*)/";
+
+ result = commonDoubleComplex(result, findExp, replaceExp);
+endfunction
+
+function result = AllocDoubleComplex(str)
+ replaceExp = mgetl("SCI/tools/api_scilab_trad/DoubleComplex_Matrix_Alloc.txt");
+ findExp = "/([\s]*)CreateCVar\([\s]*(.*)[\s]*,[\s]*MATRIX_OF_DOUBLE_DATATYPE[\s]*,[\s]*&(.*)[\s]*,[\s]*&(.*)[\s]*,[\s]*&(.*)[\s]*,[\s]*&([\S]*)[\s]*,[\s]*&([\S]*)[\s]*\);(.*)/";
+
+ result = commonDoubleComplex(str, findExp, replaceExp);
+
+ replaceExp = mgetl("SCI/tools/api_scilab_trad/DoubleComplex_Matrix_AllocAsInteger.txt");
+ findExp = "/([\s]*)CreateCVar\([\s]*(.*)[\s]*,[\s]*MATRIX_OF_INTEGER_DATATYPE[\s]*,[\s]*&(.*)[\s]*,[\s]*&(.*)[\s]*,[\s]*&(.*)[\s]*,[\s]*&([\S]*)[\s]*,[\s]*&([\S]*)[\s]*\);(.*)/";
+
+ result = commonDoubleComplex(result, findExp, replaceExp);
+endfunction
+
+function result = commonDoubleComplex(str, findExp, replaceExp)
+ result = str;
+ index = grep(result, findExp, "r");
+ while index <> []
+ i = index(1);
+ [start, end, match, captured] = regexp(result(i), findExp);
+ replace = replaceExp;
+
+ if size(captured, "c") >= 6 then
+ //try to replace stk(\6*) by (\6*).
+ if captured(6) <> "" then
+ result = sed(result, "/hstk\(" + captured(5) + "(.*[^)]?)\)/", "(long long*)(" + captured(5) + "\1)");
+ result = sed(result, "/istk\(" + captured(5) + "(.*[^)]?)\)/", "(int*)(" + captured(5) + "\1)");
+ result = sed(result, "/[^(csz]?stk\(" + captured(5) + "(.*[^)]?)\)/", "(" + captured(5) + "\1)");
+ end
+ end
+
+ if size(captured, "c") >= 7 then
+ //try to replace stk(\7*) by (\7*).
+ if captured(7) <> "" then
+ result = sed(result, "/hstk\(" + captured(7) + "(.*[^)]?)\)/", "(long long*)(" + captured(7) + "\1)");
+ result = sed(result, "/istk\(" + captured(7) + "(.*[^)]?)\)/", "(int*)(" + captured(7) + "\1)");
+ result = sed(result, "/[^(csz]?stk\(" + captured(7) + "(.*[^)]?)\)/", "(" + captured(7) + "\1)");
+ end
+ end
+
+ for j = 1:size(captured, "c")
+ replace = strsubst(replace, "\" + string(j), captured(j));
+ end
+
+ if size(replace, "*") > 1 then
+ result = [result(1:(i-1)); replace; result((i+1):$)];
+ else
+ result(i) = strsubst(str(i), match, replace);
+ end
+
+ index = grep(result, findExp, "r");
+end
+endfunction
+
+
+//string
+function result = GetSingleString(str)
+ replaceExp = mgetl("SCI/tools/api_scilab_trad/String_Single_Get.txt");
+ findExp = "/([\s]*)GetRhsVar\([\s]*(.*)[\s]*,[\s]*STRING_DATATYPE[\s]*,[\s]*&(.*)[\s]*,[\s]*&(.*)[\s]*,[\s]*&([\S]*)[\s]*\);(.*)/";
+
+ result = commonString(str, findExp, replaceExp);
+endfunction
+
+function result = GetStringMatrix(str)
+ replaceExp = mgetl("SCI/tools/api_scilab_trad/String_Matrix_Get.txt");
+ findExp = "/([\s]*)GetRhsVar\([\s]*(.*)[\s]*,[\s]*MATRIX_OF_STRING_DATATYPE[\s]*,[\s]*&(.*)[\s]*,[\s]*&(.*)[\s]*,[\s]*&([\S]*)[\s]*\);(.*)/";
+
+ result = commonString(str, findExp, replaceExp);
+endfunction
+
+function result = AllocSingleString(str)
+ replaceExp = mgetl("SCI/tools/api_scilab_trad/String_Single_Alloc.txt");
+ findExp = "/([\s]*)CreateVar\([\s]*(.*)[\s]*,[\s]*STRING_DATATYPE[\s]*,[\s]*&(.*)[\s]*,[\s]*&(.*)[\s]*,[\s]*&([\S]*)[\s]*\);(.*)/";
+
+ result = commonString(str, findExp, replaceExp);
+endfunction
+
+function result = CreateSingleString(str)
+ replaceExp = mgetl("SCI/tools/api_scilab_trad/String_Single_Create.txt");
+ findExp = "/([\s]*)CreateVarFromPtr\([\s]*(.*)[\s]*,[\s]*STRING_DATATYPE[\s]*,[\s]*&(.*)[\s]*,[\s]*&(.*)[\s]*,[\s]*&([\S]*)[\s]*\);(.*)/";
+
+ result = commonString(str, findExp, replaceExp);
+endfunction
+
+function result = CreateStringMatrix(str)
+ replaceExp = mgetl("SCI/tools/api_scilab_trad/String_Matrix_Create.txt");
+ findExp = "/([\s]*)CreateVarFromPtr\([\s]*(.*)[\s]*,[\s]*MATRIX_OF_STRING_DATATYPE[\s]*,[\s]*&(.*)[\s]*,[\s]*&(.*)[\s]*,[\s]*&([\S]*)[\s]*\);(.*)/";
+
+ result = commonString(str, findExp, replaceExp);
+endfunction
+
+function result = commonString(str, findExp, ReplaceExp)
+ result = str;
+ index = grep(result, findExp, "r");
+ while index <> []
+ i = index(1);
+ [start, end, match, captured] = regexp(result(i), findExp);
+ replace = replaceExp;
+
+ if size(captured, "c") >= 5 then
+ //try to replace stk(\5*) by (\5*).
+ if captured(5) <> "" then
+ result = sed(result, "/cstk\(" + captured(5) + "(.*[^)]?)\)/", "(" + captured(5) + "\1)");
+ end
+ end
+
+ for j = 1:size(captured, "c")
+ replace = strsubst(replace, "\" + string(j), captured(j));
+ end
+
+ if size(replace, "*") > 1 then
+ result = [result(1:(i-1)); replace; result((i+1):$)];
+ else
+ result(i) = strsubst(str(i), match, replace);
+ end
+
+ index = grep(result, findExp, "r");
+end
+endfunction
+
+//////////////
+// bool //
+//////////////
+function result = GetBoolMatrix(str)
+ replaceExp = mgetl("SCI/tools/api_scilab_trad/Bool_Matrix_Get.txt");
+ findExp = "/([\s]*)GetRhsVar\([\s]*(.*)[\s]*,[\s]*MATRIX_OF_BOOLEAN_DATATYPE[\s]*,[\s]*&(.*)[\s]*,[\s]*&(.*)[\s]*,[\s]*&([\S]*)[\s]*\);(.*)/";
+
+ result = commonBool(str, findExp, replaceExp);
+endfunction
+
+function result = AllocBoolMatrix(str)
+ replaceExp = mgetl("SCI/tools/api_scilab_trad/Bool_Matrix_Alloc.txt");
+ findExp = "/([\s]*)CreateVar\([\s]*(.*)[\s]*,[\s]*MATRIX_OF_BOOLEAN_DATATYPE[\s]*,[\s]*&(.*)[\s]*,[\s]*&(.*)[\s]*,[\s]*&([\S]*)[\s]*\);(.*)/";
+
+ result = commonBool(str, findExp, replaceExp);
+endfunction
+
+function result = CreateBoolMatrix(str)
+ replaceExp = mgetl("SCI/tools/api_scilab_trad/Bool_Matrix_Create.txt");
+ findExp = "/([\s]*)CreateVarFromPtr\([\s]*(.*)[\s]*,[\s]*MATRIX_OF_BOOLEAN_DATATYPE[\s]*,[\s]*&(.*)[\s]*,[\s]*&(.*)[\s]*,[\s]*&([\S]*)[\s]*\);(.*)/";
+
+ result = commonBool(str, findExp, replaceExp);
+endfunction
+
+function result = commonBool(str, findExp, ReplaceExp)
+ result = str;
+ index = grep(result, findExp, "r");
+ while index <> []
+ i = index(1);
+ [start, end, match, captured] = regexp(result(i), findExp);
+ replace = replaceExp;
+
+ if size(captured, "c") >= 5 then
+ //try to replace stk(\5*) by (\5*).
+ if captured(5) <> "" then
+ result = sed(result, "/istk\(" + captured(5) + "(.*[^)]?)\)/", "(" + captured(5) + "\1)");
+ end
+ end
+
+ for j = 1:size(captured, "c")
+ replace = strsubst(replace, "\" + string(j), captured(j));
+ end
+
+ if size(replace, "*") > 1 then
+ result = [result(1:(i-1)); replace; result((i+1):$)];
+ else
+ result(i) = strsubst(str(i), match, replace);
+ end
+
+ index = grep(result, findExp, "r");
+end
+endfunction
+
+/////////////////
+// pointer //
+/////////////////
+function result = GetPointer(str)
+ replaceExp = mgetl("SCI/tools/api_scilab_trad/Pointer_Get.txt");
+ findExp = "/([\s]*)GetRhsVar\([\s]*(.*)[\s]*,[\s]*SCILAB_POINTER_DATATYPE[\s]*,[\s]*&(.*)[\s]*,[\s]*&(.*)[\s]*,[\s]*&([\S]*)[\s]*\);(.*)/";
+
+ result = commonPointer(str, findExp, replaceExp);
+endfunction
+
+function result = CreatePointer(str)
+ replaceExp = mgetl("SCI/tools/api_scilab_trad/Pointer_Create.txt");
+ findExp = "/([\s]*)CreateVarFromPtr\([\s]*(.*)[\s]*,[\s]*SCILAB_POINTER_DATATYPE[\s]*,[\s]*&(.*)[\s]*,[\s]*&(.*)[\s]*,[\s]*([\S]*)[\s]*\);(.*)/";
+
+ result = commonPointer(str, findExp, replaceExp);
+endfunction
+
+function result = AllocPointer(str)
+ replaceExp = mgetl("SCI/tools/api_scilab_trad/Pointer_Alloc.txt");
+ findExp = "/([\s]*)CreateVar\([\s]*(.*)[\s]*,[\s]*SCILAB_POINTER_DATATYPE[\s]*,[\s]*&(.*)[\s]*,[\s]*&(.*)[\s]*,[\s]*&([\S]*)[\s]*\);(.*)/";
+
+ result = commonPointer(str, findExp, replaceExp);
+endfunction
+
+function result = commonPointer(str, findExp, ReplaceExp)
+ result = str;
+ index = grep(result, findExp, "r");
+ while index <> []
+ i = index(1);
+ [start, end, match, captured] = regexp(result(i), findExp);
+ replace = replaceExp;
+
+ if size(captured, "c") >= 5 then
+ //try to replace stk(\5*) by (\5*).
+ if captured(5) <> "" then
+ result = sed(result, "/[^(cisz]?stk\(" + captured(5) + "(.*[^)]?)\)/", "(" + captured(5) + "\1)");
+ end
+ end
+
+ for j = 1:size(captured, "c")
+ replace = strsubst(replace, "\" + string(j), captured(j));
+ end
+
+ if size(replace, "*") > 1 then
+ result = [result(1:(i-1)); replace; result((i+1):$)];
+ else
+ result(i) = strsubst(str(i), match, replace);
+ end
+
+ index = grep(result, findExp, "r");
+end
+endfunction
+
+////////////////
+// handle //
+////////////////
+function result = GetHandleMatrix(str)
+ replaceExp = mgetl("SCI/tools/api_scilab_trad/Handle_Matrix_Get.txt");
+ findExp = "/([\s]*)GetRhsVar\([\s]*(.*)[\s]*,[\s]*GRAPHICAL_HANDLE_DATATYPE[\s]*,[\s]*&(.*)[\s]*,[\s]*&(.*)[\s]*,[\s]*&([\S]*)[\s]*\);(.*)/";
+
+ result = commonHandle(str, findExp, replaceExp);
+endfunction
+
+function result = CreateHandleMatrix(str)
+ replaceExp = mgetl("SCI/tools/api_scilab_trad/Handle_Matrix_Create.txt");
+ findExp = "/([\s]*)CreateVarFromPtr\([\s]*(.*)[\s]*,[\s]*GRAPHICAL_HANDLE_DATATYPE[\s]*,[\s]*&(.*)[\s]*,[\s]*&(.*)[\s]*,[\s]*([\S]*)[\s]*\);(.*)/";
+
+ result = commonHandle(str, findExp, replaceExp);
+endfunction
+
+function result = AllocHandleMatrix(str)
+ replaceExp = mgetl("SCI/tools/api_scilab_trad/Handle_Matrix_Alloc.txt");
+ findExp = "/([\s]*)CreateVar\([\s]*(.*)[\s]*,[\s]*GRAPHICAL_HANDLE_DATATYPE[\s]*,[\s]*&(.*)[\s]*,[\s]*&(.*)[\s]*,[\s]*&([\S]*)[\s]*\);(.*)/";
+
+ result = commonHandle(str, findExp, replaceExp);
+endfunction
+
+function result = commonHandle(str, findExp, ReplaceExp)
+ result = str;
+ index = grep(result, findExp, "r");
+ while index <> []
+ i = index(1);
+ [start, end, match, captured] = regexp(result(i), findExp);
+ replace = replaceExp;
+
+ if size(captured, "c") >= 5 then
+ //try to replace stk(\5*) by (\5*).
+ if captured(5) <> "" then
+ result = sed(result, "/[h]?stk\(" + captured(5) + "(.*[^)]?)\)/", "(" + captured(5) + "\1)");
+ end
+ end
+
+ for j = 1:size(captured, "c")
+ replace = strsubst(replace, "\" + string(j), captured(j));
+ end
+
+ if size(replace, "*") > 1 then
+ result = [result(1:(i-1)); replace; result((i+1):$)];
+ else
+ result(i) = strsubst(str(i), match, replace);
+ end
+
+ index = grep(result, findExp, "r");
+end
+endfunction
+
+///////////////
+// tools //
+///////////////
+function result = replaceCheckScalar(str)
+ replaceExp = mgetl("SCI/tools/api_scilab_trad/Tools_Check_Scalar.txt");
+ findExp = "/([\s]*)CheckScalar\([\s]*(.*)[\s]*,[\s]*(.*)[\s]*,[\s]*(.*)\);/";
+
+ result = sed(str, findExp, replaceExp);
+endfunction
+
+function result = replaceCheckSquare(str)
+ replaceExp = mgetl("SCI/tools/api_scilab_trad/Tools_Check_Square.txt");
+ findExp = "/([\s]*)CheckSquare\([\s]*(.*)[\s]*,[\s]*(.*)[\s]*,[\s]*(.*)\);/";
+
+ result = sed(str, findExp, replaceExp);
+endfunction
+
+function result = replaceCheckVector(str)
+ replaceExp = mgetl("SCI/tools/api_scilab_trad/Tools_Check_Vector.txt");
+ findExp = "/([\s]*)CheckVector\([\s]*(.*)[\s]*,[\s]*(.*)[\s]*,[\s]*(.*)\);/";
+
+ result = sed(str, findExp, replaceExp);
+endfunction
+
+function result = replaceCheckRow(str)
+ replaceExp = mgetl("SCI/tools/api_scilab_trad/Tools_Check_Row.txt");
+ findExp = "/([\s]*)CheckRow\([\s]*(.*)[\s]*,[\s]*(.*)[\s]*,[\s]*(.*)\);/";
+
+ result = sed(str, findExp, replaceExp);
+endfunction
+
+function result = replaceCheckColumn(str)
+ replaceExp = mgetl("SCI/tools/api_scilab_trad/Tools_Check_Column.txt");
+ findExp = "/([\s]*)CheckColumn\([\s]*(.*)[\s]*,[\s]*(.*)[\s]*,[\s]*(.*)\);/";
+
+ result = sed(str, findExp, replaceExp);
+endfunction
+
+function result = replaceCheckDims(str)
+ replaceExp = mgetl("SCI/tools/api_scilab_trad/Tools_Check_Dims.txt");
+ findExp = "/([\s]*)CheckDims\([\s]*(.*)[\s]*,[\s]*(.*)[\s]*,[\s]*(.*)[\s]*,[\s]*(.*)[\s]*,[\s]*(.*)\);/";
+
+ result = sed(str, findExp, replaceExp);
+endfunction
+
+function result = replaceCheckLength(str)
+ replaceExp = mgetl("SCI/tools/api_scilab_trad/Tools_Check_Length.txt");
+ findExp = "/([\s]*)CheckLength\([\s]*(.*)[\s]*,[\s]*(.*)[\s]*,[\s]*(.*)\);/";
+
+ result = sed(str, findExp, replaceExp);
+endfunction
+
+function result = replaceCheckSameDims(str)
+ replaceExp = mgetl("SCI/tools/api_scilab_trad/Tools_Check_SameDims.txt");
+ findExp = "/([\s]*)CheckSameDims\([\s]*(.*)[\s]*,[\s]*(.*)[\s]*,[\s]*(.*)[\s]*,[\s]*(.*)[\s]*,[\s]*(.*)[\s]*,[\s]*(.*)\);/";
+
+ result = sed(str, findExp, replaceExp);
+endfunction
+
+function result = replaceCheckDimProp(str)
+ replaceExp = mgetl("SCI/tools/api_scilab_trad/Tools_Check_DimProp.txt");
+ findExp = "/([\s]*)CheckDimProp\([\s]*(.*)[\s]*,[\s]*(.*)[\s]*,[\s]*(.*)\);/";
+
+ result = sed(str, findExp, replaceExp);
+endfunction
+
+function result = replaceCheckOneDim(str)
+ replaceExp = mgetl("SCI/tools/api_scilab_trad/Tools_Check_OneDim.txt");
+ findExp = "/([\s]*)CheckOneDim\([\s]*(.*)[\s]*,[\s]*(.*)[\s]*,[\s]*(.*)[\s]*,[\s]*(.*)\);/";
+
+ result = sed(str, findExp, replaceExp);
+endfunction
+
+function result = replaceVarType(str)
+ result = str
+
+ //three cases
+ //first
+ //VarType(x) == sci_xx
+ result = sed(result, "/[\s]*VarType\([\s]*(.*)[\s]*\)[\s]*==[\s]*([^);]*)[\s]*/", "(checkInputArgumentType(pvApiCtx, \1, \2))");
+ //second
+ //VarType(x) != sci_xx
+ result = sed(result, "/[\s]*VarType\([\s]*(.*)[\s]*\)[\s]*!=[\s]*([^);]*)[\s]*/", "(!checkInputArgumentType(pvApiCtx, \1, \2))");
+ //third
+ //VarType(x)
+ result = sed(result, "/VarType\([\s]*(.*)[\s]*\)/", "getInputArgumentType(pvApiCtx, \1)");
+endfunction
+
+function result = replaceGetType(str)
+ result = str
+ //three cases
+ //first
+ //GetType(x) == sci_xx
+ result = sed(result, "/[\s]*GetType\([\s]*(.*)[\s]*\)[\s]*==[\s]*([^);]*)[\s^)]*/", "checkInputArgumentType(pvApiCtx, \1, \2)");
+ //second
+ //GetType(x) != sci_xx
+ result = sed(result, "/[\s]*GetType\([\s]*(.*)[\s]*\)[\s]*!=[\s]*([^);]*)[\s^)]*/", "(!checkInputArgumentType(pvApiCtx, \1, \2))");
+ //third
+ //GetType(x)
+ result = sed(result, "/GetType\((.*)\)/", "getInputArgumentType(pvApiCtx, \1)");
+endfunction
+
+