diff options
author | NARUSE, Yui <naruse@airemix.jp> | 2021-02-02 19:09:40 +0900 |
---|---|---|
committer | NARUSE, Yui <naruse@airemix.jp> | 2021-02-02 19:09:40 +0900 |
commit | 71b4638ca29a5d8a7d6f72e453513035d2096f47 (patch) | |
tree | 7feee157dc3a6429beba070577273e99dd6ff29d /error.c | |
parent | e9843cdaee26387310384fa0a1d43d450b017350 (diff) |
merge revision(s) 1cdae49d39fbaef654df487f168d1fb14a146d59: [Backport #17577]
Implement NameError::message#clone for Ractor
---
bootstraptest/test_ractor.rb | 13 +++++++++++++
error.c | 35 +++++++++++++++++++++++++++++++++--
test/objspace/test_objspace.rb | 9 +++++++++
3 files changed, 55 insertions(+), 2 deletions(-)
Diffstat (limited to 'error.c')
-rw-r--r-- | error.c | 35 |
1 files changed, 33 insertions, 2 deletions
@@ -1847,9 +1847,9 @@ static const rb_data_type_t name_err_mesg_data_type = { /* :nodoc: */ static VALUE -rb_name_err_mesg_new(VALUE mesg, VALUE recv, VALUE method) +rb_name_err_mesg_init(VALUE klass, VALUE mesg, VALUE recv, VALUE method) { - VALUE result = TypedData_Wrap_Struct(rb_cNameErrorMesg, &name_err_mesg_data_type, 0); + VALUE result = TypedData_Wrap_Struct(klass, &name_err_mesg_data_type, 0); VALUE *ptr = ALLOC_N(VALUE, NAME_ERR_MESG_COUNT); ptr[NAME_ERR_MESG__MESG] = mesg; @@ -1861,6 +1861,35 @@ rb_name_err_mesg_new(VALUE mesg, VALUE recv, VALUE method) /* :nodoc: */ static VALUE +rb_name_err_mesg_new(VALUE mesg, VALUE recv, VALUE method) +{ + return rb_name_err_mesg_init(rb_cNameErrorMesg, mesg, recv, method); +} + +/* :nodoc: */ +static VALUE +name_err_mesg_alloc(VALUE klass) +{ + return rb_name_err_mesg_init(klass, Qnil, Qnil, Qnil); +} + +/* :nodoc: */ +static VALUE +name_err_mesg_init_copy(VALUE obj1, VALUE obj2) +{ + VALUE *ptr1, *ptr2; + + if (obj1 == obj2) return obj1; + rb_obj_init_copy(obj1, obj2); + + TypedData_Get_Struct(obj1, VALUE, &name_err_mesg_data_type, ptr1); + TypedData_Get_Struct(obj2, VALUE, &name_err_mesg_data_type, ptr2); + MEMCPY(ptr1, ptr2, VALUE, NAME_ERR_MESG_COUNT); + return obj1; +} + +/* :nodoc: */ +static VALUE name_err_mesg_equal(VALUE obj1, VALUE obj2) { VALUE *ptr1, *ptr2; @@ -2787,6 +2816,8 @@ Init_Exception(void) rb_define_method(rb_eNameError, "receiver", name_err_receiver, 0); rb_define_method(rb_eNameError, "local_variables", name_err_local_variables, 0); rb_cNameErrorMesg = rb_define_class_under(rb_eNameError, "message", rb_cObject); + rb_define_alloc_func(rb_cNameErrorMesg, name_err_mesg_alloc); + rb_define_method(rb_cNameErrorMesg, "initialize_copy", name_err_mesg_init_copy, 1); rb_define_method(rb_cNameErrorMesg, "==", name_err_mesg_equal, 1); rb_define_method(rb_cNameErrorMesg, "to_str", name_err_mesg_to_str, 0); rb_define_method(rb_cNameErrorMesg, "_dump", name_err_mesg_dump, 1); |