ruby-changes:40239
From: nobu <ko1@a...>
Date: Wed, 28 Oct 2015 15:23:23 +0900 (JST)
Subject: [ruby-changes:40239] nobu:r52320 (trunk): error.c: rb_name_err_new
nobu 2015-10-28 15:23:16 +0900 (Wed, 28 Oct 2015) New Revision: 52320 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=52320 Log: error.c: rb_name_err_new * error.c (rb_name_err_new): new function to create NameError exception instance. [Feature #10881] Modified files: trunk/ChangeLog trunk/error.c trunk/internal.h Index: ChangeLog =================================================================== --- ChangeLog (revision 52319) +++ ChangeLog (revision 52320) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Wed Oct 28 15:23:14 2015 Nobuyoshi Nakada <nobu@r...> + + * error.c (rb_name_err_new): new function to create NameError + exception instance. [Feature #10881] + Wed Oct 28 13:29:39 2015 Nobuyoshi Nakada <nobu@r...> * parse.y (new_attr_op_assign): fix op_assign type, which is Index: error.c =================================================================== --- error.c (revision 52319) +++ error.c (revision 52320) @@ -1189,6 +1189,16 @@ rb_name_err_mesg_new(VALUE mesg, VALUE r https://github.com/ruby/ruby/blob/trunk/error.c#L1189 return result; } +VALUE +rb_name_err_new(VALUE mesg, VALUE recv, VALUE method) +{ + VALUE exc = rb_obj_alloc(rb_eNameError); + rb_ivar_set(exc, id_mesg, rb_name_err_mesg_new(mesg, recv, method)); + rb_ivar_set(exc, id_bt, Qnil); + rb_ivar_set(exc, id_name, method); + return exc; +} + /* :nodoc: */ static VALUE name_err_mesg_equal(VALUE obj1, VALUE obj2) Index: internal.h =================================================================== --- internal.h (revision 52319) +++ internal.h (revision 52320) @@ -739,6 +739,11 @@ const char *rb_builtin_class_name(VALUE https://github.com/ruby/ruby/blob/trunk/internal.h#L739 PRINTF_ARGS(void rb_enc_warn(rb_encoding *enc, const char *fmt, ...), 2, 3); PRINTF_ARGS(void rb_enc_warning(rb_encoding *enc, const char *fmt, ...), 2, 3); PRINTF_ARGS(void rb_sys_enc_warning(rb_encoding *enc, const char *fmt, ...), 2, 3); +VALUE rb_name_err_new(VALUE mesg, VALUE recv, VALUE method); +#define rb_name_err_raise_str(mesg, recv, name) \ + rb_exc_raise(rb_name_err_new(mesg, recv, name)) +#define rb_name_err_raise(mesg, recv, name) \ + rb_name_err_raise_str(rb_fstring_cstr(mesg), (recv), (name)) /* eval.c */ VALUE rb_refinement_module_get_refined_class(VALUE module); -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/