ruby-changes:57839
From: Nobuyoshi <ko1@a...>
Date: Fri, 20 Sep 2019 19:12:55 +0900 (JST)
Subject: [ruby-changes:57839] 740a98fe10 (master): Fix for explicit cast without RUBY_METHOD_FUNC
https://git.ruby-lang.org/ruby.git/commit/?id=740a98fe10 From 740a98fe108305324a66edb16f0acb8521a53da7 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Fri, 20 Sep 2019 19:03:43 +0900 Subject: Fix for explicit cast without RUBY_METHOD_FUNC diff --git a/ext/-test-/cxxanyargs/cxxanyargs.cpp b/ext/-test-/cxxanyargs/cxxanyargs.cpp index 9a800cb..9a1fb02 100644 --- a/ext/-test-/cxxanyargs/cxxanyargs.cpp +++ b/ext/-test-/cxxanyargs/cxxanyargs.cpp @@ -376,6 +376,13 @@ namespace test_rb_define_method { https://github.com/ruby/ruby/blob/trunk/ext/-test-/cxxanyargs/cxxanyargs.cpp#L376 rb_define_method(self, "m2", RUBY_METHOD_FUNC(m2), 2); rb_define_method(self, "ma", RUBY_METHOD_FUNC(ma), -2); rb_define_method(self, "mv", RUBY_METHOD_FUNC(mv), -1); + + // Explicit cast instead of RUBY_METHOD_FUNC + rb_define_method(self, "m1", (VALUE (*)(...))(m1), 1); + rb_define_method(self, "m2", (VALUE (*)(...))(m2), 2); + rb_define_method(self, "ma", (VALUE (*)(...))(ma), -2); + rb_define_method(self, "mv", (VALUE (*)(...))(mv), -1); + return self; } } diff --git a/include/ruby/ruby.h b/include/ruby/ruby.h index ad86f28..8b56faa 100644 --- a/include/ruby/ruby.h +++ b/include/ruby/ruby.h @@ -2734,6 +2734,7 @@ RUBY_SYMBOL_EXPORT_END https://github.com/ruby/ruby/blob/trunk/include/ruby/ruby.h#L2734 #define RB_METHOD_DEFINITION_DECL_CXX(def,defname,decl,vars,funcargs,arity) \ template <> struct def##_tmpl<arity> { \ static void define(RB_UNWRAP_MACRO decl, VALUE (*func)funcargs) {::defname(RB_UNWRAP_MACRO vars, func, arity);} \ + static void define(RB_UNWRAP_MACRO decl, VALUE (*func)(...)) {::defname(RB_UNWRAP_MACRO vars, reinterpret_cast<VALUE(*)funcargs>(func), arity);} \ }; #else #define RB_METHOD_DEFINITION_DECL_CXX_BEGIN(def) /* nothing */ @@ -2761,7 +2762,7 @@ RB_METHOD_DEFINITION_DECL_1(def,nonnull,def##12,12,decl,vars,(VALUE,VALUE,VALUE, https://github.com/ruby/ruby/blob/trunk/include/ruby/ruby.h#L2762 RB_METHOD_DEFINITION_DECL_1(def,nonnull,def##13,13,decl,vars,(VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE)) \ RB_METHOD_DEFINITION_DECL_1(def,nonnull,def##14,14,decl,vars,(VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE)) \ RB_METHOD_DEFINITION_DECL_1(def,nonnull,def##15,15,decl,vars,(VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE,VALUE)) \ -RB_METHOD_DEFINITION_DECL_1(def,nonnull,def##m3,-3,decl,vars,(ANYARGS)) \ +RB_METHOD_DEFINITION_DECL_M3(def,nonnull,def##m3,decl,vars) \ RB_METHOD_DEFINITION_DECL_1(def,nonnull,def##m2,-2,decl,vars,(VALUE,VALUE)) \ RB_METHOD_DEFINITION_DECL_M1(def,nonnull,def##m1,decl,vars) /* END */ #ifdef __cplusplus @@ -2769,14 +2770,19 @@ RB_METHOD_DEFINITION_DECL_M1(def,nonnull,def##m1,decl,vars) /* END */ https://github.com/ruby/ruby/blob/trunk/include/ruby/ruby.h#L2770 RB_METHOD_DEFINITION_DECL_C(def,nonnull,defname,decl,vars,(int,VALUE*,VALUE)) \ RB_METHOD_DEFINITION_DECL_C(def,nonnull,defname,decl,vars,(int,const VALUE*,VALUE)) \ RB_METHOD_DEFINITION_DECL_C(def,nonnull,defname,decl,vars,(int,const VALUE*,VALUE,VALUE)) \ + RB_METHOD_DEFINITION_DECL_C(def,nonnull,defname,decl,vars,(...)) \ template <> struct def##_tmpl<-1> { \ static void define(RB_UNWRAP_MACRO decl, VALUE (*func)(int,VALUE*,VALUE)) {::defname(RB_UNWRAP_MACRO vars, func, -1);} \ static void define(RB_UNWRAP_MACRO decl, VALUE (*func)(int,const VALUE*,VALUE)) {::defname(RB_UNWRAP_MACRO vars, func, -1);} \ static void define(RB_UNWRAP_MACRO decl, VALUE (*func)(int,const VALUE*,VALUE,VALUE)) {::defname(RB_UNWRAP_MACRO vars, func, -1);} \ + static void define(RB_UNWRAP_MACRO decl, VALUE (*func)(...)) {::defname(RB_UNWRAP_MACRO vars, func, -1);} \ }; +#define RB_METHOD_DEFINITION_DECL_M3(def,nonnull,defname,decl,vars) /* nothing */ #else #define RB_METHOD_DEFINITION_DECL_M1(def,nonnull,defname,decl,vars) \ RB_METHOD_DEFINITION_DECL_C(def,nonnull,defname,decl,vars,(int,union{VALUE*x;const VALUE*y;}__attribute__((__transparent_union__)),VALUE)) +#define RB_METHOD_DEFINITION_DECL_M3(def,nonnull,defname,decl,vars) \ + RB_METHOD_DEFINITION_DECL_C(def,nonnull,defname,decl,vars,()) #endif #endif -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/