From 2f6a268e555b8bae91dd73a921943f5eea725861 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Sat, 23 Sep 2006 21:39:09 +0000 Subject: [PATCH] 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 --- CHANGES.current | 4 ++ Lib/ruby/argcargv.i | 4 +- Lib/ruby/jstring.i | 2 +- Lib/ruby/progargcargv.i | 12 ++--- Lib/ruby/rubyhead.swg | 19 +++++++- Lib/ruby/rubyrun.swg | 2 +- Lib/ruby/rubystrings.swg | 2 +- Lib/ruby/std_common.i | 2 +- Lib/ruby/std_map.i | 64 +++++++++++++-------------- Lib/ruby/std_pair.i | 96 ++++++++++++++++++++-------------------- Lib/ruby/std_vector.i | 48 ++++++++++---------- 11 files changed, 137 insertions(+), 118 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index aa4ec3267..dcbcfe55a 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -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.: diff --git a/Lib/ruby/argcargv.i b/Lib/ruby/argcargv.i index eb662a794..ae1f6bbd3 100644 --- a/Lib/ruby/argcargv.i +++ b/Lib/ruby/argcargv.i @@ -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); } diff --git a/Lib/ruby/jstring.i b/Lib/ruby/jstring.i index 6922dadcd..17efa978d 100644 --- a/Lib/ruby/jstring.i +++ b/Lib/ruby/jstring.i @@ -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; diff --git a/Lib/ruby/progargcargv.i b/Lib/ruby/progargcargv.i index 6720bd791..a2843c344 100644 --- a/Lib/ruby/progargcargv.i +++ b/Lib/ruby/progargcargv.i @@ -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); } diff --git a/Lib/ruby/rubyhead.swg b/Lib/ruby/rubyhead.swg index defffef65..0f73a32ec 100644 --- a/Lib/ruby/rubyhead.swg +++ b/Lib/ruby/rubyhead.swg @@ -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 {\ diff --git a/Lib/ruby/rubyrun.swg b/Lib/ruby/rubyrun.swg index c08d1a599..3c2f60d63 100644 --- a/Lib/ruby/rubyrun.swg +++ b/Lib/ruby/rubyrun.swg @@ -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; diff --git a/Lib/ruby/rubystrings.swg b/Lib/ruby/rubystrings.swg index 0589f809f..c4ddd2211 100644 --- a/Lib/ruby/rubystrings.swg +++ b/Lib/ruby/rubystrings.swg @@ -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) { diff --git a/Lib/ruby/std_common.i b/Lib/ruby/std_common.i index 49a8a297b..956bfc37d 100644 --- a/Lib/ruby/std_common.i +++ b/Lib/ruby/std_common.i @@ -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()); diff --git a/Lib/ruby/std_map.i b/Lib/ruby/std_map.i index 7c9b8de09..63b8d91fd 100644 --- a/Lib/ruby/std_map.i +++ b/Lib/ruby/std_map.i @@ -50,11 +50,11 @@ namespace std { if (rb_obj_is_kind_of($input,rb_cHash)) { $1 = std::map(); 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; iptr[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(); $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; iptr[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(); 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; iptr[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(); $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; iptr[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(); 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; iptr[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(); $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; iptr[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(); 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; iptr[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(); $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; iptr[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; diff --git a/Lib/ruby/std_pair.i b/Lib/ruby/std_pair.i index cd4e580f6..626a6c3c8 100644 --- a/Lib/ruby/std_pair.i +++ b/Lib/ruby/std_pair.i @@ -27,14 +27,14 @@ namespace std { template struct pair { %typemap(in) pair (std::pair* 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* (std::pair temp, std::pair* 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 { /* 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* { /* 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 struct pair { %typemap(in) pair (std::pair* 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* (std::pair temp, std::pair* 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 { /* 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* { /* 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 struct pair { %typemap(in) pair (std::pair* 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* (std::pair temp, std::pair* 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 { /* 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* { /* 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 { %typemap(in) pair (std::pair* 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* (std::pair temp, std::pair* 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 { /* 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* { /* 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 diff --git a/Lib/ruby/std_vector.i b/Lib/ruby/std_vector.i index 42c2f91f7..666e5f74f 100644 --- a/Lib/ruby/std_vector.i +++ b/Lib/ruby/std_vector.i @@ -48,10 +48,10 @@ namespace std { template class vector { %typemap(in) vector { 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; iptr[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& (std::vector temp), const vector* (std::vector 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; iptr[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 { /* 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* { /* 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 vector { %typemap(in) vector { if (rb_obj_is_kind_of($input,rb_cArray)) { - unsigned int size = RARRAY($input)->len; + unsigned int size = RARRAY_LEN($input); $1 = std::vector(size); for (unsigned int i=0; iptr[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& (std::vector temp), const vector* (std::vector 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(size); $1 = &temp; for (unsigned int i=0; iptr[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 { /* 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* { /* 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 { %typemap(in) vector { if (rb_obj_is_kind_of($input,rb_cArray)) { - unsigned int size = RARRAY($input)->len; + unsigned int size = RARRAY_LEN($input); $1 = std::vector(size); for (unsigned int i=0; iptr[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& (std::vector temp), const vector* (std::vector 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(size); $1 = &temp; for (unsigned int i=0; iptr[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 { /* 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* { /* 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