mirror of
https://github.com/ruby/ruby.git
synced 2025-08-16 05:59:00 +02:00
* variable.c (rb_obj_remove_instance_variable): raise NameError if
specified instance variable is not defined. * variable.c (generic_ivar_remove): modified to check ivar existence. * file.c (rb_file_s_extname): new method based on the proposal (and patch) from Mike Hall. [new] * eval.c (error_handle): default to 1 unless status is set. * eval.c (ruby_options): guard error_handle() with PROT_NONE. * eval.c (ruby_stop): ditto. * math.c (math_acosh): added. [new] * math.c (math_asinh): ditto. * math.c (math_atanh): ditto. * struct.c (rb_struct_each_pair): method added. [new] * class.c (rb_singleton_class): wrong condition; was creating unnecessary singleton class. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2348 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
ff0abdc55e
commit
19c42c0740
14 changed files with 209 additions and 146 deletions
31
variable.c
31
variable.c
|
@ -259,7 +259,7 @@ rb_autoload_id(id, filename)
|
|||
{
|
||||
rb_secure(4);
|
||||
if (!rb_is_const_id(id)) {
|
||||
rb_name_error(id, "autoload must be constant name", rb_id2name(id));
|
||||
rb_name_error(id, "autoload must be constant name");
|
||||
}
|
||||
|
||||
if (!autoload_tbl) {
|
||||
|
@ -845,22 +845,23 @@ generic_ivar_defined(obj, id)
|
|||
return Qfalse;
|
||||
}
|
||||
|
||||
static VALUE
|
||||
generic_ivar_remove(obj, id)
|
||||
static int
|
||||
generic_ivar_remove(obj, id, valp)
|
||||
VALUE obj;
|
||||
ID id;
|
||||
VALUE *valp;
|
||||
{
|
||||
st_table *tbl;
|
||||
VALUE val;
|
||||
int status;
|
||||
|
||||
if (!generic_iv_tbl) return Qnil;
|
||||
if (!st_lookup(generic_iv_tbl, obj, &tbl)) return Qnil;
|
||||
st_delete(tbl, &id, &val);
|
||||
if (!generic_iv_tbl) return 0;
|
||||
if (!st_lookup(generic_iv_tbl, obj, &tbl)) return 0;
|
||||
status = st_delete(tbl, &id, valp);
|
||||
if (tbl->num_entries == 0) {
|
||||
st_delete(generic_iv_tbl, &obj, &tbl);
|
||||
st_free_table(tbl);
|
||||
}
|
||||
return val;
|
||||
return status;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -1052,16 +1053,20 @@ rb_obj_remove_instance_variable(obj, name)
|
|||
case T_OBJECT:
|
||||
case T_CLASS:
|
||||
case T_MODULE:
|
||||
if (ROBJECT(obj)->iv_tbl) {
|
||||
st_delete(ROBJECT(obj)->iv_tbl, &id, &val);
|
||||
if (ROBJECT(obj)->iv_tbl && st_delete(ROBJECT(obj)->iv_tbl, &id, &val)) {
|
||||
return val;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (FL_TEST(obj, FL_EXIVAR) || rb_special_const_p(obj))
|
||||
return generic_ivar_remove(obj, id);
|
||||
if (FL_TEST(obj, FL_EXIVAR) || rb_special_const_p(obj)) {
|
||||
if (generic_ivar_remove(obj, id, &val)) {
|
||||
return val;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
return val;
|
||||
rb_name_error(id, "instance variable %s not defined", rb_id2name(id));
|
||||
return Qnil; /* not reached */
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue