13#include "internal/error.h"
14#include "internal/gc.h"
15#include "internal/hash.h"
16#include "internal/object.h"
17#include "internal/symbol.h"
18#include "internal/vm.h"
26#if defined(USE_SYMBOL_GC) && !(USE_SYMBOL_GC+0)
28# define USE_SYMBOL_GC 0
31# define USE_SYMBOL_GC 1
33#if defined(SYMBOL_DEBUG) && (SYMBOL_DEBUG+0)
35# define SYMBOL_DEBUG 1
38# define SYMBOL_DEBUG 0
40#ifndef CHECK_ID_SERIAL
41# define CHECK_ID_SERIAL SYMBOL_DEBUG
44#define SYMBOL_PINNED_P(sym) (RSYMBOL(sym)->id&~ID_SCOPE_MASK)
46#define STATIC_SYM2ID(sym) RSHIFT((VALUE)(sym), RUBY_SPECIAL_SHIFT)
49static ID register_static_symid_str(
ID,
VALUE);
50#define REGISTER_SYMID(id, name) register_static_symid((id), (name), strlen(name), enc)
53#define is_identchar(p,e,enc) (ISALNUM((unsigned char)*(p)) || (*(p)) == '_' || !ISASCII(*(p)))
55#define op_tbl_count numberof(op_tbl)
56STATIC_ASSERT(op_tbl_name_size,
sizeof(op_tbl[0].name) == 3);
57#define op_tbl_len(i) (!op_tbl[i].name[1] ? 1 : !op_tbl[i].name[2] ? 2 : 3)
65 for (i =
'!'; i <=
'~'; ++i) {
68 register_static_symid(i, &c, 1, enc);
71 for (i = 0; i < op_tbl_count; ++i) {
72 register_static_symid(op_tbl[i].token, op_tbl[i].name, op_tbl_len(i), enc);
76static const int ID_ENTRY_UNIT = 512;
96 VALUE dsym_fstrs = rb_ident_hash_new();
97 symbols->dsymbol_fstr_hash = dsym_fstrs;
98 rb_gc_register_mark_object(dsym_fstrs);
99 rb_obj_hide(dsym_fstrs);
101 symbols->str_sym = st_init_table_with_size(&symhash, 1000);
102 symbols->ids = rb_ary_hidden_new(0);
103 rb_gc_register_mark_object(symbols->ids);
111WARN_UNUSED_RESULT(
static ID lookup_str_id(
VALUE str));
113WARN_UNUSED_RESULT(
static VALUE lookup_str_sym(
const VALUE str));
114WARN_UNUSED_RESULT(
static VALUE lookup_id_str(
ID id));
115WARN_UNUSED_RESULT(
static ID intern_str(
VALUE str,
int mutable));
117#define GLOBAL_SYMBOLS_ENTER(symbols) rb_symbols_t *symbols = &ruby_global_symbols; RB_VM_LOCK_ENTER()
118#define GLOBAL_SYMBOLS_LEAVE() RB_VM_LOCK_LEAVE()
126 if (!is_notop_id(
id)) {
128 case tAREF:
case tASET:
131 rb_name_error(
id,
"cannot make operator ID :%"PRIsVALUE
" attrset",
137 case ID_LOCAL:
case ID_INSTANCE:
case ID_GLOBAL:
138 case ID_CONST:
case ID_CLASS:
case ID_JUNK:
144 if ((str = lookup_id_str(
id)) != 0) {
145 rb_name_error(
id,
"cannot make unknown type ID %d:%"PRIsVALUE
" attrset",
157 if (!(str = lookup_id_str(
id))) {
158 static const char id_types[][8] = {
168 rb_name_error(
id,
"cannot make anonymous %.*s ID %"PRIxVALUE
" attrset",
169 (
int)
sizeof(id_types[0]), id_types[scope], (
VALUE)
id);
171 str = rb_str_dup(str);
172 rb_str_cat(str,
"=", 1);
173 sym = lookup_str_sym(str);
174 id = sym ?
rb_sym2id(sym) : intern_str(str, 1);
179is_special_global_name(
const char *m,
const char *e,
rb_encoding *enc)
183 if (m >= e)
return 0;
184 if (is_global_name_punct(*m)) {
187 else if (*m ==
'-') {
188 if (++m >= e)
return 0;
189 if (is_identchar(m, e, enc)) {
191 m += rb_enc_mbclen(m, e, enc);
199 }
while (m < e &&
ISDIGIT(*m));
201 return m == e ? mb + 1 : 0;
217rb_sym_constant_char_p(
const char *name,
long nlen,
rb_encoding *enc)
220 const char *end = name + nlen;
222 if (nlen < 1)
return FALSE;
224 c = rb_enc_precise_mbclen(name, end, enc);
230 if (ONIGENC_IS_UNICODE(enc)) {
231 static int ctype_titlecase = 0;
232 if (!ctype_titlecase) {
233 static const UChar cname[] =
"titlecaseletter";
234 static const UChar *
const end = cname +
sizeof(cname) - 1;
235 ctype_titlecase = ONIGENC_PROPERTY_NAME_TO_CTYPE(enc, cname, end);
241 OnigUChar fold[ONIGENC_GET_CASE_FOLD_CODES_MAX_NUM];
242 const OnigUChar *beg = (
const OnigUChar *)name;
243 int r = enc->mbc_case_fold(ONIGENC_CASE_FOLD,
244 &beg, (
const OnigUChar *)end,
246 if (r > 0 && (r !=
len || memcmp(fold, name, r)))
252#define IDSET_ATTRSET_FOR_SYNTAX ((1U<<ID_LOCAL)|(1U<<ID_CONST))
253#define IDSET_ATTRSET_FOR_INTERN (~(~0U<<(1<<ID_SCOPE_SHIFT)) & ~(1U<<ID_ATTRSET))
256 const enum { invalid, stophere, needmore, } kind;
257 const enum ruby_id_types type;
261#define t struct enc_synmane_type_leading_chars_tag
264enc_synmane_type_leading_chars(const char *name,
long len,
rb_encoding *enc,
int allowed_attrset)
266 const char *m = name;
267 const char *e = m +
len;
269 if (! rb_enc_asciicompat(enc)) {
270 return (t) { invalid, 0, 0, };
273 return (t) { invalid, 0, 0, };
275 else if (
len <= 0 ) {
276 return (t) { invalid, 0, 0, };
280 return (t) { invalid, 0, 0, };
283 if (is_special_global_name(++m, e, enc)) {
284 return (t) { stophere, ID_GLOBAL,
len, };
287 return (t) { needmore, ID_GLOBAL, 1, };
292 default:
return (t) { needmore, ID_INSTANCE, 1, };
293 case '@':
return (t) { needmore, ID_CLASS, 2, };
298 default:
return (t) { stophere, ID_JUNK, 1, };
299 case '<':
return (t) { stophere, ID_JUNK, 2, };
302 default:
return (t) { stophere, ID_JUNK, 2, };
303 case '>':
return (t) { stophere, ID_JUNK, 3, };
309 default:
return (t) { stophere, ID_JUNK, 1, };
310 case '>':
case '=':
return (t) { stophere, ID_JUNK, 2, };
315 default:
return (t) { invalid, 0, 1, };
316 case '~':
return (t) { stophere, ID_JUNK, 2, };
319 default:
return (t) { stophere, ID_JUNK, 2, };
320 case '=':
return (t) { stophere, ID_JUNK, 3, };
326 default:
return (t) { stophere, ID_JUNK, 1, };
327 case '*':
return (t) { stophere, ID_JUNK, 2, };
332 default:
return (t) { stophere, ID_JUNK, 1, };
333 case '@':
return (t) { stophere, ID_JUNK, 2, };
336 case '|':
case '^':
case '&':
case '/':
case '%':
case '~':
case '`':
337 return (t) { stophere, ID_JUNK, 1, };
341 default:
return (t) { needmore, ID_JUNK, 0, };
344 default:
return (t) { stophere, ID_JUNK, 2, };
345 case '=':
return (t) { stophere, ID_JUNK, 3, };
351 case '=':
case '~':
return (t) { stophere, ID_JUNK, 2, };
353 if (allowed_attrset & (1U << ID_JUNK)) {
354 return (t) { needmore, ID_JUNK, 1, };
357 return (t) { stophere, ID_JUNK, 1, };
362 if (rb_sym_constant_char_p(name,
len, enc)) {
363 return (t) { needmore, ID_CONST, 0, };
366 return (t) { needmore, ID_LOCAL, 0, };
373rb_enc_symname_type(
const char *name,
long len,
rb_encoding *enc,
unsigned int allowed_attrset)
376 enc_synmane_type_leading_chars(name,
len, enc, allowed_attrset);
377 const char *m = name + f.nread;
378 const char *e = name +
len;
379 int type = (int)f.type;
382 case invalid:
return -1;
383 case stophere:
break;
387 if (
len > 1 && *(e-1) ==
'=') {
388 type = rb_enc_symname_type(name,
len-1, enc, allowed_attrset);
389 if (allowed_attrset & (1U <<
type))
return ID_ATTRSET;
393 while (m < e && is_identchar(m, e, enc)) m += rb_enc_mbclen(m, e, enc);
397 if (
type == ID_GLOBAL ||
type == ID_CLASS ||
type == ID_INSTANCE)
return -1;
400 if (m + 1 < e || *m !=
'=')
break;
403 if (!(allowed_attrset & (1U <<
type)))
return -1;
410 return m == e ?
type : -1;
416 return rb_enc_symname_type(name,
len, enc, IDSET_ATTRSET_FOR_SYNTAX) != -1;
420rb_str_symname_type(
VALUE name,
unsigned int allowed_attrset)
423 long len = RSTRING_LEN(name);
424 int type = rb_enc_symname_type(ptr,
len, rb_enc_get(name), allowed_attrset);
433 size_t idx = num / ID_ENTRY_UNIT;
435 VALUE ary, ids = symbols->ids;
436 if (idx >= (
size_t)
RARRAY_LEN(ids) ||
NIL_P(ary = rb_ary_entry(ids, (
long)idx))) {
437 ary = rb_ary_hidden_new(ID_ENTRY_UNIT * ID_ENTRY_SIZE);
438 rb_ary_store(ids, (
long)idx, ary);
440 idx = (num % ID_ENTRY_UNIT) * ID_ENTRY_SIZE;
441 rb_ary_store(ary, (
long)idx + ID_ENTRY_STR, str);
442 rb_ary_store(ary, (
long)idx + ID_ENTRY_SYM, sym);
446get_id_serial_entry(rb_id_serial_t num,
ID id,
const enum id_entry_type t)
450 GLOBAL_SYMBOLS_ENTER(symbols);
452 if (num && num <= symbols->last_id) {
453 size_t idx = num / ID_ENTRY_UNIT;
454 VALUE ids = symbols->ids;
456 if (idx < (
size_t)
RARRAY_LEN(ids) && !
NIL_P(ary = rb_ary_entry(ids, (
long)idx))) {
457 long pos = (long)(num % ID_ENTRY_UNIT) * ID_ENTRY_SIZE;
458 result = rb_ary_entry(ary, pos + t);
463 else if (CHECK_ID_SERIAL) {
466 if (t != ID_ENTRY_SYM)
467 sym = rb_ary_entry(ary, pos + ID_ENTRY_SYM);
469 if (STATIC_SYM2ID(sym) !=
id) result = 0;
472 if (RSYMBOL(sym)->
id !=
id) result = 0;
479 GLOBAL_SYMBOLS_LEAVE();
485get_id_entry(
ID id,
const enum id_entry_type t)
487 return get_id_serial_entry(rb_id_to_serial(
id),
id, t);
491rb_static_id_valid_p(
ID id)
493 return STATIC_ID2SYM(
id) == get_id_entry(
id, ID_ENTRY_SYM);
497rb_id_serial_to_id(rb_id_serial_t num)
499 if (is_notop_id((
ID)num)) {
500 VALUE sym = get_id_serial_entry(num, 0, ID_ENTRY_SYM);
501 if (sym)
return SYM2ID(sym);
502 return ((
ID)num << ID_SCOPE_SHIFT) | ID_INTERNAL | ID_STATIC_SYM;
510register_sym_update_callback(st_data_t *key, st_data_t *value, st_data_t arg,
int existing)
513 rb_fatal(
"symbol :% "PRIsVALUE
" is already registered with %"PRIxVALUE,
526 st_update(symbols->str_sym, (st_data_t)str,
527 register_sym_update_callback, (st_data_t)sym);
530 st_add_direct(symbols->str_sym, (st_data_t)str, (st_data_t)sym);
535rb_free_static_symid_str(
void)
537 GLOBAL_SYMBOLS_ENTER(symbols)
539 st_free_table(symbols->str_sym);
541 GLOBAL_SYMBOLS_LEAVE();
549 st_data_t str_data = (st_data_t)str;
550 if (!st_delete(symbols->str_sym, &str_data, NULL)) {
551 rb_bug(
"%p can't remove str from str_id (%s)", (
void *)sym, RSTRING_PTR(str));
558 VALUE str = rb_enc_str_new(name,
len, enc);
559 return register_static_symid_str(
id, str);
563register_static_symid_str(
ID id,
VALUE str)
565 rb_id_serial_t num = rb_id_to_serial(
id);
566 VALUE sym = STATIC_ID2SYM(
id);
569 str = rb_fstring(str);
571 RUBY_DTRACE_CREATE_HOOK(SYMBOL, RSTRING_PTR(str));
573 GLOBAL_SYMBOLS_ENTER(symbols)
575 register_sym(symbols, str, sym);
576 set_id_entry(symbols, num, str, sym);
578 GLOBAL_SYMBOLS_LEAVE();
584sym_check_asciionly(
VALUE str)
586 if (!rb_enc_asciicompat(rb_enc_get(str)))
return FALSE;
590 rb_enc_name(rb_enc_get(str)), str);
605must_be_dynamic_symbol(
VALUE x)
612 rb_bug(
"wrong argument: %s (inappropriate Symbol)", RSTRING_PTR(str));
615 rb_bug(
"wrong argument: inappropriate Symbol (%p)", (
void *)x);
619 rb_bug(
"wrong argument type %s (expected Symbol)", rb_builtin_class_name(x));
633 rb_enc_set_index(dsym, rb_enc_to_index(enc));
636 RSYMBOL(dsym)->id =
type;
640 RSYMBOL(dsym)->hashval = RSHIFT((
long)hashval, 1);
641 register_sym(symbols, str, dsym);
642 rb_hash_aset(symbols->dsymbol_fstr_hash, str,
Qtrue);
643 RUBY_DTRACE_CREATE_HOOK(SYMBOL, RSTRING_PTR(RSYMBOL(dsym)->fstr));
653 if (UNLIKELY(rb_objspace_garbage_object_p(sym))) {
654 const VALUE fstr = RSYMBOL(sym)->fstr;
655 const ID type = RSYMBOL(sym)->id & ID_SCOPE_MASK;
656 RSYMBOL(sym)->fstr = 0;
657 unregister_sym(symbols, fstr, sym);
658 return dsymbol_alloc(symbols,
rb_cSymbol, fstr, rb_enc_get(fstr),
type);
666lookup_str_id(
VALUE str)
671 GLOBAL_SYMBOLS_ENTER(symbols);
673 found = st_lookup(symbols->str_sym, (st_data_t)str, &sym_data);
675 GLOBAL_SYMBOLS_LEAVE();
681 return STATIC_SYM2ID(sym);
684 ID id = RSYMBOL(sym)->id;
685 if (
id & ~ID_SCOPE_MASK)
return id;
688 rb_bug(
"non-symbol object %s:%"PRIxVALUE
" for %"PRIsVALUE
" in symbol table",
689 rb_builtin_class_name(sym), sym, str);
699 if (st_lookup(symbols->str_sym, (st_data_t)str, &sym_data)) {
702 sym = dsymbol_check(symbols, sym);
712lookup_str_sym(
const VALUE str)
716 GLOBAL_SYMBOLS_ENTER(symbols);
718 sym = lookup_str_sym_with_lock(symbols, str);
720 GLOBAL_SYMBOLS_LEAVE();
728 return get_id_entry(
id, ID_ENTRY_STR);
736 VALUE str = rb_setup_fake_str(&fake_str, name,
len, enc);
738 sym = lookup_str_sym(str);
740 str = rb_enc_str_new(name,
len, enc);
741 return intern_str(str, 1);
748 rb_id_serial_t next_serial = symbols->last_id + 1;
750 if (next_serial == 0) {
754 const size_t num = ++symbols->last_id;
755 id = num << ID_SCOPE_SHIFT;
765 GLOBAL_SYMBOLS_ENTER(symbols);
767 id = next_id_base_with_lock(symbols);
769 GLOBAL_SYMBOLS_LEAVE();
774intern_str(
VALUE str,
int mutable)
779 id = rb_str_symname_type(str, IDSET_ATTRSET_FOR_INTERN);
780 if (
id == (
ID)-1)
id = ID_JUNK;
781 if (sym_check_asciionly(str)) {
782 if (!
mutable) str = rb_str_dup(str);
783 rb_enc_associate(str, rb_usascii_encoding());
785 if ((nid = next_id_base()) == (
ID)-1) {
792 return register_static_symid_str(
id, str);
796rb_intern2(
const char *name,
long len)
798 return rb_intern3(name,
len, rb_usascii_encoding());
803rb_intern(
const char *name)
805 return rb_intern2(name, strlen(name));
811 VALUE sym = lookup_str_sym(str);
817 return intern_str(str, 0);
821rb_gc_free_dsymbol(
VALUE sym)
823 VALUE str = RSYMBOL(sym)->fstr;
826 RSYMBOL(sym)->fstr = 0;
828 GLOBAL_SYMBOLS_ENTER(symbols);
830 unregister_sym(symbols, str, sym);
831 rb_hash_delete_entry(symbols->dsymbol_fstr_hash, str);
833 GLOBAL_SYMBOLS_LEAVE();
862 GLOBAL_SYMBOLS_ENTER(symbols);
864 sym = lookup_str_sym_with_lock(symbols, str);
869 else if (USE_SYMBOL_GC) {
872 if (enc != ascii && sym_check_asciionly(str)) {
873 str = rb_str_dup(str);
874 rb_enc_associate(str, ascii);
879 str = rb_str_dup(str);
882 str = rb_fstring(str);
883 int type = rb_str_symname_type(str, IDSET_ATTRSET_FOR_INTERN);
888 ID id = intern_str(str, 0);
892 GLOBAL_SYMBOLS_LEAVE();
901 id = STATIC_SYM2ID(sym);
904 GLOBAL_SYMBOLS_ENTER(symbols);
906 sym = dsymbol_check(symbols, sym);
907 id = RSYMBOL(sym)->id;
909 if (UNLIKELY(!(
id & ~ID_SCOPE_MASK))) {
910 VALUE fstr = RSYMBOL(sym)->fstr;
911 ID num = next_id_base_with_lock(symbols);
913 RSYMBOL(sym)->id =
id |= num;
916 set_id_entry(symbols, rb_id_to_serial(num), fstr, sym);
917 rb_hash_delete_entry(symbols->dsymbol_fstr_hash, fstr);
920 GLOBAL_SYMBOLS_LEAVE();
923 rb_raise(
rb_eTypeError,
"wrong argument type %s (expected Symbol)",
924 rb_builtin_class_name(sym));
933 if (!DYNAMIC_ID_P(x))
return STATIC_ID2SYM(x);
934 return get_id_entry(x, ID_ENTRY_SYM);
953 return RSYMBOL(sym)->fstr;
956 return rb_id2str(STATIC_SYM2ID(sym));
963 return lookup_id_str(
id);
969 VALUE str = rb_id2str(
id);
972 return RSTRING_PTR(str);
976rb_make_internal_id(
void)
978 return next_id_base() | ID_INTERNAL | ID_STATIC_SYM;
982rb_make_temporary_id(
size_t n)
984 const ID max_id = RB_ID_SERIAL_MAX & ~0xffff;
985 const ID id = max_id - (
ID)n;
986 if (
id <= ruby_global_symbols.last_id) {
989 return (
id << ID_SCOPE_SHIFT) | ID_STATIC_SYM | ID_INTERNAL;
993symbols_i(st_data_t key, st_data_t value, st_data_t arg)
999 rb_ary_push(ary, sym);
1003 rb_bug(
"invalid symbol: %s", RSTRING_PTR((
VALUE)key));
1005 else if (!SYMBOL_PINNED_P(sym) && rb_objspace_garbage_object_p(sym)) {
1006 RSYMBOL(sym)->fstr = 0;
1010 rb_ary_push(ary, sym);
1021 GLOBAL_SYMBOLS_ENTER(symbols);
1024 st_foreach(symbols->str_sym, symbols_i, ary);
1026 GLOBAL_SYMBOLS_LEAVE();
1032rb_sym_immortal_count(
void)
1034 return (
size_t)ruby_global_symbols.last_id;
1040 return is_const_id(
id);
1046 return is_class_id(
id);
1052 return is_global_id(
id);
1058 return is_instance_id(
id);
1064 return is_attrset_id(
id);
1070 return is_local_id(
id);
1076 return is_junk_id(
id);
1080rb_is_const_sym(
VALUE sym)
1082 return is_const_sym(sym);
1086rb_is_attrset_sym(
VALUE sym)
1088 return is_attrset_sym(sym);
1095 VALUE name = *namep;
1098 return STATIC_SYM2ID(name);
1101 if (SYMBOL_PINNED_P(name)) {
1102 return RSYMBOL(name)->id;
1105 *namep = RSYMBOL(name)->fstr;
1109 else if (!RB_TYPE_P(name,
T_STRING)) {
1112 rb_raise(
rb_eTypeError,
"%+"PRIsVALUE
" is not a symbol nor a string",
1119 sym_check_asciionly(name);
1121 return lookup_str_id(name);
1126rb_get_symbol_id(
VALUE name)
1129 return STATIC_SYM2ID(name);
1132 if (SYMBOL_PINNED_P(name)) {
1133 return RSYMBOL(name)->id;
1141 return lookup_str_id(name);
1151 VALUE name = *namep;
1157 if (!SYMBOL_PINNED_P(name)) {
1158 GLOBAL_SYMBOLS_ENTER(symbols);
1160 name = dsymbol_check(symbols, name);
1162 GLOBAL_SYMBOLS_LEAVE();
1168 else if (!RB_TYPE_P(name,
T_STRING)) {
1171 rb_raise(
rb_eTypeError,
"%+"PRIsVALUE
" is not a symbol nor a string",
1178 sym_check_asciionly(name);
1180 if ((sym = lookup_str_sym(name)) != 0) {
1191 const VALUE name = rb_setup_fake_str(&fake_str,
ptr,
len, enc);
1193 sym_check_asciionly(name);
1195 return lookup_str_id(name);
1203 const VALUE name = rb_setup_fake_str(&fake_str,
ptr,
len, enc);
1205 sym_check_asciionly(name);
1207 if ((sym = lookup_str_sym(name)) != 0) {
1214#undef rb_sym_intern_ascii_cstr
1219FUNC_MINIMIZED(
VALUE rb_sym_intern_ascii(
const char *
ptr,
long len));
1220FUNC_MINIMIZED(
VALUE rb_sym_intern_ascii_cstr(
const char *
ptr));
1227 const VALUE name = rb_setup_fake_str(&fake_str,
ptr,
len, enc);
1228 return rb_str_intern(name);
1232rb_sym_intern_ascii(
const char *
ptr,
long len)
1234 return rb_sym_intern(
ptr,
len, rb_usascii_encoding());
1238rb_sym_intern_ascii_cstr(
const char *
ptr)
1240 return rb_sym_intern_ascii(
ptr, strlen(
ptr));
1244rb_to_symbol_type(
VALUE obj)
1246 return rb_convert_type_with_id(obj,
T_SYMBOL,
"Symbol", idTo_sym);
1250rb_is_const_name(
VALUE name)
1252 return rb_str_symname_type(name, 0) == ID_CONST;
1256rb_is_class_name(
VALUE name)
1258 return rb_str_symname_type(name, 0) == ID_CLASS;
1262rb_is_instance_name(
VALUE name)
1264 return rb_str_symname_type(name, 0) == ID_INSTANCE;
1268rb_is_local_name(
VALUE name)
1270 return rb_str_symname_type(name, 0) == ID_LOCAL;
1273#include "id_table.c"
1274#include "symbol.rbinc"
#define RUBY_ASSERT_ALWAYS(expr)
A variant of RUBY_ASSERT that does not interface with RUBY_DEBUG.
static bool rb_enc_isupper(OnigCodePoint c, rb_encoding *enc)
Identical to rb_isupper(), except it additionally takes an encoding.
static bool rb_enc_isctype(OnigCodePoint c, OnigCtype t, rb_encoding *enc)
Queries if the passed code point is of passed character type in the passed encoding.
static bool rb_enc_islower(OnigCodePoint c, rb_encoding *enc)
Identical to rb_islower(), except it additionally takes an encoding.
#define ENC_CODERANGE_7BIT
Old name of RUBY_ENC_CODERANGE_7BIT.
#define T_STRING
Old name of RUBY_T_STRING.
#define ISUPPER
Old name of rb_isupper.
#define ID2SYM
Old name of RB_ID2SYM.
#define OBJ_FREEZE
Old name of RB_OBJ_FREEZE.
#define SYM2ID
Old name of RB_SYM2ID.
#define ISDIGIT
Old name of rb_isdigit.
#define STATIC_SYM_P
Old name of RB_STATIC_SYM_P.
#define MBCLEN_CHARFOUND_LEN(ret)
Old name of ONIGENC_MBCLEN_CHARFOUND_LEN.
#define ISALPHA
Old name of rb_isalpha.
#define ISASCII
Old name of rb_isascii.
#define Qtrue
Old name of RUBY_Qtrue.
#define DYNAMIC_SYM_P
Old name of RB_DYNAMIC_SYM_P.
#define Qnil
Old name of RUBY_Qnil.
#define Qfalse
Old name of RUBY_Qfalse.
#define ENC_CODERANGE_BROKEN
Old name of RUBY_ENC_CODERANGE_BROKEN.
#define NIL_P
Old name of RB_NIL_P.
#define MBCLEN_CHARFOUND_P(ret)
Old name of ONIGENC_MBCLEN_CHARFOUND_P.
#define FL_WB_PROTECTED
Old name of RUBY_FL_WB_PROTECTED.
#define T_SYMBOL
Old name of RUBY_T_SYMBOL.
#define rb_ary_new2
Old name of rb_ary_new_capa.
#define ISALNUM
Old name of rb_isalnum.
void rb_name_error(ID id, const char *fmt,...)
Raises an instance of rb_eNameError.
VALUE rb_eTypeError
TypeError exception.
void rb_name_error_str(VALUE str, const char *fmt,...)
Identical to rb_name_error(), except it takes a VALUE instead of ID.
VALUE rb_eRuntimeError
RuntimeError exception.
VALUE rb_eEncodingError
EncodingError exception.
VALUE rb_cSymbol
Symbol class.
#define RB_OBJ_WRITE(old, slot, young)
Declaration of a "back" pointer.
static OnigCodePoint rb_enc_mbc_to_codepoint(const char *p, const char *e, rb_encoding *enc)
Identical to rb_enc_codepoint(), except it assumes the passed character is not broken.
int rb_enc_str_coderange(VALUE str)
Scans the passed string to collect its code range.
int rb_enc_symname_p(const char *str, rb_encoding *enc)
Identical to rb_symname_p(), except it additionally takes an encoding.
VALUE rb_check_symbol_cstr(const char *ptr, long len, rb_encoding *enc)
Identical to rb_check_id_cstr(), except for the return type.
int rb_enc_symname2_p(const char *name, long len, rb_encoding *enc)
Identical to rb_enc_symname_p(), except it additionally takes the passed string's length.
ID rb_check_id_cstr(const char *ptr, long len, rb_encoding *enc)
Identical to rb_check_id(), except it takes a pointer to a memory region instead of Ruby's string.
VALUE rb_sym_all_symbols(void)
Collects every single bits of symbols that have ever interned in the entire history of the current pr...
int rb_is_global_id(ID id)
Classifies the given ID, then sees if it is a global variable.
int rb_is_instance_id(ID id)
Classifies the given ID, then sees if it is an instance variable.
int rb_is_const_id(ID id)
Classifies the given ID, then sees if it is a constant.
int rb_is_junk_id(ID)
Classifies the given ID, then sees if it is a junk ID.
int rb_symname_p(const char *str)
Sees if the passed C string constructs a valid syntactic symbol.
int rb_is_class_id(ID id)
Classifies the given ID, then sees if it is a class variable.
int rb_is_attrset_id(ID id)
Classifies the given ID, then sees if it is an attribute writer.
int rb_is_local_id(ID id)
Classifies the given ID, then sees if it is a local variable.
int rb_str_hash_cmp(VALUE str1, VALUE str2)
Compares two strings.
VALUE rb_str_ellipsize(VALUE str, long len)
Shortens str and adds three dots, an ellipsis, if it is longer than len characters.
st_index_t rb_str_hash(VALUE str)
Calculates a hash value of a string.
VALUE rb_check_string_type(VALUE obj)
Try converting an object to its stringised representation using its to_str method,...
VALUE rb_check_symbol(volatile VALUE *namep)
Identical to rb_check_id(), except it returns an instance of rb_cSymbol instead.
ID rb_check_id(volatile VALUE *namep)
Detects if the given name is already interned or not.
VALUE rb_sym2str(VALUE id)
Identical to rb_id2str(), except it takes an instance of rb_cSymbol rather than an ID.
ID rb_sym2id(VALUE obj)
Converts an instance of rb_cSymbol into an ID.
int len
Length of the buffer.
#define RB_GC_GUARD(v)
Prevents premature destruction of local objects.
VALUE type(ANYARGS)
ANYARGS-ed function type.
#define RARRAY_LEN
Just another name of rb_array_len.
#define StringValuePtr(v)
Identical to StringValue, except it returns a char*.
@ RUBY_SPECIAL_SHIFT
Least significant 8 bits are reserved.
char * ptr
Pointer to the contents of the string.
uintptr_t ID
Type that represents a Ruby identifier such as a variable name.
uintptr_t VALUE
Type that represents a Ruby object.