diff options
Diffstat (limited to 'modules/javasci/src/c')
-rwxr-xr-x | modules/javasci/src/c/.deps/.dirstamp | 0 | ||||
-rwxr-xr-x | modules/javasci/src/c/.deps/libjavasci2_la-javasci2_helper.Plo | 271 | ||||
-rwxr-xr-x | modules/javasci/src/c/.dirstamp | 0 | ||||
-rwxr-xr-x | modules/javasci/src/c/.libs/libjavasci2_la-javasci2_helper.o | bin | 0 -> 51456 bytes | |||
-rwxr-xr-x | modules/javasci/src/c/DllmainJavasci.c | 33 | ||||
-rwxr-xr-x | modules/javasci/src/c/javasci2_helper.c | 623 | ||||
-rwxr-xr-x | modules/javasci/src/c/javasci2_helper.h | 403 | ||||
-rwxr-xr-x | modules/javasci/src/c/libjavasci2_la-javasci2_helper.lo | 12 |
8 files changed, 1342 insertions, 0 deletions
diff --git a/modules/javasci/src/c/.deps/.dirstamp b/modules/javasci/src/c/.deps/.dirstamp new file mode 100755 index 000000000..e69de29bb --- /dev/null +++ b/modules/javasci/src/c/.deps/.dirstamp diff --git a/modules/javasci/src/c/.deps/libjavasci2_la-javasci2_helper.Plo b/modules/javasci/src/c/.deps/libjavasci2_la-javasci2_helper.Plo new file mode 100755 index 000000000..f972c4ab4 --- /dev/null +++ b/modules/javasci/src/c/.deps/libjavasci2_la-javasci2_helper.Plo @@ -0,0 +1,271 @@ +src/c/libjavasci2_la-javasci2_helper.lo: src/c/javasci2_helper.c \ + /usr/include/stdc-predef.h /usr/include/stdlib.h /usr/include/features.h \ + /usr/include/x86_64-linux-gnu/sys/cdefs.h \ + /usr/include/x86_64-linux-gnu/bits/wordsize.h \ + /usr/include/x86_64-linux-gnu/gnu/stubs.h \ + /usr/include/x86_64-linux-gnu/gnu/stubs-64.h \ + /usr/lib/gcc/x86_64-linux-gnu/5/include/stddef.h \ + /usr/include/x86_64-linux-gnu/bits/waitflags.h \ + /usr/include/x86_64-linux-gnu/bits/waitstatus.h /usr/include/endian.h \ + /usr/include/x86_64-linux-gnu/bits/endian.h \ + /usr/include/x86_64-linux-gnu/bits/byteswap.h \ + /usr/include/x86_64-linux-gnu/bits/types.h \ + /usr/include/x86_64-linux-gnu/bits/typesizes.h \ + /usr/include/x86_64-linux-gnu/bits/byteswap-16.h \ + /usr/include/x86_64-linux-gnu/sys/types.h /usr/include/time.h \ + /usr/include/x86_64-linux-gnu/sys/select.h \ + /usr/include/x86_64-linux-gnu/bits/select.h \ + /usr/include/x86_64-linux-gnu/bits/sigset.h \ + /usr/include/x86_64-linux-gnu/bits/time.h \ + /usr/include/x86_64-linux-gnu/bits/select2.h \ + /usr/include/x86_64-linux-gnu/sys/sysmacros.h \ + /usr/include/x86_64-linux-gnu/bits/pthreadtypes.h /usr/include/alloca.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib-float.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib.h /usr/include/string.h \ + /usr/include/xlocale.h /usr/include/x86_64-linux-gnu/bits/string.h \ + /usr/include/x86_64-linux-gnu/bits/string2.h \ + /usr/include/x86_64-linux-gnu/bits/string3.h src/c/javasci2_helper.h \ + ../../modules/core/includes/BOOL.h \ + ../../modules/core/includes/sci_types.h \ + ../../modules/api_scilab/includes/api_scilab.h \ + ../../modules/core/includes/stack-c.h \ + ../../modules/core/includes/core_math.h \ + /usr/lib/gcc/x86_64-linux-gnu/5/include-fixed/limits.h \ + /usr/lib/gcc/x86_64-linux-gnu/5/include-fixed/syslimits.h \ + /usr/include/limits.h /usr/include/x86_64-linux-gnu/bits/posix1_lim.h \ + /usr/include/x86_64-linux-gnu/bits/local_lim.h \ + /usr/include/linux/limits.h \ + /usr/include/x86_64-linux-gnu/bits/posix2_lim.h /usr/include/math.h \ + /usr/include/x86_64-linux-gnu/bits/math-vector.h \ + /usr/include/x86_64-linux-gnu/bits/libm-simd-decl-stubs.h \ + /usr/include/x86_64-linux-gnu/bits/huge_val.h \ + /usr/include/x86_64-linux-gnu/bits/huge_valf.h \ + /usr/include/x86_64-linux-gnu/bits/huge_vall.h \ + /usr/include/x86_64-linux-gnu/bits/inf.h \ + /usr/include/x86_64-linux-gnu/bits/nan.h \ + /usr/include/x86_64-linux-gnu/bits/mathdef.h \ + /usr/include/x86_64-linux-gnu/bits/mathcalls.h \ + /usr/include/x86_64-linux-gnu/bits/mathinline.h \ + ../../modules/core/includes/stack-def.h \ + ../../modules/core/includes/machine.h \ + ../../modules/core/includes/stackTypeVariable.h \ + ../../modules/core/includes/BOOL.h \ + ../../modules/core/includes/doublecomplex.h \ + ../../modules/core/includes/stack1.h \ + ../../modules/core/includes/scisparse.h \ + ../../modules/core/includes/stack2.h \ + ../../modules/core/includes/stack3.h \ + ../../modules/core/includes/stack-optional.h \ + ../../modules/core/includes/sci_types.h \ + ../../modules/api_scilab/includes/api_common.h \ + ../../modules/api_scilab/includes/api_scilab.h \ + ../../modules/api_scilab/includes/api_double.h \ + ../../modules/core/includes/doublecomplex.h \ + ../../modules/api_scilab/includes/api_string.h /usr/include/wchar.h \ + /usr/include/stdio.h /usr/lib/gcc/x86_64-linux-gnu/5/include/stdarg.h \ + /usr/include/x86_64-linux-gnu/bits/wchar.h \ + /usr/include/x86_64-linux-gnu/bits/wchar2.h \ + ../../modules/api_scilab/includes/api_int.h \ + ../../modules/api_scilab/includes/api_poly.h \ + ../../modules/api_scilab/includes/api_sparse.h \ + ../../modules/api_scilab/includes/api_boolean.h \ + ../../modules/api_scilab/includes/api_boolean_sparse.h \ + ../../modules/api_scilab/includes/api_pointer.h \ + ../../modules/api_scilab/includes/api_list.h \ + ../../modules/api_scilab/includes/api_error.h \ + ../../modules/api_scilab/includes/api_handle.h \ + ../../modules/api_scilab/includes/api_optional.h \ + ../../modules/core/includes/stack-optional.h \ + ../../modules/api_scilab/includes/api_hypermat.h \ + ../../modules/core/includes/core_math.h \ + ../../modules/output_stream/includes/lasterror.h \ + ../../modules/output_stream/includes/dynlib_output_stream.h + +/usr/include/stdc-predef.h: + +/usr/include/stdlib.h: + +/usr/include/features.h: + +/usr/include/x86_64-linux-gnu/sys/cdefs.h: + +/usr/include/x86_64-linux-gnu/bits/wordsize.h: + +/usr/include/x86_64-linux-gnu/gnu/stubs.h: + +/usr/include/x86_64-linux-gnu/gnu/stubs-64.h: + +/usr/lib/gcc/x86_64-linux-gnu/5/include/stddef.h: + +/usr/include/x86_64-linux-gnu/bits/waitflags.h: + +/usr/include/x86_64-linux-gnu/bits/waitstatus.h: + +/usr/include/endian.h: + +/usr/include/x86_64-linux-gnu/bits/endian.h: + +/usr/include/x86_64-linux-gnu/bits/byteswap.h: + +/usr/include/x86_64-linux-gnu/bits/types.h: + +/usr/include/x86_64-linux-gnu/bits/typesizes.h: + +/usr/include/x86_64-linux-gnu/bits/byteswap-16.h: + +/usr/include/x86_64-linux-gnu/sys/types.h: + +/usr/include/time.h: + +/usr/include/x86_64-linux-gnu/sys/select.h: + +/usr/include/x86_64-linux-gnu/bits/select.h: + +/usr/include/x86_64-linux-gnu/bits/sigset.h: + +/usr/include/x86_64-linux-gnu/bits/time.h: + +/usr/include/x86_64-linux-gnu/bits/select2.h: + +/usr/include/x86_64-linux-gnu/sys/sysmacros.h: + +/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h: + +/usr/include/alloca.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib-float.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib.h: + +/usr/include/string.h: + +/usr/include/xlocale.h: + +/usr/include/x86_64-linux-gnu/bits/string.h: + +/usr/include/x86_64-linux-gnu/bits/string2.h: + +/usr/include/x86_64-linux-gnu/bits/string3.h: + +src/c/javasci2_helper.h: + +../../modules/core/includes/BOOL.h: + +../../modules/core/includes/sci_types.h: + +../../modules/api_scilab/includes/api_scilab.h: + +../../modules/core/includes/stack-c.h: + +../../modules/core/includes/core_math.h: + +/usr/lib/gcc/x86_64-linux-gnu/5/include-fixed/limits.h: + +/usr/lib/gcc/x86_64-linux-gnu/5/include-fixed/syslimits.h: + +/usr/include/limits.h: + +/usr/include/x86_64-linux-gnu/bits/posix1_lim.h: + +/usr/include/x86_64-linux-gnu/bits/local_lim.h: + +/usr/include/linux/limits.h: + +/usr/include/x86_64-linux-gnu/bits/posix2_lim.h: + +/usr/include/math.h: + +/usr/include/x86_64-linux-gnu/bits/math-vector.h: + +/usr/include/x86_64-linux-gnu/bits/libm-simd-decl-stubs.h: + +/usr/include/x86_64-linux-gnu/bits/huge_val.h: + +/usr/include/x86_64-linux-gnu/bits/huge_valf.h: + +/usr/include/x86_64-linux-gnu/bits/huge_vall.h: + +/usr/include/x86_64-linux-gnu/bits/inf.h: + +/usr/include/x86_64-linux-gnu/bits/nan.h: + +/usr/include/x86_64-linux-gnu/bits/mathdef.h: + +/usr/include/x86_64-linux-gnu/bits/mathcalls.h: + +/usr/include/x86_64-linux-gnu/bits/mathinline.h: + +../../modules/core/includes/stack-def.h: + +../../modules/core/includes/machine.h: + +../../modules/core/includes/stackTypeVariable.h: + +../../modules/core/includes/BOOL.h: + +../../modules/core/includes/doublecomplex.h: + +../../modules/core/includes/stack1.h: + +../../modules/core/includes/scisparse.h: + +../../modules/core/includes/stack2.h: + +../../modules/core/includes/stack3.h: + +../../modules/core/includes/stack-optional.h: + +../../modules/core/includes/sci_types.h: + +../../modules/api_scilab/includes/api_common.h: + +../../modules/api_scilab/includes/api_scilab.h: + +../../modules/api_scilab/includes/api_double.h: + +../../modules/core/includes/doublecomplex.h: + +../../modules/api_scilab/includes/api_string.h: + +/usr/include/wchar.h: + +/usr/include/stdio.h: + +/usr/lib/gcc/x86_64-linux-gnu/5/include/stdarg.h: + +/usr/include/x86_64-linux-gnu/bits/wchar.h: + +/usr/include/x86_64-linux-gnu/bits/wchar2.h: + +../../modules/api_scilab/includes/api_int.h: + +../../modules/api_scilab/includes/api_poly.h: + +../../modules/api_scilab/includes/api_sparse.h: + +../../modules/api_scilab/includes/api_boolean.h: + +../../modules/api_scilab/includes/api_boolean_sparse.h: + +../../modules/api_scilab/includes/api_pointer.h: + +../../modules/api_scilab/includes/api_list.h: + +../../modules/api_scilab/includes/api_error.h: + +../../modules/api_scilab/includes/api_handle.h: + +../../modules/api_scilab/includes/api_optional.h: + +../../modules/core/includes/stack-optional.h: + +../../modules/api_scilab/includes/api_hypermat.h: + +../../modules/core/includes/core_math.h: + +../../modules/output_stream/includes/lasterror.h: + +../../modules/output_stream/includes/dynlib_output_stream.h: diff --git a/modules/javasci/src/c/.dirstamp b/modules/javasci/src/c/.dirstamp new file mode 100755 index 000000000..e69de29bb --- /dev/null +++ b/modules/javasci/src/c/.dirstamp diff --git a/modules/javasci/src/c/.libs/libjavasci2_la-javasci2_helper.o b/modules/javasci/src/c/.libs/libjavasci2_la-javasci2_helper.o Binary files differnew file mode 100755 index 000000000..fe70acf09 --- /dev/null +++ b/modules/javasci/src/c/.libs/libjavasci2_la-javasci2_helper.o diff --git a/modules/javasci/src/c/DllmainJavasci.c b/modules/javasci/src/c/DllmainJavasci.c new file mode 100755 index 000000000..4b23d9192 --- /dev/null +++ b/modules/javasci/src/c/DllmainJavasci.c @@ -0,0 +1,33 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2005 - INRIA - Allan CORNET + * + * 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 <windows.h> +/*--------------------------------------------------------------------------*/ +#pragma comment(lib,"../../bin/libintl.lib") +/*--------------------------------------------------------------------------*/ +int WINAPI DllMain (HINSTANCE hInstance , DWORD reason, PVOID pvReserved) +{ + switch (reason) + { + case DLL_PROCESS_ATTACH: + break; + case DLL_PROCESS_DETACH: + break; + case DLL_THREAD_ATTACH: + break; + case DLL_THREAD_DETACH: + break; + } + return 1; +} +/*--------------------------------------------------------------------------*/ + diff --git a/modules/javasci/src/c/javasci2_helper.c b/modules/javasci/src/c/javasci2_helper.c new file mode 100755 index 000000000..1420dcc2a --- /dev/null +++ b/modules/javasci/src/c/javasci2_helper.c @@ -0,0 +1,623 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2010 - DIGITEO - Sylvestre LEDRU + * + * 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 <string.h> + +#define ENABLE_HELPERS +#include "javasci2_helper.h" +#include "api_scilab.h" +#include "lasterror.h" + +BOOL isComplexVar(char *variableName) +{ + /* 0 = not complex */ + return isNamedVarComplex(pvApiCtx, variableName) != 0; +} + +sci_int_types getIntegerPrecision(char *variableName) +{ + SciErr sciErr; + int iPrec; + + sciErr = getNamedMatrixOfIntegerPrecision(pvApiCtx, variableName, &iPrec); + if (sciErr.iErr) + { + printError(&sciErr, 0); + return sciErr.iErr; + } + return iPrec; +} + +double *getDouble(char *variableName, int *nbRow, int *nbCol) +{ + SciErr sciErr; + double *matrixOfDouble = NULL; + + sciErr = readNamedMatrixOfDouble(pvApiCtx, variableName, nbRow, nbCol, NULL); + if (sciErr.iErr) + { + printError(&sciErr, 0); + } + + /* Alloc the memory */ + matrixOfDouble = (double *)malloc(((*nbRow) * (*nbCol)) * sizeof(double)); + + /* Load the matrix */ + sciErr = readNamedMatrixOfDouble(pvApiCtx, variableName, nbRow, nbCol, matrixOfDouble); + if (sciErr.iErr) + { + printError(&sciErr, 0); + } + + return matrixOfDouble; + +} + +int putDouble(char *variableName, double *variable, int nbRow, int nbCol) +{ + SciErr sciErr; + + sciErr = createNamedMatrixOfDouble(pvApiCtx, variableName, nbRow, nbCol, variable); + if (sciErr.iErr) + { + printError(&sciErr, 0); + return -1; + } + return 0; +} + +double *getDoubleComplexReal(char *variableName, int *nbRow, int *nbCol) +{ + SciErr sciErr; + double *matrixOfDoubleComplexReal = NULL; + double *matrixOfDoubleComplexImg = NULL; + + sciErr = readNamedComplexMatrixOfDouble(pvApiCtx, variableName, nbRow, nbCol, NULL, NULL); + if (sciErr.iErr) + { + printError(&sciErr, 0); + } + + /* Alloc the memory */ + matrixOfDoubleComplexReal = (double *)malloc(((*nbRow) * (*nbCol)) * sizeof(double)); + matrixOfDoubleComplexImg = (double *)malloc(((*nbRow) * (*nbCol)) * sizeof(double)); + + /* Load the matrix */ + sciErr = readNamedComplexMatrixOfDouble(pvApiCtx, variableName, nbRow, nbCol, matrixOfDoubleComplexReal, matrixOfDoubleComplexImg); + if (sciErr.iErr) + { + printError(&sciErr, 0); + } + + return matrixOfDoubleComplexReal; +} + +double *getDoubleComplexImg(char *variableName, int *nbRow, int *nbCol) +{ + SciErr sciErr; + double *matrixOfDoubleComplexReal = NULL; + double *matrixOfDoubleComplexImg = NULL; + + sciErr = readNamedComplexMatrixOfDouble(pvApiCtx, variableName, nbRow, nbCol, NULL, NULL); + if (sciErr.iErr) + { + printError(&sciErr, 0); + } + + /* Alloc the memory */ + matrixOfDoubleComplexReal = (double *)malloc(((*nbRow) * (*nbCol)) * sizeof(double)); + matrixOfDoubleComplexImg = (double *)malloc(((*nbRow) * (*nbCol)) * sizeof(double)); + + /* Load the matrix */ + sciErr = readNamedComplexMatrixOfDouble(pvApiCtx, variableName, nbRow, nbCol, matrixOfDoubleComplexReal, matrixOfDoubleComplexImg); + if (sciErr.iErr) + { + printError(&sciErr, 0); + } + + return matrixOfDoubleComplexImg; + +} + +int putDoubleComplex(char* variableName, double *variable, int nbRow, int nbCol, double * imag, int nbRowI, int nbColI) +{ + SciErr sciErr; + + sciErr = createNamedComplexMatrixOfDouble(pvApiCtx, variableName, nbRow, nbCol, variable, imag); + if (sciErr.iErr) + { + printError(&sciErr, 0); + return -1; + } + return 0; +} + +BOOL *getBoolean(char *variableName, int *nbRow, int *nbCol) +{ + SciErr sciErr; + BOOL *matrixOfBoolean = NULL; + + sciErr = readNamedMatrixOfBoolean(pvApiCtx, variableName, nbRow, nbCol, NULL); + if (sciErr.iErr) + { + printError(&sciErr, 0); + } + + /* Alloc the memory */ + matrixOfBoolean = (BOOL *) malloc(((*nbRow) * (*nbCol)) * sizeof(BOOL)); + + /* Load the matrix */ + sciErr = readNamedMatrixOfBoolean(pvApiCtx, variableName, nbRow, nbCol, matrixOfBoolean); + + if (sciErr.iErr) + { + printError(&sciErr, 0); + } + + return matrixOfBoolean; + +} + +int putBoolean(char *variableName, BOOL * variable, int nbRow, int nbCol) +{ + SciErr sciErr; + + sciErr = createNamedMatrixOfBoolean(pvApiCtx, variableName, nbRow, nbCol, variable); + if (sciErr.iErr) + { + printError(&sciErr, 0); + return -1; + } + return 0; + +} + +///////////////////// byte / int8 +byte *getByte(char *variableName, int *nbRow, int *nbCol) +{ + SciErr sciErr; + byte *matrixOfByte = NULL; + + sciErr = readNamedMatrixOfInteger8(pvApiCtx, variableName, nbRow, nbCol, NULL); + if (sciErr.iErr) + { + printError(&sciErr, 0); + } + + /* Alloc the memory */ + matrixOfByte = (byte *) malloc(((*nbRow) * (*nbCol)) * sizeof(byte)); + + /* Load the matrix */ + sciErr = readNamedMatrixOfInteger8(pvApiCtx, variableName, nbRow, nbCol, (char *)matrixOfByte); + if (sciErr.iErr) + { + printError(&sciErr, 0); + } + + return matrixOfByte; + +} + +int putByte(char *variableName, byte * variable, int nbRow, int nbCol) +{ + SciErr sciErr; + + sciErr = createNamedMatrixOfInteger8(pvApiCtx, variableName, nbRow, nbCol, (const char *)variable); + if (sciErr.iErr) + { + printError(&sciErr, 0); + return -1; + } + return 0; +} + +byte *getUnsignedByte(char *variableName, int *nbRow, int *nbCol) +{ + SciErr sciErr; + byte *matrixOfByte = NULL; + + sciErr = readNamedMatrixOfUnsignedInteger8(pvApiCtx, variableName, nbRow, nbCol, NULL); + if (sciErr.iErr) + { + printError(&sciErr, 0); + } + + /* Alloc the memory */ + matrixOfByte = (byte *) malloc(((*nbRow) * (*nbCol)) * sizeof(byte)); + + /* Load the matrix */ + sciErr = readNamedMatrixOfUnsignedInteger8(pvApiCtx, variableName, nbRow, nbCol, matrixOfByte); + if (sciErr.iErr) + { + printError(&sciErr, 0); + } + + return matrixOfByte; + +} + +int putUnsignedByte(char *variableName, byte * variable, int nbRow, int nbCol) +{ + SciErr sciErr; + + sciErr = createNamedMatrixOfUnsignedInteger8(pvApiCtx, variableName, nbRow, nbCol, variable); + if (sciErr.iErr) + { + printError(&sciErr, 0); + return -1; + } + return 0; +} + +//////////////////////////// short / int16 + +short *getShort(char *variableName, int *nbRow, int *nbCol) +{ + SciErr sciErr; + short *matrixOfShort = NULL; + + sciErr = readNamedMatrixOfInteger16(pvApiCtx, variableName, nbRow, nbCol, NULL); + if (sciErr.iErr) + { + printError(&sciErr, 0); + } + + /* Alloc the memory */ + matrixOfShort = (short *)malloc(((*nbRow) * (*nbCol)) * sizeof(short)); + + /* Load the matrix */ + sciErr = readNamedMatrixOfInteger16(pvApiCtx, variableName, nbRow, nbCol, matrixOfShort); + if (sciErr.iErr) + { + printError(&sciErr, 0); + } + + return matrixOfShort; + +} + +int putShort(char *variableName, short *variable, int nbRow, int nbCol) +{ + SciErr sciErr; + + sciErr = createNamedMatrixOfInteger16(pvApiCtx, variableName, nbRow, nbCol, variable); + if (sciErr.iErr) + { + printError(&sciErr, 0); + return -1; + } + return 0; +} + +unsigned short *getUnsignedShort(char *variableName, int *nbRow, int *nbCol) +{ + SciErr sciErr; + unsigned short *matrixOfShort = NULL; + + sciErr = readNamedMatrixOfUnsignedInteger16(pvApiCtx, variableName, nbRow, nbCol, NULL); + if (sciErr.iErr) + { + printError(&sciErr, 0); + } + + /* Alloc the memory */ + matrixOfShort = (unsigned short *)malloc(((*nbRow) * (*nbCol)) * sizeof(unsigned short)); + + /* Load the matrix */ + sciErr = readNamedMatrixOfUnsignedInteger16(pvApiCtx, variableName, nbRow, nbCol, matrixOfShort); + if (sciErr.iErr) + { + printError(&sciErr, 0); + } + + return matrixOfShort; + +} + +int putUnsignedShort(char *variableName, unsigned short *variable, int nbRow, int nbCol) +{ + SciErr sciErr; + + sciErr = createNamedMatrixOfUnsignedInteger16(pvApiCtx, variableName, nbRow, nbCol, variable); + if (sciErr.iErr) + { + printError(&sciErr, 0); + return -1; + } + return 0; +} + +////////////////////// int / int32 + +int *getInt(char *variableName, int *nbRow, int *nbCol) +{ + SciErr sciErr; + int *matrixOfInt = NULL; + + sciErr = readNamedMatrixOfInteger32(pvApiCtx, variableName, nbRow, nbCol, NULL); + if (sciErr.iErr) + { + printError(&sciErr, 0); + } + + /* Alloc the memory */ + matrixOfInt = (int *)malloc(((*nbRow) * (*nbCol)) * sizeof(int)); + + /* Load the matrix */ + sciErr = readNamedMatrixOfInteger32(pvApiCtx, variableName, nbRow, nbCol, matrixOfInt); + if (sciErr.iErr) + { + printError(&sciErr, 0); + } + + return matrixOfInt; + +} + +int putInt(char *variableName, int *variable, int nbRow, int nbCol) +{ + SciErr sciErr; + + sciErr = createNamedMatrixOfInteger32(pvApiCtx, variableName, nbRow, nbCol, variable); + if (sciErr.iErr) + { + printError(&sciErr, 0); + return -1; + } + return 0; +} + +unsigned int *getUnsignedInt(char *variableName, int *nbRow, int *nbCol) +{ + SciErr sciErr; + int *matrixOfInt = NULL; + + sciErr = readNamedMatrixOfUnsignedInteger32(pvApiCtx, variableName, nbRow, nbCol, NULL); + if (sciErr.iErr) + { + printError(&sciErr, 0); + } + + /* Alloc the memory */ + matrixOfInt = (int *)malloc(((*nbRow) * (*nbCol)) * sizeof(int)); + + /* Load the matrix */ + sciErr = readNamedMatrixOfUnsignedInteger32(pvApiCtx, variableName, nbRow, nbCol, (unsigned int *)matrixOfInt); + if (sciErr.iErr) + { + printError(&sciErr, 0); + } + + return (unsigned int *)matrixOfInt; + +} + +int putUnsignedInt(char *variableName, unsigned int *variable, int nbRow, int nbCol) +{ + SciErr sciErr; + + sciErr = createNamedMatrixOfUnsignedInteger32(pvApiCtx, variableName, nbRow, nbCol, variable); + if (sciErr.iErr) + { + printError(&sciErr, 0); + return -1; + } + return 0; +} + +////////////////////// long / int64 +#ifdef __SCILAB_INT64__ + +long *getLong(char *variableName, int *nbRow, int *nbCol) +{ + SciErr sciErr; + long *matrixOfLong = NULL; + + sciErr = readNamedMatrixOfInteger64(pvApiCtx, variableName, nbRow, nbCol, NULL); + if (sciErr.iErr) + { + printError(&sciErr, 0); + } + + /* Alloc the memory */ + matrixOfLong = (long *)malloc(((*nbRow) * (*nbCol)) * sizeof(long)); + + /* Load the matrix */ + sciErr = readNamedMatrixOfInteger64(pvApiCtx, variableName, nbRow, nbCol, matrixOfLong); + if (sciErr.iErr) + { + printError(&sciErr, 0); + } + + return matrixOfLong; + +} + +int putLong(char *variableName, long *variable, int *nbRow, int *nbCol) +{ + SciErr sciErr; + + sciErr = createNamedMatrixOfInteger64(pvApiCtx, variableName, nbRow, nbCol, variable); + if (sciErr.iErr) + { + printError(&sciErr, 0); + return -1; + } + return 0; +} + +unsigned long *getUnsignedLong(char *variableName, int *nbRow, int *nbCol) +{ + SciErr sciErr; + long *matrixOfLong = NULL; + + sciErr = readNamedMatrixOfUnsignedInteger64(pvApiCtx, variableName, nbRow, nbCol, NULL); + if (sciErr.iErr) + { + printError(&sciErr, 0); + } + + /* Alloc the memory */ + matrixOfLong = (long *)malloc(((*nbRow) * (*nbCol)) * sizeof(long)); + + /* Load the matrix */ + sciErr = readNamedMatrixOfUnsignedInteger64(pvApiCtx, variableName, nbRow, nbCol, matrixOfLong); + if (sciErr.iErr) + { + printError(&sciErr, 0); + } + + return matrixOfLong; + +} + +int putUnsignedLong(char *variableName, unsigned long *variable, int *nbRow, int *nbCol) +{ + SciErr sciErr; + + sciErr = createNamedMatrixOfUnsignedInteger64(pvApiCtx, variableName, nbRow, nbCol, variable); + if (sciErr.iErr) + { + printError(&sciErr, 0); + return -1; + } + return 0; +} + +#endif + +char **getString(char *variableName, int *nbRow, int *nbCol) +{ + SciErr sciErr; + int i = 0; + + int *piLen = NULL; + char **pstData = NULL; + + //first call to retrieve dimensions + sciErr = readNamedMatrixOfString(pvApiCtx, variableName, nbRow, nbCol, NULL, NULL); + if (sciErr.iErr) + { + printError(&sciErr, 0); + } + + piLen = (int *)malloc(sizeof(int) * (*nbRow) * (*nbCol)); + + //second call to retrieve length of each string + sciErr = readNamedMatrixOfString(pvApiCtx, variableName, nbRow, nbCol, piLen, NULL); + if (sciErr.iErr) + { + printError(&sciErr, 0); + } + + pstData = (char **)malloc(sizeof(char *) * (*nbRow) * (*nbCol)); + + for (i = 0; i < (*nbRow) * (*nbCol); i++) + { + pstData[i] = (char *)malloc(sizeof(char) * (piLen[i] + 1)); //+ 1 for null termination + } + //third call to retrieve data + sciErr = readNamedMatrixOfString(pvApiCtx, variableName, nbRow, nbCol, piLen, pstData); + if (sciErr.iErr) + { + printError(&sciErr, 0); + } + + return pstData; + +} + +int putString(char *variableName, char **variable, int nbRow, int nbCol) +{ + SciErr sciErr; + + sciErr = createNamedMatrixOfString(pvApiCtx, variableName, nbRow, nbCol, variable); + if (sciErr.iErr) + { + printError(&sciErr, 0); + return -1; + } + return 0; +} + +int putSparse(char * variableName, int nbRow, int nbCol, int * nbRowItem, int nbRowItemL, int * colPos, int colPosL, double * data, int dataL) +{ + SciErr sciErr; + + sciErr = createNamedSparseMatrix(pvApiCtx, variableName, nbRow, nbCol, colPosL, nbRowItem, colPos, data); + if (sciErr.iErr) + { + printError(&sciErr, 0); + return -1; + } + return 0; +} + +int putComplexSparse(char * variableName, int nbRow, int nbCol, int * nbRowItem, int nbRowItemL, int * colPos, int colPosL, double * data, int dataL, double * imag, int imagL) +{ + SciErr sciErr; + + sciErr = createNamedComplexSparseMatrix(pvApiCtx, variableName, nbRow, nbCol, colPosL, nbRowItem, colPos, data, imag); + if (sciErr.iErr) + { + printError(&sciErr, 0); + return -1; + } + return 0; +} + +int putBooleanSparse(char * variableName, int nbRow, int nbCol, int * nbRowItem, int nbRowItemL, int * colPos, int colPosL) +{ + SciErr sciErr; + + sciErr = createNamedBooleanSparseMatrix(pvApiCtx, variableName, nbRow, nbCol, colPosL, nbRowItem, colPos); + if (sciErr.iErr) + { + printError(&sciErr, 0); + return -1; + } + return 0; +} + +int putPolynomial(char * variableName, char * polyVarName, double ** data, int nbRow, int nbCol, int * nbCoef) +{ + SciErr sciErr; + + sciErr = createNamedMatrixOfPoly(pvApiCtx, variableName, polyVarName, nbRow, nbCol, nbCoef, data); + if (sciErr.iErr) + { + printError(&sciErr, 0); + return -1; + } + return 0; +} + +int putComplexPolynomial(char * variableName, char * polyVarName, double ** data, int nbRow, int nbCol, int * nbCoef, double ** imag, int nbRowI, int nbColI, int * nbCoefI) +{ + SciErr sciErr; + + sciErr = createNamedComplexMatrixOfPoly(pvApiCtx, variableName, polyVarName, nbRow, nbCol, nbCoef, data, imag); + if (sciErr.iErr) + { + printError(&sciErr, 0); + return -1; + } + return 0; +} + + +BOOL isExistingVariable(char *variableName) +{ + int iExisting = isNamedVarExist(pvApiCtx, variableName); + + return iExisting != 0; /* 0 = not existing variable */ +} diff --git a/modules/javasci/src/c/javasci2_helper.h b/modules/javasci/src/c/javasci2_helper.h new file mode 100755 index 000000000..5b14a8c2e --- /dev/null +++ b/modules/javasci/src/c/javasci2_helper.h @@ -0,0 +1,403 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2010 - DIGITEO - Sylvestre LEDRU + * + * 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 + * + */ + +#ifndef __JAVASCI2_HELPER_H__ +#define __JAVASCI2_HELPER_H__ + +/** + * This header describes a serie of helper functions. + * This function should be only used when writing a wrapper of Scilab into an + * other language (Java). + * All these functions are based on api_scilab. They provide a simple profile + * to be easily integrate into a SWIG wrapper. + */ + +#ifndef ENABLE_HELPERS +#error "This file cannot be used directly" +#endif +#include "BOOL.h" +#include "sci_types.h" + +typedef unsigned char byte; + +/** + * If the variable is complex or not + * + * @param variableName The name of the variable + * @return TRUE is complex, FALSE otherwise + */ +BOOL isComplex(char *variableName); + +/** + * Return the precision of an integer + * + * @param variableName The name of tbe variable + * @return the type of the integer (see sci_int_types) + */ +sci_int_types getIntegerPrecision(char* variableName); + + +/** + * Return a matrix of double (the default type in Scilab) + * + * @param variableName The name of the variable + * @param[out] nbRow Number of rows + * @param[out] nbCol Number of cols + * @return The matrix of double (column sorted) + */ +double * getDouble(char* variableName, int *nbRow, int *nbCol); + +/** + * Set a matrix of double (the default type in Scilab) + * + * @param variableName The name of the variable + * @param variable The values + * @param nbRow Number of rows + * @param nbCol Number of cols + * @return 0 if successfull, != 0 otherwise + */ +int putDouble(char* variableName, double *variable, int nbRow, int nbCol); + +/** + * Return the real part of a matrix of complex double + * + * @param variableName The name of the variable + * @param[out] nbRow Number of rows + * @param[out] nbCol Number of cols + * @return The real part of a matrix of complex double (column sorted) + */ +double * getDoubleComplexReal(char* variableName, int *nbRow, int *nbCol); + +/** + * Return the imaginary part of a matrix of complex double + * + * @param variableName The name of the variable + * @param[out] nbRow Number of rows + * @param[out] nbCol Number of cols + * @return The imaginary part of a matrix of complex double (column sorted) + */ +double * getDoubleComplexImg(char* variableName, int *nbRow, int *nbCol); + +/** + * Set a matrix of complex double + * + * @param variableName The name of the variable + * @param variable The complex values + * @param nbRow Number of rows + * @param nbCol Number of cols + * @return 0 if successfull, != 0 otherwise + */ +int putDoubleComplex(char* variableName, double *variable, int nbRow, int nbCol, double * imag, int nbRowI, int nbColI); + +/** + * Return a matrix of boolean + * + * @param variableName The name of the variable + * @param[out] nbRow Number of rows + * @param[out] nbCol Number of cols + * @return The matrix of boolean (column sorted) + */ +BOOL * getBoolean(char* variableName, int *nbRow, int *nbCol); + +/** + * Set a matrix of boolean + * + * @param variableName The name of the variable + * @param variable The values + * @param nbRow Number of rows + * @param nbCol Number of cols + * @return 0 if successfull, != 0 otherwise + */ +int putBoolean(char* variableName, BOOL *variable, int nbRow, int nbCol); + +/** + * Return a matrix of byte (int8) + * + * @param variableName The name of the variable + * @param[out] nbRow Number of rows + * @param[out] nbCol Number of cols + * @return The matrix of byte (column sorted) + */ +byte * getByte(char* variableName, int *nbRow, int *nbCol); + +/** + * Set a matrix of byte (int8) + * + * @param variableName The name of the variable + * @param variable The values + * @param nbRow Number of rows + * @param nbCol Number of cols + * @return 0 if successfull, != 0 otherwise + */ +int putByte(char* variableName, byte *variable, int nbRow, int nbCol); + +/** + * Return a matrix of unsigned byte (uint8) + * + * @param variableName The name of the variable + * @param[out] nbRow Number of rows + * @param[out] nbCol Number of cols + * @return The matrix of unsigned byte (column sorted) + */ +byte * getUnsignedByte(char* variableName, int *nbRow, int *nbCol); + +/** + * Set a matrix of unsigned byte (uint8) + * + * @param variableName The name of the variable + * @param variable The values + * @param nbRow Number of rows + * @param nbCol Number of cols + * @return 0 if successfull, != 0 otherwise + */ +int putUnsignedByte(char* variableName, byte *variable, int nbRow, int nbCol); + +/** + * Return a matrix of short (int16) + * + * @param variableName The name of the variable + * @param[out] nbRow Number of rows + * @param[out] nbCol Number of cols + * @return The matrix of short (column sorted) + */ +short * getShort(char* variableName, int *nbRow, int *nbCol); + +/** + * Set a matrix of short (int16) + * + * @param variableName The name of the variable + * @param variable The values + * @param nbRow Number of rows + * @param nbCol Number of cols + * @return 0 if successfull, != 0 otherwise + */ +int putShort(char* variableName, short *variable, int nbRow, int nbCol); + +/** + * Return a matrix of unsigned short (uint16) + * + * @param variableName The name of the variable + * @param[out] nbRow Number of rows + * @param[out] nbCol Number of cols + * @return The matrix of unsigned short (column sorted) + */ +unsigned short * getUnsignedShort(char* variableName, int *nbRow, int *nbCol); + +/** + * Set a matrix of unsigned short (uint16) + * + * @param variableName The name of the variable + * @param variable The values + * @param nbRow Number of rows + * @param nbCol Number of cols + * @return 0 if successfull, != 0 otherwise + */ +int putUnsignedShort(char* variableName, unsigned short *variable, int nbRow, int nbCol); + +/** + * Return a matrix of integer (int32) + * + * @param variableName The name of the variable + * @param[out] nbRow Number of rows + * @param[out] nbCol Number of cols + * @return The matrix of integer (column sorted) + */ +int * getInt(char* variableName, int *nbRow, int *nbCol); + +/** + * Set a matrix of integer (int32) + * + * @param variableName The name of the variable + * @param variable The values + * @param nbRow Number of rows + * @param nbCol Number of cols + * @return 0 if successfull, != 0 otherwise + */ +int putInt(char* variableName, int *variable, int nbRow, int nbCol); + +/** + * Return a matrix of unsigned integer (uint32) + * + * @param variableName The name of the variable + * @param[out] nbRow Number of rows + * @param[out] nbCol Number of cols + * @return The matrix of unsigned integer (column sorted) + */ +unsigned int * getUnsignedInt(char* variableName, int *nbRow, int *nbCol); + +/** + * Set a matrix of unsigned integer (uint32) + * + * @param variableName The name of the variable + * @param variable The values + * @param nbRow Number of rows + * @param nbCol Number of cols + * @return 0 if successfull, != 0 otherwise + */ +int putUnsignedInt(char* variableName, unsigned int *variable, int nbRow, int nbCol); + +/** + * Return a matrix of long (int64) + * + * @param variableName The name of the variable + * @param[out] nbRow Number of rows + * @param[out] nbCol Number of cols + * @return The matrix of long (column sorted) + */ +long * getLong(char* variableName, int *nbRow, int *nbCol); + +/** + * Set a matrix of long (int64) + * + * @param variableName The name of the variable + * @param variable The values + * @param nbRow Number of rows + * @param nbCol Number of cols + * @return 0 if successfull, != 0 otherwise + */ +int putLong(char* variableName, long *variable, int nbRow, int nbCol); + +/** + * Return a matrix of unsigned long (uint64) + * + * @param variableName The name of the variable + * @param[out] nbRow Number of rows + * @param[out] nbCol Number of cols + * @return The matrix of unsigned long (column sorted) + */ +unsigned long * getUnsignedLong(char* variableName, int *nbRow, int *nbCol); + +/** + * Set a matrix of unsigned long (int64) + * + * @param variableName The name of the variable + * @param variable The values + * @param nbRow Number of rows + * @param nbCol Number of cols + * @return 0 if successfull, != 0 otherwise + */ +int putUnsignedLong(char* variableName, unsigned long *variable, int nbRow, int nbCol); + +/** + * Return a matrix of string + * + * @param variableName The name of the variable + * @param[out] nbRow Number of rows + * @param[out] nbCol Number of cols + * @return The matrix of string (column sorted) + */ +char ** getString(char* variableName, int *nbRow, int *nbCol); + +/** + * Set a matrix of string + * + * @param variableName The name of the variable + * @param variable The values + * @param nbRow Number of rows + * @param nbCol Number of cols + * @return 0 if successfull, != 0 otherwise + */ +int putString(char* variableName, char **variable, int nbRow, int nbCol); + +/** + * Set a sparse matrix + * + * @param variableName The name of the variable + * @param nbRow Number of rows + * @param nbCol Number of cols + * @param nbRowItem the number of non null items by row + * @param nbRowItemL the length of the previous array + * @param colPos the column position of each non null item + * @param colPosL the length of the previous array + * @param data the double data + * @param dataL the length of the previous array + * @return 0 if successfull, != 0 otherwise + */ +int putSparse(char * variableName, int nbRow, int nbCol, int * nbRowItem, int nbRowItemL, int * colPos, int colPosL, double * data, int dataL); + +/** + * Set a complex sparse matrix + * + * @param variableName The name of the variable + * @param nbRow Number of rows + * @param nbCol Number of cols + * @param nbRowItem the number of non null items by row + * @param nbRowItemL the length of the previous array + * @param colPos the column position of each non null item + * @param colPosL the length of the previous array + * @param data the double data + * @param dataL the length of the previous array + * @param imag the double data + * @param imagL the length of the previous array + * @return 0 if successfull, != 0 otherwise + */ +int putComplexSparse(char * variableName, int nbRow, int nbCol, int * nbRowItem, int nbRowItemL, int * colPos, int colPosL, double * data, int dataL, double * imag, int imagL); + +/** + * Set a boolean sparse matrix + * + * @param variableName The name of the variable + * @param nbRow Number of rows + * @param nbCol Number of cols + * @param nbRowItem the number of non null items by row + * @param nbRowItemL the length of the previous array + * @param colPos the column position of each non null item + * @param colPosL the length of the previous array + * @return 0 if successfull, != 0 otherwise + */ +int putBooleanSparse(char * variableName, int nbRow, int nbCol, int * nbRowItem, int nbRowItemL, int * colPos, int colPosL); + +/** + * Set a polynomial matrix + * + * @param variableName The name of the variable + * @param polyVarName The name of the polynomial variable + * @param data the double data + * @param nbRow Number of rows + * @param nbCol Number of cols + * @param nbCoef the number of coef of each polynomial + * @return 0 if successfull, != 0 otherwise + */ +int putPolynomial(char * variableName, char * polyVarName, double ** data, int nbRow, int nbCol, int * nbCoef); + +/** + * Set a complex polynomial matrix + * + * @param variableName The name of the variable + * @param polyVarName The name of the polynomial variable + * @param data the double data + * @param nbRow Number of rows + * @param nbCol Number of cols + * @param imag the double data + * @param nbRowI Number of rows + * @param nbColI Number of cols + * @param nbCoef the number of coef of each polynomial + * @return 0 if successfull, != 0 otherwise + */ +int putComplexPolynomial(char * variableName, char * polyVarName, double ** data, int nbRow, int nbCol, int * nbCoef, double ** imag, int nbRowI, int nbColI, int * nbCoefI); + +/** + * Check if a variable exists in Context + * + * @param variableName The name of the variable + * @return TRUE if the given variable exists, FALSE otherwise + */ +BOOL isExistingVariable(char* variableName); + +/** + * Check if a variable is complex. + * + * @param variableName The name of the variable + * @return TRUE if the given variable is complex, FALSE otherwise + */ +BOOL isComplexVar(char *variableName); +#endif /* __JAVASCI2_HELPER_H__ */ diff --git a/modules/javasci/src/c/libjavasci2_la-javasci2_helper.lo b/modules/javasci/src/c/libjavasci2_la-javasci2_helper.lo new file mode 100755 index 000000000..c5c027a09 --- /dev/null +++ b/modules/javasci/src/c/libjavasci2_la-javasci2_helper.lo @@ -0,0 +1,12 @@ +# src/c/libjavasci2_la-javasci2_helper.lo - a libtool object file +# Generated by libtool (GNU libtool) 2.4.2 +# +# Please DO NOT delete this file! +# It is necessary for linking the library. + +# Name of the PIC object. +pic_object='.libs/libjavasci2_la-javasci2_helper.o' + +# Name of the non-PIC object +non_pic_object=none + |