Extract build_const_pathname
* variable.c (build_const_pathname): build constant path from name as a string. [Feature #15765]
This commit is contained in:
parent
b00f280d4b
commit
1b20d6a6c6
35
variable.c
35
variable.c
@ -192,6 +192,22 @@ save_temporary_path(VALUE obj, VALUE name)
|
|||||||
return rb_ivar_set(obj, tmp_classpath, make_temporary_path(obj, name));
|
return rb_ivar_set(obj, tmp_classpath, make_temporary_path(obj, name));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static VALUE
|
||||||
|
build_const_pathname(VALUE head, VALUE tail)
|
||||||
|
{
|
||||||
|
VALUE path = rb_str_dup(head);
|
||||||
|
rb_str_cat2(path, "::");
|
||||||
|
rb_str_append(path, tail);
|
||||||
|
OBJ_FREEZE(path);
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
static VALUE
|
||||||
|
build_const_path(VALUE head, ID tail)
|
||||||
|
{
|
||||||
|
return build_const_pathname(head, rb_id2str(tail));
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
rb_set_class_path_string(VALUE klass, VALUE under, VALUE name)
|
rb_set_class_path_string(VALUE klass, VALUE under, VALUE name)
|
||||||
{
|
{
|
||||||
@ -203,10 +219,8 @@ rb_set_class_path_string(VALUE klass, VALUE under, VALUE name)
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int permanent;
|
int permanent;
|
||||||
str = rb_str_dup(rb_tmp_class_path(under, &permanent, save_temporary_path));
|
str = rb_tmp_class_path(under, &permanent, save_temporary_path);
|
||||||
rb_str_cat2(str, "::");
|
str = build_const_pathname(str, name);
|
||||||
rb_str_append(str, name);
|
|
||||||
OBJ_FREEZE(str);
|
|
||||||
if (!permanent) {
|
if (!permanent) {
|
||||||
pathid = tmp_classpath;
|
pathid = tmp_classpath;
|
||||||
}
|
}
|
||||||
@ -2682,16 +2696,6 @@ check_before_mod_set(VALUE klass, ID id, VALUE val, const char *dest)
|
|||||||
rb_check_frozen(klass);
|
rb_check_frozen(klass);
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
|
||||||
build_const_path(VALUE head, ID tail)
|
|
||||||
{
|
|
||||||
VALUE path = rb_str_dup(head);
|
|
||||||
rb_str_cat2(path, "::");
|
|
||||||
rb_str_append(path, rb_id2str(tail));
|
|
||||||
OBJ_FREEZE(path);
|
|
||||||
return path;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void finalize_classpath_for_children(VALUE named_namespace);
|
static void finalize_classpath_for_children(VALUE named_namespace);
|
||||||
|
|
||||||
static enum rb_id_table_iterator_result
|
static enum rb_id_table_iterator_result
|
||||||
@ -2786,7 +2790,8 @@ rb_const_set(VALUE klass, ID id, VALUE val)
|
|||||||
if (parental_path_permanent && !val_path_permanent) {
|
if (parental_path_permanent && !val_path_permanent) {
|
||||||
rb_ivar_set(val, classpath, build_const_path(parental_path, id));
|
rb_ivar_set(val, classpath, build_const_path(parental_path, id));
|
||||||
finalize_classpath_for_children(val);
|
finalize_classpath_for_children(val);
|
||||||
} else if (!parental_path_permanent && NIL_P(val_path)) {
|
}
|
||||||
|
else if (!parental_path_permanent && NIL_P(val_path)) {
|
||||||
rb_ivar_set(val, tmp_classpath, build_const_path(parental_path, id));
|
rb_ivar_set(val, tmp_classpath, build_const_path(parental_path, id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user