* expand tabs.
This commit is contained in:
parent
ef524c13d9
commit
c5c3486340
114
object.c
114
object.c
@ -2733,17 +2733,17 @@ rb_mod_const_source_location(int argc, VALUE *argv, VALUE mod)
|
|||||||
recur = (argc == 1) ? Qtrue : argv[1];
|
recur = (argc == 1) ? Qtrue : argv[1];
|
||||||
|
|
||||||
if (SYMBOL_P(name)) {
|
if (SYMBOL_P(name)) {
|
||||||
if (!rb_is_const_sym(name)) goto wrong_name;
|
if (!rb_is_const_sym(name)) goto wrong_name;
|
||||||
id = rb_check_id(&name);
|
id = rb_check_id(&name);
|
||||||
if (!id) return Qnil;
|
if (!id) return Qnil;
|
||||||
return RTEST(recur) ? rb_const_source_location(mod, id) : rb_const_source_location_at(mod, id);
|
return RTEST(recur) ? rb_const_source_location(mod, id) : rb_const_source_location_at(mod, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
path = StringValuePtr(name);
|
path = StringValuePtr(name);
|
||||||
enc = rb_enc_get(name);
|
enc = rb_enc_get(name);
|
||||||
|
|
||||||
if (!rb_enc_asciicompat(enc)) {
|
if (!rb_enc_asciicompat(enc)) {
|
||||||
rb_raise(rb_eArgError, "invalid class path encoding (non ASCII)");
|
rb_raise(rb_eArgError, "invalid class path encoding (non ASCII)");
|
||||||
}
|
}
|
||||||
|
|
||||||
pbeg = p = path;
|
pbeg = p = path;
|
||||||
@ -2751,69 +2751,69 @@ rb_mod_const_source_location(int argc, VALUE *argv, VALUE mod)
|
|||||||
|
|
||||||
if (p >= pend || !*p) {
|
if (p >= pend || !*p) {
|
||||||
wrong_name:
|
wrong_name:
|
||||||
rb_name_err_raise(wrong_constant_name, mod, name);
|
rb_name_err_raise(wrong_constant_name, mod, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p + 2 < pend && p[0] == ':' && p[1] == ':') {
|
if (p + 2 < pend && p[0] == ':' && p[1] == ':') {
|
||||||
mod = rb_cObject;
|
mod = rb_cObject;
|
||||||
p += 2;
|
p += 2;
|
||||||
pbeg = p;
|
pbeg = p;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (p < pend) {
|
while (p < pend) {
|
||||||
VALUE part;
|
VALUE part;
|
||||||
long len, beglen;
|
long len, beglen;
|
||||||
|
|
||||||
while (p < pend && *p != ':') p++;
|
while (p < pend && *p != ':') p++;
|
||||||
|
|
||||||
if (pbeg == p) goto wrong_name;
|
if (pbeg == p) goto wrong_name;
|
||||||
|
|
||||||
id = rb_check_id_cstr(pbeg, len = p-pbeg, enc);
|
id = rb_check_id_cstr(pbeg, len = p-pbeg, enc);
|
||||||
beglen = pbeg-path;
|
beglen = pbeg-path;
|
||||||
|
|
||||||
if (p < pend && p[0] == ':') {
|
if (p < pend && p[0] == ':') {
|
||||||
if (p + 2 >= pend || p[1] != ':') goto wrong_name;
|
if (p + 2 >= pend || p[1] != ':') goto wrong_name;
|
||||||
p += 2;
|
p += 2;
|
||||||
pbeg = p;
|
pbeg = p;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!id) {
|
if (!id) {
|
||||||
part = rb_str_subseq(name, beglen, len);
|
part = rb_str_subseq(name, beglen, len);
|
||||||
OBJ_FREEZE(part);
|
OBJ_FREEZE(part);
|
||||||
if (!rb_is_const_name(part)) {
|
if (!rb_is_const_name(part)) {
|
||||||
name = part;
|
name = part;
|
||||||
goto wrong_name;
|
goto wrong_name;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return Qnil;
|
return Qnil;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!rb_is_const_id(id)) {
|
if (!rb_is_const_id(id)) {
|
||||||
name = ID2SYM(id);
|
name = ID2SYM(id);
|
||||||
goto wrong_name;
|
goto wrong_name;
|
||||||
}
|
}
|
||||||
if (p < pend) {
|
if (p < pend) {
|
||||||
if (RTEST(recur)) {
|
if (RTEST(recur)) {
|
||||||
mod = rb_const_get(mod, id);
|
mod = rb_const_get(mod, id);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
mod = rb_const_get_at(mod, id);
|
mod = rb_const_get_at(mod, id);
|
||||||
}
|
}
|
||||||
if (!RB_TYPE_P(mod, T_MODULE) && !RB_TYPE_P(mod, T_CLASS)) {
|
if (!RB_TYPE_P(mod, T_MODULE) && !RB_TYPE_P(mod, T_CLASS)) {
|
||||||
rb_raise(rb_eTypeError, "%"PRIsVALUE" does not refer to class/module",
|
rb_raise(rb_eTypeError, "%"PRIsVALUE" does not refer to class/module",
|
||||||
QUOTE(name));
|
QUOTE(name));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (RTEST(recur)) {
|
if (RTEST(recur)) {
|
||||||
loc = rb_const_source_location(mod, id);
|
loc = rb_const_source_location(mod, id);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
loc = rb_const_source_location_at(mod, id);
|
loc = rb_const_source_location_at(mod, id);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
recur = Qfalse;
|
recur = Qfalse;
|
||||||
}
|
}
|
||||||
|
|
||||||
return loc;
|
return loc;
|
||||||
|
28
variable.c
28
variable.c
@ -2411,7 +2411,7 @@ rb_const_search_from(VALUE klass, ID id, int exclude, int recurse, int visibilit
|
|||||||
rb_autoload_load(tmp, id);
|
rb_autoload_load(tmp, id);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (exclude && tmp == rb_cObject) {
|
if (exclude && tmp == rb_cObject) {
|
||||||
goto not_found;
|
goto not_found;
|
||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
@ -2487,20 +2487,20 @@ static VALUE
|
|||||||
rb_const_location_from(VALUE klass, ID id, int exclude, int recurse, int visibility)
|
rb_const_location_from(VALUE klass, ID id, int exclude, int recurse, int visibility)
|
||||||
{
|
{
|
||||||
while (RTEST(klass)) {
|
while (RTEST(klass)) {
|
||||||
rb_const_entry_t *ce;
|
rb_const_entry_t *ce;
|
||||||
|
|
||||||
while ((ce = rb_const_lookup(klass, id))) {
|
while ((ce = rb_const_lookup(klass, id))) {
|
||||||
if (visibility && RB_CONST_PRIVATE_P(ce)) {
|
if (visibility && RB_CONST_PRIVATE_P(ce)) {
|
||||||
return Qnil;
|
return Qnil;
|
||||||
}
|
}
|
||||||
if (exclude && klass == rb_cObject) {
|
if (exclude && klass == rb_cObject) {
|
||||||
goto not_found;
|
goto not_found;
|
||||||
}
|
}
|
||||||
if (NIL_P(ce->file)) return rb_ary_new();
|
if (NIL_P(ce->file)) return rb_ary_new();
|
||||||
return rb_assoc_new(ce->file, INT2NUM(ce->line));
|
return rb_assoc_new(ce->file, INT2NUM(ce->line));
|
||||||
}
|
}
|
||||||
if (!recurse) break;
|
if (!recurse) break;
|
||||||
klass = RCLASS_SUPER(klass);
|
klass = RCLASS_SUPER(klass);
|
||||||
}
|
}
|
||||||
|
|
||||||
not_found:
|
not_found:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user