Skip to content

Commit d488935

Browse files
committed
Get rid of ID_JUNK
It has been aliased as ID_INTERNAL for a long time and that alias is much more descriptive.
1 parent 1a68f1b commit d488935

File tree

3 files changed

+33
-35
lines changed

3 files changed

+33
-35
lines changed

symbol.c

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ sym_set_create(VALUE sym, void *data)
276276
RB_OBJ_WRITE((VALUE)obj, &obj->fstr, str);
277277

278278
int id = rb_str_symname_type(str, IDSET_ATTRSET_FOR_INTERN);
279-
if (id < 0) id = ID_JUNK;
279+
if (id < 0) id = ID_INTERNAL;
280280
obj->id = id;
281281

282282
obj->hashval = rb_str_hash(str);
@@ -291,7 +291,7 @@ sym_set_create(VALUE sym, void *data)
291291
VALUE static_sym = static_sym_entry->sym;
292292
if (static_sym == 0) {
293293
ID id = rb_str_symname_type(str, IDSET_ATTRSET_FOR_INTERN);
294-
if (id == (ID)-1) id = ID_JUNK;
294+
if (id == (ID)-1) id = ID_INTERNAL;
295295

296296
ID nid = next_id_base();
297297
if (nid == (ID)-1) {
@@ -431,7 +431,7 @@ rb_id_attrset(ID id)
431431
scope = id_type(id);
432432
switch (scope) {
433433
case ID_LOCAL: case ID_INSTANCE: case ID_GLOBAL:
434-
case ID_CONST: case ID_CLASS: case ID_JUNK:
434+
case ID_CONST: case ID_CLASS: case ID_INTERNAL:
435435
break;
436436
case ID_ATTRSET:
437437
return id;
@@ -476,7 +476,7 @@ rb_id_attrset(ID id)
476476
"attrset",
477477
"const",
478478
"class",
479-
"junk",
479+
"internal",
480480
};
481481
rb_name_error(id, "cannot make anonymous %.*s ID %"PRIxVALUE" attrset",
482482
(int)sizeof(id_types[0]), id_types[scope], (VALUE)id);
@@ -602,66 +602,66 @@ enc_synmane_type_leading_chars(const char *name, long len, rb_encoding *enc, int
602602

603603
case '<':
604604
switch (*++m) {
605-
default: return (t) { stophere, ID_JUNK, 1, };
606-
case '<': return (t) { stophere, ID_JUNK, 2, };
605+
default: return (t) { stophere, ID_INTERNAL, 1, };
606+
case '<': return (t) { stophere, ID_INTERNAL, 2, };
607607
case '=':
608608
switch (*++m) {
609-
default: return (t) { stophere, ID_JUNK, 2, };
610-
case '>': return (t) { stophere, ID_JUNK, 3, };
609+
default: return (t) { stophere, ID_INTERNAL, 2, };
610+
case '>': return (t) { stophere, ID_INTERNAL, 3, };
611611
}
612612
}
613613

614614
case '>':
615615
switch (*++m) {
616-
default: return (t) { stophere, ID_JUNK, 1, };
617-
case '>': case '=': return (t) { stophere, ID_JUNK, 2, };
616+
default: return (t) { stophere, ID_INTERNAL, 1, };
617+
case '>': case '=': return (t) { stophere, ID_INTERNAL, 2, };
618618
}
619619

620620
case '=':
621621
switch (*++m) {
622-
default: return (t) { invalid, 0, 1, };
623-
case '~': return (t) { stophere, ID_JUNK, 2, };
622+
default: return (t) { invalid, 0, 1, };
623+
case '~': return (t) { stophere, ID_INTERNAL, 2, };
624624
case '=':
625625
switch (*++m) {
626-
default: return (t) { stophere, ID_JUNK, 2, };
627-
case '=': return (t) { stophere, ID_JUNK, 3, };
626+
default: return (t) { stophere, ID_INTERNAL, 2, };
627+
case '=': return (t) { stophere, ID_INTERNAL, 3, };
628628
}
629629
}
630630

631631
case '*':
632632
switch (*++m) {
633-
default: return (t) { stophere, ID_JUNK, 1, };
634-
case '*': return (t) { stophere, ID_JUNK, 2, };
633+
default: return (t) { stophere, ID_INTERNAL, 1, };
634+
case '*': return (t) { stophere, ID_INTERNAL, 2, };
635635
}
636636

637637
case '+': case '-':
638638
switch (*++m) {
639-
default: return (t) { stophere, ID_JUNK, 1, };
640-
case '@': return (t) { stophere, ID_JUNK, 2, };
639+
default: return (t) { stophere, ID_INTERNAL, 1, };
640+
case '@': return (t) { stophere, ID_INTERNAL, 2, };
641641
}
642642

643643
case '|': case '^': case '&': case '/': case '%': case '~': case '`':
644-
return (t) { stophere, ID_JUNK, 1, };
644+
return (t) { stophere, ID_INTERNAL, 1, };
645645

646646
case '[':
647647
switch (*++m) {
648-
default: return (t) { needmore, ID_JUNK, 0, };
648+
default: return (t) { needmore, ID_INTERNAL, 0, };
649649
case ']':
650650
switch (*++m) {
651-
default: return (t) { stophere, ID_JUNK, 2, };
652-
case '=': return (t) { stophere, ID_JUNK, 3, };
651+
default: return (t) { stophere, ID_INTERNAL, 2, };
652+
case '=': return (t) { stophere, ID_INTERNAL, 3, };
653653
}
654654
}
655655

656656
case '!':
657657
switch (*++m) {
658-
case '=': case '~': return (t) { stophere, ID_JUNK, 2, };
658+
case '=': case '~': return (t) { stophere, ID_INTERNAL, 2, };
659659
default:
660-
if (allowed_attrset & (1U << ID_JUNK)) {
661-
return (t) { needmore, ID_JUNK, 1, };
660+
if (allowed_attrset & (1U << ID_INTERNAL)) {
661+
return (t) { needmore, ID_INTERNAL, 1, };
662662
}
663663
else {
664-
return (t) { stophere, ID_JUNK, 1, };
664+
return (t) { stophere, ID_INTERNAL, 1, };
665665
}
666666
}
667667

@@ -702,7 +702,7 @@ rb_enc_symname_type(const char *name, long len, rb_encoding *enc, unsigned int a
702702
switch (*m) {
703703
case '!': case '?':
704704
if (type == ID_GLOBAL || type == ID_CLASS || type == ID_INSTANCE) return -1;
705-
type = ID_JUNK;
705+
type = ID_INTERNAL;
706706
++m;
707707
if (m + 1 < e || *m != '=') break;
708708
/* fall through */
@@ -1144,7 +1144,7 @@ rb_is_local_id(ID id)
11441144
int
11451145
rb_is_junk_id(ID id)
11461146
{
1147-
return is_junk_id(id);
1147+
return is_internal_id(id);
11481148
}
11491149

11501150
int

symbol.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ struct RSymbol {
3939
#define is_attrset_id(id) ((id)==idASET||id_type(id)==ID_ATTRSET)
4040
#define is_const_id(id) (id_type(id)==ID_CONST)
4141
#define is_class_id(id) (id_type(id)==ID_CLASS)
42-
#define is_junk_id(id) (id_type(id)==ID_JUNK)
42+
#define is_internal_id(id) (id_type(id)==ID_INTERNAL)
4343

4444
static inline int
4545
id_type(ID id)
@@ -91,7 +91,7 @@ sym_type(VALUE sym)
9191
#define is_attrset_sym(sym) (sym_type(sym)==ID_ATTRSET)
9292
#define is_const_sym(sym) (sym_type(sym)==ID_CONST)
9393
#define is_class_sym(sym) (sym_type(sym)==ID_CLASS)
94-
#define is_junk_sym(sym) (sym_type(sym)==ID_JUNK)
94+
#define is_internal_sym(sym) (sym_type(sym)==ID_INTERNAL)
9595

9696
#ifndef RIPPER
9797
RUBY_FUNC_EXPORTED

template/id.h.tmpl

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
%# -*- c -*-
2-
/* DO NOT EDIT THIS FILE DIRECTLY */
2+
/* DO NOT EDIT THIS FILE DIRECTLY: source is at template/id.h.tmpl */
33
/**********************************************************************
44
55
id.h -
@@ -19,15 +19,14 @@ types = ids.keys.grep(/^[A-Z]/)
1919
#define RUBY_ID_H
2020

2121
enum ruby_id_types {
22-
RUBY_ID_STATIC_SYM = 0x01,
2322
RUBY_ID_LOCAL = 0x00,
23+
RUBY_ID_STATIC_SYM = 0x01,
2424
RUBY_ID_INSTANCE = (0x01<<1),
2525
RUBY_ID_GLOBAL = (0x03<<1),
2626
RUBY_ID_ATTRSET = (0x04<<1),
2727
RUBY_ID_CONST = (0x05<<1),
2828
RUBY_ID_CLASS = (0x06<<1),
29-
RUBY_ID_JUNK = (0x07<<1),
30-
RUBY_ID_INTERNAL = RUBY_ID_JUNK,
29+
RUBY_ID_INTERNAL = (0x07<<1),
3130
RUBY_ID_SCOPE_SHIFT = 4,
3231
RUBY_ID_SCOPE_MASK = (~(~0U<<(RUBY_ID_SCOPE_SHIFT-1))<<1)
3332
};
@@ -41,7 +40,6 @@ enum ruby_id_types {
4140
#define ID_ATTRSET RUBY_ID_ATTRSET
4241
#define ID_CONST RUBY_ID_CONST
4342
#define ID_CLASS RUBY_ID_CLASS
44-
#define ID_JUNK RUBY_ID_JUNK
4543
#define ID_INTERNAL RUBY_ID_INTERNAL
4644

4745
#define symIFUNC ID2SYM(idIFUNC)

0 commit comments

Comments
 (0)