summaryrefslogtreecommitdiff
path: root/ruby
diff options
context:
space:
mode:
authorJoe George <joe@zeroc.com>2020-01-14 10:33:57 -0500
committerJoe George <joe@zeroc.com>2020-01-14 10:33:57 -0500
commit2ae3cb38d9b34f36e4d1b2fca4e484ef47201665 (patch)
tree4145befeecad00d60c3a417dd5bcd1aae5dc7fe9 /ruby
parentBumped number of retries for Swift carthage update (diff)
downloadice-2ae3cb38d9b34f36e4d1b2fca4e484ef47201665.tar.bz2
ice-2ae3cb38d9b34f36e4d1b2fca4e484ef47201665.tar.xz
ice-2ae3cb38d9b34f36e4d1b2fca4e484ef47201665.zip
Fix Ruby 2.7 build failure (#677)
Replaced deprecated rb_iterate with rb_block_call
Diffstat (limited to 'ruby')
-rw-r--r--ruby/src/IceRuby/Util.cpp12
-rw-r--r--ruby/src/IceRuby/Util.h36
2 files changed, 40 insertions, 8 deletions
diff --git a/ruby/src/IceRuby/Util.cpp b/ruby/src/IceRuby/Util.cpp
index 2c4a58233b4..b5b070602a4 100644
--- a/ruby/src/IceRuby/Util.cpp
+++ b/ruby/src/IceRuby/Util.cpp
@@ -448,7 +448,7 @@ IceRuby::contextToHash(const Ice::Context& ctx)
extern "C"
VALUE
-IceRuby_Util_hash_foreach_callback(VALUE val, VALUE arg)
+IceRuby_Util_hash_foreach_callback(VALUE val, VALUE arg, int, VALUE [])
{
VALUE key = rb_ary_entry(val, 0);
VALUE value = rb_ary_entry(val, 1);
@@ -465,17 +465,13 @@ IceRuby_Util_hash_foreach_callback(VALUE val, VALUE arg)
return val;
}
-extern "C"
-{
-typedef VALUE (*ICE_RUBY_HASH_FOREACH_CALLBACK)(...);
-}
-
void
IceRuby::hashIterate(VALUE h, HashIterator& iter)
{
assert(TYPE(h) == T_HASH);
- callRuby(rb_iterate, rb_each, h,
- reinterpret_cast<ICE_RUBY_HASH_FOREACH_CALLBACK>(IceRuby_Util_hash_foreach_callback),
+
+ callRuby(::rb_block_call, h, rb_intern("each"), 0, static_cast<VALUE*>(0),
+ reinterpret_cast<rb_block_call_func_t>(IceRuby_Util_hash_foreach_callback),
reinterpret_cast<VALUE>(&iter));
}
diff --git a/ruby/src/IceRuby/Util.h b/ruby/src/IceRuby/Util.h
index 765278b5555..6ceb28e8427 100644
--- a/ruby/src/IceRuby/Util.h
+++ b/ruby/src/IceRuby/Util.h
@@ -175,6 +175,9 @@ VALUE callRuby(Fun fun, T1 t1, T2 t2, T3 t3);
template<typename Fun, typename T1, typename T2, typename T3, typename T4>
VALUE callRuby(Fun fun, T1 t1, T2 t2, T3 t3, T4 t4);
+template<typename Fun, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
+VALUE callRuby(Fun fun, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6);
+
extern "C" typedef VALUE (*RubyFunction)(VALUE);
VALUE callProtected(RubyFunction, VALUE);
@@ -314,6 +317,39 @@ inline VALUE callRuby(Fun fun, T1 t1, T2 t2, T3 t3, T4 t4)
return callProtected(RF::call, reinterpret_cast<VALUE>(&f));
}
+template<typename Fun, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
+class RF_6
+{
+public:
+
+ RF_6(Fun f, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6) : _f(f), _t1(t1), _t2(t2), _t3(t3), _t4(t4), _t5(t5), _t6(t6)
+ {
+ }
+ inline VALUE operator()() { return _f(_t1, _t2, _t3, _t4, _t5, _t6); }
+ static inline VALUE call(VALUE f)
+ {
+ return (*reinterpret_cast<RF_6*>(f))();
+ }
+
+private:
+
+ Fun _f;
+ T1 _t1;
+ T2 _t2;
+ T3 _t3;
+ T4 _t4;
+ T5 _t5;
+ T6 _t6;
+};
+
+template<typename Fun, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
+inline VALUE callRuby(Fun fun, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6)
+{
+ typedef RF_6<Fun, T1, T2, T3, T4, T5, T6> RF;
+ RF f(fun, t1, t2, t3, t4, t5, t6);
+ return callProtected(RF::call, reinterpret_cast<VALUE>(&f));
+}
+
//
// The callRubyVoid functions are used to invoke Ruby C API functions
// while translating any Ruby exception into RubyException so that