fix ruby std::vector to support element with nodefault constructors
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@8754 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
2903d7c280
commit
1392d9f9f8
2 changed files with 10 additions and 8 deletions
|
|
@ -7,7 +7,7 @@
|
||||||
%ignore std::vector<Flow>::resize(size_type);
|
%ignore std::vector<Flow>::resize(size_type);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(SWIGTCL) || defined(SWIGPERL)
|
#if defined(SWIGTCL) || defined(SWIGPERL) || defined(SWIGRUBY)
|
||||||
#define SWIG_GOOD_VECTOR
|
#define SWIG_GOOD_VECTOR
|
||||||
/* here, for languages with bad declaration */
|
/* here, for languages with bad declaration */
|
||||||
%ignore std::vector<Flow>::vector(unsigned int);
|
%ignore std::vector<Flow>::vector(unsigned int);
|
||||||
|
|
|
||||||
|
|
@ -47,12 +47,12 @@ namespace std {
|
||||||
%typemap(in) vector<T> {
|
%typemap(in) vector<T> {
|
||||||
if (rb_obj_is_kind_of($input,rb_cArray)) {
|
if (rb_obj_is_kind_of($input,rb_cArray)) {
|
||||||
unsigned int size = RARRAY($input)->len;
|
unsigned int size = RARRAY($input)->len;
|
||||||
$1 = std::vector<T >(size);
|
$1;
|
||||||
for (unsigned int i=0; i<size; i++) {
|
for (unsigned int i=0; i<size; i++) {
|
||||||
VALUE o = RARRAY($input)->ptr[i];
|
VALUE o = RARRAY($input)->ptr[i];
|
||||||
T* x;
|
T* x;
|
||||||
SWIG_ConvertPtr(o, (void **) &x, $descriptor(T *), 1);
|
SWIG_ConvertPtr(o, (void **) &x, $descriptor(T *), 1);
|
||||||
(($1_type &)$1)[i] = *x;
|
$1.push_back(*x);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
void *ptr;
|
void *ptr;
|
||||||
|
|
@ -64,13 +64,12 @@ namespace std {
|
||||||
const vector<T>* (std::vector<T> temp) {
|
const vector<T>* (std::vector<T> temp) {
|
||||||
if (rb_obj_is_kind_of($input,rb_cArray)) {
|
if (rb_obj_is_kind_of($input,rb_cArray)) {
|
||||||
unsigned int size = RARRAY($input)->len;
|
unsigned int size = RARRAY($input)->len;
|
||||||
temp = std::vector<T >(size);
|
|
||||||
$1 = &temp;
|
$1 = &temp;
|
||||||
for (unsigned int i=0; i<size; i++) {
|
for (unsigned int i=0; i<size; i++) {
|
||||||
VALUE o = RARRAY($input)->ptr[i];
|
VALUE o = RARRAY($input)->ptr[i];
|
||||||
T* x;
|
T* x;
|
||||||
SWIG_ConvertPtr(o, (void **) &x, $descriptor(T *), 1);
|
SWIG_ConvertPtr(o, (void **) &x, $descriptor(T *), 1);
|
||||||
temp[i] = *x;
|
temp.push_back(*x);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
SWIG_ConvertPtr($input, (void **) &$1, $1_descriptor, 1);
|
SWIG_ConvertPtr($input, (void **) &$1, $1_descriptor, 1);
|
||||||
|
|
@ -141,7 +140,8 @@ namespace std {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public:
|
public:
|
||||||
vector(unsigned int size = 0);
|
vector();
|
||||||
|
vector(unsigned int size);
|
||||||
vector(unsigned int size, const T& value);
|
vector(unsigned int size, const T& value);
|
||||||
vector(const vector<T> &);
|
vector(const vector<T> &);
|
||||||
|
|
||||||
|
|
@ -287,7 +287,8 @@ namespace std {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public:
|
public:
|
||||||
vector(unsigned int size = 0);
|
vector();
|
||||||
|
vector(unsigned int size);
|
||||||
vector(unsigned int size, T * &value);
|
vector(unsigned int size, T * &value);
|
||||||
vector(const vector<T*> &);
|
vector(const vector<T*> &);
|
||||||
|
|
||||||
|
|
@ -433,7 +434,8 @@ namespace std {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public:
|
public:
|
||||||
vector(unsigned int size = 0);
|
vector();
|
||||||
|
vector(unsigned int size);
|
||||||
vector(unsigned int size, const T& value);
|
vector(unsigned int size, const T& value);
|
||||||
vector(const vector<T> &);
|
vector(const vector<T> &);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue