scilab: fix int array typemaps: accept in input and return by default double matrixes

This commit is contained in:
Simon Marchetto 2014-03-05 12:24:14 +01:00
commit 9442156367
6 changed files with 200 additions and 133 deletions

View file

@ -52,26 +52,26 @@
* Signed char array * Signed char array
*/ */
%typemap(in, fragment="SWIG_SciInt8_AsSignedCharArrayAndSize") signed char[] { %typemap(in, fragment="SWIG_SciDoubleOrInt8_AsSignedCharArrayAndSize") signed char[] {
int iRows = 0; int iRows = 0;
int iCols = 0; int iCols = 0;
if (SWIG_SciInt8_AsSignedCharArrayAndSize(pvApiCtx, $input, &iRows, &iCols, &$1, fname) != SWIG_OK) { if (SWIG_SciDoubleOrInt8_AsSignedCharArrayAndSize(pvApiCtx, $input, &iRows, &iCols, &$1, fname) != SWIG_OK) {
return 0; return SWIG_ERROR;
} }
} }
%typemap(varin, fragment="SWIG_SciInt8_AsSignedCharArrayAndSize") signed char[] { %typemap(varin, fragment="SWIG_SciDoubleOrInt8_AsSignedCharArrayAndSize") signed char[] {
int iRows = 0; int iRows = 0;
int iCols = 0; int iCols = 0;
if (SWIG_SciInt8_AsSignedCharArrayAndSize(pvApiCtx, $input, &iRows, &iCols, (signed char**)&$1, fname) != SWIG_OK) { if (SWIG_SciDoubleOrInt8_AsSignedCharArrayAndSize(pvApiCtx, $input, &iRows, &iCols, (signed char**)&$1, fname) != SWIG_OK) {
return 0; return SWIG_ERROR;
} }
} }
%scilab_asarrayandsize_withcopy(varin, SWIG_SciInt8_AsSignedCharArrayAndSize, signed char[ANY], signed char); %scilab_asarrayandsize_withcopy(varin, SWIG_SciDoubleOrInt8_AsSignedCharArrayAndSize, signed char[ANY], signed char);
%typemap(varout, noblock=1, fragment="SWIG_SciInt8_FromSignedCharArrayAndSize") signed char[ANY] { %typemap(varout, noblock=1, fragment="SWIG_SciDouble_FromSignedCharArrayAndSize") signed char[ANY] {
%set_output(SWIG_SciInt8_FromSignedCharArrayAndSize(pvApiCtx, $result, 1, $1_dim0, $1)); %set_output(SWIG_SciDouble_FromSignedCharArrayAndSize(pvApiCtx, $result, 1, $1_dim0, $1));
} }
%typemap(varout, noblock=1, fragment="SWIG_SciInt8_FromSignedCharArrayAndSize") signed char[] { %typemap(varout, noblock=1, fragment="SWIG_SciDouble_FromSignedCharArrayAndSize") signed char[] {
%set_output(SWIG_SciInt8_FromSignedCharArrayAndSize(pvApiCtx, $result, 1, strlen((const char*)$1), $1)); %set_output(SWIG_SciDoubleOr_FromSignedCharArrayAndSize(pvApiCtx, $result, 1, strlen((const char*)$1), $1));
} }
@ -83,14 +83,14 @@
int iRows = 0; int iRows = 0;
int iCols = 0; int iCols = 0;
if (SWIG_SciUint8_AsUnsignedCharArrayAndSize(pvApiCtx, $input, &iRows, &iCols, &$1, fname) != SWIG_OK) { if (SWIG_SciUint8_AsUnsignedCharArrayAndSize(pvApiCtx, $input, &iRows, &iCols, &$1, fname) != SWIG_OK) {
return 0; return SWIG_ERROR;
} }
} }
%typemap(varin, fragment="SWIG_SciUint8_AsUnsignedCharArrayAndSize") unsigned char[] { %typemap(varin, fragment="SWIG_SciUint8_AsUnsignedCharArrayAndSize") unsigned char[] {
int iRows = 0; int iRows = 0;
int iCols = 0; int iCols = 0;
if (SWIG_SciUint8_AsUnsignedCharArrayAndSize(pvApiCtx, $input, &iRows, &iCols, (unsigned char**)&$1, fname) != SWIG_OK) { if (SWIG_SciUint8_AsUnsignedCharArrayAndSize(pvApiCtx, $input, &iRows, &iCols, (unsigned char**)&$1, fname) != SWIG_OK) {
return 0; return SWIG_ERROR;
} }
} }
@ -107,12 +107,12 @@
* Short array * Short array
*/ */
%scilab_asarrayandsize_withcopy(varin, SWIG_SciInt16_AsShortArrayAndSize, short[ANY], short); %scilab_asarrayandsize_withcopy(varin, SWIG_SciDoubleOrInt16_AsShortArrayAndSize, short[ANY], short);
%typemap(varout, noblock=1, fragment="SWIG_SciInt16_FromShortArrayAndSize") short[ANY] { %typemap(varout, noblock=1, fragment="SWIG_SciDouble_FromShortArrayAndSize") short[ANY] {
%set_output(SWIG_SciInt16_FromShortArrayAndSize(pvApiCtx, $result, 1, $1_dim0, $1)); %set_output(SWIG_SciDouble_FromShortArrayAndSize(pvApiCtx, $result, 1, $1_dim0, $1));
} }
%apply SWIGTYPE[] { short[] }; /* short[] variables managed as pointers */ %apply SWIGTYPE[] { short[] }; /* short[] variables managed as pointers */
%scilab_asarray_withcopy(in, SWIG_SciInt16_AsShortArrayAndSize, short[], short); %scilab_asarray_withcopy(in, SWIG_SciDoubleOrInt16_AsShortArrayAndSize, short[], short);
/* /*
@ -131,12 +131,12 @@
* Int array * Int array
*/ */
%scilab_asarrayandsize_withcopy(varin, SWIG_SciInt32_AsIntArrayAndSize, int[ANY], int); %scilab_asarrayandsize_withcopy(varin, SWIG_SciDoubleOrInt32_AsIntArrayAndSize, int[ANY], int);
%typemap(varout, noblock=1, fragment="SWIG_SciInt32_FromIntArrayAndSize") int[ANY] { %typemap(varout, noblock=1, fragment="SWIG_SciDouble_FromIntArrayAndSize") int[ANY] {
%set_output(SWIG_SciInt32_FromIntArrayAndSize(pvApiCtx, $result, 1, $1_dim0, $1)); %set_output(SWIG_SciDouble_FromIntArrayAndSize(pvApiCtx, $result, 1, $1_dim0, $1));
} }
%apply SWIGTYPE[] { int[] }; /* int[] variables managed as pointers */ %apply SWIGTYPE[] { int[] }; /* int[] variables managed as pointers */
%scilab_asarray_withcopy(in, SWIG_SciInt32_AsIntArrayAndSize, int[], int); %scilab_asarray_withcopy(in, SWIG_SciDoubleOrInt32_AsIntArrayAndSize, int[], int);
/* /*
@ -155,12 +155,12 @@
* Long array * Long array
*/ */
%scilab_asarrayandsize_withcopy(varin, SWIG_SciInt32_AsIntArrayAndSize, long[ANY], int); %scilab_asarrayandsize_withcopy(varin, SWIG_SciDoubleOrInt32_AsIntArrayAndSize, long[ANY], int);
%typemap(varout, noblock=1, fragment="SWIG_SciInt32_FromIntArrayAndSize") long[ANY] { %typemap(varout, noblock=1, fragment="SWIG_SciDouble_FromIntArrayAndSize") long[ANY] {
%set_output(SWIG_SciInt32_FromIntArrayAndSize(pvApiCtx, $result, 1, $1_dim0, (const int*) $1)); %set_output(SWIG_SciDouble_FromIntArrayAndSize(pvApiCtx, $result, 1, $1_dim0, (const int*) $1));
} }
%apply SWIGTYPE[] { long[] }; /* long[] variables managed as pointers */ %apply SWIGTYPE[] { long[] }; /* long[] variables managed as pointers */
%scilab_asarray_withcopy(in, SWIG_SciInt32_AsIntArrayAndSize, long[], int); %scilab_asarray_withcopy(in, SWIG_SciDoubleOrInt32_AsIntArrayAndSize, long[], int);
/* /*

View file

@ -99,15 +99,14 @@ SWIG_SciDouble_FromInt(void *_pvApiCtx, int _iVarOut, int _iValue, char *_fname)
} }
/* /*
* C-type: int * C-type: int[]
* Scilab type: 32-bit signed integer matrix * Scilab type: double or int32 matrix
*/ */
%fragment("SWIG_SciInt32_AsIntArrayAndSize", "header") { %fragment("SWIG_SciDoubleOrInt32_AsIntArrayAndSize", "header") {
SWIGINTERN int SWIGINTERN int
SWIG_SciInt32_AsIntArrayAndSize(void *_pvApiCtx, int _iVar, int *_iRows, int *_iCols, int **_piValue, char *_fname) { SWIG_SciDoubleOrInt32_AsIntArrayAndSize(void *_pvApiCtx, int _iVar, int *_iRows, int *_iCols, int **_piValue, char *_fname) {
SciErr sciErr; SciErr sciErr;
int iType = 0; int iType = 0;
int iPrec = 0;
int *piAddrVar = NULL; int *piAddrVar = NULL;
sciErr = getVarAddressFromPosition(_pvApiCtx, _iVar, &piAddrVar); sciErr = getVarAddressFromPosition(_pvApiCtx, _iVar, &piAddrVar);
@ -117,9 +116,33 @@ SWIG_SciInt32_AsIntArrayAndSize(void *_pvApiCtx, int _iVar, int *_iRows, int *_i
return SWIG_ERROR; return SWIG_ERROR;
} }
// Accepts 32-bit signed integer matrix for input sciErr = getVarType(_pvApiCtx, piAddrVar, &iType);
if (isIntegerType(_pvApiCtx, piAddrVar)) if (sciErr.iErr) {
printError(&sciErr, 0);
return SWIG_ERROR;
}
if (iType == sci_matrix)
{ {
double *pdData = NULL;
int size = 0;
int i;
sciErr = getMatrixOfDouble(_pvApiCtx, piAddrVar, _iRows, _iCols, &pdData);
if (sciErr.iErr)
{
printError(&sciErr, 0);
return SWIG_ERROR;
}
size = (*_iRows) * (*_iCols);
*_piValue = (int*) malloc(size * sizeof(int*));
for (i = 0; i < size; i++)
(*_piValue)[i] = (int) pdData[i];
}
else if (iType == sci_ints)
{
int iPrec = 0;
sciErr = getMatrixOfIntegerPrecision(_pvApiCtx, piAddrVar, &iPrec); sciErr = getMatrixOfIntegerPrecision(_pvApiCtx, piAddrVar, &iPrec);
if (sciErr.iErr) if (sciErr.iErr)
{ {
@ -137,27 +160,6 @@ SWIG_SciInt32_AsIntArrayAndSize(void *_pvApiCtx, int _iVar, int *_iRows, int *_i
printError(&sciErr, 0); printError(&sciErr, 0);
return SWIG_ERROR; return SWIG_ERROR;
} }
return SWIG_OK;
}
else if (isDoubleType(_pvApiCtx, piAddrVar))
{
double *pdData = NULL;
int size = 0;
int i;
sciErr = getMatrixOfDouble(_pvApiCtx, piAddrVar, _iRows, _iCols, &pdData);
if (sciErr.iErr)
{
printError(&sciErr, 0);
return SWIG_ERROR;
}
size = (*_iRows) * (*_iCols);
*_piValue = (int*) malloc(size * sizeof(int*));
for (i = 0; i < size; i++)
(*_piValue)[i] = (int) pdData[i];
return SWIG_OK;
} }
else else
{ {
@ -168,17 +170,25 @@ SWIG_SciInt32_AsIntArrayAndSize(void *_pvApiCtx, int _iVar, int *_iRows, int *_i
} }
} }
%fragment("SWIG_SciInt32_FromIntArrayAndSize", "header") { %fragment("SWIG_SciDouble_FromIntArrayAndSize", "header") {
SWIGINTERN int SWIGINTERN int
SWIG_SciInt32_FromIntArrayAndSize(void *_pvApiCtx, int _iVarOut, int _iRows, int _iCols, const int *_piData) { SWIG_SciDouble_FromIntArrayAndSize(void *_pvApiCtx, int _iVarOut, int _iRows, int _iCols, const int *_piData) {
SciErr sciErr; SciErr sciErr;
int i;
double *pdValues = NULL;
sciErr = createMatrixOfInteger32(_pvApiCtx, SWIG_NbInputArgument(_pvApiCtx) + _iVarOut, _iRows, _iCols, _piData); pdValues = (double*) malloc(_iRows * _iCols * sizeof(double));
if(sciErr.iErr) { for (i=0; i<_iRows * _iCols; i++)
pdValues[i] = _piData[i];
sciErr = createMatrixOfDouble(_pvApiCtx, SWIG_NbInputArgument(_pvApiCtx) + _iVarOut, _iRows, _iCols, pdValues);
if (sciErr.iErr) {
printError(&sciErr, 0); printError(&sciErr, 0);
free(pdValues);
return SWIG_ERROR; return SWIG_ERROR;
} }
free(pdValues);
return SWIG_OK; return SWIG_OK;
} }
} }

View file

@ -7,9 +7,9 @@
// in (int* matrixIn, int matrixInRowCount, int matrixInColCount) // in (int* matrixIn, int matrixInRowCount, int matrixInColCount)
%typemap(in, fragment="SWIG_SciInt32_AsIntArrayAndSize") (int* matrixIn, int matrixInRowCount, int matrixInColCount) %typemap(in, fragment="SWIG_SciDoubleOrInt32_AsIntArrayAndSize") (int* matrixIn, int matrixInRowCount, int matrixInColCount)
{ {
if (SWIG_SciInt32_AsIntArrayAndSize(pvApiCtx, $input, &$2, &$3, &$1, fname) == SWIG_ERROR) if (SWIG_SciDoubleOrInt32_AsIntArrayAndSize(pvApiCtx, $input, &$2, &$3, &$1, fname) == SWIG_ERROR)
{ {
return SWIG_ERROR; return SWIG_ERROR;
} }
@ -18,9 +18,9 @@
// in (int matrixInRowCount, int matrixInColCount, int* matrixIn) // in (int matrixInRowCount, int matrixInColCount, int* matrixIn)
%typemap(in, fragment="SWIG_SciInt32_AsIntArrayAndSize") (int matrixInRowCount, int matrixInColCount, int* matrixIn) %typemap(in, fragment="SWIG_SciDoubleOrInt32_AsIntArrayAndSize") (int matrixInRowCount, int matrixInColCount, int* matrixIn)
{ {
if (SWIG_SciInt32_AsIntArrayAndSize(pvApiCtx, $input, &$1, &$2, &$3, fname) == SWIG_ERROR) if (SWIG_SciDoubleOrInt32_AsIntArrayAndSize(pvApiCtx, $input, &$1, &$2, &$3, fname) == SWIG_ERROR)
{ {
return SWIG_ERROR; return SWIG_ERROR;
} }
@ -29,11 +29,11 @@
// in (int* vectorIn, int vectorInSize) // in (int* vectorIn, int vectorInSize)
%typemap(in) (int* vectorIn, int vectorInSize) %typemap(in, fragment="SWIG_SciDoubleOrInt32_AsIntArrayAndSize") (int* vectorIn, int vectorInSize)
{ {
int rowCount; int rowCount;
int colCount; int colCount;
if (SWIG_SciInt32_AsIntArrayAndSize(pvApiCtx, $input, &rowCount, &colCount, &$1, fname) != SWIG_ERROR) if (SWIG_SciDoubleOrInt32_AsIntArrayAndSize(pvApiCtx, $input, &rowCount, &colCount, &$1, fname) != SWIG_ERROR)
{ {
$2 = rowCount * colCount; $2 = rowCount * colCount;
} }
@ -46,11 +46,11 @@
// in (int vectorInSize, int* vectorIn) // in (int vectorInSize, int* vectorIn)
%typemap(in) (int vectorInSize, int* vectorIn) %typemap(in, fragment="SWIG_SciDoubleOrInt32_AsIntArrayAndSize") (int vectorInSize, int* vectorIn)
{ {
int rowCount; int rowCount;
int colCount; int colCount;
if (SWIG_SciInt32_AsIntArrayAndSize(pvApiCtx, $input, &rowCount, &colCount, &$2, fname) != SWIG_ERROR) if (SWIG_SciDoubleOrInt32_AsIntArrayAndSize(pvApiCtx, $input, &rowCount, &colCount, &$2, fname) != SWIG_ERROR)
{ {
$1 = rowCount * colCount; $1 = rowCount * colCount;
} }
@ -73,9 +73,9 @@
$3 = (int*) malloc(sizeof(int)); $3 = (int*) malloc(sizeof(int));
} }
%typemap(argout, fragment="SWIG_SciInt32_FromIntArrayAndSize") (int** matrixOut, int* matrixOutRowCount, int* matrixOutColCount) %typemap(argout, fragment="SWIG_SciDouble_FromIntArrayAndSize") (int** matrixOut, int* matrixOutRowCount, int* matrixOutColCount)
{ {
if (SWIG_SciInt32_FromIntArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), *$2, *$3, *$1) != SWIG_ERROR) if (SWIG_SciDouble_FromIntArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), *$2, *$3, *$1) != SWIG_ERROR)
{ {
SWIG_Scilab_SetOutput(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + SWIG_Scilab_GetOutputPosition()); SWIG_Scilab_SetOutput(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + SWIG_Scilab_GetOutputPosition());
} }
@ -107,9 +107,9 @@
$3 = (int**) malloc(sizeof(int*)); $3 = (int**) malloc(sizeof(int*));
} }
%typemap(argout, fragment="SWIG_SciInt32_FromIntArrayAndSize") (int* matrixOutRowCount, int* matrixOutColCount, int** matrixOut) %typemap(argout, fragment="SWIG_SciDouble_FromIntArrayAndSize") (int* matrixOutRowCount, int* matrixOutColCount, int** matrixOut)
{ {
if (SWIG_SciInt32_FromIntArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), *$1, *$2, *$3) != SWIG_ERROR) if (SWIG_SciDouble_FromIntArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), *$1, *$2, *$3) != SWIG_ERROR)
{ {
SWIG_Scilab_SetOutput(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + SWIG_Scilab_GetOutputPosition()); SWIG_Scilab_SetOutput(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + SWIG_Scilab_GetOutputPosition());
} }
@ -140,9 +140,9 @@
$2 = (int*) malloc(sizeof(int)); $2 = (int*) malloc(sizeof(int));
} }
%typemap(argout, fragment="SWIG_SciInt32_FromIntArrayAndSize") (int** vectorOut, int* vectorOutSize) %typemap(argout, fragment="SWIG_SciDouble_FromIntArrayAndSize") (int** vectorOut, int* vectorOutSize)
{ {
if (SWIG_SciInt32_FromIntArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), 1, *$2, *$1) != SWIG_ERROR) if (SWIG_SciDouble_FromIntArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), 1, *$2, *$1) != SWIG_ERROR)
{ {
SWIG_Scilab_SetOutput(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + SWIG_Scilab_GetOutputPosition()); SWIG_Scilab_SetOutput(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + SWIG_Scilab_GetOutputPosition());
} }
@ -172,9 +172,9 @@
$2 = (int**) malloc(sizeof(int*)); $2 = (int**) malloc(sizeof(int*));
} }
%typemap(argout, fragment="SWIG_SciInt32_FromIntArrayAndSize") (int* vectorOutSize, int** vectorOut) %typemap(argout, fragment="SWIG_SciDouble_FromIntArrayAndSize") (int* vectorOutSize, int** vectorOut)
{ {
if (SWIG_SciInt32_FromIntArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), 1, *$1, *$2) != SWIG_ERROR) if (SWIG_SciDouble_FromIntArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), 1, *$1, *$2) != SWIG_ERROR)
{ {
SWIG_Scilab_SetOutput(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + SWIG_Scilab_GetOutputPosition()); SWIG_Scilab_SetOutput(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + SWIG_Scilab_GetOutputPosition());
} }

View file

@ -6,9 +6,7 @@
%include <sciint.swg> %include <sciint.swg>
%fragment(SWIG_AsCheck_Sequence_frag(int), "header", %fragment(SWIG_AsCheck_Sequence_frag(int), "header") {
fragment="SWIG_SciInt32_AsIntArrayAndSize") {
SWIGINTERN int SWIGINTERN int
SWIG_AsCheck_Sequence_dec(int)(SwigSciObject _obj) { SWIG_AsCheck_Sequence_dec(int)(SwigSciObject _obj) {
SciErr sciErr; SciErr sciErr;
@ -33,25 +31,25 @@ SWIG_AsCheck_Sequence_dec(int)(SwigSciObject _obj) {
} }
%fragment(SWIG_AsGet_Sequence_frag(int), "header", %fragment(SWIG_AsGet_Sequence_frag(int), "header",
fragment="SWIG_SciInt32_AsIntArrayAndSize") { fragment="SWIG_SciDoubleOrInt32_AsIntArrayAndSize") {
SWIGINTERN int SWIGINTERN int
SWIG_AsGet_Sequence_dec(int)(SwigSciObject _obj, int **_pSequence) { SWIG_AsGet_Sequence_dec(int)(SwigSciObject _obj, int **_pSequence) {
int iMatrixRowCount; int iMatrixRowCount;
int iMatrixColCount; int iMatrixColCount;
return (SWIG_SciInt32_AsIntArrayAndSize(pvApiCtx, _obj, &iMatrixRowCount, &iMatrixColCount, _pSequence, SWIG_Scilab_GetFname())); return (SWIG_SciDoubleOrInt32_AsIntArrayAndSize(pvApiCtx, _obj, &iMatrixRowCount, &iMatrixColCount, _pSequence, SWIG_Scilab_GetFname()));
} }
} }
%fragment(SWIG_AsSize_Sequence_frag(int), "header", %fragment(SWIG_AsSize_Sequence_frag(int), "header",
fragment="SWIG_SciInt32_AsIntArrayAndSize") { fragment="SWIG_SciDoubleOrInt32_AsIntArrayAndSize") {
SWIGINTERN int SWIGINTERN int
SWIG_AsSize_Sequence_dec(int)(SwigSciObject _obj, int *_piSize) { SWIG_AsSize_Sequence_dec(int)(SwigSciObject _obj, int *_piSize) {
int *piMatrix; int *piMatrix;
int iMatrixRowCount; int iMatrixRowCount;
int iMatrixColCount; int iMatrixColCount;
if (SWIG_SciInt32_AsIntArrayAndSize(pvApiCtx, _obj, &iMatrixRowCount, &iMatrixColCount, &piMatrix, SWIG_Scilab_GetFname()) == SWIG_OK) { if (SWIG_SciDoubleOrInt32_AsIntArrayAndSize(pvApiCtx, _obj, &iMatrixRowCount, &iMatrixColCount, &piMatrix, SWIG_Scilab_GetFname()) == SWIG_OK) {
if ((iMatrixRowCount > 1) && (iMatrixColCount > 1)) { if ((iMatrixRowCount > 1) && (iMatrixColCount > 1)) {
Scierror(999, _("%s: Wrong size for input argument #%d: An integer vector is expected.\n"), SWIG_Scilab_GetFname(), _obj); Scierror(999, _("%s: Wrong size for input argument #%d: An integer vector is expected.\n"), SWIG_Scilab_GetFname(), _obj);
return SWIG_ERROR; return SWIG_ERROR;
@ -73,11 +71,11 @@ SWIG_FromCreate_Sequence_dec(int)(int _size, int **_sequence) {
} }
%fragment(SWIG_FromSet_Sequence_frag(int), "header", %fragment(SWIG_FromSet_Sequence_frag(int), "header",
fragment="SWIG_SciInt32_FromIntArrayAndSize") { fragment="SWIG_SciDouble_FromIntArrayAndSize") {
SWIGINTERN SwigSciObject SWIGINTERN SwigSciObject
SWIG_FromSet_Sequence_dec(int)(int _size, int *_sequence) { SWIG_FromSet_Sequence_dec(int)(int _size, int *_sequence) {
SwigSciObject obj = SWIG_SciInt32_FromIntArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), 1, _size, _sequence); SwigSciObject obj = SWIG_SciDouble_FromIntArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), 1, _size, _sequence);
delete (int *)_sequence; delete (int *)_sequence;
return obj; return obj;
} }

View file

@ -99,16 +99,11 @@ SWIG_SciDouble_FromShort(void *_pvApiCtx, int _iVarOut, short _sValue, char *_fn
/* /*
* C-type: short[] * C-type: short[]
* Scilab type: int16 vector * Scilab type: double or int16 matrix
* See in scitypemaps.swg
*/ */
/* %fragment("SWIG_SciDoubleOrInt16_AsShortArrayAndSize", "header") {
* C-type: short[ANY]
* Scilab type: int16 vector
*/
%fragment("SWIG_SciInt16_AsShortArrayAndSize", "header") {
SWIGINTERN int SWIGINTERN int
SWIG_SciInt16_AsShortArrayAndSize(void *_pvApiCtx, int _iVar, int *_iRows, int *_iCols, short **_psValue, char *_fname) { SWIG_SciDoubleOrInt16_AsShortArrayAndSize(void *_pvApiCtx, int _iVar, int *_iRows, int *_iCols, short **_psValue, char *_fname) {
SciErr sciErr; SciErr sciErr;
int iType = 0; int iType = 0;
int iPrec = 0; int iPrec = 0;
@ -125,40 +120,73 @@ SWIG_SciInt16_AsShortArrayAndSize(void *_pvApiCtx, int _iVar, int *_iRows, int *
printError(&sciErr, 0); printError(&sciErr, 0);
return SWIG_ERROR; return SWIG_ERROR;
} }
if (iType != sci_ints) {
Scierror(999, _("%s: Wrong type for input argument #%d: A 16-bit signed integer vector expected.\n"), _fname, _iVar);
return SWIG_ERROR;
}
sciErr = getMatrixOfIntegerPrecision(_pvApiCtx, piAddrVar, &iPrec); if (iType == sci_matrix)
if (sciErr.iErr) { {
printError(&sciErr, 0); double *pdData = NULL;
return SWIG_ERROR; int size = 0;
} int i;
if (iPrec != SCI_INT16) {
Scierror(999, _("%s: Wrong type for input argument #%d: A 16-bit signed integer vector expected.\n"), _fname, _iVar);
return SWIG_ERROR;
}
sciErr = getMatrixOfInteger16(_pvApiCtx, piAddrVar, _iRows, _iCols, _psValue); sciErr = getMatrixOfDouble(_pvApiCtx, piAddrVar, _iRows, _iCols, &pdData);
if (sciErr.iErr) { if (sciErr.iErr)
printError(&sciErr, 0); {
printError(&sciErr, 0);
return SWIG_ERROR;
}
size = (*_iRows) * (*_iCols);
*_psValue = (short*) malloc(size * sizeof(int*));
for (i = 0; i < size; i++)
(*_psValue)[i] = (short) pdData[i];
}
else if (iType == sci_ints)
{
int iPrec = 0;
sciErr = getMatrixOfIntegerPrecision(_pvApiCtx, piAddrVar, &iPrec);
if (sciErr.iErr)
{
printError(&sciErr, 0);
return SWIG_ERROR;
}
if (iPrec != SCI_INT16) {
Scierror(999, _("%s: Wrong type for input argument #%d: A 16-bit signed integer or a double matrix expected.\n"), _fname, _iVar);
return SWIG_ERROR;
}
sciErr = getMatrixOfInteger16(_pvApiCtx, piAddrVar, _iRows, _iCols, _psValue);
if (sciErr.iErr) {
printError(&sciErr, 0);
return SWIG_ERROR;
}
}
else
{
Scierror(999, _("%s: Wrong type for input argument #%d: A 16-bit signed integer or a double matrix expected.\n"), _fname, _iVar);
return SWIG_ERROR; return SWIG_ERROR;
} }
return SWIG_OK; return SWIG_OK;
} }
} }
%fragment("SWIG_SciInt16_FromShortArrayAndSize", "header") { %fragment("SWIG_SciDouble_FromShortArrayAndSize", "header") {
SWIGINTERN int SWIGINTERN int
SWIG_SciInt16_FromShortArrayAndSize(void *_pvApiCtx, int _iVarOut, int _iRows, int _iCols, short *_psValue) { SWIG_SciDouble_FromShortArrayAndSize(void *_pvApiCtx, int _iVarOut, int _iRows, int _iCols, short *_psValue) {
SciErr sciErr; SciErr sciErr;
sciErr = createMatrixOfInteger16(_pvApiCtx, SWIG_NbInputArgument(_pvApiCtx) + _iVarOut, _iRows, _iCols, _psValue); int i;
double *pdValues = NULL;
pdValues = (double*) malloc(_iRows * _iCols * sizeof(double));
for (i=0; i<_iRows * _iCols; i++)
pdValues[i] = _psValue[i];
sciErr = createMatrixOfDouble(_pvApiCtx, SWIG_NbInputArgument(_pvApiCtx) + _iVarOut, _iRows, _iCols, pdValues);
if (sciErr.iErr) { if (sciErr.iErr) {
printError(&sciErr, 0); printError(&sciErr, 0);
free(pdValues);
return SWIG_ERROR; return SWIG_ERROR;
} }
free(pdValues);
return SWIG_OK; return SWIG_OK;
} }
} }

View file

@ -98,14 +98,13 @@ SWIG_SciDouble_FromSignedChar(void *_pvApiCtx, int _iVarOut, signed char _scValu
/* /*
* C-type: signed char[] * C-type: signed char[]
* Scilab type: int8 vector * Scilab type: double or int8 matrix
*/ */
%fragment("SWIG_SciInt8_AsSignedCharArrayAndSize", "header") { %fragment("SWIG_SciDoubleOrInt8_AsSignedCharArrayAndSize", "header") {
SWIGINTERN int SWIGINTERN int
SWIG_SciInt8_AsSignedCharArrayAndSize(void *_pvApiCtx, int _iVar, int *_iRows, int *_iCols, signed char **_pscValue, char *_fname) { SWIG_SciDoubleOrInt8_AsSignedCharArrayAndSize(void *_pvApiCtx, int _iVar, int *_iRows, int *_iCols, signed char **_pscValue, char *_fname) {
SciErr sciErr; SciErr sciErr;
int iType = 0; int iType = 0;
int iPrec = 0;
int *piAddrVar = NULL; int *piAddrVar = NULL;
sciErr = getVarAddressFromPosition(_pvApiCtx, _iVar, &piAddrVar); sciErr = getVarAddressFromPosition(_pvApiCtx, _iVar, &piAddrVar);
@ -119,41 +118,73 @@ SWIG_SciInt8_AsSignedCharArrayAndSize(void *_pvApiCtx, int _iVar, int *_iRows, i
printError(&sciErr, 0); printError(&sciErr, 0);
return SWIG_ERROR; return SWIG_ERROR;
} }
if (iType != sci_ints) {
Scierror(999, _("%s: Wrong type for input argument #%d: A 8-bit integer vector expected.\n"), _fname, _iVar);
return SWIG_ERROR;
}
sciErr = getMatrixOfIntegerPrecision(_pvApiCtx, piAddrVar, &iPrec); if (iType == sci_matrix)
if (sciErr.iErr) { {
printError(&sciErr, 0); double *pdData = NULL;
return SWIG_ERROR; int size = 0;
} int i;
if (iPrec != SCI_INT8) {
Scierror(999, _("%s: Wrong type for input argument #%d: A 8-bit integer vector expected.\n"), _fname, _iVar);
return SWIG_ERROR;
}
sciErr = getMatrixOfInteger8(_pvApiCtx, piAddrVar, _iRows, _iCols, (char **)_pscValue); sciErr = getMatrixOfDouble(_pvApiCtx, piAddrVar, _iRows, _iCols, &pdData);
if (sciErr.iErr) { if (sciErr.iErr)
printError(&sciErr, 0); {
printError(&sciErr, 0);
return SWIG_ERROR;
}
size = (*_iRows) * (*_iCols);
*_pscValue = (signed char*) malloc(size * sizeof(int*));
for (i = 0; i < size; i++)
(*_pscValue)[i] = (signed char) pdData[i];
}
else if (iType == sci_ints)
{
int iPrec = 0;
sciErr = getMatrixOfIntegerPrecision(_pvApiCtx, piAddrVar, &iPrec);
if (sciErr.iErr)
{
printError(&sciErr, 0);
return SWIG_ERROR;
}
if (iPrec != SCI_INT8) {
Scierror(999, _("%s: Wrong type for input argument #%d: A 8-bit signed integer or a double matrix expected.\n"), _fname, _iVar);
return SWIG_ERROR;
}
sciErr = getMatrixOfInteger8(_pvApiCtx, piAddrVar, _iRows, _iCols, (char **)_pscValue);
if (sciErr.iErr) {
printError(&sciErr, 0);
return SWIG_ERROR;
}
}
else
{
Scierror(999, _("%s: Wrong type for input argument #%d: A 8-bit signed integer or a double matrix expected.\n"), _fname, _iVar);
return SWIG_ERROR; return SWIG_ERROR;
} }
return SWIG_OK; return SWIG_OK;
} }
} }
%fragment("SWIG_SciInt8_FromSignedCharArrayAndSize", "header") {
%fragment("SWIG_SciDouble_FromSignedCharArrayAndSize", "header") {
SWIGINTERN int SWIGINTERN int
SWIG_SciInt8_FromSignedCharArrayAndSize(void *_pvApiCtx, int _iVarOut, int _iRows, int _iCols, const signed char *_pscValue) { SWIG_SciDouble_FromSignedCharArrayAndSize(void *_pvApiCtx, int _iVarOut, int _iRows, int _iCols, const signed char *_pscValue) {
SciErr sciErr; SciErr sciErr;
int i;
double *pdValues = NULL;
sciErr = createMatrixOfInteger8(pvApiCtx, SWIG_NbInputArgument(_pvApiCtx) + _iVarOut, _iRows, _iCols, (const char *)_pscValue); pdValues = (double*) malloc(_iRows * _iCols * sizeof(double));
for (i=0; i<_iRows * _iCols; i++)
pdValues[i] = _pscValue[i];
sciErr = createMatrixOfDouble(pvApiCtx, SWIG_NbInputArgument(_pvApiCtx) + _iVarOut, _iRows, _iCols, pdValues);
if (sciErr.iErr) { if (sciErr.iErr) {
printError(&sciErr, 0); printError(&sciErr, 0);
free(pdValues);
return SWIG_ERROR; return SWIG_ERROR;
} }
free(pdValues);
return SWIG_OK; return SWIG_OK;
} }
} }