Scilab: add support for STL bool containers
This commit is contained in:
parent
1cf1e72e72
commit
bc80012e0a
3 changed files with 119 additions and 0 deletions
|
|
@ -82,3 +82,18 @@ SWIG_SciBoolean_AsIntArrayAndSize(void *_pvApiCtx, int _iVar, int *_iRows, int *
|
|||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
|
||||
%fragment("SWIG_SciBoolean_FromIntArrayAndSize", "header") {
|
||||
SWIGINTERN int
|
||||
SWIG_SciBoolean_FromIntArrayAndSize(void *_pvApiCtx, int _iVarOut, int _iRows, int _iCols, const int *_piData) {
|
||||
SciErr sciErr;
|
||||
|
||||
sciErr = createMatrixOfBoolean(_pvApiCtx, Rhs + _iVarOut, _iRows, _iCols, _piData);
|
||||
if(sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
return Rhs + _iVarOut;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@
|
|||
%include <scisequenceint.swg>
|
||||
%include <scisequencedouble.swg>
|
||||
%include <scisequencestring.swg>
|
||||
%include <scisequencebool.swg>
|
||||
|
||||
//
|
||||
// Sequence conversion
|
||||
|
|
@ -150,4 +151,5 @@ namespace swig {
|
|||
%add_traits_sequence(int, int);
|
||||
%add_traits_sequence(double, double);
|
||||
%add_traits_sequence(std::string, char*);
|
||||
%add_traits_sequence(bool, int);
|
||||
|
||||
|
|
|
|||
102
Lib/scilab/scisequencebool.swg
Normal file
102
Lib/scilab/scisequencebool.swg
Normal file
|
|
@ -0,0 +1,102 @@
|
|||
/*
|
||||
*
|
||||
* Scilab matrix of bool <-> C++ bool container
|
||||
*
|
||||
*/
|
||||
|
||||
%include <scibool.swg>
|
||||
|
||||
%fragment(SWIG_AsCheck_Sequence_frag(bool), "header",
|
||||
fragment="SWIG_SciInt32_AsIntArrayAndSize") {
|
||||
|
||||
SWIGINTERN int
|
||||
SWIG_AsCheck_Sequence_dec(bool)(SciObject _obj) {
|
||||
SciErr sciErr;
|
||||
int *piAddrVar;
|
||||
|
||||
sciErr = getVarAddressFromPosition(pvApiCtx, _obj, &piAddrVar);
|
||||
if (sciErr.iErr) {
|
||||
printError(&sciErr, 0);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
|
||||
if (isBooleanType(pvApiCtx, piAddrVar))
|
||||
{
|
||||
return SWIG_OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
Scierror(999, _("%s: Wrong type for input argument #%d: A boolean is expected.\n"), SWIG_Scilab_GetFname(), _obj);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_AsGet_Sequence_frag(bool), "header",
|
||||
fragment="SWIG_SciBoolean_AsIntArrayAndSize") {
|
||||
|
||||
SWIGINTERN int
|
||||
SWIG_AsGet_Sequence_dec(bool)(SciObject _obj, int **_pSequence) {
|
||||
int iMatrixRowCount;
|
||||
int iMatrixColCount;
|
||||
return (SWIG_SciBoolean_AsIntArrayAndSize(pvApiCtx, _obj, &iMatrixRowCount, &iMatrixColCount, _pSequence, SWIG_Scilab_GetFname()));
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_AsSize_Sequence_frag(bool), "header",
|
||||
fragment="SWIG_SciBoolean_AsIntArrayAndSize") {
|
||||
|
||||
SWIGINTERN int
|
||||
SWIG_AsSize_Sequence_dec(bool)(SciObject _obj, int *_piSize) {
|
||||
int *piMatrix;
|
||||
int iMatrixRowCount;
|
||||
int iMatrixColCount;
|
||||
if (SWIG_SciBoolean_AsIntArrayAndSize(pvApiCtx, _obj, &iMatrixRowCount, &iMatrixColCount, &piMatrix, SWIG_Scilab_GetFname()) == SWIG_OK) {
|
||||
if ((iMatrixRowCount > 1) && (iMatrixColCount > 1)) {
|
||||
Scierror(999, _("%s: Wrong size for input argument #%d: An integer vector is expected.\n"), SWIG_Scilab_GetFname(), _obj);
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
*_piSize = iMatrixRowCount * iMatrixColCount;
|
||||
return SWIG_OK;
|
||||
}
|
||||
return SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_FromCreate_Sequence_frag(bool), "header") {
|
||||
|
||||
SWIGINTERN int
|
||||
SWIG_FromCreate_Sequence_dec(bool)(int _size, int **_sequence) {
|
||||
*_sequence = new int[_size];
|
||||
return *_sequence != NULL ? SWIG_OK : SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_FromSet_Sequence_frag(bool), "header",
|
||||
fragment="SWIG_SciBoolean_FromIntArrayAndSize") {
|
||||
|
||||
SWIGINTERN SciObject
|
||||
SWIG_FromSet_Sequence_dec(bool)(int _size, int *_sequence) {
|
||||
SciObject obj = SWIG_SciBoolean_FromIntArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), 1, _size, _sequence);
|
||||
delete (int *)_sequence;
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_AsVal_SequenceItem_frag(bool), "header") {
|
||||
|
||||
SWIGINTERN int
|
||||
SWIG_AsVal_SequenceItem_dec(bool)(SciObject _obj, int *_pSequence, int _iItemIndex, bool *_pItemValue) {
|
||||
*_pItemValue = _pSequence[_iItemIndex];
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
|
||||
%fragment(SWIG_From_SequenceItem_frag(bool), "header") {
|
||||
|
||||
SWIGINTERN int
|
||||
SWIG_From_SequenceItem_dec(bool)(int *_pSequence, int _iItemIndex, bool _itemValue) {
|
||||
_pSequence[_iItemIndex] = _itemValue;
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue