From 1d1ffebb59cab5514eccc3350f1936601fab55b2 Mon Sep 17 00:00:00 2001 From: Joe George Date: Thu, 16 Jan 2020 11:22:53 -0500 Subject: Additional Ruby 2.7 fix for #677 --- ruby/src/IceRuby/Util.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'ruby/src/IceRuby/Util.cpp') diff --git a/ruby/src/IceRuby/Util.cpp b/ruby/src/IceRuby/Util.cpp index b5b070602a4..6afc83d87f3 100644 --- a/ruby/src/IceRuby/Util.cpp +++ b/ruby/src/IceRuby/Util.cpp @@ -448,7 +448,11 @@ IceRuby::contextToHash(const Ice::Context& ctx) extern "C" VALUE -IceRuby_Util_hash_foreach_callback(VALUE val, VALUE arg, int, VALUE []) +#ifdef RUBY_BLOCK_CALL_FUNC_TAKES_BLOCKARG // Defined Ruby >= 2.1 +IceRuby_Util_hash_foreach_callback(VALUE val, VALUE arg, int, const VALUE*, VALUE) +#else +IceRuby_Util_hash_foreach_callback(VALUE val, VALUE arg, int, VALUE*) +#endif { VALUE key = rb_ary_entry(val, 0); VALUE value = rb_ary_entry(val, 1); @@ -465,13 +469,25 @@ IceRuby_Util_hash_foreach_callback(VALUE val, VALUE arg, int, VALUE []) return val; } +extern "C" +{ + +// Defined Ruby >= 2.1. Ruby 2.7 enables RB_BLOCK_CALL_FUNC_STRICT by default +#ifdef RB_BLOCK_CALL_FUNC_STRICT + typedef rb_block_call_func_t ICE_RUBY_HASH_FOREACH_CALLBACK; +#else + typedef VALUE (*ICE_RUBY_HASH_FOREACH_CALLBACK)(...); +#endif + +} + void IceRuby::hashIterate(VALUE h, HashIterator& iter) { assert(TYPE(h) == T_HASH); callRuby(::rb_block_call, h, rb_intern("each"), 0, static_cast(0), - reinterpret_cast(IceRuby_Util_hash_foreach_callback), + reinterpret_cast(IceRuby_Util_hash_foreach_callback), reinterpret_cast(&iter)); } -- cgit v1.2.3