* New version for Scilab module using fragments
* A C and CPP tests generate and compile except tests using vectors (to be done) git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2009-sploving@12698 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
6db40d8378
commit
a8b8b6c5d4
41 changed files with 2679 additions and 2557 deletions
86
Lib/scilab/scibool.swg
Normal file
86
Lib/scilab/scibool.swg
Normal file
|
|
@ -0,0 +1,86 @@
|
|||
/*
|
||||
* C-type: bool
|
||||
* Scilab type: boolean scalar
|
||||
*/
|
||||
%fragment(SWIG_AsVal_frag(bool), "header", fragment="SWIG_SciBoolean_AsBool") {
|
||||
#define SWIG_AsVal_bool(scilabValue, valuePointer) SWIG_SciBoolean_AsBool(pvApiCtx, scilabValue, valuePointer, fname)
|
||||
}
|
||||
%fragment("SWIG_SciBoolean_AsBool", "header") {
|
||||
SWIGINTERN int
|
||||
SWIG_SciBoolean_AsBool(void *_pvApiCtx, int _iVar, bool *_pbValue, char *_fname) {
|
||||
SciErr sciErr;
|
||||
int iRet = 0;
|
||||
int *piAddrVar = NULL;
|
||||
|
||||
sciErr = getVarAddressFromPosition(_pvApiCtx, _iVar, &piAddrVar);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
if (!isBooleanType(_pvApiCtx, piAddrVar)) {
|
||||
Scierror(999, _("%s: Wrong type for input argument #%d: A boolean expected.\n"), _fname, _iVar);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
if (!isScalar(_pvApiCtx, piAddrVar)) {
|
||||
Scierror(999, _("%s: Wrong size for input argument #%d: A boolean expected.\n"), _fname, _iVar);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
iRet = getScalarBoolean(_pvApiCtx, piAddrVar, (int*)_pbValue);
|
||||
if (iRet) {
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_From_frag(bool), "header", fragment="SWIG_SciBoolean_FromBool") {
|
||||
#define SWIG_From_bool(value) SWIG_SciBoolean_FromBool(pvApiCtx, $result, value)
|
||||
}
|
||||
%fragment("SWIG_SciBoolean_FromBool", "header") {
|
||||
SWIGINTERN int
|
||||
SWIG_SciBoolean_FromBool(void *_pvApiCtx, int _iVarOut, bool _bValue) {
|
||||
int iRet = 0;
|
||||
|
||||
iRet = createScalarBoolean(_pvApiCtx, Rhs + _iVarOut, _bValue);
|
||||
if (iRet) {
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
return Rhs + _iVarOut;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* C-type: bool[]
|
||||
* Scilab type: boolean vector (but converted to int first because can not cast bool** to int **
|
||||
*/
|
||||
%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)) {
|
||||
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 vector expected.\n"), _fname, _iVar);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
238
Lib/scilab/scichar.swg
Normal file
238
Lib/scilab/scichar.swg
Normal file
|
|
@ -0,0 +1,238 @@
|
|||
/*
|
||||
* C-type: char
|
||||
* Scilab type: string
|
||||
*/
|
||||
%fragment(SWIG_AsVal_frag(char), "header", fragment="SwigScilabStringToChar") {
|
||||
#define SWIG_AsVal_char(scilabValue, valuePointer) SwigScilabStringToChar(pvApiCtx, scilabValue, valuePointer, fname)
|
||||
}
|
||||
%fragment("SwigScilabStringToChar", "header") {
|
||||
SWIGINTERN int
|
||||
SwigScilabStringToChar(void *_pvApiCtx, int _iVar, char *_pcValue, char *_fname) {
|
||||
SciErr sciErr;
|
||||
int iType = 0;
|
||||
int iRows = 0;
|
||||
int iCols = 0;
|
||||
int *piAddrVar = NULL;
|
||||
char *_pstStrings = NULL;
|
||||
int _piLength = 0;
|
||||
|
||||
sciErr = getVarAddressFromPosition(pvApiCtx, _iVar, &piAddrVar);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
sciErr = getVarType(pvApiCtx, piAddrVar, &iType);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
if (iType != sci_strings) {
|
||||
Scierror(999, _("%s: Wrong type for input argument #%d: A string expected.\n"), _fname, _iVar);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
_pstStrings = (char *)MALLOC(sizeof(char));
|
||||
sciErr = getMatrixOfString(pvApiCtx, piAddrVar, &iRows, &iCols, &_piLength, (char **)&_pstStrings);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
if (iRows * iCols != 1) {
|
||||
Scierror(999, _("%s: Wrong size for input argument #%d: A string expected.\n"), _fname, _iVar);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
*_pcValue = _pstStrings[0];
|
||||
|
||||
FREE(_pstStrings);
|
||||
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_From_frag(char), "header", fragment="SwigScilabStringFromChar") {
|
||||
#define SWIG_From_char(value) SwigScilabStringFromChar(pvApiCtx, $result, value)
|
||||
}
|
||||
%fragment("SwigScilabStringFromChar", "header") {
|
||||
SWIGINTERN int
|
||||
SwigScilabStringFromChar(void *_pvApiCtx, int _iVarOut, char _chValue) {
|
||||
SciErr sciErr;
|
||||
|
||||
char *pchValue = (char*)MALLOC(sizeof(char) * 2);
|
||||
pchValue[0] = _chValue;
|
||||
pchValue[1] = '\0';
|
||||
|
||||
sciErr = createMatrixOfString(_pvApiCtx, Rhs + _iVarOut, 1, 1, &pchValue);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
FREE(pchValue);
|
||||
|
||||
return Rhs + _iVarOut;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* CHAR *
|
||||
*/
|
||||
%fragment("SWIG_AsCharArray", "header", fragment = "SwigScilabStringToCharPtr") {
|
||||
#define SWIG_AsCharArray(scilabValue, charPtrPointer, charPtrLength) SwigScilabStringToCharPtr(pvApiCtx, scilabValue, charPtrPointer, charPtrLength, fname)
|
||||
}
|
||||
%fragment("SWIG_AsCharPtrAndSize", "header", fragment = "SwigScilabStringToCharPtrAndSize") {
|
||||
#define SWIG_AsCharPtrAndSize(scilabValue, charPtrPointer, charPtrLength, allocMemory) SwigScilabStringToCharPtrAndSize(pvApiCtx, scilabValue, charPtrPointer, charPtrLength, allocMemory, fname)
|
||||
}
|
||||
%fragment("SWIG_FromCharPtr", "header", fragment = "SwigScilabStringFromCharPtr") {
|
||||
#define SWIG_FromCharPtr(charPtr) SwigScilabStringFromCharPtr(pvApiCtx, $result, charPtr)
|
||||
}
|
||||
%fragment("SWIG_FromCharPtrAndSize", "header", fragment = "SwigScilabStringFromCharPtrAndSize") {
|
||||
#define SWIG_FromCharPtrAndSize(charPtr, charPtrLength) SwigScilabStringFromCharPtrAndSize(pvApiCtx, $result, charPtr)
|
||||
}
|
||||
%fragment("SwigScilabStringToCharPtr", "header") {
|
||||
SWIGINTERN int
|
||||
SwigScilabStringToCharPtr(void *_pvApiCtx, int _iVar, char *_pcValue, int _iLength, char *_fname) {
|
||||
SciErr sciErr;
|
||||
int iRows = 0;
|
||||
int iCols = 0;
|
||||
int iType = 0;
|
||||
int *piAddrVar = NULL;
|
||||
char *pstStrings = NULL;
|
||||
int piLength = 0;
|
||||
|
||||
sciErr = getVarAddressFromPosition(pvApiCtx, _iVar, &piAddrVar);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
sciErr = getVarType(pvApiCtx, piAddrVar, &iType);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
if (iType != sci_strings) {
|
||||
Scierror(999, _("%s: Wrong type for input argument #%d: A string expected.\n"), _fname, _iVar);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
sciErr = getMatrixOfString(pvApiCtx, piAddrVar, &iRows, &iCols, &piLength, NULL);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
if (iRows * iCols != 1) {
|
||||
Scierror(999, _("%s: Wrong size for input argument #%d: A string expected.\n"), _fname, _iVar);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
pstStrings = (char *)MALLOC(sizeof(char) * (piLength + 1));
|
||||
sciErr = getMatrixOfString(pvApiCtx, piAddrVar, &iRows, &iCols, &piLength, (char **)&pstStrings);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
strcpy(_pcValue, pstStrings);
|
||||
|
||||
FREE(pstStrings);
|
||||
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
%fragment("SwigScilabStringToCharPtrAndSize", "header") {
|
||||
SWIGINTERN int
|
||||
SwigScilabStringToCharPtrAndSize(void *_pvApiCtx, int _iVar, char **_pcValue, size_t *_piLength, int *alloc, char *_fname) {
|
||||
SciErr sciErr;
|
||||
int iRows = 0;
|
||||
int iCols = 0;
|
||||
int iType = 0;
|
||||
int *piAddrVar = NULL;
|
||||
char *_pstStrings = NULL;
|
||||
int piLength = 0;
|
||||
|
||||
sciErr = getVarAddressFromPosition(pvApiCtx, _iVar, &piAddrVar);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
sciErr = getVarType(pvApiCtx, piAddrVar, &iType);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
if (iType != sci_strings) {
|
||||
Scierror(999, _("%s: Wrong type for input argument #%d: A string expected.\n"), _fname, _iVar);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
sciErr = getMatrixOfString(pvApiCtx, piAddrVar, &iRows, &iCols, &piLength, NULL);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
if (iRows * iCols != 1) {
|
||||
Scierror(999, _("%s: Wrong size for input argument #%d: A string expected.\n"), _fname, _iVar);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
_pstStrings = (char *)MALLOC(sizeof(char) * (piLength + 1));
|
||||
sciErr = getMatrixOfString(pvApiCtx, piAddrVar, &iRows, &iCols, &piLength, (char **)&_pstStrings);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
if (_pcValue != NULL) {
|
||||
*_pcValue = strdup(_pstStrings);
|
||||
}
|
||||
|
||||
FREE(_pstStrings);
|
||||
|
||||
if (_piLength != NULL) {
|
||||
*_piLength = (size_t) piLength;
|
||||
}
|
||||
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
%fragment("SwigScilabStringFromCharPtr", "header") {
|
||||
SWIGINTERN int
|
||||
SwigScilabStringFromCharPtr(void *_pvApiCtx, int _iVarOut, const char *_pchValue) {
|
||||
SciErr sciErr;
|
||||
char **pstData = NULL;
|
||||
|
||||
pstData = (char **)MALLOC(sizeof(char *));
|
||||
pstData[0] = strdup(_pchValue);
|
||||
|
||||
sciErr = createMatrixOfString(_pvApiCtx, Rhs + _iVarOut, 1, 1, (char **)pstData);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
freeArrayOfString(pstData, 1);
|
||||
|
||||
return Rhs + _iVarOut;
|
||||
}
|
||||
}
|
||||
%fragment("SwigScilabStringFromCharPtrAndSize", "header") {
|
||||
SWIGINTERN int
|
||||
SwigScilabStringFromCharPtrAndSize(void *_pvApiCtx, int _iVarOut, const char *_pchValue) {
|
||||
SciErr sciErr;
|
||||
char **pstData = NULL;
|
||||
|
||||
pstData = (char **)MALLOC(sizeof(char *));
|
||||
pstData[0] = strdup(_pchValue);
|
||||
|
||||
sciErr = createMatrixOfString(_pvApiCtx, Rhs + _iVarOut, 1, 1, (char **)pstData);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
FREE(pstData);
|
||||
|
||||
return Rhs + _iVarOut;
|
||||
}
|
||||
}
|
||||
127
Lib/scilab/scidouble.swg
Normal file
127
Lib/scilab/scidouble.swg
Normal file
|
|
@ -0,0 +1,127 @@
|
|||
/*
|
||||
* DOUBLE SCALAR
|
||||
*/
|
||||
%fragment(SWIG_AsVal_frag(double), "header", fragment="SwigScilabDoubleToDouble") {
|
||||
#define SWIG_AsVal_double(scilabValue, valuePointer) SwigScilabDoubleToDouble(pvApiCtx, scilabValue, valuePointer, fname)
|
||||
}
|
||||
%fragment(SWIG_From_frag(double), "header", fragment="SwigScilabDoubleFromDouble") {
|
||||
#define SWIG_From_double(value) SwigScilabDoubleFromDouble(pvApiCtx, $result, value)
|
||||
}
|
||||
|
||||
%fragment("SwigScilabDoubleToDouble", "header") {
|
||||
SWIGINTERN int
|
||||
SwigScilabDoubleToDouble(void *_pvApiCtx, int _iVar, double *_pdblValue, char *_fname) {
|
||||
SciErr sciErr;
|
||||
int iRet = 0;
|
||||
int *piAddrVar = NULL;
|
||||
|
||||
sciErr = getVarAddressFromPosition(_pvApiCtx, _iVar, &piAddrVar);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
if (!isDoubleType(_pvApiCtx, piAddrVar) || isVarComplex(_pvApiCtx, piAddrVar)) {
|
||||
Scierror(999, _("%s: Wrong type for input argument #%d: A real expected.\n"), _fname, _iVar);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
if (!isScalar(_pvApiCtx, piAddrVar)) {
|
||||
Scierror(999, _("%s: Wrong size for input argument #%d: A real expected.\n"), _fname, _iVar);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
iRet = getScalarDouble(_pvApiCtx, piAddrVar, _pdblValue);
|
||||
if (iRet) {
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
|
||||
%fragment("SwigScilabDoubleFromDouble", "header") {
|
||||
SWIGINTERN int
|
||||
SwigScilabDoubleFromDouble(void *_pvApiCtx, int _iVarOut, double _dblValue) {
|
||||
int iRet;
|
||||
|
||||
iRet = createScalarDouble(_pvApiCtx, Rhs + _iVarOut, _dblValue);
|
||||
if (iRet) {
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
return Rhs + _iVarOut;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* DOUBLE ARRAY
|
||||
*/
|
||||
%fragment("SwigScilabDoubleToDoubleArray", "header") {
|
||||
SWIGINTERN int
|
||||
SwigScilabDoubleToDoubleArray(void *_pvApiCtx, int _iVar, double **_pdblDoubleValue, char *_fname) {
|
||||
SciErr sciErr;
|
||||
int iRows = 0;
|
||||
int iCols = 0;
|
||||
int *piAddrVar = NULL;
|
||||
|
||||
sciErr = getVarAddressFromPosition(_pvApiCtx, _iVar, &piAddrVar);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
if (isDoubleType(_pvApiCtx, piAddrVar) && !isVarComplex(_pvApiCtx, piAddrVar)) {
|
||||
sciErr = getMatrixOfDouble(_pvApiCtx, piAddrVar, &iRows, &iCols, _pdblDoubleValue);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
} else {
|
||||
Scierror(999, _("%s: Wrong type for input argument #%d: A real matrix expected.\n"), _fname, _iVar);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
%fragment("SWIG_SciDouble_AsDoubleArrayAndSize", "header") {
|
||||
SWIGINTERN int
|
||||
SWIG_SciDouble_AsDoubleArrayAndSize(void *_pvApiCtx, int _iVar, int *_iRows, int *_iCols, double **_pdblDoubleValue, char *_fname) {
|
||||
SciErr sciErr;
|
||||
int *piAddrVar = NULL;
|
||||
|
||||
sciErr = getVarAddressFromPosition(_pvApiCtx, _iVar, &piAddrVar);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
if (isDoubleType(_pvApiCtx, piAddrVar) && !isVarComplex(_pvApiCtx, piAddrVar)) {
|
||||
sciErr = getMatrixOfDouble(_pvApiCtx, piAddrVar, _iRows, _iCols, _pdblDoubleValue);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
} else {
|
||||
Scierror(999, _("%s: Wrong type for input argument #%d: A real matrix expected.\n"), _fname, _iVar);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
%fragment("SWIG_SciDouble_FromDoubleArrayAndSize", "header") {
|
||||
SWIGINTERN int
|
||||
SWIG_SciDouble_FromDoubleArrayAndSize(void *_pvApiCtx, int _iVarOut, int _iRows, int _iCols, double *_pdblValue) {
|
||||
SciErr sciErr;
|
||||
|
||||
sciErr = createMatrixOfDouble(_pvApiCtx, Rhs + _iVarOut, _iRows, _iCols, _pdblValue);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
return Rhs + _iVarOut;
|
||||
}
|
||||
}
|
||||
40
Lib/scilab/scifloat.swg
Normal file
40
Lib/scilab/scifloat.swg
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* FLOAT SCALAR
|
||||
*/
|
||||
%fragment(SWIG_AsVal_frag(float), "header", fragment="SwigScilabDoubleToFloat") {
|
||||
#define SWIG_AsVal_float(scilabValue, valuePointer) SwigScilabDoubleToFloat(pvApiCtx, scilabValue, valuePointer, fname)
|
||||
}
|
||||
|
||||
%fragment(SWIG_From_frag(float), "header", fragment="SwigScilabDoubleFromFloat") {
|
||||
#define SWIG_From_float(value) SwigScilabDoubleFromFloat(pvApiCtx, $result, value)
|
||||
}
|
||||
|
||||
%fragment("SwigScilabDoubleToFloat", "header", fragment="SwigScilabDoubleToDouble") {
|
||||
SWIGINTERN int
|
||||
SwigScilabDoubleToFloat(void *_pvApiCtx, int _iVar, float *_pfValue, char *_fname) {
|
||||
double dblValue = 0.0;
|
||||
if(SwigScilabDoubleToDouble(_pvApiCtx, _iVar, &dblValue, _fname) != SWIG_OK) {
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
*_pfValue = (float) dblValue;
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
|
||||
%fragment("SwigScilabDoubleFromFloat", "header") {
|
||||
SWIGINTERN int
|
||||
SwigScilabDoubleFromFloat(void *_pvApiCtx, int _iVarOut, float _flValue) {
|
||||
SciErr sciErr;
|
||||
double dblDoubleValue = (double) _flValue;
|
||||
int iRowsOut = 1;
|
||||
int iColsOut = 1;
|
||||
|
||||
sciErr = createMatrixOfDouble(_pvApiCtx, Rhs + _iVarOut, iRowsOut, iColsOut, &dblDoubleValue);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
return Rhs + _iVarOut;
|
||||
}
|
||||
}
|
||||
106
Lib/scilab/sciint.swg
Normal file
106
Lib/scilab/sciint.swg
Normal file
|
|
@ -0,0 +1,106 @@
|
|||
/*
|
||||
* C-type: int
|
||||
* Scilab type: double scalar
|
||||
*/
|
||||
%fragment(SWIG_AsVal_frag(int), "header", fragment="SWIG_SciDouble_AsInt") {
|
||||
#define SWIG_AsVal_int(scilabValue, valuePointer) SWIG_SciDouble_AsInt(pvApiCtx, scilabValue, valuePointer, fname)
|
||||
}
|
||||
%fragment(SWIG_AsVal_frag(size_t), "header", fragment="SWIG_SciDouble_AsInt") {
|
||||
#define SWIG_AsVal_size_t(scilabValue, valuePointer) SWIG_SciDouble_AsInt(pvApiCtx, scilabValue, (int*)valuePointer, fname)
|
||||
}
|
||||
%fragment("SWIG_SciDouble_AsInt", "header", fragment="SwigScilabDoubleToDouble") {
|
||||
SWIGINTERN int
|
||||
SWIG_SciDouble_AsInt(void *_pvApiCtx, int _iVar, int *_piValue, char *_fname) {
|
||||
double dblValue = 0.0;
|
||||
if(SwigScilabDoubleToDouble(_pvApiCtx, _iVar, &dblValue, _fname) != SWIG_OK) {
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
*_piValue = (int) dblValue;
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_From_frag(int), "header", fragment="SWIG_SciDouble_FromInt") {
|
||||
#define SWIG_From_int(value) SWIG_SciDouble_FromInt(pvApiCtx, $result, value)
|
||||
}
|
||||
%fragment(SWIG_From_frag(size_t), "header", fragment="SWIG_SciDouble_FromInt") {
|
||||
#define SWIG_From_size_t(value) SWIG_SciDouble_FromInt(pvApiCtx, $result, (int)value)
|
||||
}
|
||||
%fragment("SWIG_SciDouble_FromInt", "header") {
|
||||
SWIGINTERN int
|
||||
SWIG_SciDouble_FromInt(void *_pvApiCtx, int _iVarOut, int _iValue) {
|
||||
SciErr sciErr;
|
||||
double dblDoubleValue = (double) _iValue;
|
||||
int iRowsOut = 1;
|
||||
int iColsOut = 1;
|
||||
|
||||
sciErr = createMatrixOfDouble(_pvApiCtx, Rhs + _iVarOut, iRowsOut, iColsOut, &dblDoubleValue);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
return Rhs + _iVarOut;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* C-type: int[ANY]
|
||||
* Scilab type: int32 vector
|
||||
*/
|
||||
%fragment("SWIG_SciInt32_AsIntArrayAndSize", "header") {
|
||||
SWIGINTERN int
|
||||
SWIG_SciInt32_AsIntArrayAndSize(void *_pvApiCtx, int _iVar, int *_iRows, int *_iCols, int **_piValue, char *_fname) {
|
||||
SciErr sciErr;
|
||||
int iType = 0;
|
||||
int iPrec = 0;
|
||||
int *piAddrVar = NULL;
|
||||
|
||||
sciErr = getVarAddressFromPosition(_pvApiCtx, _iVar, &piAddrVar);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
sciErr = getVarType(_pvApiCtx, piAddrVar, &iType);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
if (iType != sci_ints) {
|
||||
Scierror(999, _("%s: Wrong type for input argument #%d: A 32-bit signed 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_INT32) {
|
||||
Scierror(999, _("%s: Wrong type for input argument #%d: A 32-bit signed integer vector expected.\n"), _fname, _iVar);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
sciErr = getMatrixOfInteger32(_pvApiCtx, piAddrVar, _iRows, _iCols, _piValue);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
%fragment("SWIG_SciInt32_FromIntArrayAndSize", "header") {
|
||||
SWIGINTERN int
|
||||
SWIG_SciInt32_FromIntArrayAndSize(void *_pvApiCtx, int _iVarOut, int _iRows, int _iCols, const int *_piData) {
|
||||
SciErr sciErr;
|
||||
|
||||
sciErr = createMatrixOfInteger32(_pvApiCtx, Rhs + _iVarOut, _iRows, _iCols, _piData);
|
||||
if(sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
return Rhs + _iVarOut;
|
||||
}
|
||||
}
|
||||
83
Lib/scilab/scilong.swg
Normal file
83
Lib/scilab/scilong.swg
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
/*
|
||||
* C-type: long
|
||||
* Scilab type: double scalar
|
||||
*/
|
||||
%fragment(SWIG_AsVal_frag(long), "header", fragment="SwigScilabDoubleToLong") {
|
||||
#define SWIG_AsVal_long(scilabValue, valuePointer) SwigScilabDoubleToLong(pvApiCtx, scilabValue, valuePointer, fname)
|
||||
}
|
||||
|
||||
%fragment(SWIG_From_frag(long), "header", fragment="SwigScilabDoubleFromLong") {
|
||||
#define SWIG_From_long(value) SwigScilabDoubleFromLong(pvApiCtx, $result, value)
|
||||
}
|
||||
|
||||
/*
|
||||
* C-type: unsigned long
|
||||
* Scilab type: double scalar
|
||||
*/
|
||||
%fragment(SWIG_AsVal_frag(unsigned long), "header", fragment="SwigScilabDoubleToUnsignedLong") {
|
||||
#define SWIG_AsVal_unsigned_SS_long(scilabValue, valuePointer) SwigScilabDoubleToUnsignedLong(pvApiCtx, scilabValue, valuePointer, fname)
|
||||
}
|
||||
|
||||
%fragment(SWIG_From_frag(unsigned long), "header", fragment="SwigScilabDoubleFromUnsignedLong") {
|
||||
#define SWIG_From_unsigned_SS_long(value) SwigScilabDoubleFromUnsignedLong(pvApiCtx, $result, value)
|
||||
}
|
||||
|
||||
%fragment("SwigScilabDoubleToLong", "header", fragment="SwigScilabDoubleToDouble") {
|
||||
SWIGINTERN int
|
||||
SwigScilabDoubleToLong(void *_pvApiCtx, int _iVar, long *_plValue, char *_fname) {
|
||||
double dblValue = 0.0;
|
||||
if(SwigScilabDoubleToDouble(_pvApiCtx, _iVar, &dblValue, _fname) != SWIG_OK) {
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
*_plValue = (long) dblValue;
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
|
||||
%fragment("SwigScilabDoubleToUnsignedLong", "header", fragment="SwigScilabDoubleToDouble") {
|
||||
SWIGINTERN int
|
||||
SwigScilabDoubleToUnsignedLong(void *_pvApiCtx, int _iVar, unsigned long *_pulValue, char *_fname) {
|
||||
double dblValue = 0.0;
|
||||
if(SwigScilabDoubleToDouble(_pvApiCtx, _iVar, &dblValue, _fname) != SWIG_OK) {
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
*_pulValue = (unsigned long) dblValue;
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
|
||||
%fragment("SwigScilabDoubleFromLong", "header") {
|
||||
SWIGINTERN int
|
||||
SwigScilabDoubleFromLong(void *_pvApiCtx, int _iVarOut, long _lValue) {
|
||||
SciErr sciErr;
|
||||
double dblDoubleValue = (double) _lValue;
|
||||
int iRowsOut = 1;
|
||||
int iColsOut = 1;
|
||||
|
||||
sciErr = createMatrixOfDouble(_pvApiCtx, Rhs + _iVarOut, iRowsOut, iColsOut, &dblDoubleValue);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
return Rhs + _iVarOut;
|
||||
}
|
||||
}
|
||||
|
||||
%fragment("SwigScilabDoubleFromUnsignedLong", "header") {
|
||||
SWIGINTERN int
|
||||
SwigScilabDoubleFromUnsignedLong(void *_pvApiCtx, int _iVarOut, unsigned long _ulValue) {
|
||||
SciErr sciErr;
|
||||
double dblDoubleValue = (double) _ulValue;
|
||||
int iRowsOut = 1;
|
||||
int iColsOut = 1;
|
||||
|
||||
sciErr = createMatrixOfDouble(_pvApiCtx, Rhs + _iVarOut, iRowsOut, iColsOut, &dblDoubleValue);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
return Rhs + _iVarOut;
|
||||
}
|
||||
}
|
||||
54
Lib/scilab/scilonglong.swg
Normal file
54
Lib/scilab/scilonglong.swg
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
/*
|
||||
* C-type: long
|
||||
* Scilab 5 type: NONE
|
||||
* Scilab 6 type: int64
|
||||
*/
|
||||
%fragment(SWIG_AsVal_frag(long long), "header", fragment="SWIG_SciInt64_ToLongLong") {
|
||||
#define SWIG_AsVal_long_SS_long(scilabValue, valuePointer) SWIG_SciInt64_ToLongLong(pvApiCtx, scilabValue, valuePointer, fname)
|
||||
}
|
||||
%fragment("SWIG_SciInt64_ToLongLong", "header") {
|
||||
SWIGINTERN int
|
||||
SWIG_SciInt64_ToLongLong(void *_pvApiCtx, int _iVar, long long *_pllValue, char *_fname) {
|
||||
Scierror(999, _("%s: Scilab 5.X does not manage '%s' data type.\n"), "SWIG_SciInt64_ToLongLong", "int64");
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_From_frag(long long), "header", fragment="SWIG_SciInt64_FromLongLong") {
|
||||
#define SWIG_From_long_SS_long(value) SWIG_SciInt64_FromLongLong(pvApiCtx, $result, value)
|
||||
}
|
||||
%fragment("SWIG_SciInt64_FromLongLong", "header") {
|
||||
SWIGINTERN int
|
||||
SWIG_SciInt64_FromLongLong(void *_pvApiCtx, int _iVarOut, long long _llValue) {
|
||||
Scierror(999, _("%s: Scilab 5.X does not manage '%s' data type.\n"), "SWIG_SciInt64_ToLongLong", "int64");
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* C-type: unsigned long long
|
||||
* Scilab 5 type: NONE
|
||||
* Scilab 6 type: uint64
|
||||
*/
|
||||
%fragment(SWIG_AsVal_frag(unsigned long long), "header", fragment="SWIG_SciUint64_ToUnsignedLongLong") {
|
||||
#define SWIG_AsVal_unsigned_SS_long_SS_long(scilabValue, valuePointer) SWIG_SciUint64_ToUnsignedLongLong(pvApiCtx, scilabValue, valuePointer, fname)
|
||||
}
|
||||
%fragment("SWIG_SciUint64_ToUnsignedLongLong", "header") {
|
||||
SWIGINTERN int
|
||||
SWIG_SciUint64_ToUnsignedLongLong(void *_pvApiCtx, int _iVar, unsigned long long *_pullValue, char *_fname) {
|
||||
Scierror(999, _("%s: Scilab 5.X does not manage '%s' data type.\n"), "SWIG_SciUint64_ToLongLong", "uint64");
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_From_frag(unsigned long long), "header", fragment="SWIG_SciUint64_FromUnsignedLongLong") {
|
||||
#define SWIG_From_unsigned_SS_long_SS_long(value) SWIG_SciUint64_FromUnsignedLongLong(pvApiCtx, $result, value)
|
||||
}
|
||||
%fragment("SWIG_SciUint64_FromUnsignedLongLong", "header") {
|
||||
SWIGINTERN int
|
||||
SWIG_SciUint64_FromUnsignedLongLong(void *_pvApiCtx, int _iVarOut, unsigned long long _llValue) {
|
||||
Scierror(999, _("%s: Scilab 5.X does not manage '%s' data type.\n"), "SWIG_SciUint64_ToLongLong", "uint64");
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
32
Lib/scilab/scipointer.swg
Normal file
32
Lib/scilab/scipointer.swg
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
* POINTER
|
||||
*/
|
||||
%fragment("SWIG_ConvertPtr", "header") {
|
||||
#define SWIG_ConvertPtr(scilabValue, voidPointer, pointerDescriptor, flags) SwigScilabPtrToObject(pvApiCtx, scilabValue, voidPointer, pointerDescriptor, flags, fname)
|
||||
}
|
||||
|
||||
%fragment("SWIG_NewPointerObj", "header") {
|
||||
#define SWIG_NewPointerObj(pointer, pointerDescriptor, flags) SwigScilabPtrFromObject(pvApiCtx, $result, pointer, pointerDescriptor, flags)
|
||||
}
|
||||
|
||||
/*
|
||||
* FUNCTION POINTER
|
||||
*/
|
||||
%fragment("SWIG_ConvertFunctionPtr", "header") {
|
||||
#define SWIG_ConvertFunctionPtr(scilabValue, voidPointer, pointerDescriptor) SwigScilabPtrToObject(pvApiCtx, scilabValue, voidPointer, pointerDescriptor, 0, fname)
|
||||
}
|
||||
|
||||
%fragment("SWIG_NewFunctionPtrObj", "header") {
|
||||
#define SWIG_NewFunctionPtrObj(pointer, pointerDescriptor) SwigScilabPtrFromObject(pvApiCtx, $result, pointer, pointerDescriptor, 0)
|
||||
}
|
||||
// No fragment used here, the functions "SwigScilabPtrToObject" and "SwigScilabPtrFromObject" are defined in sciruntime.swg
|
||||
|
||||
/*
|
||||
* C++ member pointers, ie, member methods
|
||||
*/
|
||||
%fragment("SWIG_NewMemberObj", "header") {
|
||||
#define SWIG_NewMemberObj(ptr, sz, tp) SWIG_Scilab_NewMemberObj(pvApiCtx, $result, ptr, sz, tp)
|
||||
}
|
||||
%fragment("SWIG_ConvertMember", "header") {
|
||||
#define SWIG_ConvertMember(obj, ptr, sz, ty) SWIG_Scilab_ConvertPacked(pvApiCtx, obj, ptr, sz, ty, fname)
|
||||
}
|
||||
|
|
@ -1,183 +1,75 @@
|
|||
%fragment("SWIG_AsCharPtrAndSize","header") {
|
||||
%include <scidouble.swg>
|
||||
%include <scilong.swg>
|
||||
%include <scifloat.swg>
|
||||
|
||||
%include <scilonglong.swg>
|
||||
|
||||
%include <sciint.swg>
|
||||
%include <sciunsignedint.swg>
|
||||
|
||||
%include <scishort.swg>
|
||||
%include <sciunsignedshort.swg>
|
||||
|
||||
%include <scichar.swg>
|
||||
%include <scisignedchar.swg>
|
||||
%include <sciunsignedchar.swg>
|
||||
|
||||
%include <scipointer.swg>
|
||||
%include <scibool.swg>
|
||||
|
||||
%fragment("SwigScilabInt32ToEnum", "header") {
|
||||
SWIGINTERN int
|
||||
SWIG_AsCharPtrAndSize(int iPos, char** cptr, size_t* psize, int *alloc)
|
||||
{
|
||||
SciErr sciErr;
|
||||
int iType = 0;
|
||||
int *piAddrVar = NULL;
|
||||
char *_pstStrings = NULL;
|
||||
int _piLength = 0;
|
||||
int iCols = 0;
|
||||
int iRows = 0;
|
||||
SwigScilabInt32ToEnum(void *_pvApiCtx, int _iVar, int *_enumValue, char* _fname) {
|
||||
SciErr sciErr;
|
||||
int iPrec = 0;
|
||||
int iRows = 1;
|
||||
int iCols = 1;
|
||||
int *piAddrVar = NULL;
|
||||
int *piData = NULL;
|
||||
|
||||
sciErr = getVarAddressFromPosition(pvApiCtx, iPos, &piAddrVar);
|
||||
if (sciErr.iErr)
|
||||
{
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
sciErr = getVarType(pvApiCtx, piAddrVar, &iType);
|
||||
if (sciErr.iErr || iType != sci_strings)
|
||||
{
|
||||
Scierror(999, _("%s: Wrong type for input argument #%d: A string expected.\n"), "SWIG_AsCharPtrAndSize", iPos);
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_TypeError;
|
||||
}
|
||||
|
||||
sciErr = getMatrixOfString(pvApiCtx, piAddrVar, &iRows, &iCols, &_piLength, NULL);
|
||||
if (sciErr.iErr || iRows * iCols != 1)
|
||||
{
|
||||
Scierror(999, _("%s: Wrong size for input argument #%d: A string expected.\n"), "SWIG_AsCharPtrAndSize", iPos);
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_TypeError;
|
||||
}
|
||||
|
||||
_pstStrings = (char *)malloc(sizeof(char) * _piLength + 1);
|
||||
sciErr = getMatrixOfString(pvApiCtx, piAddrVar, &iRows, &iCols, &_piLength, (char**)&_pstStrings);
|
||||
if (sciErr.iErr)
|
||||
{
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
if (cptr)
|
||||
{
|
||||
*cptr = _pstStrings;
|
||||
}
|
||||
if (psize)
|
||||
{
|
||||
*psize = _piLength + 1;
|
||||
}
|
||||
if (alloc)
|
||||
{
|
||||
*alloc = SWIG_OLDOBJ;
|
||||
}
|
||||
return SWIG_OK;
|
||||
|
||||
}
|
||||
}
|
||||
%fragment("SWIG_FromCharPtrAndSize","header") {
|
||||
SWIGINTERNINLINE int
|
||||
SWIG_FromCharPtrAndSize(const char* carray, size_t size)
|
||||
{
|
||||
SciErr sciErr;
|
||||
int iVarOut = Rhs + 1; // TODO is this always true?
|
||||
sciErr = createMatrixOfString(pvApiCtx, iVarOut, 1, 1, (char **)&carray);
|
||||
if (sciErr.iErr)
|
||||
{
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_AsVal_frag(long),"header") {
|
||||
SWIGINTERN int SWIG_AsVal_dec(long)(int iPos, long* val)
|
||||
{
|
||||
SciErr sciErr;
|
||||
int iRows = 1;
|
||||
int iCols = 1;
|
||||
int iType = 0;
|
||||
int* piAddrVar = NULL;
|
||||
double* piData = NULL;
|
||||
double v = 0.0;
|
||||
|
||||
sciErr = getVarAddressFromPosition(pvApiCtx, iPos, &piAddrVar);
|
||||
if (sciErr.iErr)
|
||||
{
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_TypeError;
|
||||
}
|
||||
|
||||
sciErr = getVarType(pvApiCtx, piAddrVar, &iType);
|
||||
if (sciErr.iErr)
|
||||
{
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_TypeError;
|
||||
}
|
||||
if (iType != sci_matrix)
|
||||
{
|
||||
return SWIG_TypeError;
|
||||
}
|
||||
|
||||
if (isVarComplex(pvApiCtx, piAddrVar))
|
||||
{
|
||||
return SWIG_TypeError;
|
||||
}
|
||||
|
||||
sciErr = getMatrixOfDouble(pvApiCtx, piAddrVar, &iRows, &iCols, (double **)&piData);
|
||||
if (sciErr.iErr)
|
||||
{
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_TypeError;
|
||||
}
|
||||
if (iRows * iCols != 1)
|
||||
{
|
||||
return SWIG_TypeError;
|
||||
}
|
||||
|
||||
v = piData[0];
|
||||
if (v != floor(v))
|
||||
{
|
||||
return SWIG_TypeError;
|
||||
}
|
||||
|
||||
if (val != NULL)
|
||||
{
|
||||
*val = (long) piData[0];
|
||||
}
|
||||
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_From_frag(long),"header") {
|
||||
SWIGINTERNINLINE int SWIG_From_dec(long) (long value)
|
||||
{
|
||||
double dblValue = (double) value;
|
||||
if (createScalarDouble(pvApiCtx, Rhs + 1, dblValue) == 0)
|
||||
{
|
||||
return SWIG_OK;
|
||||
}
|
||||
sciErr = getVarAddressFromPosition(pvApiCtx, _iVar, &piAddrVar);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*%fragment(SWIG_AsPtr_frag(std::string),"header") {
|
||||
sciErr = getMatrixOfIntegerPrecision(pvApiCtx, piAddrVar, &iPrec);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
if (iPrec != SCI_INT32) {
|
||||
Scierror(999, _("%s: Wrong type for input argument #%d: A 32-bit integer expected.\n"), _fname, _iVar);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
sciErr = getMatrixOfInteger32(pvApiCtx, piAddrVar, &iRows, &iCols, &piData);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
*_enumValue = (int)piData[0];
|
||||
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
%fragment("SwigScilabInt32FromEnum", "header") {
|
||||
SWIGINTERN int
|
||||
SWIG_AsPtr_std_string(int iPos, std::string **val)
|
||||
{
|
||||
char* buf = 0;
|
||||
size_t size = 0;
|
||||
int alloc = SWIG_OLDOBJ;
|
||||
SwigScilabInt32FromEnum(void *_pvApiCtx, int _iVarOut, int _enumValue) {
|
||||
SciErr sciErr;
|
||||
int iRowsOut = 1;
|
||||
int iColsOut = 1;
|
||||
|
||||
sciErr = createMatrixOfInteger32(pvApiCtx, Rhs + _iVarOut, iRowsOut, iColsOut, &_enumValue);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
LhsVar(_iVarOut) = Rhs + _iVarOut;
|
||||
|
||||
return SWIG_OK;
|
||||
|
||||
if (SWIG_IsOK((SWIG_AsCharPtrAndSize(iPos, &buf, &size, &alloc))))
|
||||
{
|
||||
if (buf)
|
||||
{
|
||||
if (val)
|
||||
{
|
||||
*val = new std::string(buf, size - 1);
|
||||
}
|
||||
if (alloc == SWIG_NEWOBJ)
|
||||
{
|
||||
delete[] buf;
|
||||
}
|
||||
return SWIG_NEWOBJ;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (val)
|
||||
{
|
||||
*val = 0;
|
||||
}
|
||||
return SWIG_OLDOBJ;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,81 +1,178 @@
|
|||
%insert(runtime) "swigrun.swg";
|
||||
%insert(runtime) "swigerrors.swg";
|
||||
|
||||
// Error message will be displayed inside Scilab fragment functions
|
||||
// and the following line Will not work because code is not an int
|
||||
//#define SWIG_Error(code, msg) Scierror(code, _("%s\n"), msg);
|
||||
|
||||
%insert(runtime) %{
|
||||
/* Scilab standard headers */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "stack-c.h"
|
||||
#include "MALLOC.h"
|
||||
|
||||
/* Typedefs for integers mapping */
|
||||
typedef short SCI_INT16_FROM_SHORT;
|
||||
typedef signed short SCI_INT16_FROM_SIGNED_SHORT;
|
||||
typedef int SCI_INT32_FROM_INT;
|
||||
typedef long SCI_INT32_FROM_LONG;
|
||||
typedef signed int SCI_INT32_FROM_SIGNED_INT;
|
||||
typedef signed long SCI_INT32_FROM_SIGNED_LONG;
|
||||
|
||||
void SWIG_Error(int code, const char *msg)
|
||||
{
|
||||
Scierror(code, _("%s\n"), msg);
|
||||
}
|
||||
#include "sciprint.h"
|
||||
#include "Scierror.h"
|
||||
#include "api_scilab.h"
|
||||
#include "localization.h"
|
||||
#include "freeArrayOfString.h"
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#define SWIG_contract_assert(expr, msg) if (!(expr)) { SWIG_Error(999, msg); } else
|
||||
#define SWIG_fail return 0
|
||||
#undef Max
|
||||
#undef Min
|
||||
|
||||
#define SWIG_ConvertPtr(obj, vptr, descriptor, flags) SWIG_Scilab_ConvertPtr(pvApiCtx, obj, vptr, descriptor, flags)
|
||||
#define SWIG_NewPointerObj(ptr, type, flags) SWIG_Scilab_NewPointerObj(pvApiCtx, iVarOut, ptr, type, flags)
|
||||
#define SWIG_fail return SWIG_ERROR;
|
||||
#define SWIG_Error return SWIG_ERROR;
|
||||
|
||||
/* Convert a pointer value */
|
||||
SWIGRUNTIMEINLINE int
|
||||
SWIG_Scilab_ConvertPtr(StrCtx* pvApiCtx, int obj, void **ptr, swig_type_info* descriptor, int flags) {
|
||||
SciErr sciErr;
|
||||
int* piAddrVar = NULL;
|
||||
int iType = 0;
|
||||
void *_piData = NULL;
|
||||
/* Used for C++ enums */
|
||||
#define SWIG_AsVal_int(scilabValue, valuePointer) SWIG_SciDouble_AsInt(pvApiCtx, scilabValue, valuePointer, fname)
|
||||
|
||||
sciErr = getVarAddressFromPosition(pvApiCtx, obj, &piAddrVar);
|
||||
if (sciErr.iErr)
|
||||
{
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
SWIGINTERN int
|
||||
SwigScilabPtrToObject(void *_pvApiCtx, int _iVar, void **_pObjValue, swig_type_info *_descriptor, int _flags, char *_fname) {
|
||||
SciErr sciErr;
|
||||
int iType = 0;
|
||||
int *piAddrVar = NULL;
|
||||
|
||||
sciErr = getVarType(pvApiCtx, piAddrVar, &iType);
|
||||
if (sciErr.iErr)
|
||||
{
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
if (iType != sci_pointer)
|
||||
{
|
||||
Scierror(999, _("%s: Wrong type for input argument #%d: Pointer expected.\n"), "SWIG_Scilab_ConvertPtr", obj);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
sciErr = getVarAddressFromPosition(_pvApiCtx, _iVar, &piAddrVar);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
sciErr = getPointer(pvApiCtx, piAddrVar, ptr);
|
||||
if (sciErr.iErr)
|
||||
{
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
return SWIG_OK;
|
||||
sciErr = getVarType(_pvApiCtx, piAddrVar, &iType);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
if (iType != sci_pointer) {
|
||||
//Scierror(999, _("%s: Wrong type for input argument #%d: A pointer expected.\n"), _fname, _iVar);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
sciErr = getPointer(_pvApiCtx, piAddrVar, _pObjValue);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
/* Create a new pointer object */
|
||||
SWIGRUNTIMEINLINE int
|
||||
SWIG_Scilab_NewPointerObj(StrCtx* pvApiCtx, int iVarOut, void *ptr, swig_type_info *type, int flags) {
|
||||
SciErr sciErr;
|
||||
sciErr = createPointer(pvApiCtx, iVarOut, (void *)ptr);
|
||||
if (sciErr.iErr)
|
||||
{
|
||||
printError(&sciErr, 0);
|
||||
return 0;
|
||||
}
|
||||
return iVarOut;
|
||||
SwigScilabPtrFromObject(void *_pvApiCtx, int _iVarOut, void *_object, swig_type_info *_descriptor, int _flags) {
|
||||
SciErr sciErr;
|
||||
|
||||
sciErr = createPointer(pvApiCtx, Rhs + _iVarOut, (void *)_object);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
return Rhs + _iVarOut;
|
||||
}
|
||||
|
||||
SWIGRUNTIME int
|
||||
SWIG_Scilab_ConvertPacked(void *_pvApiCtx, int _iVar, void *_ptr, int sz, swig_type_info *ty, char *_fname) {
|
||||
swig_cast_info *tc;
|
||||
|
||||
SciErr sciErr;
|
||||
int iRows = 0;
|
||||
int iCols = 0;
|
||||
int iType = 0;
|
||||
int *piAddrVar = NULL;
|
||||
char *pstStrings = NULL;
|
||||
int piLength = 0;
|
||||
|
||||
sciErr = getVarAddressFromPosition(pvApiCtx, _iVar, &piAddrVar);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
sciErr = getVarType(pvApiCtx, piAddrVar, &iType);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
if (iType != sci_strings) {
|
||||
Scierror(999, _("%s: Wrong type for input argument #%d: A string expected.\n"), _fname, _iVar);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
sciErr = getMatrixOfString(pvApiCtx, piAddrVar, &iRows, &iCols, &piLength, NULL);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
if (iRows * iCols != 1) {
|
||||
Scierror(999, _("%s: Wrong size for input argument #%d: A string expected.\n"), _fname, _iVar);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
pstStrings = (char *)MALLOC(sizeof(char) * (piLength + 1));
|
||||
sciErr = getMatrixOfString(pvApiCtx, piAddrVar, &iRows, &iCols, &piLength, (char **)&pstStrings);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
/* Pointer values must start with leading underscore */
|
||||
if (*pstStrings != '_') {
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
pstStrings++;
|
||||
pstStrings = (char*)SWIG_UnpackData(pstStrings, _ptr, sz);
|
||||
if (ty) {
|
||||
tc = SWIG_TypeCheck(pstStrings, ty);
|
||||
if (!tc) {
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
FREE(pstStrings);
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
SWIGRUNTIME int
|
||||
SWIG_Scilab_NewMemberObj(void *_pvApiCtx, int _iVarOut, void *_ptr, int _sz, swig_type_info *_type) {
|
||||
char result[1024];
|
||||
char *r = result;
|
||||
|
||||
SciErr sciErr;
|
||||
char **pstData = NULL;
|
||||
if ((2*_sz + 1 + strlen(_type->name)) > 1000) {
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
*(r++) = '_';
|
||||
r = SWIG_PackData(r, _ptr, _sz);
|
||||
strcpy(r, _type->name);
|
||||
|
||||
pstData = (char **)MALLOC(sizeof(char *));
|
||||
pstData[0] = strdup(r);
|
||||
|
||||
sciErr = createMatrixOfString(_pvApiCtx, Rhs + _iVarOut, 1, 1, (char **)pstData);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
freeArrayOfString(pstData, 1);
|
||||
|
||||
return Rhs + _iVarOut;
|
||||
}
|
||||
|
||||
#define SwigScilabSetOutput(outputNumber, outputPosition)\
|
||||
{\
|
||||
/* Create a temporary variable to avoid calling function given as outputPosition two times */\
|
||||
int stackPosition = outputPosition;\
|
||||
if (stackPosition < 0) {\
|
||||
return SWIG_ERROR;\
|
||||
}\
|
||||
LhsVar(outputNumber) = stackPosition;\
|
||||
return SWIG_OK; \
|
||||
}
|
||||
|
||||
#define SwigScilabRaise(OBJ, TYPE, DESC) Scierror(999, "C++ side threw an exception of type %s.\n", TYPE)
|
||||
%}
|
||||
|
|
|
|||
97
Lib/scilab/scishort.swg
Normal file
97
Lib/scilab/scishort.swg
Normal file
|
|
@ -0,0 +1,97 @@
|
|||
/*
|
||||
* C-type: short
|
||||
* Scilab type: double scalar
|
||||
*/
|
||||
%fragment(SWIG_AsVal_frag(short), "header", fragment="SWIG_SciDouble_AsShort") {
|
||||
#define SWIG_AsVal_short(scilabValue, valuePointer) SWIG_SciDouble_AsShort(pvApiCtx, scilabValue, valuePointer, fname)
|
||||
}
|
||||
%fragment("SWIG_SciDouble_AsShort", "header", fragment="SWIG_SciDouble_AsInt") {
|
||||
SWIGINTERN int
|
||||
SWIG_SciDouble_AsShort(void *_pvApiCtx, int _iVar, short *_pshValue, char *_fname) {
|
||||
int iValue = 0.0;
|
||||
if(SWIG_SciDouble_AsInt(_pvApiCtx, _iVar, &iValue, _fname) != SWIG_OK) {
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
*_pshValue = (short) iValue;
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_From_frag(short), "header", fragment="SWIG_SciDouble_FromShort") {
|
||||
#define SWIG_From_short(value) SWIG_SciDouble_FromShort(pvApiCtx, $result, value)
|
||||
}
|
||||
%fragment("SWIG_SciDouble_FromShort", "header", fragment="SWIG_SciDouble_FromInt") {
|
||||
SWIGINTERN int
|
||||
SWIG_SciDouble_FromShort(void *_pvApiCtx, int _iVarOut, short _shValue) {
|
||||
int iValue = (int) _shValue;
|
||||
return SWIG_SciDouble_FromInt(pvApiCtx, _iVarOut, iValue);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* C-type: short[]
|
||||
* Scilab type: int16 vector
|
||||
* See in scitypemaps.swg
|
||||
*/
|
||||
/*
|
||||
* C-type: short[ANY]
|
||||
* Scilab type: int16 vector
|
||||
*/
|
||||
%fragment("SWIG_SciInt16_AsShortArrayAndSize", "header") {
|
||||
SWIGINTERN int
|
||||
SWIG_SciInt16_AsShortArrayAndSize(void *_pvApiCtx, int _iVar, int *_iRows, int *_iCols, short **_psValue, char *_fname) {
|
||||
SciErr sciErr;
|
||||
int iType = 0;
|
||||
int iPrec = 0;
|
||||
int *piAddrVar = NULL;
|
||||
|
||||
sciErr = getVarAddressFromPosition(_pvApiCtx, _iVar, &piAddrVar);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
sciErr = getVarType(_pvApiCtx, piAddrVar, &iType);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
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 (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 vector expected.\n"), _fname, _iVar);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
sciErr = getMatrixOfInteger16(_pvApiCtx, piAddrVar, _iRows, _iCols, _psValue);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
%fragment("SWIG_SciInt16_FromShortArrayAndSize", "header") {
|
||||
SWIGINTERN int
|
||||
SWIG_SciInt16_FromShortArrayAndSize(void *_pvApiCtx, int _iVarOut, int _iRows, int _iCols, short *_psValue) {
|
||||
SciErr sciErr;
|
||||
|
||||
sciErr = createMatrixOfInteger16(_pvApiCtx, Rhs + _iVarOut, _iRows, _iCols, _psValue);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
return Rhs + _iVarOut;
|
||||
}
|
||||
}
|
||||
|
||||
141
Lib/scilab/scisignedchar.swg
Normal file
141
Lib/scilab/scisignedchar.swg
Normal file
|
|
@ -0,0 +1,141 @@
|
|||
/*
|
||||
* C-type: signed char
|
||||
* Scilab type: int8 scalar
|
||||
*/
|
||||
%fragment(SWIG_AsVal_frag(signed char), "header", fragment="SwigScilabInt8ToSignedChar") {
|
||||
#define SWIG_AsVal_signed_SS_char(scilabValue, valuePointer) SwigScilabInt8ToSignedChar(pvApiCtx, scilabValue, valuePointer, fname)
|
||||
}
|
||||
%fragment("SwigScilabInt8ToSignedChar", "header") {
|
||||
SWIGINTERN int
|
||||
SwigScilabInt8ToSignedChar(void *_pvApiCtx, int _iVar, signed char *_pscValue, char *_fname) {
|
||||
SciErr sciErr;
|
||||
int iType = 0;
|
||||
int iRows = 0;
|
||||
int iCols = 0;
|
||||
int iPrec = 0;
|
||||
int *piAddrVar = NULL;
|
||||
char *pcData = NULL;
|
||||
|
||||
sciErr = getVarAddressFromPosition(_pvApiCtx, _iVar, &piAddrVar);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
sciErr = getVarType(_pvApiCtx, piAddrVar, &iType);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
if (iType != sci_ints) {
|
||||
Scierror(999, _("%s: Wrong type for input argument #%d: A 8-bit integer expected.\n"), _fname, _iVar);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
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 integer expected.\n"), _fname, _iVar);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
sciErr = getMatrixOfInteger8(_pvApiCtx, piAddrVar, &iRows, &iCols, &pcData);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
if (iRows * iCols != 1) {
|
||||
Scierror(999, _("%s: Wrong size for input argument #%d: A 8-bit integer expected.\n"), _fname, _iVar);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
*_pscValue = *pcData;
|
||||
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_From_frag(signed char), "header", fragment="SwigScilabInt8FromSignedChar") {
|
||||
#define SWIG_From_signed_SS_char(value) SwigScilabInt8FromSignedChar(pvApiCtx, $result, value)
|
||||
}
|
||||
%fragment("SwigScilabInt8FromSignedChar", "header") {
|
||||
SWIGINTERN int
|
||||
SwigScilabInt8FromSignedChar(void *_pvApiCtx, int _iVarOut, signed char _scValue) {
|
||||
SciErr sciErr;
|
||||
int iRowsOut = 1;
|
||||
int iColsOut = 1;
|
||||
|
||||
sciErr = createMatrixOfInteger8(pvApiCtx, Rhs + _iVarOut, iRowsOut, iColsOut, (char *)&_scValue);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
return Rhs + _iVarOut;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* C-type: signed char[]
|
||||
* Scilab type: int8 vector
|
||||
*/
|
||||
%fragment("SWIG_SciInt8_AsSignedCharArrayAndSize", "header") {
|
||||
SWIGINTERN int
|
||||
SWIG_SciInt8_AsSignedCharArrayAndSize(void *_pvApiCtx, int _iVar, int *_iRows, int *_iCols, signed char **_pscValue, char *_fname) {
|
||||
SciErr sciErr;
|
||||
int iType = 0;
|
||||
int iPrec = 0;
|
||||
int *piAddrVar = NULL;
|
||||
|
||||
sciErr = getVarAddressFromPosition(_pvApiCtx, _iVar, &piAddrVar);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
sciErr = getVarType(_pvApiCtx, piAddrVar, &iType);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
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 (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
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);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
%fragment("SWIG_SciInt8_FromSignedCharArrayAndSize", "header") {
|
||||
SWIGINTERN int
|
||||
SWIG_SciInt8_FromSignedCharArrayAndSize(void *_pvApiCtx, int _iVarOut, int _iRows, int _iCols, const signed char *_pscValue) {
|
||||
SciErr sciErr;
|
||||
|
||||
sciErr = createMatrixOfInteger8(pvApiCtx, Rhs + _iVarOut, _iRows, _iCols, (const char *)_pscValue);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
return Rhs + _iVarOut;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load diff
141
Lib/scilab/sciunsignedchar.swg
Normal file
141
Lib/scilab/sciunsignedchar.swg
Normal file
|
|
@ -0,0 +1,141 @@
|
|||
/*
|
||||
* C-type: unsigned char
|
||||
* Scilab type: uint8 scalar
|
||||
*/
|
||||
%fragment(SWIG_AsVal_frag(unsigned char), "header", fragment="SWIG_SciUint8_AsUnsignedChar") {
|
||||
#define SWIG_AsVal_unsigned_SS_char(scilabValue, valuePointer) SWIG_SciUint8_AsUnsignedChar(pvApiCtx, scilabValue, valuePointer, fname)
|
||||
}
|
||||
%fragment("SWIG_SciUint8_AsUnsignedChar", "header") {
|
||||
SWIGINTERN int
|
||||
SWIG_SciUint8_AsUnsignedChar(void *_pvApiCtx, int _iVar, unsigned char *_pucValue, char *_fname) {
|
||||
SciErr sciErr;
|
||||
int iType = 0;
|
||||
int iRows = 0;
|
||||
int iCols = 0;
|
||||
int iPrec = 0;
|
||||
int *piAddrVar = NULL;
|
||||
unsigned char *pucData = NULL;
|
||||
|
||||
sciErr = getVarAddressFromPosition(_pvApiCtx, _iVar, &piAddrVar);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
sciErr = getVarType(_pvApiCtx, piAddrVar, &iType);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
if (iType != sci_ints) {
|
||||
Scierror(999, _("%s: Wrong type for input argument #%d: A 8-bit unsigned integer 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 expected.\n"), _fname, _iVar);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
sciErr = getMatrixOfUnsignedInteger8(_pvApiCtx, piAddrVar, &iRows, &iCols, &pucData);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
if (iRows * iCols != 1) {
|
||||
Scierror(999, _("%s: Wrong size for input argument #%d: A 8-bit unsigned integer expected.\n"), _fname, _iVar);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
*_pucValue = *pucData;
|
||||
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_From_frag(unsigned char), "header", fragment="SWIG_SciUint8_FromUnsignedChar") {
|
||||
#define SWIG_From_unsigned_SS_char(value) SWIG_SciUint8_FromUnsignedChar(pvApiCtx, $result, value)
|
||||
}
|
||||
%fragment("SWIG_SciUint8_FromUnsignedChar", "header") {
|
||||
SWIGINTERN int
|
||||
SWIG_SciUint8_FromUnsignedChar(void *_pvApiCtx, int _iVarOut, unsigned char _ucValue) {
|
||||
SciErr sciErr;
|
||||
int iRowsOut = 1;
|
||||
int iColsOut = 1;
|
||||
|
||||
sciErr = createMatrixOfUnsignedInteger8(pvApiCtx, Rhs + _iVarOut, iRowsOut, iColsOut, &_ucValue);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
return Rhs + _iVarOut;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* C-type: unsigned char[]
|
||||
* Scilab type: uint8 vector
|
||||
*/
|
||||
%fragment("SWIG_SciUint8_AsUnsignedCharArrayAndSize", "header") {
|
||||
SWIGINTERN int
|
||||
SWIG_SciUint8_AsUnsignedCharArrayAndSize(void *_pvApiCtx, int _iVar, int *_iRows, int *_iCols, unsigned char **_pucValue, char *_fname) {
|
||||
SciErr sciErr;
|
||||
int iType = 0;
|
||||
int iPrec = 0;
|
||||
int *piAddrVar = NULL;
|
||||
|
||||
sciErr = getVarAddressFromPosition(_pvApiCtx, _iVar, &piAddrVar);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
sciErr = getVarType(_pvApiCtx, piAddrVar, &iType);
|
||||
if (sciErr.iErr) {
|
||||
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;
|
||||
}
|
||||
|
||||
sciErr = getMatrixOfUnsignedInteger8(_pvApiCtx, piAddrVar, _iRows, _iCols, _pucValue);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
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) {
|
||||
SciErr sciErr;
|
||||
|
||||
sciErr = createMatrixOfUnsignedInteger8(pvApiCtx, Rhs + _iVarOut, _iRows, _iCols, _puscValue);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
return Rhs + _iVarOut;
|
||||
}
|
||||
}
|
||||
141
Lib/scilab/sciunsignedint.swg
Normal file
141
Lib/scilab/sciunsignedint.swg
Normal file
|
|
@ -0,0 +1,141 @@
|
|||
/*
|
||||
* C-type: unsigned int
|
||||
* Scilab type: uint32 scalar
|
||||
*/
|
||||
%fragment(SWIG_AsVal_frag(unsigned int), "header", fragment="SwigScilabUint32ToUnsignedInt") {
|
||||
#define SWIG_AsVal_unsigned_SS_int(scilabValue, valuePointer) SwigScilabUint32ToUnsignedInt(pvApiCtx, scilabValue, valuePointer, fname)
|
||||
}
|
||||
%fragment("SwigScilabUint32ToUnsignedInt", "header") {
|
||||
SWIGINTERN int
|
||||
SwigScilabUint32ToUnsignedInt(void *_pvApiCtx, int _iVar, unsigned int *_puiValue, char *_fname) {
|
||||
SciErr sciErr;
|
||||
int iType = 0;
|
||||
int iRows = 0;
|
||||
int iCols = 0;
|
||||
int iPrec = 0;
|
||||
int *piAddrVar = NULL;
|
||||
unsigned int *puiData = NULL;
|
||||
|
||||
sciErr = getVarAddressFromPosition(_pvApiCtx, _iVar, &piAddrVar);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
sciErr = getVarType(_pvApiCtx, piAddrVar, &iType);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
if (iType != sci_ints) {
|
||||
Scierror(999, _("%s: Wrong type for input argument #%d: A 32-bit unsigned integer 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 expected.\n"), _fname, _iVar);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
sciErr = getMatrixOfUnsignedInteger32(_pvApiCtx, piAddrVar, &iRows, &iCols, &puiData);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
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);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
*_puiValue = *puiData;
|
||||
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
%fragment(SWIG_From_frag(unsigned int), "header", fragment="SwigScilabUint32FromUnsignedInt") {
|
||||
#define SWIG_From_unsigned_SS_int(value) SwigScilabUint32FromUnsignedInt(pvApiCtx, $result, value)
|
||||
}
|
||||
%fragment("SwigScilabUint32FromUnsignedInt", "header") {
|
||||
SWIGINTERN int
|
||||
SwigScilabUint32FromUnsignedInt(void *_pvApiCtx, int _iVarOut, unsigned int _uiValue) {
|
||||
SciErr sciErr;
|
||||
int iRowsOut = 1;
|
||||
int iColsOut = 1;
|
||||
|
||||
sciErr = createMatrixOfUnsignedInteger32(_pvApiCtx, Rhs + _iVarOut, iRowsOut, iColsOut, &_uiValue);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
return Rhs + _iVarOut;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* C-type: unsigned int[]
|
||||
* Scilab type: uint32 vector
|
||||
*/
|
||||
%fragment("SWIG_SciUint32_AsUnsignedIntArrayAndSize", "header") {
|
||||
SWIGINTERN int
|
||||
SWIG_SciUint32_AsUnsignedIntArrayAndSize(void *_pvApiCtx, int _iVar, int *_iRows, int *_iCols, unsigned int **_puiValue, char *_fname) {
|
||||
SciErr sciErr;
|
||||
int iType = 0;
|
||||
int iPrec = 0;
|
||||
int *piAddrVar = NULL;
|
||||
|
||||
sciErr = getVarAddressFromPosition(_pvApiCtx, _iVar, &piAddrVar);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
sciErr = getVarType(_pvApiCtx, piAddrVar, &iType);
|
||||
if (sciErr.iErr) {
|
||||
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;
|
||||
}
|
||||
|
||||
sciErr = getMatrixOfUnsignedInteger32(_pvApiCtx, piAddrVar, _iRows, _iCols, _puiValue);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
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) {
|
||||
SciErr sciErr;
|
||||
|
||||
sciErr = createMatrixOfUnsignedInteger32(_pvApiCtx, Rhs + _iVarOut, _iRows, _iCols, _puiValue);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
return Rhs + _iVarOut;
|
||||
}
|
||||
}
|
||||
|
||||
141
Lib/scilab/sciunsignedshort.swg
Normal file
141
Lib/scilab/sciunsignedshort.swg
Normal file
|
|
@ -0,0 +1,141 @@
|
|||
/*
|
||||
* C-type: unsigned short
|
||||
* Scilab type: uint16 scalar
|
||||
*/
|
||||
%fragment(SWIG_AsVal_frag(unsigned short), "header", fragment="SWIG_SciUint16_AsUnsignedShort") {
|
||||
#define SWIG_AsVal_unsigned_SS_short(scilabValue, valuePointer) SWIG_SciUint16_AsUnsignedShort(pvApiCtx, scilabValue, valuePointer, fname)
|
||||
}
|
||||
%fragment("SWIG_SciUint16_AsUnsignedShort", "header") {
|
||||
SWIGINTERN int
|
||||
SWIG_SciUint16_AsUnsignedShort(void *_pvApiCtx, int _iVar, unsigned short *_pusValue, char *_fname) {
|
||||
SciErr sciErr;
|
||||
int iType = 0;
|
||||
int iRows = 0;
|
||||
int iCols = 0;
|
||||
int iPrec = 0;
|
||||
int *piAddrVar = NULL;
|
||||
unsigned short *pusData = NULL;
|
||||
|
||||
sciErr = getVarAddressFromPosition(_pvApiCtx, _iVar, &piAddrVar);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
sciErr = getVarType(_pvApiCtx, piAddrVar, &iType);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
if (iType != sci_ints) {
|
||||
Scierror(999, _("%s: Wrong type for input argument #%d: A 16-bit unsigned integer 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 expected.\n"), _fname, _iVar);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
sciErr = getMatrixOfUnsignedInteger16(_pvApiCtx, piAddrVar, &iRows, &iCols, &pusData);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
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);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
*_pusValue = *pusData;
|
||||
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_From_frag(unsigned short), "header", fragment="SWIG_SciUint16_FromUnsignedShort") {
|
||||
#define SWIG_From_unsigned_SS_short(value) SWIG_SciUint16_FromUnsignedShort(pvApiCtx, $result, value)
|
||||
}
|
||||
%fragment("SWIG_SciUint16_FromUnsignedShort", "header") {
|
||||
SWIGINTERN int
|
||||
SWIG_SciUint16_FromUnsignedShort(void *_pvApiCtx, int _iVarOut, unsigned short _usValue) {
|
||||
SciErr sciErr;
|
||||
int iRowsOut = 1;
|
||||
int iColsOut = 1;
|
||||
|
||||
sciErr = createMatrixOfUnsignedInteger16(_pvApiCtx, Rhs + _iVarOut, iRowsOut, iColsOut, &_usValue);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
return Rhs + _iVarOut;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* C-type: unsigned short[]
|
||||
* Scilab type: uint16 vector
|
||||
*/
|
||||
%fragment("SWIG_SciUint16_AsUnsignedShortArrayAndSize", "header") {
|
||||
SWIGINTERN int
|
||||
SWIG_SciUint16_AsUnsignedShortArrayAndSize(void *_pvApiCtx, int _iVar, int *_iRows, int *_iCols, unsigned short **_pusValue, char *_fname) {
|
||||
SciErr sciErr;
|
||||
int iType = 0;
|
||||
int iPrec = 0;
|
||||
int *piAddrVar = NULL;
|
||||
|
||||
sciErr = getVarAddressFromPosition(_pvApiCtx, _iVar, &piAddrVar);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
sciErr = getVarType(_pvApiCtx, piAddrVar, &iType);
|
||||
if (sciErr.iErr) {
|
||||
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;
|
||||
}
|
||||
|
||||
sciErr = getMatrixOfUnsignedInteger16(_pvApiCtx, piAddrVar, _iRows, _iCols, _pusValue);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
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) {
|
||||
SciErr sciErr;
|
||||
|
||||
sciErr = createMatrixOfUnsignedInteger16(_pvApiCtx, Rhs + _iVarOut, _iRows, _iCols, _pusValue);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
return Rhs + _iVarOut;
|
||||
}
|
||||
}
|
||||
2
Lib/scilab/std_alloc.i
Normal file
2
Lib/scilab/std_alloc.i
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
%include <std/std_alloc.i>
|
||||
|
||||
2
Lib/scilab/std_common.i
Normal file
2
Lib/scilab/std_common.i
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
%include <std/std_common.i>
|
||||
|
||||
2
Lib/scilab/std_container.i
Normal file
2
Lib/scilab/std_container.i
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
%include <std/std_container.i>
|
||||
|
||||
|
|
@ -1 +1,47 @@
|
|||
/*
|
||||
* POINTER
|
||||
*/
|
||||
|
||||
%fragment(SWIG_AsPtr_frag(std::string), "header", fragment="SwigScilabStringToString") {
|
||||
#define SWIG_AsPtr_std_string(scilabValue, stringPointer) SwigScilabStringToString(pvApiCtx, scilabValue, stringPointer, fname)
|
||||
}
|
||||
%fragment(SWIG_From_frag(std::string), "header", fragment="SwigScilabStringFromString") {
|
||||
#define SWIG_From_std_string(stringPointer) SwigScilabStringFromString(pvApiCtx, $result, stringPointer)
|
||||
}
|
||||
|
||||
%fragment("SwigScilabStringToString", "header", fragment="SwigScilabStringToCharPtrAndSize") {
|
||||
SWIGINTERN int
|
||||
SwigScilabStringToString(void *_pvApiCtx, int _iVar, std::string **_pstValue, char *_fname) {
|
||||
char* buf = 0;
|
||||
size_t size = 0;
|
||||
int alloc = SWIG_OLDOBJ;
|
||||
|
||||
if (SWIG_IsOK((SwigScilabStringToCharPtrAndSize(_pvApiCtx, _iVar, &buf, &size, &alloc, _fname)))) {
|
||||
if (buf) {
|
||||
if (_pstValue) {
|
||||
*_pstValue = new std::string(buf, size);
|
||||
}
|
||||
if (alloc == SWIG_NEWOBJ) {
|
||||
delete[] buf;
|
||||
}
|
||||
return SWIG_NEWOBJ;
|
||||
} else {
|
||||
if (_pstValue) {
|
||||
*_pstValue = NULL;
|
||||
}
|
||||
return SWIG_OLDOBJ;
|
||||
}
|
||||
} else {
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
%fragment("SwigScilabStringFromString", "header", fragment="SwigScilabStringFromCharPtrAndSize") {
|
||||
SWIGINTERN int
|
||||
SwigScilabStringFromString(void *_pvApiCtx, int _iVarOut, std::string _pstValue) {
|
||||
return SwigScilabStringFromCharPtrAndSize(_pvApiCtx, _iVarOut, _pstValue.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
%include <typemaps/std_string.swg>
|
||||
|
|
|
|||
|
|
@ -1,10 +1,8 @@
|
|||
%fragment("StdVectorTraits","header")
|
||||
%{
|
||||
%}
|
||||
%fragment(SWIG_AsVal_frag(std::vector< int >), "header") {
|
||||
#define SWIG_AsPtr_std_vector(scilabValue, stringPointer) SwigScilabStringToString(pvApiCtx, scilabValue, stringPointer, fname)
|
||||
}
|
||||
|
||||
#define %swig_vector_methods(Type...) %swig_sequence_methods(Type)
|
||||
#define %swig_vector_methods_val(Type...) %swig_sequence_methods_val(Type);
|
||||
//#define %swig_vector_methods(Type...) %swig_sequence_methods(Type)
|
||||
//#define %swig_vector_methods_val(Type...) %swig_sequence_methods_val(Type);
|
||||
|
||||
|
||||
|
||||
%include <std/std_vector.i>
|
||||
%include <std/std_vector.i>
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ you would use a real value instead.
|
|||
bool *INPUT
|
||||
float *INPUT
|
||||
double *INPUT
|
||||
|
||||
|
||||
To use these, suppose you had a C function like this :
|
||||
|
||||
double fadd(double *a, double *b) {
|
||||
|
|
@ -38,7 +38,7 @@ To use these, suppose you had a C function like this :
|
|||
}
|
||||
|
||||
You could wrap it with SWIG as follows :
|
||||
|
||||
|
||||
%include typemaps.i
|
||||
double fadd(double *INPUT, double *INPUT);
|
||||
|
||||
|
|
@ -49,44 +49,31 @@ or you can use the %apply directive :
|
|||
double fadd(double *a, double *b);
|
||||
|
||||
*/
|
||||
|
||||
%typemap(in) signed char *INPUT (int *piAddrVar, int iRows, int iCols, signed char temp),
|
||||
unsigned char *INPUT (int *piAddrVar, int iRows, int iCols, unsigned char temp),
|
||||
short *INPUT (int *piAddrVar, int iRows, int iCols, short temp),
|
||||
unsigned short *INPUT (int *piAddrVar, int iRows, int iCols, unsigned short temp),
|
||||
int *INPUT (int *piAddrVar, int iRows, int iCols, int temp),
|
||||
unsigned int *INPUT (int *piAddrVar, int iRows, int iCols, unsigned int temp),
|
||||
long *INPUT (int *piAddrVar, int iRows, int iCols, long temp),
|
||||
unsigned long *INPUT (int *piAddrVar, int iRows, int iCols, unsigned long temp),
|
||||
float *INPUT (int *piAddrVar, int iRows, int iCols, float temp),
|
||||
double *INPUT (int *piAddrVar, int iRows, int iCols, double temp) {
|
||||
int iType;
|
||||
double *_piData;
|
||||
int typearg;
|
||||
sciErr = getVarAddressFromPosition(pvApiCtx, $input, &piAddrVar);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return 0;
|
||||
%typemap(in, noblock=1, fragment="SWIG_SciDouble_AsInt") int *INPUT(int temp), int &INPUT(int temp) {
|
||||
if (SWIG_SciDouble_AsInt(pvApiCtx, $input, &temp, fname) != SWIG_OK) {
|
||||
SWIG_fail;
|
||||
}
|
||||
|
||||
sciErr = getVarType(pvApiCtx, piAddrVar, &iType);
|
||||
if (sciErr.iErr || iType != sci_matrix) {
|
||||
Scierror(999, _("%s: Wrong type for input argument #%d: A real expected.\n"), fname, $argnum);
|
||||
printError(&sciErr, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
sciErr = getMatrixOfDouble(pvApiCtx, piAddrVar, &iRows, &iCols, &_piData);
|
||||
if (sciErr.iErr || iRows * iCols != 1) {
|
||||
Scierror(999, _("%s: Wrong size for input argument #%d: A real expected.\n"), fname, $argnum);
|
||||
printError(&sciErr, 0);
|
||||
return 0;
|
||||
}
|
||||
temp = ($*1_ltype)*_piData;
|
||||
$1 = &temp;
|
||||
}
|
||||
#undef INPUT_TYPEMAP
|
||||
|
||||
//short *INPUT
|
||||
//long *INPUT
|
||||
//long long *INPUT
|
||||
//unsigned int *INPUT
|
||||
//unsigned short *INPUT
|
||||
//unsigned long *INPUT
|
||||
//unsigned long long *INPUT
|
||||
//unsigned char *INPUT
|
||||
//bool *INPUT
|
||||
//float *INPUT
|
||||
%typemap(in, noblock=1, fragment="SWIG_SciDouble_AsDouble") double *INPUT(double temp), double &INPUT(double temp) {
|
||||
if (SWIG_SciDouble_AsDouble(pvApiCtx, $input, &temp, fname) != SWIG_OK) {
|
||||
SWIG_fail;
|
||||
}
|
||||
$1 = &temp;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// OUTPUT typemaps. These typemaps are used for parameters that
|
||||
// are output only. The output value is appended to the result as
|
||||
// a list element.
|
||||
|
|
@ -95,7 +82,7 @@ or you can use the %apply directive :
|
|||
The following methods can be applied to turn a pointer into an "output"
|
||||
value. When calling a function, no input value would be given for
|
||||
a parameter, but an output value would be returned. In the case of
|
||||
multiple output values, functions will return a Perl array.
|
||||
multiple output values, functions will return a Scilab array.
|
||||
|
||||
int *OUTPUT
|
||||
short *OUTPUT
|
||||
|
|
@ -109,7 +96,7 @@ multiple output values, functions will return a Perl array.
|
|||
bool *OUTPUT
|
||||
float *OUTPUT
|
||||
double *OUTPUT
|
||||
|
||||
|
||||
For example, suppose you were trying to wrap the modf() function in the
|
||||
C math library which splits x into integral and fractional parts (and
|
||||
returns the integer part in one of its parameters).:
|
||||
|
|
@ -127,84 +114,29 @@ or you can use the %apply directive :
|
|||
%apply double *OUTPUT { double *ip };
|
||||
double modf(double x, double *ip);
|
||||
|
||||
The Perl output of the function would be an array containing both
|
||||
output values.
|
||||
The Scilab output of the function would be an array containing both
|
||||
output values.
|
||||
|
||||
*/
|
||||
|
||||
// Force the argument to be ignored.
|
||||
|
||||
%typemap(in,numinputs=0) signed char *OUTPUT (signed temp),
|
||||
unsigned char *OUTPUT (unsigned temp),
|
||||
short *OUTPUT (short temp),
|
||||
unsigned short *OUTPUT (unsigned short temp),
|
||||
int *OUTPUT (int temp),
|
||||
unsigned int *OUTPUT (unsigned int temp),
|
||||
long *OUTPUT (long temp),
|
||||
unsigned long *OUTPUT (unsigned long temp),
|
||||
float *OUTPUT (float temp),
|
||||
double *OUTPUT (double temp) {
|
||||
$1 = ($1_ltype)&temp;
|
||||
%typemap(argout, noblock=1, fragment="SWIG_SciDouble_FromInt") int *OUTPUT, int &OUTPUT {
|
||||
SwigScilabSetOutput($result, SWIG_SciDouble_FromInt(pvApiCtx, $result, *$1));
|
||||
}
|
||||
|
||||
%typemap(argout) signed char *OUTPUT(int iRowsOut, int iColsOut) {
|
||||
iRowsOut = 1;
|
||||
iColsOut = 1;
|
||||
sciErr = createMatrixOfInteger8(pvApiCtx, iVarOut, iRowsOut, iColsOut, &temp$argnum);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return 0;
|
||||
}
|
||||
iOutNum++;
|
||||
iVarOut++;
|
||||
//short *OUTPUT
|
||||
//long *OUTPUT
|
||||
//long long *OUTPUT
|
||||
//unsigned int *OUTPUT
|
||||
//unsigned short *OUTPUT
|
||||
//unsigned long *OUTPUT
|
||||
//unsigned long long *OUTPUT
|
||||
//unsigned char *OUTPUT
|
||||
//bool *OUTPUT
|
||||
//float *OUTPUT
|
||||
//double *OUTPUT
|
||||
%typemap(argout, noblock=1, fragment="SWIG_SciDouble_FromDouble") double *OUTPUT, double &OUTPUT {
|
||||
SwigScilabSetOutput($result, SWIG_SciDouble_FromDouble(pvApiCtx, $result, *$1));
|
||||
}
|
||||
|
||||
%typemap(argout) short *OUTPUT(int iRowsOut, int iColsOut),
|
||||
unsigned char *OUTPUT(int iRowsOut, int iColsOut) {
|
||||
iRowsOut = 1;
|
||||
iColsOut = 1;
|
||||
sciErr = createMatrixOfInteger16(pvApiCtx, iVarOut, iRowsOut, iColsOut, &temp$argnum);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return 0;
|
||||
}
|
||||
iOutNum++;
|
||||
iVarOut++;
|
||||
}
|
||||
|
||||
%typemap(argout) int *OUTPUT(int iRowsOut,int iColsOut),
|
||||
unsigned int *OUTPUT(int iRowsOut,int iColsOut),
|
||||
unsigned short *OUTPUT(int iRowsOut,int iColsOut),
|
||||
unsigned long *OUTPUT(int iRowsOut,int iColsOut),
|
||||
long *OUTPUT(int iRowsOut,int iColsOut) {
|
||||
iRowsOut=1;
|
||||
iColsOut=1;
|
||||
sciErr = createMatrixOfInteger32(pvApiCtx, iVarOut, iRowsOut, iColsOut, &temp$argnum);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return 0;
|
||||
}
|
||||
iOutNum++;
|
||||
iVarOut++;
|
||||
}
|
||||
|
||||
|
||||
%typemap(argout) double *OUTPUT(int iRowsOut, int iColsOut),
|
||||
float *OUTPUT(int iRowsOut, int iColsOut) {
|
||||
double temp;
|
||||
temp = (double)(*$result);
|
||||
iRowsOut = 1;
|
||||
iColsOut = 1;
|
||||
sciErr = createMatrixOfDouble(pvApiCtx, iVarOut, iRowsOut, iColsOut, &temp$argnum);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return 0;
|
||||
}
|
||||
iOutNum++;
|
||||
iVarOut++;
|
||||
}
|
||||
|
||||
|
||||
// INOUT
|
||||
// Mappings for an argument that is both an input and output
|
||||
// parameter
|
||||
|
|
@ -213,7 +145,7 @@ output values.
|
|||
The following methods can be applied to make a function parameter both
|
||||
an input and output value. This combines the behavior of both the
|
||||
"INPUT" and "OUTPUT" methods described earlier. Output values are
|
||||
returned in the form of a Perl array.
|
||||
returned in the form of a Scilab array.
|
||||
|
||||
int *INOUT
|
||||
short *INOUT
|
||||
|
|
@ -227,7 +159,7 @@ returned in the form of a Perl array.
|
|||
bool *INOUT
|
||||
float *INOUT
|
||||
double *INOUT
|
||||
|
||||
|
||||
For example, suppose you were trying to wrap the following function :
|
||||
|
||||
void neg(double *x) {
|
||||
|
|
@ -247,7 +179,7 @@ or you can use the %apply directive :
|
|||
|
||||
Unlike C, this mapping does not directly modify the input value.
|
||||
Rather, the modified input value shows up as the return value of the
|
||||
function. Thus, to apply this function to a Perl variable you might
|
||||
function. Thus, to apply this function to a Scilab variable you might
|
||||
do this :
|
||||
|
||||
$x = neg($x);
|
||||
|
|
@ -275,6 +207,3 @@ do this :
|
|||
%typemap(in) signed char *INOUT = signed char *OUTPUT;
|
||||
%typemap(in) float *INOUT = float *OUTPUT;
|
||||
%typemap(in) double *INOUT = double *OUTPUT;
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue