scilab: unsigned ints typemaps behave same as ints (2nd commit: arrays)
This commit is contained in:
parent
e324ad1c6c
commit
8a2472c649
6 changed files with 203 additions and 108 deletions
|
|
@ -122,41 +122,77 @@ SWIG_SciUint8_AsUnsignedCharArrayAndSize(void *_pvApiCtx, int _iVar, int *_iRows
|
|||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
if (iType != sci_ints) {
|
||||
Scierror(999, _("%s: Wrong type for input argument #%d: A 8-bit unsigned integer vector expected.\n"), _fname, _iVar);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
sciErr = getMatrixOfIntegerPrecision(_pvApiCtx, piAddrVar, &iPrec);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
if (iPrec != SCI_UINT8) {
|
||||
Scierror(999, _("%s: Wrong type for input argument #%d: A 8-bit unsigned integer vector expected.\n"), _fname, _iVar);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
if (iType == sci_matrix)
|
||||
{
|
||||
double *pdData = NULL;
|
||||
int size = 0;
|
||||
int i;
|
||||
|
||||
sciErr = getMatrixOfUnsignedInteger8(_pvApiCtx, piAddrVar, _iRows, _iCols, _pucValue);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
sciErr = getMatrixOfDouble(_pvApiCtx, piAddrVar, _iRows, _iCols, &pdData);
|
||||
if (sciErr.iErr)
|
||||
{
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
size = (*_iRows) * (*_iCols);
|
||||
*_pucValue = (unsigned char*) malloc(size * sizeof(int*));
|
||||
for (i = 0; i < size; i++)
|
||||
(*_pucValue)[i] = (unsigned char) pdData[i];
|
||||
}
|
||||
else if (iType == sci_ints)
|
||||
{
|
||||
sciErr = getMatrixOfIntegerPrecision(_pvApiCtx, piAddrVar, &iPrec);
|
||||
if (sciErr.iErr)
|
||||
{
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
if (iPrec != SCI_UINT8)
|
||||
{
|
||||
Scierror(999, _("%s: Wrong type for input argument #%d: A 8-bit unsigned integer or a double vector expected.\n"), _fname, _iVar);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
sciErr = getMatrixOfUnsignedInteger8(_pvApiCtx, piAddrVar, _iRows, _iCols, _pucValue);
|
||||
if (sciErr.iErr)
|
||||
{
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Scierror(999, _("%s: Wrong type for input argument #%d: A 8-bit unsigned integer or a double vector expected.\n"), _fname, _iVar);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
|
||||
%fragment("SWIG_SciUint8_FromUnsignedCharArrayAndSize", "header") {
|
||||
SWIGINTERN int
|
||||
SWIG_SciUint8_FromUnsignedCharArrayAndSize(void *_pvApiCtx, int _iVarOut, int _iRows, int _iCols, const unsigned char *_puscValue) {
|
||||
SWIG_SciUint8_FromUnsignedCharArrayAndSize(void *_pvApiCtx, int _iVarOut, int _iRows, int _iCols, const unsigned char *_pucValues) {
|
||||
SciErr sciErr;
|
||||
double *pdValues = NULL;
|
||||
int i;
|
||||
|
||||
sciErr = createMatrixOfUnsignedInteger8(pvApiCtx, SWIG_NbInputArgument(_pvApiCtx) + _iVarOut, _iRows, _iCols, _puscValue);
|
||||
if (sciErr.iErr) {
|
||||
pdValues = (double*) malloc(_iRows * _iCols * sizeof(double));
|
||||
for (i=0; i<_iRows * _iCols; i++)
|
||||
pdValues[i] = _pucValues[i];
|
||||
|
||||
sciErr = createMatrixOfDouble(pvApiCtx, SWIG_NbInputArgument(_pvApiCtx) + _iVarOut, _iRows, _iCols, pdValues);
|
||||
if (sciErr.iErr)
|
||||
{
|
||||
printError(&sciErr, 0);
|
||||
free(pdValues);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
free(pdValues);
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ SWIG_SciUint32_AsUnsignedInt(void *_pvApiCtx, int _iVar, unsigned int *_puiValue
|
|||
return SWIG_ERROR;
|
||||
}
|
||||
if (iPrec != SCI_UINT32) {
|
||||
Scierror(999, _("%s: Wrong type for input argument #%d: A 32-bit unsigned integer expected.\n"), _fname, _iVar);
|
||||
Scierror(999, _("%s: Wrong type for input argument #%d: A 32-bit unsigned integer or a double expected.\n"), _fname, _iVar);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
|
|
@ -46,7 +46,7 @@ SWIG_SciUint32_AsUnsignedInt(void *_pvApiCtx, int _iVar, unsigned int *_puiValue
|
|||
return SWIG_ERROR;
|
||||
}
|
||||
if (iRows * iCols != 1) {
|
||||
Scierror(999, _("%s: Wrong size for input argument #%d: A 32-bit unsigned integer expected.\n"), _fname, _iVar);
|
||||
Scierror(999, _("%s: Wrong size for input argument #%d: A 32-bit unsigned integer or a double expected.\n"), _fname, _iVar);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
*_puiValue = *puiData;
|
||||
|
|
@ -122,41 +122,76 @@ SWIG_SciUint32_AsUnsignedIntArrayAndSize(void *_pvApiCtx, int _iVar, int *_iRows
|
|||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
if (iType != sci_ints) {
|
||||
Scierror(999, _("%s: Wrong type for input argument #%d: A 32-bit unsigned integer vector expected.\n"), _fname, _iVar);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
sciErr = getMatrixOfIntegerPrecision(_pvApiCtx, piAddrVar, &iPrec);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
if (iPrec != SCI_UINT32) {
|
||||
Scierror(999, _("%s: Wrong type for input argument #%d: A 32-bit unsigned integer vector expected.\n"), _fname, _iVar);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
if (iType == sci_matrix)
|
||||
{
|
||||
double *pdData = NULL;
|
||||
int size = 0;
|
||||
int i;
|
||||
|
||||
sciErr = getMatrixOfUnsignedInteger32(_pvApiCtx, piAddrVar, _iRows, _iCols, _puiValue);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
sciErr = getMatrixOfDouble(_pvApiCtx, piAddrVar, _iRows, _iCols, &pdData);
|
||||
if (sciErr.iErr)
|
||||
{
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
size = (*_iRows) * (*_iCols);
|
||||
*_puiValue = (unsigned int*) malloc(size * sizeof(int*));
|
||||
for (i = 0; i < size; i++)
|
||||
(*_puiValue)[i] = (unsigned int) pdData[i];
|
||||
}
|
||||
else if (iType == sci_ints)
|
||||
{
|
||||
sciErr = getMatrixOfIntegerPrecision(_pvApiCtx, piAddrVar, &iPrec);
|
||||
if (sciErr.iErr)
|
||||
{
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
if (iPrec != SCI_UINT32)
|
||||
{
|
||||
Scierror(999, _("%s: Wrong type for input argument #%d: A 32-bit unsigned integer or a double vector expected.\n"), _fname, _iVar);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
sciErr = getMatrixOfUnsignedInteger32(_pvApiCtx, piAddrVar, _iRows, _iCols, _puiValue);
|
||||
if (sciErr.iErr)
|
||||
{
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Scierror(999, _("%s: Wrong type for input argument #%d: A 32-bit unsigned integer or a double vector expected.\n"), _fname, _iVar);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
|
||||
%fragment("SWIG_SciUint32_FromUnsignedIntArrayAndSize", "header") {
|
||||
SWIGINTERN int
|
||||
SWIG_SciUint32_FromUnsignedIntArrayAndSize(void *_pvApiCtx, int _iVarOut, int _iRows, int _iCols, unsigned int *_puiValue) {
|
||||
SWIG_SciUint32_FromUnsignedIntArrayAndSize(void *_pvApiCtx, int _iVarOut, int _iRows, int _iCols, unsigned int *_puiValues) {
|
||||
SciErr sciErr;
|
||||
double *pdValues = NULL;
|
||||
int i;
|
||||
|
||||
sciErr = createMatrixOfUnsignedInteger32(_pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + _iVarOut, _iRows, _iCols, _puiValue);
|
||||
pdValues = (double*) malloc(_iRows * _iCols * sizeof(double));
|
||||
for (i=0; i<_iRows * _iCols; i++)
|
||||
pdValues[i] = _puiValues[i];
|
||||
|
||||
sciErr = createMatrixOfDouble(_pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + _iVarOut, _iRows, _iCols, pdValues);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
free(pdValues);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
free(pdValues);
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,23 +30,24 @@ SWIG_UnsignedInt_FromUnsignedLong(void *_pvApiCtx, int _iVarOut, unsigned long _
|
|||
|
||||
%fragment("SWIG_SciUint32_FromUnsignedLongArrayAndSize", "header") {
|
||||
SWIGINTERN int
|
||||
SWIG_SciUint32_FromUnsignedLongArrayAndSize(void *_pvApiCtx, int _iVarOut, int _iRows, int _iCols, const unsigned long *_pulData) {
|
||||
SWIG_SciUint32_FromUnsignedLongArrayAndSize(void *_pvApiCtx, int _iVarOut, int _iRows, int _iCols, const unsigned long *_pulValues) {
|
||||
SciErr sciErr;
|
||||
double *pdValues = NULL;
|
||||
int i;
|
||||
unsigned int *puiValues = NULL;
|
||||
|
||||
puiValues = (unsigned int*) malloc(_iRows * _iCols * sizeof(unsigned int));
|
||||
pdValues = (double*) malloc(_iRows * _iCols * sizeof(double));
|
||||
for (i=0; i<_iRows * _iCols; i++) {
|
||||
puiValues[i] = _pulData[i];
|
||||
pdValues[i] = _pulValues[i];
|
||||
}
|
||||
|
||||
sciErr = createMatrixOfUnsignedInteger32(_pvApiCtx, SWIG_NbInputArgument(_pvApiCtx) + _iVarOut, _iRows, _iCols, puiValues);
|
||||
sciErr = createMatrixOfDouble(_pvApiCtx, SWIG_NbInputArgument(_pvApiCtx) + _iVarOut, _iRows, _iCols, pdValues);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
free(puiValues);
|
||||
free(pdValues);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
free(puiValues);
|
||||
|
||||
free(pdValues);
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ SWIG_SciUint16_AsUnsignedShort(void *_pvApiCtx, int _iVar, unsigned short *_pusV
|
|||
return SWIG_ERROR;
|
||||
}
|
||||
if (iPrec != SCI_UINT16) {
|
||||
Scierror(999, _("%s: Wrong type for input argument #%d: A 16-bit unsigned integer expected.\n"), _fname, _iVar);
|
||||
Scierror(999, _("%s: Wrong type for input argument #%d: A 16-bit unsigned integer or a double expected.\n"), _fname, _iVar);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
|
|
@ -46,7 +46,7 @@ SWIG_SciUint16_AsUnsignedShort(void *_pvApiCtx, int _iVar, unsigned short *_pusV
|
|||
return SWIG_ERROR;
|
||||
}
|
||||
if (iRows * iCols != 1) {
|
||||
Scierror(999, _("%s: Wrong size for input argument #%d: A 16-bit unsigned integer expected.\n"), _fname, _iVar);
|
||||
Scierror(999, _("%s: Wrong size for input argument #%d: A 16-bit unsigned integer or a double expected.\n"), _fname, _iVar);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
*_pusValue = *pusData;
|
||||
|
|
@ -122,41 +122,77 @@ SWIG_SciUint16_AsUnsignedShortArrayAndSize(void *_pvApiCtx, int _iVar, int *_iRo
|
|||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
if (iType != sci_ints) {
|
||||
Scierror(999, _("%s: Wrong type for input argument #%d: A 16-bit unsigned integer vector expected.\n"), _fname, _iVar);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
sciErr = getMatrixOfIntegerPrecision(_pvApiCtx, piAddrVar, &iPrec);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
if (iPrec != SCI_UINT16) {
|
||||
Scierror(999, _("%s: Wrong type for input argument #%d: A 16-bit unsigned integer vector expected.\n"), _fname, _iVar);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
if (iType == sci_matrix)
|
||||
{
|
||||
double *pdData = NULL;
|
||||
int size = 0;
|
||||
int i;
|
||||
|
||||
sciErr = getMatrixOfUnsignedInteger16(_pvApiCtx, piAddrVar, _iRows, _iCols, _pusValue);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
sciErr = getMatrixOfDouble(_pvApiCtx, piAddrVar, _iRows, _iCols, &pdData);
|
||||
if (sciErr.iErr)
|
||||
{
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
size = (*_iRows) * (*_iCols);
|
||||
*_pusValue = (unsigned short*) malloc(size * sizeof(int*));
|
||||
for (i = 0; i < size; i++)
|
||||
(*_pusValue)[i] = (unsigned short) pdData[i];
|
||||
}
|
||||
else if (iType == sci_ints)
|
||||
{
|
||||
sciErr = getMatrixOfIntegerPrecision(_pvApiCtx, piAddrVar, &iPrec);
|
||||
if (sciErr.iErr)
|
||||
{
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
if (iPrec != SCI_UINT16)
|
||||
{
|
||||
Scierror(999, _("%s: Wrong type for input argument #%d: A 16-bit unsigned integer or a double vector expected.\n"), _fname, _iVar);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
sciErr = getMatrixOfUnsignedInteger16(_pvApiCtx, piAddrVar, _iRows, _iCols, _pusValue);
|
||||
if (sciErr.iErr)
|
||||
{
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Scierror(999, _("%s: Wrong type for input argument #%d: A 16-bit unsigned integer or a double vector expected.\n"), _fname, _iVar);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
|
||||
%fragment("SWIG_SciUint16_FromUnsignedShortArrayAndSize", "header") {
|
||||
SWIGINTERN int
|
||||
SWIG_SciUint16_FromUnsignedShortArrayAndSize(void *_pvApiCtx, int _iVarOut, int _iRows, int _iCols, unsigned short *_pusValue) {
|
||||
SWIG_SciUint16_FromUnsignedShortArrayAndSize(void *_pvApiCtx, int _iVarOut, int _iRows, int _iCols, unsigned short *_pusValues) {
|
||||
SciErr sciErr;
|
||||
double *pdValues = NULL;
|
||||
int i;
|
||||
|
||||
sciErr = createMatrixOfUnsignedInteger16(_pvApiCtx, SWIG_NbInputArgument(_pvApiCtx) + _iVarOut, _iRows, _iCols, _pusValue);
|
||||
if (sciErr.iErr) {
|
||||
pdValues = (double*) malloc(_iRows * _iCols * sizeof(double));
|
||||
for (i=0; i<_iRows * _iCols; i++)
|
||||
pdValues[i] = _pusValues[i];
|
||||
|
||||
sciErr = createMatrixOfDouble(_pvApiCtx, SWIG_NbInputArgument(_pvApiCtx) + _iVarOut, _iRows, _iCols, pdValues);
|
||||
if (sciErr.iErr)
|
||||
{
|
||||
printError(&sciErr, 0);
|
||||
free(pdValues);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
free(pdValues);
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue