summaryrefslogtreecommitdiff
path: root/ext/-test-
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2019-10-12 17:21:05 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2019-10-12 17:47:28 +0900
commit710bc003791b90adf3970e137c69f283c88234cd (patch)
treeabc786fce3b5b92c885a2d429c14b806a83d45e0 /ext/-test-
parent6333020fc924d3ae63775c032bbe8f57364cd42e (diff)
Moved RB_METHOD_DEFINITION_DECL to intern.h
This macro is used here before defined in ruby.h.
Diffstat (limited to 'ext/-test-')
-rw-r--r--ext/-test-/cxxanyargs/cxxanyargs.cpp204
1 files changed, 204 insertions, 0 deletions
diff --git a/ext/-test-/cxxanyargs/cxxanyargs.cpp b/ext/-test-/cxxanyargs/cxxanyargs.cpp
index 9a1fb02dd5..efe35fa359 100644
--- a/ext/-test-/cxxanyargs/cxxanyargs.cpp
+++ b/ext/-test-/cxxanyargs/cxxanyargs.cpp
@@ -387,6 +387,206 @@ namespace test_rb_define_method {
}
}
+namespace test_rb_define_module_function {
+ static VALUE
+ m1(VALUE, VALUE)
+ {
+ return Qnil;
+ }
+
+ static VALUE
+ m2(VALUE, VALUE, VALUE)
+ {
+ return Qnil;
+ }
+
+ static VALUE
+ ma(VALUE, VALUE)
+ {
+ return Qnil;
+ }
+
+ static VALUE
+ mv(int, VALUE*, VALUE)
+ {
+ return Qnil;
+ }
+
+ VALUE
+ test(VALUE self)
+ {
+ // No cast
+ rb_define_module_function(self, "m1", m1, 1);
+ rb_define_module_function(self, "m2", m2, 2);
+ rb_define_module_function(self, "ma", ma, -2);
+ rb_define_module_function(self, "mv", mv, -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);
+
+ // 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);
+
+ return self;
+ }
+}
+
+namespace test_rb_define_singleton_method {
+ static VALUE
+ m1(VALUE, VALUE)
+ {
+ return Qnil;
+ }
+
+ static VALUE
+ m2(VALUE, VALUE, VALUE)
+ {
+ return Qnil;
+ }
+
+ static VALUE
+ ma(VALUE, VALUE)
+ {
+ return Qnil;
+ }
+
+ static VALUE
+ mv(int, VALUE*, VALUE)
+ {
+ return Qnil;
+ }
+
+ VALUE
+ test(VALUE self)
+ {
+ // No cast
+ rb_define_singleton_method(self, "m1", m1, 1);
+ rb_define_singleton_method(self, "m2", m2, 2);
+ rb_define_singleton_method(self, "ma", ma, -2);
+ rb_define_singleton_method(self, "mv", mv, -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);
+
+ // 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);
+
+ return self;
+ }
+}
+
+namespace test_rb_define_protected_method {
+ static VALUE
+ m1(VALUE, VALUE)
+ {
+ return Qnil;
+ }
+
+ static VALUE
+ m2(VALUE, VALUE, VALUE)
+ {
+ return Qnil;
+ }
+
+ static VALUE
+ ma(VALUE, VALUE)
+ {
+ return Qnil;
+ }
+
+ static VALUE
+ mv(int, VALUE*, VALUE)
+ {
+ return Qnil;
+ }
+
+ VALUE
+ test(VALUE self)
+ {
+ // No cast
+ rb_define_protected_method(self, "m1", m1, 1);
+ rb_define_protected_method(self, "m2", m2, 2);
+ rb_define_protected_method(self, "ma", ma, -2);
+ rb_define_protected_method(self, "mv", mv, -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);
+
+ // 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);
+
+ return self;
+ }
+}
+
+namespace test_rb_define_private_method {
+ static VALUE
+ m1(VALUE, VALUE)
+ {
+ return Qnil;
+ }
+
+ static VALUE
+ m2(VALUE, VALUE, VALUE)
+ {
+ return Qnil;
+ }
+
+ static VALUE
+ ma(VALUE, VALUE)
+ {
+ return Qnil;
+ }
+
+ static VALUE
+ mv(int, VALUE*, VALUE)
+ {
+ return Qnil;
+ }
+
+ VALUE
+ test(VALUE self)
+ {
+ // No cast
+ rb_define_private_method(self, "m1", m1, 1);
+ rb_define_private_method(self, "m2", m2, 2);
+ rb_define_private_method(self, "ma", ma, -2);
+ rb_define_private_method(self, "mv", mv, -1);
+
+ // Cast by RUBY_METHOD_FUNC
+ rb_define_private_method(self, "m1", RUBY_METHOD_FUNC(m1), 1);
+ rb_define_private_method(self, "m2", RUBY_METHOD_FUNC(m2), 2);
+ rb_define_private_method(self, "ma", RUBY_METHOD_FUNC(ma), -2);
+ rb_define_private_method(self, "mv", RUBY_METHOD_FUNC(mv), -1);
+
+ // Explicit cast instead of RUBY_METHOD_FUNC
+ rb_define_private_method(self, "m1", (VALUE (*)(...))(m1), 1);
+ rb_define_private_method(self, "m2", (VALUE (*)(...))(m2), 2);
+ rb_define_private_method(self, "ma", (VALUE (*)(...))(ma), -2);
+ rb_define_private_method(self, "mv", (VALUE (*)(...))(mv), -1);
+
+ return self;
+ }
+}
+
extern "C" void
Init_cxxanyargs(void)
{
@@ -412,4 +612,8 @@ Init_cxxanyargs(void)
test(rb_hash_foreach);
test(rb_ivar_foreach);
test(rb_define_method);
+ test(rb_define_module_function);
+ test(rb_define_singleton_method);
+ test(rb_define_protected_method);
+ test(rb_define_private_method);
}