ruby-changes:59848
From: =E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3 <ko1@a...>
Date: Tue, 28 Jan 2020 17:30:57 +0900 (JST)
Subject: [ruby-changes:59848] 83d6487ae5 (master): fix rb_define_global_function to take const VALUE*
https://git.ruby-lang.org/ruby.git/commit/?id=83d6487ae5 From 83d6487ae5c5df6c463373b36ccf1bee3f91d386 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3?= <shyouhei@r...> Date: Tue, 28 Jan 2020 17:20:16 +0900 Subject: fix rb_define_global_function to take const VALUE* It was unable for rb_define_global_function to take VALUE(*)(int argc, const VLAUE *argv, VALUE self) -style function. Test added. diff --git a/ext/-test-/cxxanyargs/cxxanyargs.cpp b/ext/-test-/cxxanyargs/cxxanyargs.cpp index a9f2d9a..812c6d7 100644 --- a/ext/-test-/cxxanyargs/cxxanyargs.cpp +++ b/ext/-test-/cxxanyargs/cxxanyargs.cpp @@ -362,6 +362,12 @@ namespace test_rb_define_method { https://github.com/ruby/ruby/blob/trunk/ext/-test-/cxxanyargs/cxxanyargs.cpp#L362 return Qnil; } + static VALUE + mc(int, const VALUE*, VALUE) + { + return Qnil; + } + VALUE test(VALUE self) { @@ -370,24 +376,28 @@ namespace test_rb_define_method { https://github.com/ruby/ruby/blob/trunk/ext/-test-/cxxanyargs/cxxanyargs.cpp#L376 rb_define_method(self, "m2", m2, 2); rb_define_method(self, "ma", ma, -2); rb_define_method(self, "mv", mv, -1); + rb_define_method(self, "mc", mc, -1); // Cast by RUBY_METHOD_FUNC rb_define_method(self, "m1", RUBY_METHOD_FUNC(m1), 1); 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); + rb_define_method(self, "mc", RUBY_METHOD_FUNC(mc), -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); + rb_define_method(self, "mc", (VALUE (*)(...))(mc), -1); // rb_f_notimplement rb_define_method(self, "m1", rb_f_notimplement, 1); rb_define_method(self, "m2", rb_f_notimplement, 2); rb_define_method(self, "ma", rb_f_notimplement, -2); rb_define_method(self, "mv", rb_f_notimplement, -1); + rb_define_method(self, "mc", rb_f_notimplement, -1); return self; } @@ -418,6 +428,12 @@ namespace test_rb_define_method_id { https://github.com/ruby/ruby/blob/trunk/ext/-test-/cxxanyargs/cxxanyargs.cpp#L428 return Qnil; } + static VALUE + mc(int, const VALUE*, VALUE) + { + return Qnil; + } + VALUE test(VALUE self) { @@ -426,24 +442,28 @@ namespace test_rb_define_method_id { https://github.com/ruby/ruby/blob/trunk/ext/-test-/cxxanyargs/cxxanyargs.cpp#L442 rb_define_method_id(self, rb_intern("m2"), m2, 2); rb_define_method_id(self, rb_intern("ma"), ma, -2); rb_define_method_id(self, rb_intern("mv"), mv, -1); + rb_define_method_id(self, rb_intern("mc"), mc, -1); // Cast by RUBY_METHOD_FUNC rb_define_method_id(self, rb_intern("m1"), RUBY_METHOD_FUNC(m1), 1); rb_define_method_id(self, rb_intern("m2"), RUBY_METHOD_FUNC(m2), 2); rb_define_method_id(self, rb_intern("ma"), RUBY_METHOD_FUNC(ma), -2); rb_define_method_id(self, rb_intern("mv"), RUBY_METHOD_FUNC(mv), -1); + rb_define_method_id(self, rb_intern("mc"), RUBY_METHOD_FUNC(mc), -1); // Explicit cast instead of RUBY_METHOD_FUNC rb_define_method_id(self, rb_intern("m1"), (VALUE (*)(...))(m1), 1); rb_define_method_id(self, rb_intern("m2"), (VALUE (*)(...))(m2), 2); rb_define_method_id(self, rb_intern("ma"), (VALUE (*)(...))(ma), -2); rb_define_method_id(self, rb_intern("mv"), (VALUE (*)(...))(mv), -1); + rb_define_method_id(self, rb_intern("mc"), (VALUE (*)(...))(mc), -1); // rb_f_notimplement rb_define_method_id(self, rb_intern("m1"), rb_f_notimplement, 1); rb_define_method_id(self, rb_intern("m2"), rb_f_notimplement, 2); rb_define_method_id(self, rb_intern("ma"), rb_f_notimplement, -2); rb_define_method_id(self, rb_intern("mv"), rb_f_notimplement, -1); + rb_define_method_id(self, rb_intern("mc"), rb_f_notimplement, -1); return self; } @@ -474,6 +494,12 @@ namespace test_rb_define_module_function { https://github.com/ruby/ruby/blob/trunk/ext/-test-/cxxanyargs/cxxanyargs.cpp#L494 return Qnil; } + static VALUE + mc(int, const VALUE*, VALUE) + { + return Qnil; + } + VALUE test(VALUE self) { @@ -482,24 +508,28 @@ namespace test_rb_define_module_function { https://github.com/ruby/ruby/blob/trunk/ext/-test-/cxxanyargs/cxxanyargs.cpp#L508 rb_define_module_function(self, "m2", m2, 2); rb_define_module_function(self, "ma", ma, -2); rb_define_module_function(self, "mv", mv, -1); + rb_define_module_function(self, "mc", mc, -1); // Cast by RUBY_METHOD_FUNC rb_define_module_function(self, "m1", RUBY_METHOD_FUNC(m1), 1); rb_define_module_function(self, "m2", RUBY_METHOD_FUNC(m2), 2); rb_define_module_function(self, "ma", RUBY_METHOD_FUNC(ma), -2); rb_define_module_function(self, "mv", RUBY_METHOD_FUNC(mv), -1); + rb_define_module_function(self, "mc", RUBY_METHOD_FUNC(mc), -1); // Explicit cast instead of RUBY_METHOD_FUNC rb_define_module_function(self, "m1", (VALUE (*)(...))(m1), 1); rb_define_module_function(self, "m2", (VALUE (*)(...))(m2), 2); rb_define_module_function(self, "ma", (VALUE (*)(...))(ma), -2); rb_define_module_function(self, "mv", (VALUE (*)(...))(mv), -1); + rb_define_module_function(self, "mc", (VALUE (*)(...))(mc), -1); // rb_f_notimplement rb_define_module_function(self, "m1", rb_f_notimplement, 1); rb_define_module_function(self, "m2", rb_f_notimplement, 2); rb_define_module_function(self, "ma", rb_f_notimplement, -2); rb_define_module_function(self, "mv", rb_f_notimplement, -1); + rb_define_module_function(self, "mc", rb_f_notimplement, -1); return self; } @@ -530,6 +560,12 @@ namespace test_rb_define_singleton_method { https://github.com/ruby/ruby/blob/trunk/ext/-test-/cxxanyargs/cxxanyargs.cpp#L560 return Qnil; } + static VALUE + mc(int, const VALUE*, VALUE) + { + return Qnil; + } + VALUE test(VALUE self) { @@ -538,24 +574,28 @@ namespace test_rb_define_singleton_method { https://github.com/ruby/ruby/blob/trunk/ext/-test-/cxxanyargs/cxxanyargs.cpp#L574 rb_define_singleton_method(self, "m2", m2, 2); rb_define_singleton_method(self, "ma", ma, -2); rb_define_singleton_method(self, "mv", mv, -1); + rb_define_singleton_method(self, "mc", mc, -1); // Cast by RUBY_METHOD_FUNC rb_define_singleton_method(self, "m1", RUBY_METHOD_FUNC(m1), 1); rb_define_singleton_method(self, "m2", RUBY_METHOD_FUNC(m2), 2); rb_define_singleton_method(self, "ma", RUBY_METHOD_FUNC(ma), -2); rb_define_singleton_method(self, "mv", RUBY_METHOD_FUNC(mv), -1); + rb_define_singleton_method(self, "mc", RUBY_METHOD_FUNC(mc), -1); // Explicit cast instead of RUBY_METHOD_FUNC rb_define_singleton_method(self, "m1", (VALUE (*)(...))(m1), 1); rb_define_singleton_method(self, "m2", (VALUE (*)(...))(m2), 2); rb_define_singleton_method(self, "ma", (VALUE (*)(...))(ma), -2); rb_define_singleton_method(self, "mv", (VALUE (*)(...))(mv), -1); + rb_define_singleton_method(self, "mc", (VALUE (*)(...))(mc), -1); // rb_f_notimplement rb_define_singleton_method(self, "m1", rb_f_notimplement, 1); rb_define_singleton_method(self, "m2", rb_f_notimplement, 2); rb_define_singleton_method(self, "ma", rb_f_notimplement, -2); rb_define_singleton_method(self, "mv", rb_f_notimplement, -1); + rb_define_singleton_method(self, "mc", rb_f_notimplement, -1); return self; } @@ -586,6 +626,12 @@ namespace test_rb_define_protected_method { https://github.com/ruby/ruby/blob/trunk/ext/-test-/cxxanyargs/cxxanyargs.cpp#L626 return Qnil; } + static VALUE + mc(int, const VALUE*, VALUE) + { + return Qnil; + } + VALUE test(VALUE self) { @@ -594,24 +640,28 @@ namespace test_rb_define_protected_method { https://github.com/ruby/ruby/blob/trunk/ext/-test-/cxxanyargs/cxxanyargs.cpp#L640 rb_define_protected_method(self, "m2", m2, 2); rb_define_protected_method(self, "ma", ma, -2); rb_define_protected_method(self, "mv", mv, -1); + rb_define_protected_method(self, "mc", mc, -1); // Cast by RUBY_METHOD_FUNC rb_define_protected_method(self, "m1", RUBY_METHOD_FUNC(m1), 1); rb_define_protected_method(self, "m2", RUBY_METHOD_FUNC(m2), 2); rb_define_protected_method(self, "ma", RUBY_METHOD_FUNC(ma), -2); rb_define_protected_method(self, "mv", RUBY_METHOD_FUNC(mv), -1); + rb_define_protected_method(self, "mc", RUBY_METHOD_FUNC(mc), -1); // Explicit cast instead of RUBY_METHOD_FUNC rb_define_protected_method(self, "m1", (VALUE (*)(...))(m1), 1); rb_define_protected_method(self, "m2", (VALUE (*)(...))(m2), 2); rb_define_protected_method(self, "ma", (VALUE (*)(...))(ma), -2); rb_define_protected_method(self, "mv", (VALUE (*)(...))(mv), -1); + rb_define_protected_method(self, "mc", (VALUE (*)(...))(mc), -1); // rb_f_notimplement rb_define_protected_method(self, "m1", rb_f_notimplement, 1); rb_define_protected_method(self, "m2", rb_f_notimplement, 2); rb_define_protected_method(self, "ma", rb_f_notimplement, -2); rb_define_protected_m (... truncated) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/