summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Reitmayr <treitmayr@devbase.at>2021-06-01 19:07:05 +0200
committerOlly Betts <ojwbetts@gmail.com>2022-01-29 11:07:57 +1300
commit5a10e103992c49b8b402745b294fcdd4ca48e705 (patch)
treef5e0510474526c972845bf672c3caacfb0cd811a
parentc7cfabd0a77b0dbcd09cd93a84b17ce5734c713a (diff)
downloadswig-5a10e103992c49b8b402745b294fcdd4ca48e705.tar.gz
Ruby: Fix warnings in generated code about missing parameter in variadic macro
The Ruby C API function 'rb_funcall' is used in various places in generated code for invoking a Ruby method without parameters. The C function uses a variadic parameter list for the arguments passed to Ruby, therefore in these cases the list of variadic parameters is empty. As an optimization Ruby may implement the 'rb_funcall' function as a macro which however will not accept an empty list of arguments for '...' as of C99 and C++11. In order to prevent compiler warnings, this commit replaces all such occurrences with a call to 'rb_funcall2' (which in its current name 'rb_funcallv' is invoked by the 'rb_funcall' macro anyway, at least for Ruby 2.6.6).
-rw-r--r--Lib/ruby/rubyclasses.swg4
-rw-r--r--Lib/ruby/rubycomplex.swg4
-rw-r--r--Lib/ruby/rubycontainer.swg6
-rw-r--r--Lib/ruby/rubyrun.swg2
-rw-r--r--Lib/ruby/std_map.i2
-rw-r--r--Lib/ruby/std_multimap.i2
-rw-r--r--Lib/ruby/std_unordered_map.i2
-rw-r--r--Lib/ruby/std_unordered_multimap.i2
-rw-r--r--Lib/ruby/timeval.i2
9 files changed, 13 insertions, 13 deletions
diff --git a/Lib/ruby/rubyclasses.swg b/Lib/ruby/rubyclasses.swg
index b345fcebe..c43f38fc5 100644
--- a/Lib/ruby/rubyclasses.swg
+++ b/Lib/ruby/rubyclasses.swg
@@ -207,8 +207,8 @@ namespace swig {
(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);
diff --git a/Lib/ruby/rubycomplex.swg b/Lib/ruby/rubycomplex.swg
index a62bfe531..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);
}
}
diff --git a/Lib/ruby/rubycontainer.swg b/Lib/ruby/rubycontainer.swg
index e72330853..597ae83d2 100644
--- a/Lib/ruby/rubycontainer.swg
+++ b/Lib/ruby/rubycontainer.swg
@@ -803,9 +803,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();
diff --git a/Lib/ruby/rubyrun.swg b/Lib/ruby/rubyrun.swg
index 3b6fd32b0..7c94c4e12 100644
--- a/Lib/ruby/rubyrun.swg
+++ b/Lib/ruby/rubyrun.swg
@@ -443,7 +443,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/std_map.i b/Lib/ruby/std_map.i
index 7077fa104..6dd2ffa72 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;
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_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/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