This commit is contained in:
Nobuyoshi Nakada 2019-07-09 10:58:12 +09:00
Родитель 9b18cb341f
Коммит 4cda2e5013
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4BC7D6DF58D8DF60
1 изменённых файлов: 15 добавлений и 13 удалений

Просмотреть файл

@ -2262,9 +2262,14 @@ rb_class_get_superclass(VALUE klass)
return RCLASS(klass)->super;
}
static const char bad_instance_name[] = "`%1$s' is not allowed as an instance variable name";
static const char bad_class_name[] = "`%1$s' is not allowed as a class variable name";
static const char bad_const_name[] = "wrong constant name %1$s";
static const char bad_attr_name[] = "invalid attribute name `%1$s'";
#define wrong_constant_name bad_const_name
/*! \private */
#define id_for_var(obj, name, part, type) \
id_for_setter(obj, name, type, "`%1$s' is not allowed as "#part" "#type" variable name")
#define id_for_var(obj, name, type) id_for_setter(obj, name, type, bad_##type##_name)
/*! \private */
#define id_for_setter(obj, name, type, message) \
check_setter_id(obj, &(name), rb_is_##type##_id, rb_is_##type##_name, message, strlen(message))
@ -2295,13 +2300,10 @@ rb_is_attr_id(ID id)
return rb_is_local_id(id) || rb_is_const_id(id);
}
static const char wrong_constant_name[] = "wrong constant name %1$s";
static const char invalid_attribute_name[] = "invalid attribute name `%1$s'";
static ID
id_for_attr(VALUE obj, VALUE name)
{
ID id = id_for_setter(obj, name, attr, invalid_attribute_name);
ID id = id_for_var(obj, name, attr);
if (!id) id = rb_intern_str(name);
return id;
}
@ -2566,7 +2568,7 @@ rb_mod_const_get(int argc, VALUE *argv, VALUE mod)
static VALUE
rb_mod_const_set(VALUE mod, VALUE name, VALUE value)
{
ID id = id_for_setter(mod, name, const, wrong_constant_name);
ID id = id_for_var(mod, name, const);
if (!id) id = rb_intern_str(name);
rb_const_set(mod, id, value);
@ -2844,7 +2846,7 @@ rb_mod_const_source_location(int argc, VALUE *argv, VALUE mod)
static VALUE
rb_obj_ivar_get(VALUE obj, VALUE iv)
{
ID id = id_for_var(obj, iv, an, instance);
ID id = id_for_var(obj, iv, instance);
if (!id) {
return Qnil;
@ -2878,7 +2880,7 @@ rb_obj_ivar_get(VALUE obj, VALUE iv)
static VALUE
rb_obj_ivar_set(VALUE obj, VALUE iv, VALUE val)
{
ID id = id_for_var(obj, iv, an, instance);
ID id = id_for_var(obj, iv, instance);
if (!id) id = rb_intern_str(iv);
return rb_ivar_set(obj, id, val);
}
@ -2906,7 +2908,7 @@ rb_obj_ivar_set(VALUE obj, VALUE iv, VALUE val)
static VALUE
rb_obj_ivar_defined(VALUE obj, VALUE iv)
{
ID id = id_for_var(obj, iv, an, instance);
ID id = id_for_var(obj, iv, instance);
if (!id) {
return Qfalse;
@ -2933,7 +2935,7 @@ rb_obj_ivar_defined(VALUE obj, VALUE iv)
static VALUE
rb_mod_cvar_get(VALUE obj, VALUE iv)
{
ID id = id_for_var(obj, iv, a, class);
ID id = id_for_var(obj, iv, class);
if (!id) {
rb_name_err_raise("uninitialized class variable %1$s in %2$s",
@ -2965,7 +2967,7 @@ rb_mod_cvar_get(VALUE obj, VALUE iv)
static VALUE
rb_mod_cvar_set(VALUE obj, VALUE iv, VALUE val)
{
ID id = id_for_var(obj, iv, a, class);
ID id = id_for_var(obj, iv, class);
if (!id) id = rb_intern_str(iv);
rb_cvar_set(obj, id, val);
return val;
@ -2990,7 +2992,7 @@ rb_mod_cvar_set(VALUE obj, VALUE iv, VALUE val)
static VALUE
rb_mod_cvar_defined(VALUE obj, VALUE iv)
{
ID id = id_for_var(obj, iv, a, class);
ID id = id_for_var(obj, iv, class);
if (!id) {
return Qfalse;