scilab: fix constructor_copy and other STL container tests
finally vector<class> and vector<enum> are not supported
This commit is contained in:
parent
eb7d2bd43b
commit
dc5de4b5c9
7 changed files with 37 additions and 58 deletions
|
|
@ -43,8 +43,6 @@
|
||||||
fragment="StdTraits",
|
fragment="StdTraits",
|
||||||
fragment="SwigSciIterator_T")
|
fragment="SwigSciIterator_T")
|
||||||
{
|
{
|
||||||
%#include <stdio.h>
|
|
||||||
|
|
||||||
namespace swig
|
namespace swig
|
||||||
{
|
{
|
||||||
template <class T>
|
template <class T>
|
||||||
|
|
@ -63,12 +61,7 @@ namespace swig
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
T value;
|
return traits_asval_sequenceitem<T>::asval(_seq, _piSeqAddr, _index);
|
||||||
if (traits_asval_sequenceitem<T>::asval(_seq, _piSeqAddr, _index, &value) == SWIG_OK)
|
|
||||||
{
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
else throw std::invalid_argument("Cannot get sequence item.");
|
|
||||||
}
|
}
|
||||||
catch (std::exception& e)
|
catch (std::exception& e)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -34,11 +34,6 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
%fragment(SWIG_Traits_Sequence_frag(ptr), "header",
|
%fragment(SWIG_Traits_Sequence_frag(ptr), "header",
|
||||||
fragment=SWIG_AsCheck_Sequence_frag(int),
|
|
||||||
fragment=SWIG_AsGet_Sequence_frag(int),
|
|
||||||
fragment=SWIG_AsSize_Sequence_frag(int),
|
|
||||||
fragment=SWIG_FromCreate_Sequence_frag(int),
|
|
||||||
fragment=SWIG_FromSet_Sequence_frag(int),
|
|
||||||
fragment=SWIG_AsCheck_Sequence_frag(ptr),
|
fragment=SWIG_AsCheck_Sequence_frag(ptr),
|
||||||
fragment=SWIG_AsGet_Sequence_frag(ptr),
|
fragment=SWIG_AsGet_Sequence_frag(ptr),
|
||||||
fragment=SWIG_AsSize_Sequence_frag(ptr),
|
fragment=SWIG_AsSize_Sequence_frag(ptr),
|
||||||
|
|
@ -47,30 +42,28 @@
|
||||||
fragment="StdTraits") {
|
fragment="StdTraits") {
|
||||||
|
|
||||||
namespace swig {
|
namespace swig {
|
||||||
// For sequence of values, considers int as default type (so it works for enums)
|
// Error returned for sequence containers of default item type
|
||||||
|
|
||||||
template <typename T> struct traits_as_sequence {
|
template <typename T> struct traits_as_sequence {
|
||||||
static int check(SwigSciObject obj) {
|
static int check(SwigSciObject obj) {
|
||||||
return SWIG_AsCheck_Sequence_dec(int)(obj);
|
SWIG_Error(SWIG_TypeError, type_name<T>());
|
||||||
}
|
}
|
||||||
static int get(SwigSciObject obj, void **sequence) {
|
static int get(SwigSciObject obj, void **sequence) {
|
||||||
return SWIG_AsGet_Sequence_dec(int)(obj, (int **)sequence);
|
SWIG_Error(SWIG_TypeError, type_name<T>());
|
||||||
}
|
}
|
||||||
static int size(SwigSciObject obj, int *size) {
|
static int size(SwigSciObject obj, int *size) {
|
||||||
return SWIG_AsSize_Sequence_dec(int)(obj, size);
|
SWIG_Error(SWIG_TypeError, type_name<T>());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
template <typename T> struct traits_from_sequence {
|
template <typename T> struct traits_from_sequence {
|
||||||
static int create(int size, void **sequence) {
|
static int create(int size, void **sequence) {
|
||||||
return SWIG_FromCreate_Sequence_dec(int)(size, (int **)sequence);
|
SWIG_Error(SWIG_TypeError, type_name<T>());
|
||||||
}
|
}
|
||||||
static SwigSciObject set(int size, void *sequence) {
|
static SwigSciObject set(int size, void *sequence) {
|
||||||
return SWIG_FromSet_Sequence_dec(int)(size, (int *)sequence);
|
SWIG_Error(SWIG_TypeError, type_name<T>());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// For sequence of pointers
|
// Support sequence containers of pointers
|
||||||
|
|
||||||
template <typename T> struct traits_as_sequence<T*> {
|
template <typename T> struct traits_as_sequence<T*> {
|
||||||
static int check(SwigSciObject obj) {
|
static int check(SwigSciObject obj) {
|
||||||
return SWIG_AsCheck_Sequence_dec(ptr)(obj);
|
return SWIG_AsCheck_Sequence_dec(ptr)(obj);
|
||||||
|
|
@ -132,31 +125,27 @@ namespace swig {
|
||||||
//
|
//
|
||||||
|
|
||||||
%fragment(SWIG_Traits_SequenceItem_frag(ptr), "header",
|
%fragment(SWIG_Traits_SequenceItem_frag(ptr), "header",
|
||||||
fragment=SWIG_AsVal_SequenceItem_frag(int),
|
|
||||||
fragment=SWIG_From_SequenceItem_frag(int),
|
|
||||||
fragment=SWIG_AsVal_SequenceItem_frag(ptr),
|
fragment=SWIG_AsVal_SequenceItem_frag(ptr),
|
||||||
fragment=SWIG_From_SequenceItem_frag(ptr),
|
fragment=SWIG_From_SequenceItem_frag(ptr),
|
||||||
fragment="StdTraits") {
|
fragment="StdTraits") {
|
||||||
|
|
||||||
namespace swig {
|
namespace swig {
|
||||||
// For sequence of values, considers int as default type (so it works for enums)
|
// Error returned for sequence containers of default item type
|
||||||
|
|
||||||
template <typename T> struct traits_asval_sequenceitem {
|
template <typename T> struct traits_asval_sequenceitem {
|
||||||
static int asval(SwigSciObject obj, void *pSequence, int iItemIndex, T *pItemValue) {
|
static T asval(SwigSciObject obj, void *pSequence, int iItemIndex) {
|
||||||
return SWIG_AsVal_SequenceItem_dec(int)(obj, (int *)pSequence, iItemIndex, (int *)pItemValue);
|
SWIG_Error(SWIG_TypeError, type_name<T>());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
template <typename T> struct traits_from_sequenceitem {
|
template <typename T> struct traits_from_sequenceitem {
|
||||||
static int from(void *pSequence, int iItemIndex, T itemValue) {
|
static int from(void *pSequence, int iItemIndex, T itemValue) {
|
||||||
return SWIG_From_SequenceItem_dec(int)((int *)pSequence, iItemIndex, (int)itemValue);
|
SWIG_Error(SWIG_TypeError, type_name<T>());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Sequence of pointers
|
// Support sequence containers of pointers
|
||||||
|
|
||||||
template <typename T> struct traits_asval_sequenceitem<T*> {
|
template <typename T> struct traits_asval_sequenceitem<T*> {
|
||||||
static int asval(SwigSciObject obj, void *pSequence, int iItemIndex, T **pItemValue) {
|
static T* asval(SwigSciObject obj, void *pSequence, int iItemIndex) {
|
||||||
return SWIG_AsVal_SequenceItem_dec(ptr)(obj, (int *)pSequence, iItemIndex, (void **)pItemValue);
|
return static_cast<T*>(SWIG_AsVal_SequenceItem_dec(ptr)(obj, (int *)pSequence, iItemIndex));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
template <typename T> struct traits_from_sequenceitem<T*> {
|
template <typename T> struct traits_from_sequenceitem<T*> {
|
||||||
|
|
@ -175,8 +164,8 @@ namespace swig {
|
||||||
|
|
||||||
namespace swig {
|
namespace swig {
|
||||||
template <> struct traits_asval_sequenceitem<CppType > {
|
template <> struct traits_asval_sequenceitem<CppType > {
|
||||||
static int asval(SwigSciObject obj, void *pSequence, int iItemIndex, CppType *pItemValue) {
|
static CppType asval(SwigSciObject obj, void *pSequence, int iItemIndex) {
|
||||||
return SWIG_AsVal_SequenceItem_dec(CppType)(obj, (ScilabType *)pSequence, iItemIndex, pItemValue);
|
return SWIG_AsVal_SequenceItem_dec(CppType)(obj, (ScilabType *)pSequence, iItemIndex);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
template <> struct traits_from_sequenceitem<CppType > {
|
template <> struct traits_from_sequenceitem<CppType > {
|
||||||
|
|
|
||||||
|
|
@ -84,10 +84,9 @@ SWIG_FromSet_Sequence_dec(bool)(int _size, int *_sequence) {
|
||||||
|
|
||||||
%fragment(SWIG_AsVal_SequenceItem_frag(bool), "header") {
|
%fragment(SWIG_AsVal_SequenceItem_frag(bool), "header") {
|
||||||
|
|
||||||
SWIGINTERN int
|
SWIGINTERN bool
|
||||||
SWIG_AsVal_SequenceItem_dec(bool)(SwigSciObject _obj, int *_pSequence, int _iItemIndex, bool *_pItemValue) {
|
SWIG_AsVal_SequenceItem_dec(bool)(SwigSciObject _obj, int *_pSequence, int _iItemIndex) {
|
||||||
*_pItemValue = _pSequence[_iItemIndex];
|
return _pSequence[_iItemIndex];
|
||||||
return SWIG_OK;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -84,10 +84,9 @@ SWIG_FromSet_Sequence_dec(double)(int _size, double *_sequence) {
|
||||||
|
|
||||||
%fragment(SWIG_AsVal_SequenceItem_frag(double), "header") {
|
%fragment(SWIG_AsVal_SequenceItem_frag(double), "header") {
|
||||||
|
|
||||||
SWIGINTERN int
|
SWIGINTERN double
|
||||||
SWIG_AsVal_SequenceItem_dec(double)(SwigSciObject _obj, double *_pSequence, int _iItemIndex, double *_pItemValue) {
|
SWIG_AsVal_SequenceItem_dec(double)(SwigSciObject _obj, double *_pSequence, int _iItemIndex) {
|
||||||
*_pItemValue = _pSequence[_iItemIndex];
|
return _pSequence[_iItemIndex];
|
||||||
return SWIG_OK;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -84,9 +84,8 @@ SWIG_FromSet_Sequence_dec(int)(int _size, int *_sequence) {
|
||||||
%fragment(SWIG_AsVal_SequenceItem_frag(int), "header") {
|
%fragment(SWIG_AsVal_SequenceItem_frag(int), "header") {
|
||||||
|
|
||||||
SWIGINTERN int
|
SWIGINTERN int
|
||||||
SWIG_AsVal_SequenceItem_dec(int)(SwigSciObject _obj, int *_pSequence, int _iItemIndex, int *_pItemValue) {
|
SWIG_AsVal_SequenceItem_dec(int)(SwigSciObject _obj, int *_pSequence, int _iItemIndex) {
|
||||||
*_pItemValue = _pSequence[_iItemIndex];
|
return _pSequence[_iItemIndex];
|
||||||
return SWIG_OK;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -74,41 +74,42 @@ SWIG_FromSet_Sequence_dec(ptr)(int _size, long long *_sequence) {
|
||||||
|
|
||||||
%fragment(SWIG_AsVal_SequenceItem_frag(ptr), "header") {
|
%fragment(SWIG_AsVal_SequenceItem_frag(ptr), "header") {
|
||||||
|
|
||||||
SWIGINTERN int
|
SWIGINTERN void*
|
||||||
SWIG_AsVal_SequenceItem_dec(ptr)(SwigSciObject _obj, int *_piSequence, int _itemIndex, void **_pItemValue)
|
SWIG_AsVal_SequenceItem_dec(ptr)(SwigSciObject _obj, int *_piSequence, int _itemIndex)
|
||||||
{
|
{
|
||||||
SciErr sciErr;
|
SciErr sciErr;
|
||||||
int *piItemAddr;
|
int *piItemAddr;
|
||||||
int iType;
|
int iType;
|
||||||
|
void* pItemValue = NULL;
|
||||||
|
|
||||||
sciErr = getListItemAddress(pvApiCtx, _piSequence, _itemIndex + 1, &piItemAddr);
|
sciErr = getListItemAddress(pvApiCtx, _piSequence, _itemIndex + 1, &piItemAddr);
|
||||||
if (sciErr.iErr)
|
if (sciErr.iErr)
|
||||||
{
|
{
|
||||||
printError(&sciErr, 0);
|
printError(&sciErr, 0);
|
||||||
return SWIG_ERROR;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
sciErr = getVarType(pvApiCtx, piItemAddr, &iType);
|
sciErr = getVarType(pvApiCtx, piItemAddr, &iType);
|
||||||
if (sciErr.iErr)
|
if (sciErr.iErr)
|
||||||
{
|
{
|
||||||
printError(&sciErr, 0);
|
printError(&sciErr, 0);
|
||||||
return SWIG_ERROR;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (iType != sci_pointer)
|
if (iType != sci_pointer)
|
||||||
{
|
{
|
||||||
Scierror(999, _("%s: Wrong type for input argument #%d: A pointer is expected at list item #%d.\n"), fname, _obj, _itemIndex + 1);
|
Scierror(999, _("%s: Wrong type for input argument #%d: A pointer is expected at list item #%d.\n"), fname, _obj, _itemIndex + 1);
|
||||||
return SWIG_ERROR;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
sciErr = getPointerInList(pvApiCtx, _piSequence, _itemIndex + 1, (void **)_pItemValue);
|
sciErr = getPointerInList(pvApiCtx, _piSequence, _itemIndex + 1, &pItemValue);
|
||||||
if (sciErr.iErr)
|
if (sciErr.iErr)
|
||||||
{
|
{
|
||||||
printError(&sciErr, 0);
|
printError(&sciErr, 0);
|
||||||
return SWIG_ERROR;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return SWIG_OK;
|
return pItemValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -76,10 +76,9 @@ SWIG_FromSet_Sequence_dec(std::string)(int _size, char **_sequence) {
|
||||||
|
|
||||||
%fragment(SWIG_AsVal_SequenceItem_frag(std::string), "header") {
|
%fragment(SWIG_AsVal_SequenceItem_frag(std::string), "header") {
|
||||||
|
|
||||||
SWIGINTERN int
|
SWIGINTERN std::string
|
||||||
SWIG_AsVal_SequenceItem_dec(std::string)(SwigSciObject _obj, char **_pSequence, int _iItemIndex, std::string *_pItemValue) {
|
SWIG_AsVal_SequenceItem_dec(std::string)(SwigSciObject _obj, char **_pSequence, int _iItemIndex) {
|
||||||
*_pItemValue = std::string(_pSequence[_iItemIndex]);
|
return std::string(_pSequence[_iItemIndex]);
|
||||||
return SWIG_OK;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue