scilab: fix typemap bool array regression error
This commit is contained in:
parent
013b9f9769
commit
e3a3540542
1 changed files with 51 additions and 3 deletions
|
|
@ -49,7 +49,7 @@ SWIG_From_dec(bool)(bool _bValue) {
|
|||
|
||||
/*
|
||||
* C-type: bool[]
|
||||
* Scilab type: boolean vector (but converted to int first because can not cast bool** to int **
|
||||
* Scilab type: boolean matrix
|
||||
*/
|
||||
%fragment("SWIG_SciBoolean_AsBoolArrayAndSize", "header") {
|
||||
SWIGINTERN int
|
||||
|
|
@ -73,7 +73,7 @@ SWIG_SciBoolean_AsBoolArrayAndSize(void *_pvApiCtx, int _iVar, int *_iRows, int
|
|||
}
|
||||
|
||||
*_pbValue = (bool*) malloc((*_iRows) * (*_iCols) * sizeof(bool));
|
||||
for (i=0; i< (*_iRows) * (*_iCols); i++)
|
||||
for (i = 0; i < (*_iRows) * (*_iCols); i++)
|
||||
(*_pbValue)[i] = piValue[i] != 0;
|
||||
}
|
||||
else {
|
||||
|
|
@ -93,7 +93,7 @@ SWIG_SciBoolean_FromBoolArrayAndSize(void *_pvApiCtx, int _iVarOut, int _iRows,
|
|||
int i;
|
||||
|
||||
piValue = (int*) malloc(_iRows * _iCols * sizeof(int));
|
||||
for (i=0; i< _iRows * _iCols; i++)
|
||||
for (i = 0; i < _iRows * _iCols; i++)
|
||||
piValue[i] = _pbValue[i];
|
||||
|
||||
sciErr = createMatrixOfBoolean(_pvApiCtx, SWIG_NbInputArgument(_pvApiCtx) + _iVarOut, _iRows, _iCols, piValue);
|
||||
|
|
@ -107,3 +107,51 @@ SWIG_SciBoolean_FromBoolArrayAndSize(void *_pvApiCtx, int _iVarOut, int _iRows,
|
|||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* C-type: int[]
|
||||
* Scilab type: boolean matrix
|
||||
*/
|
||||
%fragment("SWIG_SciBoolean_AsIntArrayAndSize", "header") {
|
||||
SWIGINTERN int
|
||||
SWIG_SciBoolean_AsIntArrayAndSize(void *_pvApiCtx, int _iVar, int *_iRows, int *_iCols, int **_piValue, char *_fname) {
|
||||
SciErr sciErr;
|
||||
int *piAddrVar = NULL;
|
||||
|
||||
sciErr = getVarAddressFromPosition(_pvApiCtx, _iVar, &piAddrVar);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
if (isBooleanType(_pvApiCtx, piAddrVar)) {
|
||||
int i;
|
||||
sciErr = getMatrixOfBoolean(_pvApiCtx, piAddrVar, _iRows, _iCols, _piValue);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
else {
|
||||
Scierror(999, _("%s: Wrong type for input argument #%d: A boolean matrix expected.\n"), _fname, _iVar);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
|
||||
%fragment("SWIG_SciBoolean_FromIntArrayAndSize", "header") {
|
||||
SWIGINTERN int
|
||||
SWIG_SciBoolean_FromIntArrayAndSize(void *_pvApiCtx, int _iVarOut, int _iRows, int _iCols, int *_piValue) {
|
||||
SciErr sciErr;
|
||||
|
||||
sciErr = createMatrixOfBoolean(_pvApiCtx, SWIG_NbInputArgument(_pvApiCtx) + _iVarOut, _iRows, _iCols, _piValue);
|
||||
if(sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue