aboutsummaryrefslogtreecommitdiff
path: root/Lib/ruby
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/ruby')
-rw-r--r--Lib/ruby/argcargv.i22
-rw-r--r--Lib/ruby/boost_shared_ptr.i6
-rw-r--r--Lib/ruby/carrays.i1
-rw-r--r--Lib/ruby/progargcargv.i2
-rw-r--r--Lib/ruby/ruby.swg2
-rw-r--r--Lib/ruby/rubyautodoc.swg4
-rw-r--r--Lib/ruby/rubyclasses.swg18
-rw-r--r--Lib/ruby/rubycomplex.swg6
-rw-r--r--Lib/ruby/rubycontainer.swg53
-rw-r--r--Lib/ruby/rubyerrors.swg2
-rw-r--r--Lib/ruby/rubyhead.swg76
-rw-r--r--Lib/ruby/rubykw.swg2
-rw-r--r--Lib/ruby/rubyprimtypes.swg19
-rw-r--r--Lib/ruby/rubyrun.swg32
-rw-r--r--Lib/ruby/rubytracking.swg14
-rw-r--r--Lib/ruby/std_array.i2
-rw-r--r--Lib/ruby/std_auto_ptr.i39
-rw-r--r--Lib/ruby/std_map.i6
-rw-r--r--Lib/ruby/std_multimap.i2
-rw-r--r--Lib/ruby/std_set.i7
-rw-r--r--Lib/ruby/std_shared_ptr.i37
-rw-r--r--Lib/ruby/std_string_view.i6
-rw-r--r--Lib/ruby/std_unique_ptr.i39
-rw-r--r--Lib/ruby/std_unordered_map.i2
-rw-r--r--Lib/ruby/std_unordered_multimap.i2
-rw-r--r--Lib/ruby/std_wstring.i15
-rw-r--r--Lib/ruby/swigmove.i1
-rw-r--r--Lib/ruby/timeval.i2
-rw-r--r--Lib/ruby/typemaps.i10
29 files changed, 287 insertions, 142 deletions
diff --git a/Lib/ruby/argcargv.i b/Lib/ruby/argcargv.i
index fc0bc406a..b8efcffb7 100644
--- a/Lib/ruby/argcargv.i
+++ b/Lib/ruby/argcargv.i
@@ -1,26 +1,22 @@
-/* ------------------------------------------------------------
- * --- Argc & Argv ---
- * ------------------------------------------------------------ */
-
-/* ------------------------------------------------------------
+/* -------------------------------------------------------------
+ * SWIG library containing argc and argv multi-argument typemaps
- Use it as follow:
+ Use it as follows:
%apply (int ARGC, char **ARGV) { (size_t argc, const char **argv) }
%inline %{
- int mainApp(size_t argc, const char **argv)
- {
+ int mainApp(size_t argc, const char **argv) {
return argc;
}
- then in the ruby side:
+ then from ruby:
- args = ["asdf", "asdf2"]
- mainApp(args);
+ $args = ["asdf", "asdf2"]
+ mainApp(args)
- * ------------------------------------------------------------ */
+ * ------------------------------------------------------------- */
%typemap(in) (int ARGC, char **ARGV) {
if (rb_obj_is_kind_of($input,rb_cArray)) {
@@ -31,7 +27,7 @@
VALUE *ptr = RARRAY_PTR($input);
for (i=0; i < size; i++, ptr++) {
$2[i]= StringValuePtr(*ptr);
- }
+ }
$2[i]=NULL;
} else {
$1 = 0; $2 = 0;
diff --git a/Lib/ruby/boost_shared_ptr.i b/Lib/ruby/boost_shared_ptr.i
index 9676bf9d8..70deae4f2 100644
--- a/Lib/ruby/boost_shared_ptr.i
+++ b/Lib/ruby/boost_shared_ptr.i
@@ -35,7 +35,7 @@
}
}
%typemap(out) CONST TYPE {
- SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(new $1_ltype(($1_ltype &)$1));
+ SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(new $1_ltype($1));
%set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
}
@@ -54,12 +54,12 @@
}
}
%typemap(varout) CONST TYPE {
- SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(new $1_ltype(($1_ltype &)$1));
+ SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(new $1_ltype($1));
%set_varoutput(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
}
%typemap(directorin,noblock=1) CONST TYPE (SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{
- smartarg = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(new $1_ltype(($1_ltype &)$1));
+ smartarg = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(new $1_ltype(SWIG_STD_MOVE($1)));
$input = SWIG_NewPointerObj(%as_voidptr(smartarg), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN | %newpointer_flags);
%}
%typemap(directorout,noblock=1) CONST TYPE (void *swig_argp, int swig_res = 0) {
diff --git a/Lib/ruby/carrays.i b/Lib/ruby/carrays.i
index 8f74cd9ba..7e1e66a7f 100644
--- a/Lib/ruby/carrays.i
+++ b/Lib/ruby/carrays.i
@@ -3,4 +3,3 @@
%enddef
%include <typemaps/carrays.swg>
-
diff --git a/Lib/ruby/progargcargv.i b/Lib/ruby/progargcargv.i
index a2843c344..36f1c9ada 100644
--- a/Lib/ruby/progargcargv.i
+++ b/Lib/ruby/progargcargv.i
@@ -3,7 +3,7 @@ int PROG_ARGC
char **PROG_ARGV
Some C function receive argc and argv from C main function.
- This typemap provides ignore typemap which pass Ruby ARGV contents
+ This file provides typemaps which pass Ruby ARGV contents
as argc and argv to C function.
*/
diff --git a/Lib/ruby/ruby.swg b/Lib/ruby/ruby.swg
index d1335974e..cf7c10926 100644
--- a/Lib/ruby/ruby.swg
+++ b/Lib/ruby/ruby.swg
@@ -17,7 +17,7 @@
/* SWIG only considers static class members with inline initializers
to be constants. For examples of what is and isn't considered
a constant by SWIG see naming.i in the Ruby test suite. */
-%rename("%(uppercase)s", %$ismember, %$isvariable,%$isimmutable,%$isstatic,%$hasvalue,%$hasconsttype) "";
+%rename("%(uppercase)s", %$ismember, %$isvariable, %$isstatic, %$hasvalue, %$hasconsttype) "";
/* Enums are mapped to constants but all we do is make sure the
first letter is uppercase */
diff --git a/Lib/ruby/rubyautodoc.swg b/Lib/ruby/rubyautodoc.swg
index 1e6b0d9dc..6b0472ce8 100644
--- a/Lib/ruby/rubyautodoc.swg
+++ b/Lib/ruby/rubyautodoc.swg
@@ -77,7 +77,7 @@ AUTODOC(operator>, "Higher than comparison operator");
AUTODOC(operator<<, "Left shifting or appending operator");
AUTODOC(operator>>, "Right shifting operator or extracting operator");
AUTODOC(operator+, "Add operator");
-AUTODOC(operator-, "Substraction operator");
+AUTODOC(operator-, "Subtraction operator");
AUTODOC(operator+(), "Positive operator");
AUTODOC(operator-(), "Negation operator");
AUTODOC(operator&, "AND operator");
@@ -93,7 +93,7 @@ AUTODOC(__gt__, "Higher than comparison operator");
AUTODOC(__lshift__, "Left shifting or appending operator");
AUTODOC(__rshift__, "Right shifting operator or extracting operator");
AUTODOC(__add___, "Add operator");
-AUTODOC(__sub__, "Substraction operator");
+AUTODOC(__sub__, "Subtraction operator");
AUTODOC(__pos__, "Positive operator");
AUTODOC(__neg__, "Negation operator");
AUTODOC(__and__, "AND operator");
diff --git a/Lib/ruby/rubyclasses.swg b/Lib/ruby/rubyclasses.swg
index f7b51bdcc..c43f38fc5 100644
--- a/Lib/ruby/rubyclasses.swg
+++ b/Lib/ruby/rubyclasses.swg
@@ -174,7 +174,7 @@ namespace swig {
return rb_inspect(_obj);
}
- static VALUE swig_rescue_swallow(VALUE)
+ static VALUE swig_rescue_swallow(VALUE, VALUE)
{
/*
VALUE errstr = rb_obj_as_string(rb_errinfo());
@@ -203,12 +203,12 @@ namespace swig {
args.id = op_id;
args.nargs = 1;
args.target = VALUE(other);
- ret = rb_rescue(RUBY_METHOD_FUNC(swig_rescue_funcall), VALUE(&args),
- (RUBY_METHOD_FUNC(swig_rescue_swallow)), Qnil);
+ ret = rb_rescue(VALUEFUNC(swig_rescue_funcall), VALUE(&args),
+ (VALUEFUNC(swig_rescue_swallow)), Qnil);
}
if (ret == Qnil) {
- VALUE a = rb_funcall( _obj, hash_id, 0 );
- VALUE b = rb_funcall( VALUE(other), hash_id, 0 );
+ VALUE a = rb_funcall2( _obj, hash_id, 0, 0 );
+ VALUE b = rb_funcall2( VALUE(other), hash_id, 0, 0 );
res = op_func(a, b);
} else {
res = RTEST(ret);
@@ -243,8 +243,8 @@ namespace swig {
args.id = op_id;
args.nargs = 0;
args.target = Qnil;
- ret = rb_rescue(RUBY_METHOD_FUNC(swig_rescue_funcall), VALUE(&args),
- (RUBY_METHOD_FUNC(swig_rescue_swallow)), Qnil);
+ ret = rb_rescue(VALUEFUNC(swig_rescue_funcall), VALUE(&args),
+ (VALUEFUNC(swig_rescue_swallow)), Qnil);
SWIG_RUBY_THREAD_END_BLOCK;
return ret;
}
@@ -262,8 +262,8 @@ namespace swig {
args.id = op_id;
args.nargs = 1;
args.target = VALUE(other);
- ret = rb_rescue(RUBY_METHOD_FUNC(swig_rescue_funcall), VALUE(&args),
- (RUBY_METHOD_FUNC(swig_rescue_swallow)), Qnil);
+ ret = rb_rescue(VALUEFUNC(swig_rescue_funcall), VALUE(&args),
+ (VALUEFUNC(swig_rescue_swallow)), Qnil);
SWIG_RUBY_THREAD_END_BLOCK;
return GC_VALUE(ret);
}
diff --git a/Lib/ruby/rubycomplex.swg b/Lib/ruby/rubycomplex.swg
index 4e249c71f..d2aaf6cb1 100644
--- a/Lib/ruby/rubycomplex.swg
+++ b/Lib/ruby/rubycomplex.swg
@@ -36,12 +36,12 @@ SWIGINTERN int SWIG_Is_Complex( VALUE obj ) {
SWIGINTERN VALUE SWIG_Complex_Real(VALUE obj) {
static ID real_id = rb_intern("real");
- return rb_funcall(obj, real_id, 0);
+ return rb_funcall2(obj, real_id, 0, 0);
}
SWIGINTERN VALUE SWIG_Complex_Imaginary(VALUE obj) {
static ID imag_id = rb_intern("imag");
- return rb_funcall(obj, imag_id, 0);
+ return rb_funcall2(obj, imag_id, 0, 0);
}
}
@@ -127,7 +127,7 @@ SWIG_AsVal(Type)(VALUE o, Type *val)
float re;
int res = SWIG_AddCast(SWIG_AsVal(float)(o, &re));
if (SWIG_IsOK(res)) {
- if (val) *val = Constructor(re, 0.0);
+ if (val) *val = Constructor(re, 0.0f);
return res;
}
}
diff --git a/Lib/ruby/rubycontainer.swg b/Lib/ruby/rubycontainer.swg
index 9fa205bf5..cd912d959 100644
--- a/Lib/ruby/rubycontainer.swg
+++ b/Lib/ruby/rubycontainer.swg
@@ -101,7 +101,7 @@ namespace swig {
inline Sequence*
getslice(const Sequence* self, Difference i, Difference j) {
typename Sequence::size_type size = self->size();
- typename Sequence::size_type ii = swig::check_index(i, size, (i == size && j == size));
+ typename Sequence::size_type ii = swig::check_index(i, size, (i == (Difference)size && j == (Difference)size));
typename Sequence::size_type jj = swig::slice_index(j, size);
if (jj > ii) {
@@ -117,25 +117,29 @@ namespace swig {
template <class Sequence, class Difference, class InputSeq>
inline void
- setslice(Sequence* self, Difference i, Difference j, const InputSeq& v) {
+ setslice(Sequence* self, Difference i, Difference j, const InputSeq& is) {
typename Sequence::size_type size = self->size();
typename Sequence::size_type ii = swig::check_index(i, size, true);
typename Sequence::size_type jj = swig::slice_index(j, size);
if (jj < ii) jj = ii;
size_t ssize = jj - ii;
- if (ssize <= v.size()) {
+ if (ssize <= is.size()) {
+ // expanding/staying the same size
typename Sequence::iterator sb = self->begin();
- typename InputSeq::const_iterator vmid = v.begin();
+ typename InputSeq::const_iterator vmid = is.begin();
std::advance(sb,ii);
std::advance(vmid, jj - ii);
- self->insert(std::copy(v.begin(), vmid, sb), vmid, v.end());
+ self->insert(std::copy(is.begin(), vmid, sb), vmid, is.end());
} else {
+ // shrinking
typename Sequence::iterator sb = self->begin();
typename Sequence::iterator se = self->begin();
std::advance(sb,ii);
std::advance(se,jj);
self->erase(sb,se);
- self->insert(sb, v.begin(), v.end());
+ sb = self->begin();
+ std::advance(sb,ii);
+ self->insert(sb, is.begin(), is.end());
}
}
@@ -186,7 +190,7 @@ namespace swig
return swig::as<T>(item);
} catch (const std::invalid_argument& e) {
char msg[1024];
- sprintf(msg, "in sequence element %d ", _index);
+ SWIG_snprintf(msg, sizeof(msg), "in sequence element %d ", _index);
VALUE lastErr = rb_gv_get("$!");
if ( lastErr == Qnil ) {
%type_error(swig::type_name<T>());
@@ -338,7 +342,7 @@ namespace swig
typedef T value_type;
typedef T* pointer;
typedef int difference_type;
- typedef int size_type;
+ typedef std::size_t size_type;
typedef const pointer const_pointer;
typedef RubySequence_InputIterator<T, reference> iterator;
typedef RubySequence_InputIterator<T, const_reference> const_iterator;
@@ -628,7 +632,7 @@ namespace swig
try {
r = swig::from< const Sequence* >( swig::getslice(self, i, j) );
}
- catch( std::out_of_range ) {
+ catch( const std::out_of_range& ) {
}
return r;
}
@@ -687,9 +691,8 @@ namespace swig
r = swig::from< Sequence::value_type >( *(at) );
$self->erase(at);
}
- catch (std::out_of_range)
- {
- }
+ catch (const std::out_of_range&) {
+ }
return r;
}
}
@@ -757,7 +760,7 @@ namespace swig
try {
r = swig::from< Sequence::value_type >( *(swig::cgetpos(self, i)) );
}
- catch( std::out_of_range ) {
+ catch( const std::out_of_range& ) {
}
return r;
}
@@ -780,7 +783,7 @@ namespace swig
try {
r = swig::from< const Sequence* >( swig::getslice(self, i, j) );
}
- catch( std::out_of_range ) {
+ catch( const std::out_of_range& ) {
}
return r;
}
@@ -790,7 +793,7 @@ namespace swig
try {
r = swig::from< Sequence::value_type >( *(swig::cgetpos(self, i)) );
}
- catch( std::out_of_range ) {
+ catch( const std::out_of_range& ) {
}
return r;
}
@@ -804,9 +807,9 @@ namespace swig
static ID id_start = rb_intern("begin");
static ID id_noend = rb_intern("exclude_end?");
- VALUE start = rb_funcall( i, id_start, 0 );
- VALUE end = rb_funcall( i, id_end, 0 );
- bool noend = ( rb_funcall( i, id_noend, 0 ) == Qtrue );
+ VALUE start = rb_funcall2( i, id_start, 0, 0 );
+ VALUE end = rb_funcall2( i, id_end, 0, 0 );
+ bool noend = ( rb_funcall2( i, id_noend, 0, 0 ) == Qtrue );
int len = $self->size();
@@ -838,7 +841,7 @@ namespace swig
return swig::from< Sequence::value_type >( x );
}
- VALUE __setitem__(difference_type i, difference_type length, const Sequence& v) throw (std::invalid_argument) {
+ VALUE __setitem__(difference_type i, difference_type length, const Sequence& is) throw (std::invalid_argument) {
if ( length < 0 )
return Qnil;
@@ -850,13 +853,13 @@ namespace swig
i = len + i;
}
Sequence::difference_type j = length + i;
- if ( j > static_cast<Sequence::difference_type>(len) ) {
- swig::resize( $self, j, *(v.begin()) );
+ if ( j > static_cast<Sequence::difference_type>(len) && is.size() > 0 ) {
+ swig::resize( $self, j, *(is.begin()) );
}
VALUE r = Qnil;
- swig::setslice($self, i, j, v);
- r = swig::from< const Sequence* >( &v );
+ swig::setslice($self, i, j, is);
+ r = swig::from< const Sequence* >( &is );
return r;
}
}
@@ -1017,7 +1020,7 @@ namespace swig {
} else {
return rubyseq.check() ? SWIG_OK : SWIG_ERROR;
}
- } catch (std::exception& e) {
+ } catch (const std::exception& e) {
if (seq) {
VALUE lastErr = rb_gv_get("$!");
if (lastErr == Qnil) {
@@ -1057,7 +1060,7 @@ namespace swig {
} else {
return true;
}
- } catch (std::exception& e) {
+ } catch (const std::exception& e) {
if (seq) {
VALUE lastErr = rb_gv_get("$!");
if (lastErr == Qnil) {
diff --git a/Lib/ruby/rubyerrors.swg b/Lib/ruby/rubyerrors.swg
index 434544bc9..ad71d1d39 100644
--- a/Lib/ruby/rubyerrors.swg
+++ b/Lib/ruby/rubyerrors.swg
@@ -110,7 +110,7 @@ const char* Ruby_Format_TypeError( const char* msg,
}
str = rb_str_cat2( str, "Expected argument " );
- sprintf( buf, "%d of type ", argn-1 );
+ SWIG_snprintf( buf, sizeof( buf), "%d of type ", argn-1 );
str = rb_str_cat2( str, buf );
str = rb_str_cat2( str, type );
str = rb_str_cat2( str, ", but got " );
diff --git a/Lib/ruby/rubyhead.swg b/Lib/ruby/rubyhead.swg
index 90f07cf68..39196d4e0 100644
--- a/Lib/ruby/rubyhead.swg
+++ b/Lib/ruby/rubyhead.swg
@@ -1,4 +1,22 @@
+#if __GNUC__ >= 7
+#pragma GCC diagnostic push
+#if defined(__cplusplus)
+#pragma GCC diagnostic ignored "-Wregister"
+#if __GNUC__ >= 10
+#pragma GCC diagnostic ignored "-Wvolatile"
+#if __GNUC__ >= 11
+#pragma GCC diagnostic ignored "-Wdeprecated-enum-enum-conversion"
+#endif
+#endif
+#endif
+#endif
+
#include <ruby.h>
+#include <ruby/version.h> /* For RUBY_API_VERSION_CODE */
+
+#if __GNUC__ >= 7
+#pragma GCC diagnostic pop
+#endif
/* Ruby 1.9.1 has a "memoisation optimisation" when compiling with GCC which
* breaks using rb_intern as an lvalue, as SWIG does. We work around this
@@ -98,38 +116,46 @@
/*
- * Need to be very careful about how these macros are defined, especially
- * when compiling C++ code or C code with an ANSI C compiler.
+ * The following macros are used for providing the correct type of a
+ * function pointer to the Ruby C API.
+ *
+ * Starting with Ruby 2.7 these macros act transparently due to Ruby's moving
+ * moving away from ANYARGS and instead employing strict function signatures.
+ *
+ * Note: In case of C (not C++) the macros are transparent even before
+ * Ruby 2.7 due to the fact that the Ruby C API used function declarators
+ * with empty parentheses, which allows for an unspecified number of
+ * arguments.
*
- * VALUEFUNC(f) is a macro used to typecast a C function that implements
- * a Ruby method so that it can be passed as an argument to API functions
- * like rb_define_method() and rb_define_singleton_method().
+ * PROTECTFUNC(f) is used for the function pointer argument of the Ruby
+ * C API function rb_protect().
*
- * VOIDFUNC(f) is a macro used to typecast a C function that implements
- * either the "mark" or "free" stuff for a Ruby Data object, so that it
- * can be passed as an argument to API functions like Data_Wrap_Struct()
+ * VALUEFUNC(f) is used for the function pointer argument(s) of Ruby C API
+ * functions like rb_define_method() and rb_define_singleton_method().
+ *
+ * VOIDFUNC(f) is used to typecast a C function that implements either
+ * the "mark" or "free" stuff for a Ruby Data object, so that it can be
+ * passed as an argument to Ruby C API functions like Data_Wrap_Struct()
* and Data_Make_Struct().
+ *
+ * SWIG_RUBY_VOID_ANYARGS_FUNC(f) is used for the function pointer
+ * argument(s) of Ruby C API functions like rb_define_virtual_variable().
+ *
+ * SWIG_RUBY_INT_ANYARGS_FUNC(f) is used for the function pointer
+ * argument(s) of Ruby C API functions like st_foreach().
*/
-
-#ifdef __cplusplus
-# ifndef RUBY_METHOD_FUNC /* These definitions should work for Ruby 1.4.6 */
-# define PROTECTFUNC(f) ((VALUE (*)()) f)
-# define VALUEFUNC(f) ((VALUE (*)()) f)
-# define VOIDFUNC(f) ((void (*)()) f)
-# else
-# ifndef ANYARGS /* These definitions should work for Ruby 1.6 */
-# define PROTECTFUNC(f) ((VALUE (*)()) f)
-# define VALUEFUNC(f) ((VALUE (*)()) f)
-# define VOIDFUNC(f) ((RUBY_DATA_FUNC) f)
-# else /* These definitions should work for Ruby 1.7+ */
-# define PROTECTFUNC(f) ((VALUE (*)(VALUE)) f)
-# define VALUEFUNC(f) ((VALUE (*)(ANYARGS)) f)
-# define VOIDFUNC(f) ((RUBY_DATA_FUNC) f)
-# endif
-# endif
+#if defined(__cplusplus) && RUBY_API_VERSION_CODE < 20700
+# define PROTECTFUNC(f) ((VALUE (*)(VALUE)) f)
+# define VALUEFUNC(f) ((VALUE (*)(ANYARGS)) f)
+# define VOIDFUNC(f) ((RUBY_DATA_FUNC) f)
+# define SWIG_RUBY_VOID_ANYARGS_FUNC(f) ((void (*)(ANYARGS))(f))
+# define SWIG_RUBY_INT_ANYARGS_FUNC(f) ((int (*)(ANYARGS))(f))
#else
+# define PROTECTFUNC(f) (f)
# define VALUEFUNC(f) (f)
# define VOIDFUNC(f) (f)
+# define SWIG_RUBY_VOID_ANYARGS_FUNC(f) (f)
+# define SWIG_RUBY_INT_ANYARGS_FUNC(f) (f)
#endif
/* Don't use for expressions have side effect */
diff --git a/Lib/ruby/rubykw.swg b/Lib/ruby/rubykw.swg
index 194687b95..6b4685eb8 100644
--- a/Lib/ruby/rubykw.swg
+++ b/Lib/ruby/rubykw.swg
@@ -2,7 +2,7 @@
#define RUBY_RUBYKW_SWG_
/* Warnings for Ruby keywords */
-#define RUBYKW(x) %keywordwarn("'" `x` "' is a ruby keyword, renaming to 'C_" `x` "'",rename="C_%s",fullname=1) `x`
+#define RUBYKW(x) %keywordwarn("'" `x` "' is a ruby keyword",rename="C_%s",fullname=1) `x`
/*
diff --git a/Lib/ruby/rubyprimtypes.swg b/Lib/ruby/rubyprimtypes.swg
index 3a848191c..d5d9d7339 100644
--- a/Lib/ruby/rubyprimtypes.swg
+++ b/Lib/ruby/rubyprimtypes.swg
@@ -10,15 +10,16 @@
%fragment("SWIG_ruby_failed","header")
{
SWIGINTERN VALUE
-SWIG_ruby_failed(void)
+SWIG_ruby_failed(VALUE SWIGUNUSEDPARM(arg1), VALUE SWIGUNUSEDPARM(arg2))
{
return Qnil;
}
}
%define %ruby_aux_method(Type, Method, Action)
-SWIGINTERN VALUE SWIG_AUX_##Method##(VALUE *args)
+SWIGINTERN VALUE SWIG_AUX_##Method##(VALUE arg)
{
+ VALUE *args = (VALUE *)arg;
VALUE obj = args[0];
VALUE type = TYPE(obj);
Type *res = (Type *)(args[1]);
@@ -79,7 +80,7 @@ SWIG_AsVal_dec(long)(VALUE obj, long* val)
VALUE a[2];
a[0] = obj;
a[1] = (VALUE)(&v);
- if (rb_rescue(RUBY_METHOD_FUNC(SWIG_AUX_NUM2LONG), (VALUE)a, RUBY_METHOD_FUNC(SWIG_ruby_failed), 0) != Qnil) {
+ if (rb_rescue(VALUEFUNC(SWIG_AUX_NUM2LONG), (VALUE)a, VALUEFUNC(SWIG_ruby_failed), 0) != Qnil) {
if (val) *val = v;
return SWIG_OK;
}
@@ -111,7 +112,9 @@ SWIG_AsVal_dec(unsigned long)(VALUE obj, unsigned long *val)
VALUE a[2];
a[0] = obj;
a[1] = (VALUE)(&v);
- if (rb_rescue(RUBY_METHOD_FUNC(SWIG_AUX_NUM2ULONG), (VALUE)a, RUBY_METHOD_FUNC(SWIG_ruby_failed), 0) != Qnil) {
+ if (rb_rescue(VALUEFUNC(SWIG_AUX_NUM2ULONG), (VALUE)a, VALUEFUNC(SWIG_ruby_failed), 0) != Qnil) {
+ if (rb_funcall(obj, swig_lowerthan_id, 1, INT2FIX(0)) != Qfalse)
+ return SWIG_OverflowError;
if (val) *val = v;
return SWIG_OK;
}
@@ -149,7 +152,7 @@ SWIG_AsVal_dec(long long)(VALUE obj, long long *val)
VALUE a[2];
a[0] = obj;
a[1] = (VALUE)(&v);
- if (rb_rescue(RUBY_METHOD_FUNC(SWIG_AUX_NUM2LL), (VALUE)a, RUBY_METHOD_FUNC(SWIG_ruby_failed), 0) != Qnil) {
+ if (rb_rescue(VALUEFUNC(SWIG_AUX_NUM2LL), (VALUE)a, VALUEFUNC(SWIG_ruby_failed), 0) != Qnil) {
if (val) *val = v;
return SWIG_OK;
}
@@ -187,7 +190,9 @@ SWIG_AsVal_dec(unsigned long long)(VALUE obj, unsigned long long *val)
VALUE a[2];
a[0] = obj;
a[1] = (VALUE)(&v);
- if (rb_rescue(RUBY_METHOD_FUNC(SWIG_AUX_NUM2ULL), (VALUE)a, RUBY_METHOD_FUNC(SWIG_ruby_failed), 0) != Qnil) {
+ if (rb_rescue(VALUEFUNC(SWIG_AUX_NUM2ULL), (VALUE)a, VALUEFUNC(SWIG_ruby_failed), 0) != Qnil) {
+ if (rb_funcall(obj, swig_lowerthan_id, 1, INT2FIX(0)) != Qfalse)
+ return SWIG_OverflowError;
if (val) *val = v;
return SWIG_OK;
}
@@ -215,7 +220,7 @@ SWIG_AsVal_dec(double)(VALUE obj, double *val)
VALUE a[2];
a[0] = obj;
a[1] = (VALUE)(&v);
- if (rb_rescue(RUBY_METHOD_FUNC(SWIG_AUX_NUM2DBL), (VALUE)a, RUBY_METHOD_FUNC(SWIG_ruby_failed), 0) != Qnil) {
+ if (rb_rescue(VALUEFUNC(SWIG_AUX_NUM2DBL), (VALUE)a, VALUEFUNC(SWIG_ruby_failed), 0) != Qnil) {
if (val) *val = v;
return SWIG_OK;
}
diff --git a/Lib/ruby/rubyrun.swg b/Lib/ruby/rubyrun.swg
index 4b2ffe4b4..d72102af3 100644
--- a/Lib/ruby/rubyrun.swg
+++ b/Lib/ruby/rubyrun.swg
@@ -80,6 +80,7 @@ static VALUE swig_runtime_data_type_pointer = Qnil;
/* Global IDs used to keep some internal SWIG stuff */
static ID swig_arity_id = 0;
static ID swig_call_id = 0;
+static ID swig_lowerthan_id = 0;
/*
If your swig extension is to be run within an embedded ruby and has
@@ -131,7 +132,7 @@ SWIG_Ruby_ExceptionType(swig_type_info *desc, VALUE obj) {
VALUE exceptionClass = getExceptionClass();
if (rb_obj_is_kind_of(obj, exceptionClass)) {
return obj;
- } else {
+ } else {
return rb_exc_new3(rb_eRuntimeError, rb_obj_as_string(obj));
}
}
@@ -144,6 +145,7 @@ SWIG_Ruby_InitRuntime(void)
_mSWIG = rb_define_module("SWIG");
swig_call_id = rb_intern("call");
swig_arity_id = rb_intern("arity");
+ swig_lowerthan_id = rb_intern("<");
}
}
@@ -151,13 +153,14 @@ SWIG_Ruby_InitRuntime(void)
SWIGRUNTIME void
SWIG_Ruby_define_class(swig_type_info *type)
{
- char *klass_name = (char *) malloc(4 + strlen(type->name) + 1);
- sprintf(klass_name, "TYPE%s", type->name);
+ size_t klass_len = 4 + strlen(type->name) + 1;
+ char *klass_name = (char *) malloc(klass_len);
+ SWIG_snprintf(klass_name, klass_len, "TYPE%s", type->name);
if (NIL_P(_cSWIG_Pointer)) {
_cSWIG_Pointer = rb_define_class_under(_mSWIG, "Pointer", rb_cObject);
rb_undef_method(CLASS_OF(_cSWIG_Pointer), "new");
}
- rb_define_class_under(_mSWIG, klass_name, _cSWIG_Pointer);
+ rb_undef_alloc_func(rb_define_class_under(_mSWIG, klass_name, _cSWIG_Pointer));
free((void *) klass_name);
}
@@ -208,8 +211,9 @@ SWIG_Ruby_NewPointerObj(void *ptr, swig_type_info *type, int flags)
SWIG_RubyAddTracking(ptr, obj);
}
} else {
- klass_name = (char *) malloc(4 + strlen(type->name) + 1);
- sprintf(klass_name, "TYPE%s", type->name);
+ size_t klass_len = 4 + strlen(type->name) + 1;
+ klass_name = (char *) malloc(klass_len);
+ SWIG_snprintf(klass_name, klass_len, "TYPE%s", type->name);
klass = rb_const_get(_mSWIG, rb_intern(klass_name));
free((void *) klass_name);
obj = Data_Wrap_Struct(klass, 0, 0, ptr);
@@ -235,6 +239,8 @@ SWIGRUNTIMEINLINE char *
SWIG_Ruby_MangleStr(VALUE obj)
{
VALUE stype = rb_iv_get(obj, "@__swigtype__");
+ if (NIL_P(stype))
+ return NULL;
return StringValuePtr(stype);
}
@@ -279,6 +285,11 @@ SWIG_Ruby_ConvertPtrAndOwn(VALUE obj, void **ptr, swig_type_info *ty, int flags,
own->own = 0;
}
+ if (((flags & SWIG_POINTER_RELEASE) == SWIG_POINTER_RELEASE)) {
+ if (!RDATA(obj)->dfree)
+ return SWIG_ERROR_RELEASE_NOT_OWNED;
+ }
+
/* Check to see if the input object is giving up ownership
of the underlying C struct or C++ object. If so then we
need to reset the destructor since the Ruby object no
@@ -290,7 +301,7 @@ SWIG_Ruby_ConvertPtrAndOwn(VALUE obj, void **ptr, swig_type_info *ty, int flags,
swig_class *sklass = (swig_class *) ty->clientdata;
track = sklass->trackObjects;
}
-
+
if (track) {
/* We are tracking objects for this class. Thus we change the destructor
* to SWIG_RubyRemoveTracking. This allows us to
@@ -304,6 +315,10 @@ SWIG_Ruby_ConvertPtrAndOwn(VALUE obj, void **ptr, swig_type_info *ty, int flags,
}
}
+ if (flags & SWIG_POINTER_CLEAR) {
+ DATA_PTR(obj) = 0;
+ }
+
/* Do type-checking if type info was provided */
if (ty) {
if (ty->clientdata) {
@@ -411,6 +426,7 @@ SWIG_Ruby_SetModule(swig_module_info *pointer)
{
/* register a new class */
VALUE cl = rb_define_class("swig_runtime_data", rb_cObject);
+ rb_undef_alloc_func(cl);
/* create and store the structure pointer to a global variable */
swig_runtime_data_type_pointer = Data_Wrap_Struct(cl, 0, 0, pointer);
rb_define_readonly_variable("$swig_runtime_data_type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME, &swig_runtime_data_type_pointer);
@@ -441,7 +457,7 @@ int SWIG_Ruby_arity( VALUE proc, int minimal )
{
if ( rb_respond_to( proc, swig_arity_id ) )
{
- VALUE num = rb_funcall( proc, swig_arity_id, 0 );
+ VALUE num = rb_funcall2( proc, swig_arity_id, 0, 0 );
int arity = NUM2INT(num);
if ( arity < 0 && (arity+1) < -minimal ) return 1;
if ( arity == minimal ) return 1;
diff --git a/Lib/ruby/rubytracking.swg b/Lib/ruby/rubytracking.swg
index b9fb249d8..1edcc5681 100644
--- a/Lib/ruby/rubytracking.swg
+++ b/Lib/ruby/rubytracking.swg
@@ -32,7 +32,7 @@ extern "C" {
*/
static st_table* swig_ruby_trackings = NULL;
-static VALUE swig_ruby_trackings_count(ANYARGS) {
+static VALUE swig_ruby_trackings_count(ID id, VALUE *var) {
return SWIG2NUM(swig_ruby_trackings->num_entries);
}
@@ -69,7 +69,9 @@ SWIGRUNTIME void SWIG_RubyInitializeTrackings(void) {
swig_ruby_trackings = (st_table*)NUM2SWIG(trackings_value);
}
- rb_define_virtual_variable("SWIG_TRACKINGS_COUNT", swig_ruby_trackings_count, NULL);
+ rb_define_virtual_variable("SWIG_TRACKINGS_COUNT",
+ VALUEFUNC(swig_ruby_trackings_count),
+ SWIG_RUBY_VOID_ANYARGS_FUNC((rb_gvar_setter_t*)NULL));
}
/* Add a Tracking from a C/C++ struct to a Ruby object */
@@ -118,13 +120,15 @@ SWIGRUNTIME void SWIG_RubyUnlinkObjects(void* ptr) {
to the passed callback function. */
/* Proxy method to abstract the internal trackings datatype */
-static int swig_ruby_internal_iterate_callback(void* ptr, VALUE obj, void(*meth)(void* ptr, VALUE obj)) {
- (*meth)(ptr, obj);
+static int swig_ruby_internal_iterate_callback(st_data_t ptr, st_data_t obj, st_data_t meth) {
+ ((void (*) (void *, VALUE))meth)((void *)ptr, (VALUE)obj);
return ST_CONTINUE;
}
SWIGRUNTIME void SWIG_RubyIterateTrackings( void(*meth)(void* ptr, VALUE obj) ) {
- st_foreach(swig_ruby_trackings, (int (*)(ANYARGS))&swig_ruby_internal_iterate_callback, (st_data_t)meth);
+ st_foreach(swig_ruby_trackings,
+ SWIG_RUBY_INT_ANYARGS_FUNC(swig_ruby_internal_iterate_callback),
+ (st_data_t)meth);
}
#ifdef __cplusplus
diff --git a/Lib/ruby/std_array.i b/Lib/ruby/std_array.i
index a4d3ef54b..c00685f27 100644
--- a/Lib/ruby/std_array.i
+++ b/Lib/ruby/std_array.i
@@ -41,7 +41,7 @@
getslice(const std::array<T, N>* self, Difference i, Difference j) {
typedef std::array<T, N> Sequence;
typename Sequence::size_type size = self->size();
- typename Sequence::size_type ii = swig::check_index(i, size, (i == size && j == size));
+ typename Sequence::size_type ii = swig::check_index(i, size, (i == (Difference)size && j == (Difference)size));
typename Sequence::size_type jj = swig::slice_index(j, size);
if (ii == 0 && jj == size) {
diff --git a/Lib/ruby/std_auto_ptr.i b/Lib/ruby/std_auto_ptr.i
new file mode 100644
index 000000000..3d7ae8ba1
--- /dev/null
+++ b/Lib/ruby/std_auto_ptr.i
@@ -0,0 +1,39 @@
+/* -----------------------------------------------------------------------------
+ * std_auto_ptr.i
+ *
+ * SWIG library file for handling std::auto_ptr.
+ * Memory ownership is passed from the std::auto_ptr C++ layer to the proxy
+ * class when returning a std::auto_ptr from a function.
+ * Memory ownership is passed from the proxy class to the std::auto_ptr in the
+ * C++ layer when passed as a parameter to a wrapped function.
+ * ----------------------------------------------------------------------------- */
+
+%define %auto_ptr(TYPE)
+%typemap(in, noblock=1) std::auto_ptr< TYPE > (void *argp = 0, int res = 0) {
+ res = SWIG_ConvertPtr($input, &argp, $descriptor(TYPE *), SWIG_POINTER_RELEASE | %convertptr_flags);
+ if (!SWIG_IsOK(res)) {
+ if (res == SWIG_ERROR_RELEASE_NOT_OWNED) {
+ %releasenotowned_fail(res, "TYPE *", $symname, $argnum);
+ } else {
+ %argument_fail(res, "TYPE *", $symname, $argnum);
+ }
+ }
+ $1.reset((TYPE *)argp);
+}
+
+%typemap (out) std::auto_ptr< TYPE > %{
+ %set_output(SWIG_NewPointerObj($1.release(), $descriptor(TYPE *), SWIG_POINTER_OWN | %newpointer_flags));
+%}
+
+%typemap(typecheck, precedence=SWIG_TYPECHECK_POINTER, equivalent="TYPE *", noblock=1) std::auto_ptr< TYPE > {
+ void *vptr = 0;
+ int res = SWIG_ConvertPtr($input, &vptr, $descriptor(TYPE *), 0);
+ $1 = SWIG_CheckState(res);
+}
+
+%template() std::auto_ptr< TYPE >;
+%enddef
+
+namespace std {
+ template <class T> class auto_ptr {};
+}
diff --git a/Lib/ruby/std_map.i b/Lib/ruby/std_map.i
index 7077fa104..99e3d40bd 100644
--- a/Lib/ruby/std_map.i
+++ b/Lib/ruby/std_map.i
@@ -96,7 +96,7 @@
int res = SWIG_ERROR;
if ( TYPE(obj) == T_HASH ) {
static ID id_to_a = rb_intern("to_a");
- VALUE items = rb_funcall(obj, id_to_a, 0);
+ VALUE items = rb_funcall2(obj, id_to_a, 0, 0);
res = traits_asptr_stdseq<std::map<K,T>, std::pair<K, T> >::asptr(items, val);
} else {
map_type *p;
@@ -344,7 +344,11 @@
}
void __setitem__(const key_type& key, const mapped_type& x) throw (std::out_of_range) {
+%#ifdef __cpp_lib_map_try_emplace
+ (*self).insert_or_assign(key, x);
+%#else
(*self)[key] = x;
+%#endif
}
VALUE inspect()
diff --git a/Lib/ruby/std_multimap.i b/Lib/ruby/std_multimap.i
index 762a87653..5d8e33e97 100644
--- a/Lib/ruby/std_multimap.i
+++ b/Lib/ruby/std_multimap.i
@@ -23,7 +23,7 @@
int res = SWIG_ERROR;
if ( TYPE(obj) == T_HASH ) {
static ID id_to_a = rb_intern("to_a");
- VALUE items = rb_funcall(obj, id_to_a, 0);
+ VALUE items = rb_funcall2(obj, id_to_a, 0, 0);
return traits_asptr_stdseq<std::multimap<K,T>, std::pair<K, T> >::asptr(items, val);
} else {
multimap_type *p;
diff --git a/Lib/ruby/std_set.i b/Lib/ruby/std_set.i
index e38702ef5..1b425c6b5 100644
--- a/Lib/ruby/std_set.i
+++ b/Lib/ruby/std_set.i
@@ -180,17 +180,14 @@
// Redefine std::set iterator/reverse_iterator typemap
%typemap(out,noblock=1) iterator, reverse_iterator {
- $result = SWIG_NewPointerObj(swig::make_set_nonconst_iterator(%static_cast($1,const $type &),
- self),
- swig::Iterator::descriptor(),SWIG_POINTER_OWN);
+ $result = SWIG_NewPointerObj((swig::make_set_nonconst_iterator<$type>($1, self)), swig::Iterator::descriptor(), SWIG_POINTER_OWN);
}
// Redefine std::set std::pair<iterator, bool> typemap
%typemap(out,noblock=1,fragment="RubyPairBoolOutputIterator")
std::pair<iterator, bool> {
$result = rb_ary_new2(2);
- rb_ary_push($result, SWIG_NewPointerObj(swig::make_set_nonconst_iterator(%static_cast($1,$type &).first),
- swig::Iterator::descriptor(),SWIG_POINTER_OWN));
+ rb_ary_push($result, SWIG_NewPointerObj((swig::make_set_nonconst_iterator($1.first)), swig::Iterator::descriptor(), SWIG_POINTER_OWN));
rb_ary_push($result, SWIG_From(bool)(%static_cast($1,const $type &).second));
}
diff --git a/Lib/ruby/std_shared_ptr.i b/Lib/ruby/std_shared_ptr.i
index dee35ec03..086e30814 100644
--- a/Lib/ruby/std_shared_ptr.i
+++ b/Lib/ruby/std_shared_ptr.i
@@ -13,24 +13,27 @@ namespace swig {
template <class Type>
struct traits_asptr<std::shared_ptr<Type> > {
static int asptr(VALUE obj, std::shared_ptr<Type> **val) {
- std::shared_ptr<Type> *p = 0;
+ int res = SWIG_ERROR;
swig_type_info *descriptor = type_info<std::shared_ptr<Type> >();
- swig_ruby_owntype newmem = {0, 0};
- int res = descriptor ? SWIG_ConvertPtrAndOwn(obj, (void **)&p, descriptor, 0, &newmem) : SWIG_ERROR;
- if (SWIG_IsOK(res)) {
- if (val) {
- if (*val) {
- **val = p ? *p : std::shared_ptr<Type>();
- } else {
- *val = p;
- if (newmem.own & SWIG_CAST_NEW_MEMORY) {
- // Upcast for pointers to shared_ptr in this generic framework has not been implemented
- res = SWIG_ERROR;
- }
- }
- }
- if (newmem.own & SWIG_CAST_NEW_MEMORY)
- delete p;
+ if (val) {
+ std::shared_ptr<Type> *p = 0;
+ swig_ruby_owntype newmem = {0, 0};
+ res = descriptor ? SWIG_ConvertPtrAndOwn(obj, (void **)&p, descriptor, 0, &newmem) : SWIG_ERROR;
+ if (SWIG_IsOK(res)) {
+ if (*val) {
+ **val = p ? *p : std::shared_ptr<Type>();
+ } else {
+ *val = p;
+ if (newmem.own & SWIG_CAST_NEW_MEMORY) {
+ // Upcast for pointers to shared_ptr in this generic framework has not been implemented
+ res = SWIG_ERROR;
+ }
+ }
+ if (newmem.own & SWIG_CAST_NEW_MEMORY)
+ delete p;
+ }
+ } else {
+ res = descriptor ? SWIG_ConvertPtr(obj, 0, descriptor, 0) : SWIG_ERROR;
}
return res;
}
diff --git a/Lib/ruby/std_string_view.i b/Lib/ruby/std_string_view.i
new file mode 100644
index 000000000..cbfc42897
--- /dev/null
+++ b/Lib/ruby/std_string_view.i
@@ -0,0 +1,6 @@
+
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) std::basic_string_view<char>;
+
+AUTODOC(substr, "Return a portion of the String");
+
+%include <typemaps/std_string_view.swg>
diff --git a/Lib/ruby/std_unique_ptr.i b/Lib/ruby/std_unique_ptr.i
new file mode 100644
index 000000000..f988714df
--- /dev/null
+++ b/Lib/ruby/std_unique_ptr.i
@@ -0,0 +1,39 @@
+/* -----------------------------------------------------------------------------
+ * std_unique_ptr.i
+ *
+ * SWIG library file for handling std::unique_ptr.
+ * Memory ownership is passed from the std::unique_ptr C++ layer to the proxy
+ * class when returning a std::unique_ptr from a function.
+ * Memory ownership is passed from the proxy class to the std::unique_ptr in the
+ * C++ layer when passed as a parameter to a wrapped function.
+ * ----------------------------------------------------------------------------- */
+
+%define %unique_ptr(TYPE)
+%typemap(in, noblock=1) std::unique_ptr< TYPE > (void *argp = 0, int res = 0) {
+ res = SWIG_ConvertPtr($input, &argp, $descriptor(TYPE *), SWIG_POINTER_RELEASE | %convertptr_flags);
+ if (!SWIG_IsOK(res)) {
+ if (res == SWIG_ERROR_RELEASE_NOT_OWNED) {
+ %releasenotowned_fail(res, "TYPE *", $symname, $argnum);
+ } else {
+ %argument_fail(res, "TYPE *", $symname, $argnum);
+ }
+ }
+ $1.reset((TYPE *)argp);
+}
+
+%typemap (out) std::unique_ptr< TYPE > %{
+ %set_output(SWIG_NewPointerObj($1.release(), $descriptor(TYPE *), SWIG_POINTER_OWN | %newpointer_flags));
+%}
+
+%typemap(typecheck, precedence=SWIG_TYPECHECK_POINTER, equivalent="TYPE *", noblock=1) std::unique_ptr< TYPE > {
+ void *vptr = 0;
+ int res = SWIG_ConvertPtr($input, &vptr, $descriptor(TYPE *), 0);
+ $1 = SWIG_CheckState(res);
+}
+
+%template() std::unique_ptr< TYPE >;
+%enddef
+
+namespace std {
+ template <class T> class unique_ptr {};
+}
diff --git a/Lib/ruby/std_unordered_map.i b/Lib/ruby/std_unordered_map.i
index 48c875214..3c6b65027 100644
--- a/Lib/ruby/std_unordered_map.i
+++ b/Lib/ruby/std_unordered_map.i
@@ -23,7 +23,7 @@
int res = SWIG_ERROR;
if (TYPE(obj) == T_HASH) {
static ID id_to_a = rb_intern("to_a");
- VALUE items = rb_funcall(obj, id_to_a, 0);
+ VALUE items = rb_funcall2(obj, id_to_a, 0, 0);
res = traits_asptr_stdseq<std::unordered_map<K,T,Hash,Compare,Alloc>, std::pair<K, T> >::asptr(items, val);
} else {
map_type *p;
diff --git a/Lib/ruby/std_unordered_multimap.i b/Lib/ruby/std_unordered_multimap.i
index ebc53b597..c3261f9e6 100644
--- a/Lib/ruby/std_unordered_multimap.i
+++ b/Lib/ruby/std_unordered_multimap.i
@@ -23,7 +23,7 @@
int res = SWIG_ERROR;
if ( TYPE(obj) == T_HASH ) {
static ID id_to_a = rb_intern("to_a");
- VALUE items = rb_funcall(obj, id_to_a, 0);
+ VALUE items = rb_funcall2(obj, id_to_a, 0, 0);
return traits_asptr_stdseq<std::unordered_multimap<K,T,Hash,Compare,Alloc>, std::pair<K, T> >::asptr(items, val);
} else {
multimap_type *p;
diff --git a/Lib/ruby/std_wstring.i b/Lib/ruby/std_wstring.i
index 2b633438e..c5d168a0a 100644
--- a/Lib/ruby/std_wstring.i
+++ b/Lib/ruby/std_wstring.i
@@ -1,4 +1,15 @@
%{
+#if defined(__linux__)
+#include <endian.h>
+#if BYTE_ORDER == LITTLE_ENDIAN
+#define SWIG_RUBY_ENDIAN "LE"
+#elif BYTE_ORDER == BIG_ENDIAN
+#define SWIG_RUBY_ENDIAN "BE"
+#endif
+#else
+#define SWIG_RUBY_ENDIAN "LE"
+#endif
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -15,9 +26,9 @@ extern "C" {
#ifndef SWIG_RUBY_WSTRING_ENCODING
#if WCHAR_MAX == 0x7fff || WCHAR_MAX == 0xffff
-#define SWIG_RUBY_WSTRING_ENCODING "UTF-16LE"
+#define SWIG_RUBY_WSTRING_ENCODING "UTF-16" SWIG_RUBY_ENDIAN
#elif WCHAR_MAX == 0x7fffffff || WCHAR_MAX == 0xffffffff
-#define SWIG_RUBY_WSTRING_ENCODING "UTF-32LE"
+#define SWIG_RUBY_WSTRING_ENCODING "UTF-32" SWIG_RUBY_ENDIAN
#else
#error unsupported wchar_t size. SWIG_RUBY_WSTRING_ENCODING must be given.
#endif
diff --git a/Lib/ruby/swigmove.i b/Lib/ruby/swigmove.i
new file mode 100644
index 000000000..62ecca768
--- /dev/null
+++ b/Lib/ruby/swigmove.i
@@ -0,0 +1 @@
+%include <typemaps/swigmove.swg>
diff --git a/Lib/ruby/timeval.i b/Lib/ruby/timeval.i
index e7bc2d322..94a75c802 100644
--- a/Lib/ruby/timeval.i
+++ b/Lib/ruby/timeval.i
@@ -55,7 +55,7 @@ struct timeval rb_time_timeval(VALUE);
if (NIL_P($input))
$1 = (time_t)-1;
else
- $1 = NUM2LONG(rb_funcall($input, rb_intern("tv_sec"), 0));
+ $1 = NUM2LONG(rb_funcall2($input, rb_intern("tv_sec"), 0, 0));
}
%typemap(typecheck) time_t
diff --git a/Lib/ruby/typemaps.i b/Lib/ruby/typemaps.i
index c4db82161..a3eaa0c16 100644
--- a/Lib/ruby/typemaps.i
+++ b/Lib/ruby/typemaps.i
@@ -119,7 +119,7 @@ multiple output values, they are returned in the form of a Ruby Array.
For example, suppose you were trying to wrap the modf() function in the
C math library which splits x into integral and fractional parts (and
-returns the integer part in one of its parameters).K:
+returns the integer part in one of its parameters) :
double modf(double x, double *ip);
@@ -139,7 +139,7 @@ output values.
*/
%define OUTPUT_TYPEMAP(type, converter, convtype)
-%typemap(in,numinputs=0) type *OUTPUT($*1_ltype temp), type &OUTPUT($*1_ltype temp) "$1 = &temp;";
+%typemap(in,numinputs=0) type *OUTPUT($*1_ltype temp), type &OUTPUT($*1_ltype temp) "$1 = &temp;"
%typemap(argout, fragment="output_helper") type *OUTPUT, type &OUTPUT {
VALUE o = converter(convtype (*$1));
$result = output_helper($result, o);
@@ -161,7 +161,7 @@ OUTPUT_TYPEMAP(double, rb_float_new, (double));
#undef OUTPUT_TYPEMAP
-%typemap(in,numinputs=0) bool *OUTPUT(bool temp), bool &OUTPUT(bool temp) "$1 = &temp;";
+%typemap(in,numinputs=0) bool *OUTPUT(bool temp), bool &OUTPUT(bool temp) "$1 = &temp;"
%typemap(argout, fragment="output_helper") bool *OUTPUT, bool &OUTPUT {
VALUE o = (*$1) ? Qtrue : Qfalse;
$result = output_helper($result, o);
@@ -214,10 +214,6 @@ to a Ruby variable you might do this :
x = neg(x)
-Note : previous versions of SWIG used the symbol 'BOTH' to mark
-input/output arguments. This is still supported, but will be slowly
-phased out in future releases.
-
*/
%typemap(in) int *INOUT = int *INPUT;