Support building with recent versions of the Ruby 1.9 development branch.
Fixes bug #1560092. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@9333 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
8fa318ee36
commit
2f6a268e55
11 changed files with 137 additions and 118 deletions
|
|
@ -1,6 +1,10 @@
|
|||
Version 1.3.30 (in progress)
|
||||
============================
|
||||
|
||||
09/23/2006: olly
|
||||
[Ruby] Support building with recent versions of the Ruby 1.9
|
||||
development branch. Fixes bug #1560092.
|
||||
|
||||
09/23/2006: olly
|
||||
Templates can now be instantiated using negative numbers and
|
||||
constant expressions, e.g.:
|
||||
|
|
|
|||
|
|
@ -25,10 +25,10 @@
|
|||
%typemap(in) (int ARGC, char **ARGV) {
|
||||
if (rb_obj_is_kind_of($input,rb_cArray)) {
|
||||
int i;
|
||||
int size = RARRAY($input)->len;
|
||||
int size = RARRAY_LEN($input);
|
||||
$1 = ($1_ltype) size;
|
||||
$2 = (char **) malloc((size+1)*sizeof(char *));
|
||||
VALUE *ptr = RARRAY($input)->ptr;
|
||||
VALUE *ptr = RARRAY_PTR($input);
|
||||
for (i=0; i < size; i++, ptr++) {
|
||||
$2[i]= STR2CSTR(*ptr);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ SWIG_AsVal(jstring)(VALUE obj, jstring *val)
|
|||
if (TYPE(obj) == T_STRING) {
|
||||
if (val) {
|
||||
char *cstr = rb_string_value_ptr(&(obj));
|
||||
jsize len = RSTRING(obj)->len;
|
||||
jsize len = RSTRING_LEN(obj);
|
||||
*val = JvNewStringLatin1(cstr, len);
|
||||
}
|
||||
return SWIG_NEWOBJ;
|
||||
|
|
|
|||
|
|
@ -11,23 +11,23 @@ char **PROG_ARGV
|
|||
|
||||
// argc and argv
|
||||
%typemap(in,numinputs=0) int PROG_ARGC {
|
||||
$1 = RARRAY(rb_argv)->len + 1;
|
||||
$1 = RARRAY_LEN(rb_argv) + 1;
|
||||
}
|
||||
|
||||
%typemap(in,numinputs=0) char **PROG_ARGV {
|
||||
int i, n;
|
||||
VALUE ary = rb_eval_string("[$0] + ARGV");
|
||||
n = RARRAY(ary)->len;
|
||||
n = RARRAY_LEN(ary);
|
||||
$1 = (char **)malloc(n + 1);
|
||||
for (i = 0; i < n; i++) {
|
||||
VALUE v = rb_obj_as_string(RARRAY(ary)->ptr[i]);
|
||||
$1[i] = (char *)malloc(RSTRING(v)->len + 1);
|
||||
strcpy($1[i], RSTRING(v)->ptr);
|
||||
VALUE v = rb_obj_as_string(RARRAY_PTR(ary)[i]);
|
||||
$1[i] = (char *)malloc(RSTRING_LEN(v) + 1);
|
||||
strcpy($1[i], RSTRING_PTR(v));
|
||||
}
|
||||
}
|
||||
|
||||
%typemap(freearg) char **PROG_ARGV {
|
||||
int i, n = RARRAY(rb_argv)->len + 1;
|
||||
int i, n = RARRAY_LEN(rb_argv) + 1;
|
||||
for (i = 0; i < n; i++) free($1[i]);
|
||||
free($1);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,6 +20,21 @@
|
|||
#endif
|
||||
#endif
|
||||
|
||||
/* RSTRING_LEN, etc are new in Ruby 1.9, but ->ptr and ->len no longer work */
|
||||
/* Define these for older versions so we can just write code the new way */
|
||||
#ifndef RSTRING_LEN
|
||||
# define RSTRING_LEN(x) RSTRING(x)->len
|
||||
#endif
|
||||
#ifndef RSTRING_PTR
|
||||
# define RSTRING_PTR(x) RSTRING(x)->ptr
|
||||
#endif
|
||||
#ifndef RARRAY_LEN
|
||||
# define RARRAY_LEN(x) RARRAY(x)->len
|
||||
#endif
|
||||
#ifndef RARRAY_PTR
|
||||
# define RARRAY_PTR(x) RARRAY(x)->ptr
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Need to be very careful about how these macros are defined, especially
|
||||
* when compiling C++ code or C code with an ANSI C compiler.
|
||||
|
|
@ -63,10 +78,10 @@
|
|||
#define StringValue(s) RB_STRING_VALUE(s)
|
||||
#endif
|
||||
#ifndef StringValuePtr
|
||||
#define StringValuePtr(s) RSTRING(RB_STRING_VALUE(s))->ptr
|
||||
#define StringValuePtr(s) RSTRING_PTR(RB_STRING_VALUE(s))
|
||||
#endif
|
||||
#ifndef StringValueLen
|
||||
#define StringValueLen(s) RSTRING(RB_STRING_VALUE(s))->len
|
||||
#define StringValueLen(s) RSTRING_LEN(RB_STRING_VALUE(s))
|
||||
#endif
|
||||
#ifndef SafeStringValue
|
||||
#define SafeStringValue(v) do {\
|
||||
|
|
|
|||
|
|
@ -157,7 +157,7 @@ SWIG_Ruby_NewPointerObj(void *ptr, swig_type_info *type, int flags)
|
|||
downcast methods. */
|
||||
if (obj != Qnil) {
|
||||
VALUE value = rb_iv_get(obj, "__swigtype__");
|
||||
char* type_name = RSTRING(value)->ptr;
|
||||
char* type_name = RSTRING_PTR(value);
|
||||
|
||||
if (strcmp(type->name, type_name) == 0) {
|
||||
return obj;
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ SWIG_AsCharPtrAndSize(VALUE obj, char** cptr, size_t* psize, int *alloc)
|
|||
#else
|
||||
char *cstr = STR2CSTR(obj);
|
||||
#endif
|
||||
size_t size = RSTRING(obj)->len + 1;
|
||||
size_t size = RSTRING_LEN(obj) + 1;
|
||||
if (cptr) {
|
||||
if (alloc) {
|
||||
if (*alloc == SWIG_NEWOBJ) {
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ bool SWIG_STRING_P(VALUE x) {
|
|||
return TYPE(x) == T_STRING;
|
||||
}
|
||||
std::string SWIG_RB2STR(VALUE x) {
|
||||
return std::string(RSTRING(x)->ptr, RSTRING(x)->len);
|
||||
return std::string(RSTRING_PTR(x), RSTRING_LEN(x));
|
||||
}
|
||||
VALUE SWIG_STR2RB(const std::string& s) {
|
||||
return rb_str_new(s.data(), s.size());
|
||||
|
|
|
|||
|
|
@ -50,11 +50,11 @@ namespace std {
|
|||
if (rb_obj_is_kind_of($input,rb_cHash)) {
|
||||
$1 = std::map<K,T >();
|
||||
VALUE keys = rb_funcall($input,rb_intern("keys"),0);
|
||||
unsigned int size = RARRAY(keys)->len;
|
||||
unsigned int size = RARRAY_LEN(keys);
|
||||
for (unsigned int i=0; i<size; i++) {
|
||||
K* k;
|
||||
T* x;
|
||||
VALUE key = RARRAY(keys)->ptr[i];
|
||||
VALUE key = RARRAY_PTR(keys)[i];
|
||||
VALUE val = rb_hash_aref($input,key);
|
||||
SWIG_ConvertPtr(key, (void **) &k, $descriptor(K *), 1);
|
||||
SWIG_ConvertPtr(val, (void **) &x, $descriptor(T *), 1);
|
||||
|
|
@ -73,11 +73,11 @@ namespace std {
|
|||
temp = std::map<K,T >();
|
||||
$1 = &temp;
|
||||
VALUE keys = rb_funcall($input,rb_intern("keys"),0);
|
||||
unsigned int size = RARRAY(keys)->len;
|
||||
unsigned int size = RARRAY_LEN(keys);
|
||||
for (unsigned int i=0; i<size; i++) {
|
||||
K* k;
|
||||
T* x;
|
||||
VALUE key = RARRAY(keys)->ptr[i];
|
||||
VALUE key = RARRAY_PTR(keys)[i];
|
||||
VALUE val = rb_hash_aref($input,key);
|
||||
SWIG_ConvertPtr(key, (void **) &k, $descriptor(K *), 1);
|
||||
SWIG_ConvertPtr(val, (void **) &x, $descriptor(T *), 1);
|
||||
|
|
@ -104,7 +104,7 @@ namespace std {
|
|||
/* native sequence? */
|
||||
if (rb_obj_is_kind_of($input,rb_cHash)) {
|
||||
VALUE keys = rb_funcall($input,rb_intern("keys"),0);
|
||||
unsigned int size = RARRAY(keys)->len;
|
||||
unsigned int size = RARRAY_LEN(keys);
|
||||
if (size == 0) {
|
||||
/* an empty dictionary can be of any type */
|
||||
$1 = 1;
|
||||
|
|
@ -112,7 +112,7 @@ namespace std {
|
|||
/* check the first element only */
|
||||
K* k;
|
||||
T* x;
|
||||
VALUE key = RARRAY(keys)->ptr[0];
|
||||
VALUE key = RARRAY_PTR(keys)[0];
|
||||
VALUE val = rb_hash_aref($input,key);
|
||||
if (SWIG_ConvertPtr(key,(void **) &k,
|
||||
$descriptor(K *),0) != -1 &&
|
||||
|
|
@ -137,7 +137,7 @@ namespace std {
|
|||
/* native sequence? */
|
||||
if (rb_obj_is_kind_of($input,rb_cHash)) {
|
||||
VALUE keys = rb_funcall($input,rb_intern("keys"),0);
|
||||
unsigned int size = RARRAY(keys)->len;
|
||||
unsigned int size = RARRAY_LEN(keys);
|
||||
if (size == 0) {
|
||||
/* an empty dictionary can be of any type */
|
||||
$1 = 1;
|
||||
|
|
@ -145,7 +145,7 @@ namespace std {
|
|||
/* check the first element only */
|
||||
K* k;
|
||||
T* x;
|
||||
VALUE key = RARRAY(keys)->ptr[0];
|
||||
VALUE key = RARRAY_PTR(keys)[0];
|
||||
VALUE val = rb_hash_aref($input,key);
|
||||
if (SWIG_ConvertPtr(key,(void **) &k,
|
||||
$descriptor(K *),0) != -1 &&
|
||||
|
|
@ -254,10 +254,10 @@ namespace std {
|
|||
if (rb_obj_is_kind_of($input,rb_cHash)) {
|
||||
$1 = std::map<K,T >();
|
||||
VALUE keys = rb_funcall($input,rb_intern("keys"),0);
|
||||
unsigned int size = RARRAY(keys)->len;
|
||||
unsigned int size = RARRAY_LEN(keys);
|
||||
for (unsigned int i=0; i<size; i++) {
|
||||
T* x;
|
||||
VALUE key = RARRAY(keys)->ptr[i];
|
||||
VALUE key = RARRAY_PTR(keys)[i];
|
||||
VALUE val = rb_hash_aref($input,key);
|
||||
if (!CHECK(key))
|
||||
rb_raise(rb_eTypeError,
|
||||
|
|
@ -280,10 +280,10 @@ namespace std {
|
|||
temp = std::map<K,T >();
|
||||
$1 = &temp;
|
||||
VALUE keys = rb_funcall($input,rb_intern("keys"),0);
|
||||
unsigned int size = RARRAY(keys)->len;
|
||||
unsigned int size = RARRAY_LEN(keys);
|
||||
for (unsigned int i=0; i<size; i++) {
|
||||
T* x;
|
||||
VALUE key = RARRAY(keys)->ptr[i];
|
||||
VALUE key = RARRAY_PTR(keys)[i];
|
||||
VALUE val = rb_hash_aref($input,key);
|
||||
if (!CHECK(key))
|
||||
rb_raise(rb_eTypeError,
|
||||
|
|
@ -312,14 +312,14 @@ namespace std {
|
|||
// native sequence?
|
||||
if (rb_obj_is_kind_of($input,rb_cHash)) {
|
||||
VALUE keys = rb_funcall($input,rb_intern("keys"),0);
|
||||
unsigned int size = RARRAY(keys)->len;
|
||||
unsigned int size = RARRAY_LEN(keys);
|
||||
if (size == 0) {
|
||||
// an empty dictionary can be of any type
|
||||
$1 = 1;
|
||||
} else {
|
||||
// check the first element only
|
||||
T* x;
|
||||
VALUE key = RARRAY(keys)->ptr[0];
|
||||
VALUE key = RARRAY_PTR(keys)[0];
|
||||
VALUE val = rb_hash_aref($input,key);
|
||||
if (CHECK(key) &&
|
||||
SWIG_ConvertPtr(val,(void **) &x,
|
||||
|
|
@ -343,14 +343,14 @@ namespace std {
|
|||
// native sequence?
|
||||
if (rb_obj_is_kind_of($input,rb_cHash)) {
|
||||
VALUE keys = rb_funcall($input,rb_intern("keys"),0);
|
||||
unsigned int size = RARRAY(keys)->len;
|
||||
unsigned int size = RARRAY_LEN(keys);
|
||||
if (size == 0) {
|
||||
// an empty dictionary can be of any type
|
||||
$1 = 1;
|
||||
} else {
|
||||
// check the first element only
|
||||
T* x;
|
||||
VALUE key = RARRAY(keys)->ptr[0];
|
||||
VALUE key = RARRAY_PTR(keys)[0];
|
||||
VALUE val = rb_hash_aref($input,key);
|
||||
if (CHECK(key) &&
|
||||
SWIG_ConvertPtr(val,(void **) &x,
|
||||
|
|
@ -452,10 +452,10 @@ namespace std {
|
|||
if (rb_obj_is_kind_of($input,rb_cHash)) {
|
||||
$1 = std::map<K,T >();
|
||||
VALUE keys = rb_funcall($input,rb_intern("keys"),0);
|
||||
unsigned int size = RARRAY(keys)->len;
|
||||
unsigned int size = RARRAY_LEN(keys);
|
||||
for (unsigned int i=0; i<size; i++) {
|
||||
K* k;
|
||||
VALUE key = RARRAY(keys)->ptr[i];
|
||||
VALUE key = RARRAY_PTR(keys)[i];
|
||||
VALUE val = rb_hash_aref($input,key);
|
||||
if (!CHECK(val))
|
||||
rb_raise(rb_eTypeError,
|
||||
|
|
@ -478,10 +478,10 @@ namespace std {
|
|||
temp = std::map<K,T >();
|
||||
$1 = &temp;
|
||||
VALUE keys = rb_funcall($input,rb_intern("keys"),0);
|
||||
unsigned int size = RARRAY(keys)->len;
|
||||
unsigned int size = RARRAY_LEN(keys);
|
||||
for (unsigned int i=0; i<size; i++) {
|
||||
K* k;
|
||||
VALUE key = RARRAY(keys)->ptr[i];
|
||||
VALUE key = RARRAY_PTR(keys)[i];
|
||||
VALUE val = rb_hash_aref($input,key);
|
||||
if (!CHECK(val))
|
||||
rb_raise(rb_eTypeError,
|
||||
|
|
@ -510,14 +510,14 @@ namespace std {
|
|||
// native sequence?
|
||||
if (rb_obj_is_kind_of($input,rb_cHash)) {
|
||||
VALUE keys = rb_funcall($input,rb_intern("keys"),0);
|
||||
unsigned int size = RARRAY(keys)->len;
|
||||
unsigned int size = RARRAY_LEN(keys);
|
||||
if (size == 0) {
|
||||
// an empty dictionary can be of any type
|
||||
$1 = 1;
|
||||
} else {
|
||||
// check the first element only
|
||||
K* k;
|
||||
VALUE key = RARRAY(keys)->ptr[0];
|
||||
VALUE key = RARRAY_PTR(keys)[0];
|
||||
VALUE val = rb_hash_aref($input,key);
|
||||
if (SWIG_ConvertPtr(val,(void **) &k,
|
||||
$descriptor(K *),0) != -1 &&
|
||||
|
|
@ -541,14 +541,14 @@ namespace std {
|
|||
// native sequence?
|
||||
if (rb_obj_is_kind_of($input,rb_cHash)) {
|
||||
VALUE keys = rb_funcall($input,rb_intern("keys"),0);
|
||||
unsigned int size = RARRAY(keys)->len;
|
||||
unsigned int size = RARRAY_LEN(keys);
|
||||
if (size == 0) {
|
||||
// an empty dictionary can be of any type
|
||||
$1 = 1;
|
||||
} else {
|
||||
// check the first element only
|
||||
K* k;
|
||||
VALUE key = RARRAY(keys)->ptr[0];
|
||||
VALUE key = RARRAY_PTR(keys)[0];
|
||||
VALUE val = rb_hash_aref($input,key);
|
||||
if (SWIG_ConvertPtr(val,(void **) &k,
|
||||
$descriptor(K *),0) != -1 &&
|
||||
|
|
@ -650,9 +650,9 @@ namespace std {
|
|||
if (rb_obj_is_kind_of($input,rb_cHash)) {
|
||||
$1 = std::map<K,T >();
|
||||
VALUE keys = rb_funcall($input,rb_intern("keys"),0);
|
||||
unsigned int size = RARRAY(keys)->len;
|
||||
unsigned int size = RARRAY_LEN(keys);
|
||||
for (unsigned int i=0; i<size; i++) {
|
||||
VALUE key = RARRAY(keys)->ptr[i];
|
||||
VALUE key = RARRAY_PTR(keys)[i];
|
||||
VALUE val = rb_hash_aref($input,key);
|
||||
if (!(CHECK_K(key) && CHECK_T(val)))
|
||||
rb_raise(rb_eTypeError,
|
||||
|
|
@ -674,9 +674,9 @@ namespace std {
|
|||
temp = std::map<K,T >();
|
||||
$1 = &temp;
|
||||
VALUE keys = rb_funcall($input,rb_intern("keys"),0);
|
||||
unsigned int size = RARRAY(keys)->len;
|
||||
unsigned int size = RARRAY_LEN(keys);
|
||||
for (unsigned int i=0; i<size; i++) {
|
||||
VALUE key = RARRAY(keys)->ptr[i];
|
||||
VALUE key = RARRAY_PTR(keys)[i];
|
||||
VALUE val = rb_hash_aref($input,key);
|
||||
if (!(CHECK_K(key) && CHECK_T(val)))
|
||||
rb_raise(rb_eTypeError,
|
||||
|
|
@ -701,13 +701,13 @@ namespace std {
|
|||
// native sequence?
|
||||
if (rb_obj_is_kind_of($input,rb_cHash)) {
|
||||
VALUE keys = rb_funcall($input,rb_intern("keys"),0);
|
||||
unsigned int size = RARRAY(keys)->len;
|
||||
unsigned int size = RARRAY_LEN(keys);
|
||||
if (size == 0) {
|
||||
// an empty dictionary can be of any type
|
||||
$1 = 1;
|
||||
} else {
|
||||
// check the first element only
|
||||
VALUE key = RARRAY(keys)->ptr[0];
|
||||
VALUE key = RARRAY_PTR(keys)[0];
|
||||
VALUE val = rb_hash_aref($input,key);
|
||||
if (CHECK_K(key) && CHECK_T(val))
|
||||
$1 = 1;
|
||||
|
|
@ -729,13 +729,13 @@ namespace std {
|
|||
// native sequence?
|
||||
if (rb_obj_is_kind_of($input,rb_cHash)) {
|
||||
VALUE keys = rb_funcall($input,rb_intern("keys"),0);
|
||||
unsigned int size = RARRAY(keys)->len;
|
||||
unsigned int size = RARRAY_LEN(keys);
|
||||
if (size == 0) {
|
||||
// an empty dictionary can be of any type
|
||||
$1 = 1;
|
||||
} else {
|
||||
// check the first element only
|
||||
VALUE key = RARRAY(keys)->ptr[0];
|
||||
VALUE key = RARRAY_PTR(keys)[0];
|
||||
VALUE val = rb_hash_aref($input,key);
|
||||
if (CHECK_K(key) && CHECK_T(val))
|
||||
$1 = 1;
|
||||
|
|
|
|||
|
|
@ -27,14 +27,14 @@ namespace std {
|
|||
template<class T, class U> struct pair {
|
||||
%typemap(in) pair<T,U> (std::pair<T,U>* p) {
|
||||
if (rb_obj_is_kind_of($input,rb_cArray)) {
|
||||
unsigned int size = RARRAY($input)->len;
|
||||
unsigned int size = RARRAY_LEN($input);
|
||||
if (size != 2)
|
||||
SWIG_exception(SWIG_TypeError,
|
||||
"pair<" #T "," #U "> expected");
|
||||
T* x;
|
||||
U* y;
|
||||
VALUE first = RARRAY($input)->ptr[0];
|
||||
VALUE second = RARRAY($input)->ptr[1];
|
||||
VALUE first = RARRAY_PTR($input)[0];
|
||||
VALUE second = RARRAY_PTR($input)[1];
|
||||
SWIG_ConvertPtr(first, (void **) &x, $descriptor(T *), 1);
|
||||
SWIG_ConvertPtr(second, (void **) &y, $descriptor(U *), 1);
|
||||
$1 = std::make_pair(*x,*y);
|
||||
|
|
@ -48,14 +48,14 @@ namespace std {
|
|||
const pair<T,U>* (std::pair<T,U> temp,
|
||||
std::pair<T,U>* p) {
|
||||
if (rb_obj_is_kind_of($input,rb_cArray)) {
|
||||
unsigned int size = RARRAY($input)->len;
|
||||
unsigned int size = RARRAY_LEN($input);
|
||||
if (size != 2)
|
||||
SWIG_exception(SWIG_TypeError,
|
||||
"pair<" #T "," #U "> expected");
|
||||
T* x;
|
||||
U* y;
|
||||
VALUE first = RARRAY($input)->ptr[0];
|
||||
VALUE second = RARRAY($input)->ptr[1];
|
||||
VALUE first = RARRAY_PTR($input)[0];
|
||||
VALUE second = RARRAY_PTR($input)[1];
|
||||
SWIG_ConvertPtr(first, (void **) &x, $descriptor(T *), 1);
|
||||
SWIG_ConvertPtr(second, (void **) &y, $descriptor(U *), 1);
|
||||
temp = std::make_pair(*x,*y);
|
||||
|
|
@ -79,15 +79,15 @@ namespace std {
|
|||
%typecheck(SWIG_TYPECHECK_PAIR) pair<T,U> {
|
||||
/* native sequence? */
|
||||
if (rb_obj_is_kind_of($input,rb_cArray)) {
|
||||
unsigned int size = RARRAY($input)->len;
|
||||
unsigned int size = RARRAY_LEN($input);
|
||||
if (size != 2) {
|
||||
/* not a pair */
|
||||
$1 = 0;
|
||||
} else {
|
||||
T* x;
|
||||
U* y;
|
||||
VALUE first = RARRAY($input)->ptr[0];
|
||||
VALUE second = RARRAY($input)->ptr[1];
|
||||
VALUE first = RARRAY_PTR($input)[0];
|
||||
VALUE second = RARRAY_PTR($input)[1];
|
||||
if (SWIG_ConvertPtr(first,(void **) &x,
|
||||
$descriptor(T *),0) != -1 &&
|
||||
SWIG_ConvertPtr(second,(void **) &y,
|
||||
|
|
@ -110,15 +110,15 @@ namespace std {
|
|||
const pair<T,U>* {
|
||||
/* native sequence? */
|
||||
if (rb_obj_is_kind_of($input,rb_cHash)) {
|
||||
unsigned int size = RARRAY($input)->len;
|
||||
unsigned int size = RARRAY_LEN($input);
|
||||
if (size != 2) {
|
||||
/* not a pair */
|
||||
$1 = 0;
|
||||
} else {
|
||||
T* x;
|
||||
U* y;
|
||||
VALUE first = RARRAY($input)->ptr[0];
|
||||
VALUE second = RARRAY($input)->ptr[1];
|
||||
VALUE first = RARRAY_PTR($input)[0];
|
||||
VALUE second = RARRAY_PTR($input)[1];
|
||||
if (SWIG_ConvertPtr(first,(void **) &x,
|
||||
$descriptor(T *),0) != -1 &&
|
||||
SWIG_ConvertPtr(second,(void **) &y,
|
||||
|
|
@ -154,13 +154,13 @@ namespace std {
|
|||
template<class U> struct pair<T,U> {
|
||||
%typemap(in) pair<T,U> (std::pair<T,U>* p) {
|
||||
if (rb_obj_is_kind_of($input,rb_cArray)) {
|
||||
unsigned int size = RARRAY($input)->len;
|
||||
unsigned int size = RARRAY_LEN($input);
|
||||
if (size != 2)
|
||||
SWIG_exception(SWIG_TypeError,
|
||||
"pair<" #T "," #U "> expected");
|
||||
U* y;
|
||||
VALUE first = RARRAY($input)->ptr[0];
|
||||
VALUE second = RARRAY($input)->ptr[1];
|
||||
VALUE first = RARRAY_PTR($input)[0];
|
||||
VALUE second = RARRAY_PTR($input)[1];
|
||||
if (!CHECK(first))
|
||||
SWIG_exception(SWIG_TypeError,
|
||||
"pair<" #T "," #U "> expected");
|
||||
|
|
@ -176,13 +176,13 @@ namespace std {
|
|||
const pair<T,U>* (std::pair<T,U> temp,
|
||||
std::pair<T,U>* p) {
|
||||
if (rb_obj_is_kind_of($input,rb_cArray)) {
|
||||
unsigned int size = RARRAY($input)->len;
|
||||
unsigned int size = RARRAY_LEN($input);
|
||||
if (size != 2)
|
||||
SWIG_exception(SWIG_TypeError,
|
||||
"pair<" #T "," #U "> expected");
|
||||
U* y;
|
||||
VALUE first = RARRAY($input)->ptr[0];
|
||||
VALUE second = RARRAY($input)->ptr[1];
|
||||
VALUE first = RARRAY_PTR($input)[0];
|
||||
VALUE second = RARRAY_PTR($input)[1];
|
||||
if (!CHECK(first))
|
||||
SWIG_exception(SWIG_TypeError,
|
||||
"pair<" #T "," #U "> expected");
|
||||
|
|
@ -205,14 +205,14 @@ namespace std {
|
|||
%typecheck(SWIG_TYPECHECK_MAP) pair<T,U> {
|
||||
/* native sequence? */
|
||||
if (rb_obj_is_kind_of($input,rb_cArray)) {
|
||||
unsigned int size = RARRAY($input)->len;
|
||||
unsigned int size = RARRAY_LEN($input);
|
||||
if (size != 2) {
|
||||
/* not a pair */
|
||||
$1 = 0;
|
||||
} else {
|
||||
U* y;
|
||||
VALUE first = RARRAY($input)->ptr[0];
|
||||
VALUE second = RARRAY($input)->ptr[1];
|
||||
VALUE first = RARRAY_PTR($input)[0];
|
||||
VALUE second = RARRAY_PTR($input)[1];
|
||||
if (CHECK(first) &&
|
||||
SWIG_ConvertPtr(second,(void **) &y,
|
||||
$descriptor(U *),0) != -1)
|
||||
|
|
@ -234,14 +234,14 @@ namespace std {
|
|||
const pair<T,U>* {
|
||||
/* native sequence? */
|
||||
if (rb_obj_is_kind_of($input,rb_cHash)) {
|
||||
unsigned int size = RARRAY($input)->len;
|
||||
unsigned int size = RARRAY_LEN($input);
|
||||
if (size != 2) {
|
||||
/* not a pair */
|
||||
$1 = 0;
|
||||
} else {
|
||||
U* y;
|
||||
VALUE first = RARRAY($input)->ptr[0];
|
||||
VALUE second = RARRAY($input)->ptr[1];
|
||||
VALUE first = RARRAY_PTR($input)[0];
|
||||
VALUE second = RARRAY_PTR($input)[1];
|
||||
if (CHECK(first) &&
|
||||
SWIG_ConvertPtr(second,(void **) &y,
|
||||
$descriptor(U *),0) != -1)
|
||||
|
|
@ -275,14 +275,14 @@ namespace std {
|
|||
template<class T> struct pair<T,U> {
|
||||
%typemap(in) pair<T,U> (std::pair<T,U>* p) {
|
||||
if (rb_obj_is_kind_of($input,rb_cArray)) {
|
||||
unsigned int size = RARRAY($input)->len;
|
||||
unsigned int size = RARRAY_LEN($input);
|
||||
if (size != 2) {
|
||||
SWIG_exception(SWIG_TypeError,
|
||||
"pair<" #T "," #U "> expected");
|
||||
}
|
||||
T* x;
|
||||
VALUE first = RARRAY($input)->ptr[0];
|
||||
VALUE second = RARRAY($input)->ptr[1];
|
||||
VALUE first = RARRAY_PTR($input)[0];
|
||||
VALUE second = RARRAY_PTR($input)[1];
|
||||
SWIG_ConvertPtr(first, (void **) &x, $descriptor(T *), 1);
|
||||
if (!CHECK(second))
|
||||
SWIG_exception(SWIG_TypeError,
|
||||
|
|
@ -298,14 +298,14 @@ namespace std {
|
|||
const pair<T,U>* (std::pair<T,U> temp,
|
||||
std::pair<T,U>* p) {
|
||||
if (rb_obj_is_kind_of($input,rb_cArray)) {
|
||||
unsigned int size = RARRAY($input)->len;
|
||||
unsigned int size = RARRAY_LEN($input);
|
||||
if (size != 2) {
|
||||
SWIG_exception(SWIG_TypeError,
|
||||
"pair<" #T "," #U "> expected");
|
||||
}
|
||||
T* x;
|
||||
VALUE first = RARRAY($input)->ptr[0];
|
||||
VALUE second = RARRAY($input)->ptr[1];
|
||||
VALUE first = RARRAY_PTR($input)[0];
|
||||
VALUE second = RARRAY_PTR($input)[1];
|
||||
SWIG_ConvertPtr(first, (void **) &x, $descriptor(T *), 1);
|
||||
if (!CHECK(second))
|
||||
SWIG_exception(SWIG_TypeError,
|
||||
|
|
@ -328,14 +328,14 @@ namespace std {
|
|||
%typecheck(SWIG_TYPECHECK_PAIR) pair<T,U> {
|
||||
/* native sequence? */
|
||||
if (rb_obj_is_kind_of($input,rb_cArray)) {
|
||||
unsigned int size = RARRAY($input)->len;
|
||||
unsigned int size = RARRAY_LEN($input);
|
||||
if (size != 2) {
|
||||
/* not a pair */
|
||||
$1 = 0;
|
||||
} else {
|
||||
T* x;
|
||||
VALUE first = RARRAY($input)->ptr[0];
|
||||
VALUE second = RARRAY($input)->ptr[1];
|
||||
VALUE first = RARRAY_PTR($input)[0];
|
||||
VALUE second = RARRAY_PTR($input)[1];
|
||||
if (SWIG_ConvertPtr(first,(void **) &x,
|
||||
$descriptor(T *),0) != -1 &&
|
||||
CHECK(second))
|
||||
|
|
@ -357,14 +357,14 @@ namespace std {
|
|||
const pair<T,U>* {
|
||||
/* native sequence? */
|
||||
if (rb_obj_is_kind_of($input,rb_cHash)) {
|
||||
unsigned int size = RARRAY($input)->len;
|
||||
unsigned int size = RARRAY_LEN($input);
|
||||
if (size != 2) {
|
||||
/* not a pair */
|
||||
$1 = 0;
|
||||
} else {
|
||||
T* x;
|
||||
VALUE first = RARRAY($input)->ptr[0];
|
||||
VALUE second = RARRAY($input)->ptr[1];
|
||||
VALUE first = RARRAY_PTR($input)[0];
|
||||
VALUE second = RARRAY_PTR($input)[1];
|
||||
if (SWIG_ConvertPtr(first,(void **) &x,
|
||||
$descriptor(T *),0) != -1 &&
|
||||
CHECK(second))
|
||||
|
|
@ -398,13 +398,13 @@ namespace std {
|
|||
template<> struct pair<T,U> {
|
||||
%typemap(in) pair<T,U> (std::pair<T,U>* p) {
|
||||
if (rb_obj_is_kind_of($input,rb_cArray)) {
|
||||
unsigned int size = RARRAY($input)->len;
|
||||
unsigned int size = RARRAY_LEN($input);
|
||||
if (size != 2) {
|
||||
SWIG_exception(SWIG_TypeError,
|
||||
"pair<" #T "," #U "> expected");
|
||||
}
|
||||
VALUE first = RARRAY($input)->ptr[0];
|
||||
VALUE second = RARRAY($input)->ptr[1];
|
||||
VALUE first = RARRAY_PTR($input)[0];
|
||||
VALUE second = RARRAY_PTR($input)[1];
|
||||
if (!CHECK_T(first) || !CHECK_U(second))
|
||||
SWIG_exception(SWIG_TypeError,
|
||||
"pair<" #T "," #U "> expected");
|
||||
|
|
@ -420,13 +420,13 @@ namespace std {
|
|||
const pair<T,U>* (std::pair<T,U> temp,
|
||||
std::pair<T,U>* p) {
|
||||
if (rb_obj_is_kind_of($input,rb_cArray)) {
|
||||
unsigned int size = RARRAY($input)->len;
|
||||
unsigned int size = RARRAY_LEN($input);
|
||||
if (size != 2) {
|
||||
SWIG_exception(SWIG_TypeError,
|
||||
"pair<" #T "," #U "> expected");
|
||||
}
|
||||
VALUE first = RARRAY($input)->ptr[0];
|
||||
VALUE second = RARRAY($input)->ptr[1];
|
||||
VALUE first = RARRAY_PTR($input)[0];
|
||||
VALUE second = RARRAY_PTR($input)[1];
|
||||
if (!CHECK_T(first) || !CHECK_U(second))
|
||||
SWIG_exception(SWIG_TypeError,
|
||||
"pair<" #T "," #U "> expected");
|
||||
|
|
@ -446,13 +446,13 @@ namespace std {
|
|||
%typecheck(SWIG_TYPECHECK_PAIR) pair<T,U> {
|
||||
/* native sequence? */
|
||||
if (rb_obj_is_kind_of($input,rb_cArray)) {
|
||||
unsigned int size = RARRAY($input)->len;
|
||||
unsigned int size = RARRAY_LEN($input);
|
||||
if (size != 2) {
|
||||
/* not a pair */
|
||||
$1 = 0;
|
||||
} else {
|
||||
VALUE first = RARRAY($input)->ptr[0];
|
||||
VALUE second = RARRAY($input)->ptr[1];
|
||||
VALUE first = RARRAY_PTR($input)[0];
|
||||
VALUE second = RARRAY_PTR($input)[1];
|
||||
if (CHECK_T(first) && CHECK_U(second))
|
||||
$1 = 1;
|
||||
else
|
||||
|
|
@ -472,13 +472,13 @@ namespace std {
|
|||
const pair<T,U>* {
|
||||
/* native sequence? */
|
||||
if (rb_obj_is_kind_of($input,rb_cHash)) {
|
||||
unsigned int size = RARRAY($input)->len;
|
||||
unsigned int size = RARRAY_LEN($input);
|
||||
if (size != 2) {
|
||||
/* not a pair */
|
||||
$1 = 0;
|
||||
} else {
|
||||
VALUE first = RARRAY($input)->ptr[0];
|
||||
VALUE second = RARRAY($input)->ptr[1];
|
||||
VALUE first = RARRAY_PTR($input)[0];
|
||||
VALUE second = RARRAY_PTR($input)[1];
|
||||
if (CHECK_T(first) && CHECK_U(second))
|
||||
$1 = 1;
|
||||
else
|
||||
|
|
|
|||
|
|
@ -48,10 +48,10 @@ namespace std {
|
|||
template<class T> class vector {
|
||||
%typemap(in) vector<T> {
|
||||
if (rb_obj_is_kind_of($input,rb_cArray)) {
|
||||
unsigned int size = RARRAY($input)->len;
|
||||
unsigned int size = RARRAY_LEN($input);
|
||||
$1;
|
||||
for (unsigned int i=0; i<size; i++) {
|
||||
VALUE o = RARRAY($input)->ptr[i];
|
||||
VALUE o = RARRAY_PTR($input)[i];
|
||||
T* x;
|
||||
SWIG_ConvertPtr(o, (void **) &x, $descriptor(T *), 1);
|
||||
$1.push_back(*x);
|
||||
|
|
@ -65,10 +65,10 @@ namespace std {
|
|||
%typemap(in) const vector<T>& (std::vector<T> temp),
|
||||
const vector<T>* (std::vector<T> temp) {
|
||||
if (rb_obj_is_kind_of($input,rb_cArray)) {
|
||||
unsigned int size = RARRAY($input)->len;
|
||||
unsigned int size = RARRAY_LEN($input);
|
||||
$1 = &temp;
|
||||
for (unsigned int i=0; i<size; i++) {
|
||||
VALUE o = RARRAY($input)->ptr[i];
|
||||
VALUE o = RARRAY_PTR($input)[i];
|
||||
T* x;
|
||||
SWIG_ConvertPtr(o, (void **) &x, $descriptor(T *), 1);
|
||||
temp.push_back(*x);
|
||||
|
|
@ -89,14 +89,14 @@ namespace std {
|
|||
%typecheck(SWIG_TYPECHECK_VECTOR) vector<T> {
|
||||
/* native sequence? */
|
||||
if (rb_obj_is_kind_of($input,rb_cArray)) {
|
||||
unsigned int size = RARRAY($input)->len;
|
||||
unsigned int size = RARRAY_LEN($input);
|
||||
if (size == 0) {
|
||||
/* an empty sequence can be of any type */
|
||||
$1 = 1;
|
||||
} else {
|
||||
/* check the first element only */
|
||||
T* x;
|
||||
VALUE o = RARRAY($input)->ptr[0];
|
||||
VALUE o = RARRAY_PTR($input)[0];
|
||||
if ((SWIG_ConvertPtr(o,(void **) &x,
|
||||
$descriptor(T *),0)) != -1)
|
||||
$1 = 1;
|
||||
|
|
@ -117,14 +117,14 @@ namespace std {
|
|||
const vector<T>* {
|
||||
/* native sequence? */
|
||||
if (rb_obj_is_kind_of($input,rb_cArray)) {
|
||||
unsigned int size = RARRAY($input)->len;
|
||||
unsigned int size = RARRAY_LEN($input);
|
||||
if (size == 0) {
|
||||
/* an empty sequence can be of any type */
|
||||
$1 = 1;
|
||||
} else {
|
||||
/* check the first element only */
|
||||
T* x;
|
||||
VALUE o = RARRAY($input)->ptr[0];
|
||||
VALUE o = RARRAY_PTR($input)[0];
|
||||
if ((SWIG_ConvertPtr(o,(void **) &x,
|
||||
$descriptor(T *),0)) != -1)
|
||||
$1 = 1;
|
||||
|
|
@ -194,10 +194,10 @@ namespace std {
|
|||
template<class T> class vector<T*> {
|
||||
%typemap(in) vector<T*> {
|
||||
if (rb_obj_is_kind_of($input,rb_cArray)) {
|
||||
unsigned int size = RARRAY($input)->len;
|
||||
unsigned int size = RARRAY_LEN($input);
|
||||
$1 = std::vector<T* >(size);
|
||||
for (unsigned int i=0; i<size; i++) {
|
||||
VALUE o = RARRAY($input)->ptr[i];
|
||||
VALUE o = RARRAY_PTR($input)[i];
|
||||
T* x;
|
||||
SWIG_ConvertPtr(o, (void **) &x, $descriptor(T *), 1);
|
||||
(($1_type &)$1)[i] = x;
|
||||
|
|
@ -211,11 +211,11 @@ namespace std {
|
|||
%typemap(in) const vector<T*>& (std::vector<T*> temp),
|
||||
const vector<T*>* (std::vector<T*> temp) {
|
||||
if (rb_obj_is_kind_of($input,rb_cArray)) {
|
||||
unsigned int size = RARRAY($input)->len;
|
||||
unsigned int size = RARRAY_LEN($input);
|
||||
temp = std::vector<T* >(size);
|
||||
$1 = &temp;
|
||||
for (unsigned int i=0; i<size; i++) {
|
||||
VALUE o = RARRAY($input)->ptr[i];
|
||||
VALUE o = RARRAY_PTR($input)[i];
|
||||
T* x;
|
||||
SWIG_ConvertPtr(o, (void **) &x, $descriptor(T *), 1);
|
||||
temp[i] = x;
|
||||
|
|
@ -236,14 +236,14 @@ namespace std {
|
|||
%typecheck(SWIG_TYPECHECK_VECTOR) vector<T*> {
|
||||
/* native sequence? */
|
||||
if (rb_obj_is_kind_of($input,rb_cArray)) {
|
||||
unsigned int size = RARRAY($input)->len;
|
||||
unsigned int size = RARRAY_LEN($input);
|
||||
if (size == 0) {
|
||||
/* an empty sequence can be of any type */
|
||||
$1 = 1;
|
||||
} else {
|
||||
/* check the first element only */
|
||||
T* x;
|
||||
VALUE o = RARRAY($input)->ptr[0];
|
||||
VALUE o = RARRAY_PTR($input)[0];
|
||||
if ((SWIG_ConvertPtr(o,(void **) &x,
|
||||
$descriptor(T *),0)) != -1)
|
||||
$1 = 1;
|
||||
|
|
@ -264,14 +264,14 @@ namespace std {
|
|||
const vector<T*>* {
|
||||
/* native sequence? */
|
||||
if (rb_obj_is_kind_of($input,rb_cArray)) {
|
||||
unsigned int size = RARRAY($input)->len;
|
||||
unsigned int size = RARRAY_LEN($input);
|
||||
if (size == 0) {
|
||||
/* an empty sequence can be of any type */
|
||||
$1 = 1;
|
||||
} else {
|
||||
/* check the first element only */
|
||||
T* x;
|
||||
VALUE o = RARRAY($input)->ptr[0];
|
||||
VALUE o = RARRAY_PTR($input)[0];
|
||||
if ((SWIG_ConvertPtr(o,(void **) &x,
|
||||
$descriptor(T *),0)) != -1)
|
||||
$1 = 1;
|
||||
|
|
@ -343,10 +343,10 @@ namespace std {
|
|||
template<> class vector<T> {
|
||||
%typemap(in) vector<T> {
|
||||
if (rb_obj_is_kind_of($input,rb_cArray)) {
|
||||
unsigned int size = RARRAY($input)->len;
|
||||
unsigned int size = RARRAY_LEN($input);
|
||||
$1 = std::vector<T >(size);
|
||||
for (unsigned int i=0; i<size; i++) {
|
||||
VALUE o = RARRAY($input)->ptr[i];
|
||||
VALUE o = RARRAY_PTR($input)[i];
|
||||
if (CHECK(o))
|
||||
(($1_type &)$1)[i] = (T)(CONVERT_FROM(o));
|
||||
else
|
||||
|
|
@ -363,11 +363,11 @@ namespace std {
|
|||
%typemap(in) const vector<T>& (std::vector<T> temp),
|
||||
const vector<T>* (std::vector<T> temp) {
|
||||
if (rb_obj_is_kind_of($input,rb_cArray)) {
|
||||
unsigned int size = RARRAY($input)->len;
|
||||
unsigned int size = RARRAY_LEN($input);
|
||||
temp = std::vector<T >(size);
|
||||
$1 = &temp;
|
||||
for (unsigned int i=0; i<size; i++) {
|
||||
VALUE o = RARRAY($input)->ptr[i];
|
||||
VALUE o = RARRAY_PTR($input)[i];
|
||||
if (CHECK(o))
|
||||
temp[i] = (T)(CONVERT_FROM(o));
|
||||
else
|
||||
|
|
@ -387,13 +387,13 @@ namespace std {
|
|||
%typecheck(SWIG_TYPECHECK_VECTOR) vector<T> {
|
||||
/* native sequence? */
|
||||
if (rb_obj_is_kind_of($input,rb_cArray)) {
|
||||
unsigned int size = RARRAY($input)->len;
|
||||
unsigned int size = RARRAY_LEN($input);
|
||||
if (size == 0) {
|
||||
/* an empty sequence can be of any type */
|
||||
$1 = 1;
|
||||
} else {
|
||||
/* check the first element only */
|
||||
VALUE o = RARRAY($input)->ptr[0];
|
||||
VALUE o = RARRAY_PTR($input)[0];
|
||||
if (CHECK(o))
|
||||
$1 = 1;
|
||||
else
|
||||
|
|
@ -413,13 +413,13 @@ namespace std {
|
|||
const vector<T>* {
|
||||
/* native sequence? */
|
||||
if (rb_obj_is_kind_of($input,rb_cArray)) {
|
||||
unsigned int size = RARRAY($input)->len;
|
||||
unsigned int size = RARRAY_LEN($input);
|
||||
if (size == 0) {
|
||||
/* an empty sequence can be of any type */
|
||||
$1 = 1;
|
||||
} else {
|
||||
/* check the first element only */
|
||||
VALUE o = RARRAY($input)->ptr[0];
|
||||
VALUE o = RARRAY_PTR($input)[0];
|
||||
if (CHECK(o))
|
||||
$1 = 1;
|
||||
else
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue