From 3cfbfa9628435e3b09316a18c2db9e4f250fdd77 Mon Sep 17 00:00:00 2001 From: Jeremy Evans Date: Fri, 13 Sep 2019 16:42:27 -0700 Subject: Consolidate empty keyword handling Remove rb_add_empty_keyword, and instead of calling that every place you need to add empty keyword hashes, run that code in a single static function in vm_eval.c. Add 4 defines to include/ruby/ruby.h, these are to be used as int kw_splat values when calling the various rb_*_kw functions: RB_NO_KEYWORDS :: Do not pass keywords RB_PASS_KEYWORDS :: Pass final argument (which should be hash) as keywords RB_PASS_EMPTY_KEYWORDS :: Add an empty hash to arguments and pass as keywords RB_PASS_CALLED_KEYWORDS :: Passes same keyword type as current method was called with (for method delegation) rb_empty_keyword_given_p needs to stay. It is required if argument delegation is done but delayed to a later point, which Enumerator does. Use RB_PASS_CALLED_KEYWORDS in rb_call_super to correctly delegate keyword arguments to super method. --- include/ruby/ruby.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'include') diff --git a/include/ruby/ruby.h b/include/ruby/ruby.h index 0bede6ffdd..1b396f4c19 100644 --- a/include/ruby/ruby.h +++ b/include/ruby/ruby.h @@ -1967,6 +1967,10 @@ VALUE rb_yield_values(int n, ...); VALUE rb_yield_values2(int n, const VALUE *argv); VALUE rb_yield_splat(VALUE); VALUE rb_yield_block(VALUE, VALUE, int, const VALUE *, VALUE); /* rb_block_call_func */ +#define RB_NO_KEYWORDS 0 +#define RB_PASS_KEYWORDS 1 +#define RB_PASS_EMPTY_KEYWORDS 2 +#define RB_PASS_CALLED_KEYWORDS 3 int rb_keyword_given_p(void); int rb_block_given_p(void); void rb_need_block(void); -- cgit v1.2.3