Scilab: rollback, support of container<class*> only (not <class>)
This commit is contained in:
parent
077e69a851
commit
255603639f
6 changed files with 11 additions and 77 deletions
|
|
@ -75,34 +75,6 @@ std::vector<bool> concat_bool_vector(const std::vector<bool> vector, const std::
|
|||
return concat_vector<bool>(vector, other_vector);
|
||||
}
|
||||
|
||||
// object vectors
|
||||
|
||||
std::vector<classA> create_classA_vector(const int size, const int value)
|
||||
{
|
||||
std::vector<classA> out_vector;
|
||||
for (int i=0; i<size; i++)
|
||||
{
|
||||
classA objA(value);
|
||||
out_vector.push_back(objA);
|
||||
}
|
||||
return out_vector;
|
||||
}
|
||||
|
||||
void print_classA_vector(const std::vector<classA>& vector)
|
||||
{
|
||||
std::vector<classA>::const_iterator it;
|
||||
std::cout << std::endl;
|
||||
for (it = vector.begin(); it != vector.end(); ++it)
|
||||
{
|
||||
std::cout << "<classA a:" << it->a << ">" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<classA> concat_classA_vector(const std::vector<classA> vector, const std::vector<classA> other_vector)
|
||||
{
|
||||
return concat_vector<classA>(vector, other_vector);
|
||||
}
|
||||
|
||||
// pointer (on objects) vectors
|
||||
|
||||
std::vector<classA*> create_classAPtr_vector(const int size, const int value)
|
||||
|
|
|
|||
|
|
@ -22,23 +22,16 @@ std::vector<std::string> concat_string_vector(const std::vector<std::string> vec
|
|||
std::vector<bool> create_bool_vector(const int size, const bool value);
|
||||
std::vector<bool> concat_bool_vector(const std::vector<bool> vector, const std::vector<bool> other_vector);
|
||||
|
||||
|
||||
// pointer (on object) vectors
|
||||
class classA
|
||||
{
|
||||
public:
|
||||
classA() : a(0) {}
|
||||
classA(int _a) : a(_a) {}
|
||||
classA(const classA& c) : a(c.a) {}
|
||||
int a;
|
||||
};
|
||||
|
||||
// object vectors
|
||||
|
||||
std::vector<classA> create_classA_vector(const int size, const int value);
|
||||
void print_classA_vector(const std::vector<classA>& pvector);
|
||||
std::vector<classA> concat_classA_vector(const std::vector<classA> vector, const std::vector<classA> other_vector);
|
||||
|
||||
// pointer (on objects) vectors
|
||||
|
||||
std::vector<classA*> create_classAPtr_vector(const int size, const int value);
|
||||
void print_classAPtr_vector(const std::vector<classA*>& pvector);
|
||||
std::vector<classA*> concat_classAPtr_vector(const std::vector<classA*> vector, const std::vector<classA*> other_vector);
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@ namespace std
|
|||
%template(DoubleVector) vector<double>;
|
||||
%template(StringVector) vector<std::string>;
|
||||
%template(BoolVector) vector<bool>;
|
||||
%template(ClassAVector) vector<classA>;
|
||||
%template(ClassAPtrVector) vector<classA*>;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ SWIG_Init();
|
|||
// This example shows how to use C++ fonctions with STL vectors arguments
|
||||
// Here, STL vectors are converted from/to Scilab matrices (SWIG_SCILAB_EXTRA_NATIVE_CONTAINERS is not defined)
|
||||
|
||||
|
||||
// double vectors
|
||||
|
||||
disp("Example of passing matrices of double as vector arguments of C++ functions.");
|
||||
|
|
@ -55,17 +54,6 @@ disp("concat this vector with the vector of bool {false, false, false} with conc
|
|||
bv3 = concat_bool_vector(bv, bv2);
|
||||
disp(bv3);
|
||||
|
||||
// object vectors
|
||||
|
||||
disp("Example of passing lists of pointer on object as vector of objects arguments of C++ functions.");
|
||||
disp("get a vector of objects {<classA a:1>, <classA a:1>, <classA a:1>} with create_classA_vector():");
|
||||
pv = create_classA_vector(3, 1);
|
||||
print_classA_vector(pv);
|
||||
pv2 = create_classA_vector(2, 5);
|
||||
disp("concat this vector with the vector of objects {<classA a:5>, <classA a:5>} with concat_classA_vector():");
|
||||
pv3 = concat_classA_vector(pv, pv2);
|
||||
print_classA_vector(pv3);
|
||||
|
||||
// pointer (on object) vectors
|
||||
|
||||
disp("Example of passing lists of pointers on object as vector of pointers on objects arguments of C++ functions.");
|
||||
|
|
|
|||
|
|
@ -55,10 +55,10 @@ namespace swig {
|
|||
};
|
||||
template <typename T> struct traits_from_sequence {
|
||||
static int create(int size, void **sequence) {
|
||||
return SWIG_FromCreate_Sequence_dec(ptr)(size, (long long **)sequence);
|
||||
return SWIG_FromCreate_Sequence_dec(ptr)(size, (int ***)sequence);
|
||||
}
|
||||
static SciObject set(int size, void *sequence) {
|
||||
return SWIG_FromSet_Sequence_dec(ptr)(size, (long long *)sequence);
|
||||
return SWIG_FromSet_Sequence_dec(ptr)(size, (int **)sequence);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
@ -107,32 +107,14 @@ namespace swig {
|
|||
fragment=SWIG_From_SequenceItem_frag(ptr)) {
|
||||
|
||||
namespace swig {
|
||||
|
||||
// Default value container conversion of item
|
||||
|
||||
template <typename T> struct traits_asval_sequenceitem {
|
||||
static int asval(SciObject obj, void *pSequence, int iItemIndex, T *pItemValue) {
|
||||
T* tmp;
|
||||
int ret = SWIG_AsVal_SequenceItem_dec(ptr)(obj, (int *)pSequence, iItemIndex, (void **)&tmp);
|
||||
*pItemValue = *tmp;
|
||||
return SWIG_AsVal_SequenceItem_dec(ptr)(obj, (int *)pSequence, iItemIndex, (int **)pItemValue);
|
||||
}
|
||||
};
|
||||
template <typename T> struct traits_from_sequenceitem {
|
||||
static int from(void *pSequence, int iItemIndex, T itemValue) {
|
||||
return SWIG_From_SequenceItem_dec(ptr)((long long *)pSequence, iItemIndex, (long long) &itemValue);
|
||||
}
|
||||
};
|
||||
|
||||
// Default pointer container conversion of item
|
||||
|
||||
template <typename T> struct traits_asval_sequenceitem<T*> {
|
||||
static int asval(SciObject obj, void *pSequence, int iItemIndex, T **pItemValue) {
|
||||
return SWIG_AsVal_SequenceItem_dec(ptr)(obj, (int *)pSequence, iItemIndex, (void **)pItemValue);
|
||||
}
|
||||
};
|
||||
template <typename T> struct traits_from_sequenceitem<T*> {
|
||||
static int from(void *pSequence, int iItemIndex, T *itemValue) {
|
||||
return SWIG_From_SequenceItem_dec(ptr)((long long *)pSequence, iItemIndex, (long long) itemValue);
|
||||
return SWIG_From_SequenceItem_dec(ptr)((int **)pSequence, iItemIndex, (int*)itemValue);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,8 +36,8 @@ SWIG_AsSize_Sequence_dec(ptr)(SciObject _obj, int *_piSize) {
|
|||
%fragment(SWIG_FromCreate_Sequence_frag(ptr), "header") {
|
||||
|
||||
SWIGINTERN int
|
||||
SWIG_FromCreate_Sequence_dec(ptr)(int _size, long long **_sequence) {
|
||||
*_sequence = new long long[_size];
|
||||
SWIG_FromCreate_Sequence_dec(ptr)(int _size, int ***_sequence) {
|
||||
*_sequence = new int*[_size];
|
||||
return *_sequence != NULL ? SWIG_OK : SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
|
|
@ -45,7 +45,7 @@ SWIG_FromCreate_Sequence_dec(ptr)(int _size, long long **_sequence) {
|
|||
%fragment(SWIG_FromSet_Sequence_frag(ptr), "header") {
|
||||
|
||||
SWIGINTERN SciObject
|
||||
SWIG_FromSet_Sequence_dec(ptr)(int _size, long long *_sequence) {
|
||||
SWIG_FromSet_Sequence_dec(ptr)(int _size, int **_sequence) {
|
||||
SciErr sciErr;
|
||||
int *piListAddr;
|
||||
|
||||
|
|
@ -75,7 +75,7 @@ SWIG_FromSet_Sequence_dec(ptr)(int _size, long long *_sequence) {
|
|||
%fragment(SWIG_AsVal_SequenceItem_frag(ptr), "header") {
|
||||
|
||||
SWIGINTERN int
|
||||
SWIG_AsVal_SequenceItem_dec(ptr)(SciObject _obj, int *_piSequence, int _itemIndex, void **_pItemValue)
|
||||
SWIG_AsVal_SequenceItem_dec(ptr)(SciObject _obj, int* _piSequence, int _itemIndex, int **_pItemValue)
|
||||
{
|
||||
SciErr sciErr;
|
||||
int *piItemAddr;
|
||||
|
|
@ -115,7 +115,7 @@ SWIG_AsVal_SequenceItem_dec(ptr)(SciObject _obj, int *_piSequence, int _itemInde
|
|||
%fragment(SWIG_From_SequenceItem_frag(ptr), "header") {
|
||||
|
||||
SWIGINTERN int
|
||||
SWIG_From_SequenceItem_dec(ptr)(long long *_pSequence, int _iItemIndex, long long _itemValue) {
|
||||
SWIG_From_SequenceItem_dec(ptr)(int **_pSequence, int _iItemIndex, int *_itemValue) {
|
||||
_pSequence[_iItemIndex] = _itemValue;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue