diff options
Diffstat (limited to 'spec/ruby/optional/capi/ext/class_spec.c')
-rw-r--r-- | spec/ruby/optional/capi/ext/class_spec.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/spec/ruby/optional/capi/ext/class_spec.c b/spec/ruby/optional/capi/ext/class_spec.c index 36b8c8f2f3..b860742906 100644 --- a/spec/ruby/optional/capi/ext/class_spec.c +++ b/spec/ruby/optional/capi/ext/class_spec.c @@ -61,18 +61,15 @@ static VALUE class_spec_rb_class_new(VALUE self, VALUE super) { return rb_class_new(super); } -static VALUE class_spec_rb_class_new_instance(VALUE self, - VALUE nargs, VALUE args, - VALUE klass) { - int c_nargs = FIX2INT(nargs); - VALUE *c_args = (VALUE*)alloca(sizeof(VALUE) * c_nargs); - int i; - - for (i = 0; i < c_nargs; i++) - c_args[i] = rb_ary_entry(args, i); +static VALUE class_spec_rb_class_new_instance(VALUE self, VALUE args, VALUE klass) { + return rb_class_new_instance(RARRAY_LENINT(args), RARRAY_PTR(args), klass); +} - return rb_class_new_instance(c_nargs, c_args, klass); +#ifdef RUBY_VERSION_IS_3_0 +static VALUE class_spec_rb_class_new_instance_kw(VALUE self, VALUE args, VALUE klass) { + return rb_class_new_instance_kw(RARRAY_LENINT(args), RARRAY_PTR(args), klass, RB_PASS_KEYWORDS); } +#endif static VALUE class_spec_rb_class_real(VALUE self, VALUE object) { if(rb_type_p(object, T_FIXNUM)) { @@ -171,7 +168,10 @@ void Init_class_spec(void) { rb_define_method(cls, "rb_class_protected_instance_methods", class_spec_rb_class_protected_instance_methods, -1); rb_define_method(cls, "rb_class_private_instance_methods", class_spec_rb_class_private_instance_methods, -1); rb_define_method(cls, "rb_class_new", class_spec_rb_class_new, 1); - rb_define_method(cls, "rb_class_new_instance", class_spec_rb_class_new_instance, 3); + rb_define_method(cls, "rb_class_new_instance", class_spec_rb_class_new_instance, 2); +#ifdef RUBY_VERSION_IS_3_0 + rb_define_method(cls, "rb_class_new_instance_kw", class_spec_rb_class_new_instance_kw, 2); +#endif rb_define_method(cls, "rb_class_real", class_spec_rb_class_real, 1); rb_define_method(cls, "rb_class_superclass", class_spec_rb_class_superclass, 1); rb_define_method(cls, "rb_cvar_defined", class_spec_cvar_defined, 2); |