summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorJeremy Evans <code@jeremyevans.net>2019-09-29 17:47:17 -0700
committerJeremy Evans <code@jeremyevans.net>2019-09-29 18:31:08 -0700
commit649a64ae29318501472f74798a12eb60871ab990 (patch)
tree8295ea066c04d326bb7462a4f7569d60d393c5b4 /ext
parentfba8627dc1c5b191713edeb5fc21cbe0ddde9e3c (diff)
Add three more C-API functions for handling keywords
This adds rb_funcall_passing_block_kw, rb_funcallv_public_kw, and rb_yield_splat_kw. This functions are necessary to easily handle cases where rb_funcall_passing_block, rb_funcallv_public, and rb_yield_splat are currently used and a keyword argument separation warning is raised.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/2507
Diffstat (limited to 'ext')
-rw-r--r--ext/-test-/funcall/funcall.c32
1 files changed, 30 insertions, 2 deletions
diff --git a/ext/-test-/funcall/funcall.c b/ext/-test-/funcall/funcall.c
index 4e13c952e5..43521bf2e9 100644
--- a/ext/-test-/funcall/funcall.c
+++ b/ext/-test-/funcall/funcall.c
@@ -1,7 +1,5 @@
#include "ruby.h"
-VALUE rb_funcall_passing_block(VALUE, ID, int, const VALUE*);
-
static VALUE
with_funcall2(int argc, VALUE *argv, VALUE self)
{
@@ -15,6 +13,24 @@ with_funcall_passing_block(int argc, VALUE *argv, VALUE self)
}
static VALUE
+with_funcall_passing_block_kw(int argc, VALUE *argv, VALUE self)
+{
+ return rb_funcall_passing_block_kw(self, rb_intern("target"), argc-1, argv+1, FIX2INT(argv[0]));
+}
+
+static VALUE
+with_funcallv_public_kw(int argc, VALUE *argv, VALUE self)
+{
+ return rb_funcallv_public_kw(argv[0], SYM2ID(argv[1]), argc-3, argv+3, FIX2INT(argv[2]));
+}
+
+static VALUE
+with_yield_splat_kw(int argc, VALUE *argv, VALUE self)
+{
+ return rb_yield_splat_kw(argv[1], FIX2INT(argv[0]));
+}
+
+static VALUE
extra_args_name(VALUE self)
{
/*
@@ -35,9 +51,21 @@ Init_funcall(void)
with_funcall2,
-1);
rb_define_singleton_method(cRelay,
+ "with_funcall_passing_block_kw",
+ with_funcall_passing_block_kw,
+ -1);
+ rb_define_singleton_method(cRelay,
"with_funcall_passing_block",
with_funcall_passing_block,
-1);
+ rb_define_singleton_method(cRelay,
+ "with_funcallv_public_kw",
+ with_funcallv_public_kw,
+ -1);
+ rb_define_singleton_method(cRelay,
+ "with_yield_splat_kw",
+ with_yield_splat_kw,
+ -1);
rb_define_singleton_method(cTestFuncall, "extra_args_name",
extra_args_name,
0);