From e1d59d0016f65cc4b15f0f1840b3beef5555267a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20DAVID?= Date: Wed, 19 Apr 2023 09:32:02 +1200 Subject: [scilab] Extract values with ":" Fixes #894 --- Lib/scilab/scidouble.swg | 14 +++++++++++++- Lib/scilab/sciint.swg | 5 +++++ Lib/scilab/scimatrixdouble.swg | 12 ++++++++++-- Lib/scilab/scimatrixint.swg | 12 ++++++++++-- 4 files changed, 38 insertions(+), 5 deletions(-) (limited to 'Lib') diff --git a/Lib/scilab/scidouble.swg b/Lib/scilab/scidouble.swg index 1b8263306..e14c84647 100644 --- a/Lib/scilab/scidouble.swg +++ b/Lib/scilab/scidouble.swg @@ -56,6 +56,7 @@ SWIG_SciDouble_FromDouble(void *pvApiCtx, int iVarOut, double dblValue, char *fn SWIGINTERN int SWIG_SciDouble_AsDoubleArrayAndSize(void *pvApiCtx, int iVar, int *iRows, int *iCols, double **pdValue, char *fname) { SciErr sciErr; + int iType = 0; int *piAddrVar = NULL; sciErr = getVarAddressFromPosition(pvApiCtx, iVar, &piAddrVar); @@ -64,13 +65,24 @@ SWIG_SciDouble_AsDoubleArrayAndSize(void *pvApiCtx, int iVar, int *iRows, int *i return SWIG_ERROR; } - if (isDoubleType(pvApiCtx, piAddrVar) && !isVarComplex(pvApiCtx, piAddrVar)) { + sciErr = getVarType(pvApiCtx, piAddrVar, &iType); + if (sciErr.iErr) { + printError(&sciErr, 0); + return SWIG_ERROR; + } + + if (iType == sci_matrix && !isVarComplex(pvApiCtx, piAddrVar)) { sciErr = getMatrixOfDouble(pvApiCtx, piAddrVar, iRows, iCols, pdValue); if (sciErr.iErr) { printError(&sciErr, 0); return SWIG_ERROR; } } + else if (iType == sci_implicit_poly) { + *iRows = -1; + *iCols = 0; + *pdValue = NULL; + } else { Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A real matrix expected.\n"), fname, iVar); return SWIG_ERROR; diff --git a/Lib/scilab/sciint.swg b/Lib/scilab/sciint.swg index 2d6993569..b7b2563e8 100644 --- a/Lib/scilab/sciint.swg +++ b/Lib/scilab/sciint.swg @@ -157,6 +157,11 @@ SWIG_SciDoubleOrInt32_AsIntArrayAndSize(void *pvApiCtx, int iVar, int *iRows, in return SWIG_ERROR; } } + else if (iType == sci_implicit_poly) { + *iRows = -1; + *iCols = 0; + *piValue = NULL; + } else { Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A 32-bit signed integer or a double matrix expected.\n"), fname, iVar); return SWIG_ERROR; diff --git a/Lib/scilab/scimatrixdouble.swg b/Lib/scilab/scimatrixdouble.swg index 9444a8078..bb9403edd 100644 --- a/Lib/scilab/scimatrixdouble.swg +++ b/Lib/scilab/scimatrixdouble.swg @@ -28,7 +28,11 @@ %typemap(in, noblock=1, fragment="SWIG_SciDouble_AsDoubleArrayAndSize") (double *IN, int IN_SIZE) (int rowCount, int colCount) { if (SWIG_SciDouble_AsDoubleArrayAndSize(pvApiCtx, $input, &rowCount, &colCount, &$1, fname) == SWIG_OK) { - $2 = rowCount * colCount; + if (rowCount < 0) { + $2 = rowCount; + } else { + $2 = rowCount * colCount; + } } else { return SWIG_ERROR; @@ -40,7 +44,11 @@ %typemap(in, noblock=1, fragment="SWIG_SciDouble_AsDoubleArrayAndSize") (int IN_SIZE, double *IN) (int rowCount, int colCount) { if (SWIG_SciDouble_AsDoubleArrayAndSize(pvApiCtx, $input, &rowCount, &colCount, &$2, fname) == SWIG_OK) { - $1 = rowCount * colCount; + if (rowCount < 0) { + $1 = rowCount; + } else { + $1 = rowCount * colCount; + } } else { return SWIG_ERROR; diff --git a/Lib/scilab/scimatrixint.swg b/Lib/scilab/scimatrixint.swg index e304d4f64..057710725 100644 --- a/Lib/scilab/scimatrixint.swg +++ b/Lib/scilab/scimatrixint.swg @@ -30,7 +30,11 @@ %typemap(in, noblock=1, fragment="SWIG_SciDoubleOrInt32_AsIntArrayAndSize") (int *IN, int IN_SIZE) (int rowCount, int colCount) { if (SWIG_SciDoubleOrInt32_AsIntArrayAndSize(pvApiCtx, $input, &rowCount, &colCount, &$1, fname) == SWIG_OK) { - $2 = rowCount * colCount; + if (rowCount < 0) { + $2 = rowCount; + } else { + $2 = rowCount * colCount; + } } else { return SWIG_ERROR; @@ -43,7 +47,11 @@ %typemap(in, noblock=1, fragment="SWIG_SciDoubleOrInt32_AsIntArrayAndSize") (int IN_SIZE, int *IN) (int rowCount, int colCount) { if (SWIG_SciDoubleOrInt32_AsIntArrayAndSize(pvApiCtx, $input, &rowCount, &colCount, &$2, fname) == SWIG_OK) { - $1 = rowCount * colCount; + if (rowCount < 0) { + $1 = rowCount; + } else { + $1 = rowCount * colCount; + } } else { return SWIG_ERROR; -- cgit v1.2.1