108 res->
path = arg.path;
195 rb_bug(
"class path is not set properly");
236 const char *s =
"Class";
250 path =
rb_sprintf(
"#<%s:%p>", s, (
void*)klass);
253 cache_path(klass, tmp_classpath, path);
342 if (path[0] ==
'#') {
347 while (*p && *p !=
':') p++;
350 if (p[1] !=
':')
goto undefined_class;
357 (
int)(p-path), pathname);
401 #define global_variable rb_global_variable
402 #define global_entry rb_global_entry
404 #define gvar_getter_t rb_gvar_getter_t
405 #define gvar_setter_t rb_gvar_setter_t
406 #define gvar_marker_t rb_gvar_marker_t
425 #define undef_getter rb_gvar_undef_getter
426 #define undef_setter rb_gvar_undef_setter
427 #define undef_marker rb_gvar_undef_marker
429 #define val_getter rb_gvar_val_getter
430 #define val_setter rb_gvar_val_setter
431 #define val_marker rb_gvar_val_marker
433 #define var_getter rb_gvar_var_getter
434 #define var_setter rb_gvar_var_setter
435 #define var_marker rb_gvar_var_marker
437 #define readonly_setter rb_gvar_readonly_setter
482 var->
data = (
void*)val;
499 var->
data = (
void*)val;
513 if (!var)
return Qnil;
520 *(
VALUE *)data = val;
563 if (name[0] ==
'$')
id =
rb_intern(name);
565 size_t len =
strlen(name);
568 memcpy(buf+1, name, len);
585 gvar->
data = (
void*)var;
664 trace->
next = entry->var->trace;
668 entry->var->trace = trace;
682 while (trace->
next) {
724 trace = (entry = (
struct global_entry *)data)->var->trace;
740 if (trace->
data == cmd) {
755 return (*var->
getter)(entry->id, var->
data, var);
792 (*var->
setter)(val, entry->id, var->
data, var);
855 for (i = 1; i <= 9; ++
i) {
856 buf[1] = (char)(i +
'0');
877 else if ((entry1 = (
struct global_entry *)data1)->var != entry2->var) {
896 entry2->var->counter++;
897 entry1->var = entry2->var;
909 if (!generic_iv_tbl)
return 0;
919 if (generic_iv_tbl) {
940 special_generic_ivar = 1;
942 if (!generic_iv_tbl) {
961 if (!generic_iv_tbl)
return Qfalse;
977 if (!generic_iv_tbl)
return 0;
994 if (!generic_iv_tbl)
return;
1022 if (!generic_iv_tbl)
return;
1023 if (special_generic_ivar == 0)
return;
1032 if (!generic_iv_tbl)
return;
1033 if (
st_delete(generic_iv_tbl, &key, &tbl))
1051 if (!generic_iv_tbl)
return;
1091 if (!iv_index_tbl)
break;
1093 if (len <= (
long)index)
break;
1101 return (
VALUE)index;
1142 if (!iv_index_tbl) {
1145 if (!iv_index_tbl) {
1156 if (len <= (
long)index) {
1167 long newsize = (index+1) + (index+1)/4;
1168 if (!ivar_extended &&
1176 ROBJECT(obj)->as.heap.ivptr = newptr;
1180 newptr =
ROBJECT(obj)->as.heap.ivptr;
1182 for (; len < newsize; len++)
1184 ROBJECT(obj)->as.heap.numiv = newsize;
1185 ROBJECT(obj)->as.heap.iv_index_tbl = iv_index_tbl;
1213 if (!iv_index_tbl)
break;
1247 return (data->
func)((
ID)key, val, data->
arg);
1286 if (!generic_iv_tbl)
break;
1308 for (i = count = 0; i < num; ++
i) {
1309 if (ivptr[i] !=
Qundef) {
1324 if (!generic_iv_tbl)
break;
1430 if (!iv_index_tbl)
break;
1550 #define check_autoload_table(av) \
1551 (struct st_table *)rb_check_typeddata((av), &autoload_data_type)
1600 #define check_autoload_data(av) \
1601 (struct autoload_data_i *)rb_check_typeddata((av), &autoload_data_i_type)
1615 if (!file || !*file) {
1670 const char **
p = (
const char **)arg;
1686 const char *loading;
1703 if (loadingpath && loading) {
1704 *loadingpath = loading;
1722 *value = ele->
value;
1768 const char *loading = 0, *src;
1774 if (!load)
return Qfalse;
1776 if (src && loading && strcmp(src, loading) == 0)
return Qfalse;
1792 if (
RTEST(result)) {
1794 if (ele->value !=
Qundef) {
1799 args.
value = ele->value;
1817 if (!mod)
return Qnil;
1820 if (!load)
return Qnil;
1827 VALUE value, tmp, av;
1832 while (
RTEST(tmp)) {
1843 if (am == tmp)
break;
1855 if (!recurse)
break;
2057 if (
RTEST(inherit)) {
2085 if (!recurse)
break;
2176 visibility = ce->
flag;
2184 "previous definition of %"PRIsVALUE
" was here", name);
2207 rb_warn(
"rb_define_const: invalid name `%s' for constant", name);
2230 "Insecure: can't change constant visibility");
2238 for (i = 0; i <
argc; i++) {
2316 #define CVAR_FOREACH_ANCESTORS(klass, v, r) \
2317 for (klass = cvar_front_klass(klass); klass; klass = RCLASS_SUPER(klass)) { \
2318 if (cvar_lookup_at(klass, id, (v))) { \
2323 #define CVAR_LOOKUP(v,r) do {\
2324 if (cvar_lookup_at(klass, id, (v))) {r;}\
2325 CVAR_FOREACH_ANCESTORS(klass, v, r);\
2331 VALUE tmp, front = 0, target = 0;
2334 CVAR_LOOKUP(0, {
if (!front) front = klass; target = klass;});
2336 if (front && target != front) {
2364 VALUE tmp, front = 0, target = 0;
2368 CVAR_LOOKUP(&value, {
if (!front) front = klass; target = klass;});
2373 if (front && target != front) {
2385 return (
VALUE)value;
2391 if (!klass)
return Qfalse;
2520 if (
RTEST(inherit)) {
void rb_mark_generic_ivar(VALUE obj)
#define RB_TYPE_P(obj, type)
static VALUE classname(VALUE klass, int *permanent)
Returns +classpath+ of klass, if it is named, or +nil+ for anonymous +class+/+module+.
static int givar_mark_i(st_data_t k, st_data_t v, st_data_t a)
void rb_define_hooked_variable(const char *name, VALUE *var, VALUE(*getter)(ANYARGS), void(*setter)(ANYARGS))
void rb_set_class_path_string(VALUE klass, VALUE under, VALUE name)
NORETURN(static void uninitialized_constant(VALUE, ID))
static VALUE rb_const_get_0(VALUE klass, ID id, int exclude, int recurse, int visibility)
static VALUE cvar_list(void *data)
static int rb_special_const_p(VALUE obj)
void rb_bug(const char *fmt,...)
VALUE rb_require_safe(VALUE, int)
void rb_mark_tbl(struct st_table *)
int rb_is_class_name(VALUE name)
RUBY_EXTERN VALUE rb_cModule
size_t strlen(const char *)
VALUE rb_mod_const_missing(VALUE klass, VALUE name)
void * rb_mod_const_at(VALUE mod, void *data)
static void uninitialized_constant(VALUE klass, ID id)
VALUE rb_mod_class_variables(int argc, VALUE *argv, VALUE mod)
VALUE rb_eval_cmd(VALUE, VALUE, int)
VALUE rb_f_global_variables(void)
static VALUE generic_ivar_defined(VALUE obj, ID id)
int st_lookup(st_table *, st_data_t, st_data_t *)
void st_add_direct(st_table *, st_data_t, st_data_t)
static int autoload_defined_p(VALUE mod, ID id)
static st_table * generic_iv_tbl
void rb_define_const(VALUE klass, const char *name, VALUE val)
static int cv_i(st_data_t k, st_data_t v, st_data_t a)
void rb_define_variable(const char *name, VALUE *var)
st_table * st_init_numtable(void)
VALUE rb_ivar_defined(VALUE obj, ID id)
static VALUE autoload_require(VALUE arg)
static void remove_trace(struct global_variable *var)
void rb_error_frozen(const char *what)
static VALUE rb_tmp_class_path(VALUE klass, int *permanent, path_cache_func cache_path)
#define rb_check_frozen(obj)
VALUE(* path_cache_func)(VALUE obj, ID id, VALUE val)
#define ROBJECT_EMBED_LEN_MAX
VALUE rb_str_new_cstr(const char *)
static VALUE find_class_path(VALUE klass, ID preferred)
Traverse constant namespace and find +classpath+ for klass.
ID rb_frame_this_func(void)
void rb_autoload(VALUE mod, ID id, const char *file)
void rb_vm_inc_const_missing_count(void)
VALUE rb_autoload_p(VALUE mod, ID id)
void rb_define_virtual_variable(const char *name, VALUE(*getter)(ANYARGS), void(*setter)(ANYARGS))
VALUE rb_ary_push(VALUE ary, VALUE item)
static int cvar_lookup_at(VALUE klass, ID id, st_data_t *v)
VALUE rb_ivar_get(VALUE obj, ID id)
static VALUE trace_en(struct global_variable *var)
VALUE rb_const_list(void *data)
void rb_define_global_const(const char *name, VALUE val)
const char * rb_class2name(VALUE klass)
#define check_autoload_table(av)
VALUE rb_public_const_get_at(VALUE klass, ID id)
VALUE rb_mod_remove_const(VALUE mod, VALUE name)
static int obj_ivar_i(st_data_t key, st_data_t index, st_data_t arg)
void rb_gc_mark_global_tbl(void)
static VALUE cvar_front_klass(VALUE klass)
VALUE rb_protect(VALUE(*proc)(VALUE), VALUE data, int *state)
static int givar_i(st_data_t k, st_data_t v, st_data_t a)
VALUE rb_funcall(VALUE, ID, int,...)
Calls a method.
VALUE rb_mod_name(VALUE mod)
VALUE rb_cv_get(VALUE klass, const char *name)
void rb_raise(VALUE exc, const char *fmt,...)
VALUE rb_obj_class(VALUE)
static VALUE autoload_const_set(VALUE arg)
void rb_compile_warn(const char *file, int line, const char *fmt,...)
VALUE rb_path2class(const char *path)
size_t st_memsize(const st_table *)
int rb_public_const_defined(VALUE klass, ID id)
VALUE rb_ary_new3(long n,...)
static VALUE autoload_provided(VALUE arg)
static void set_const_visibility(VALUE mod, int argc, VALUE *argv, rb_const_flag_t flag)
static int special_generic_ivar
#define check_autoload_data(av)
VALUE rb_const_get(VALUE klass, ID id)
int rb_public_const_defined_at(VALUE klass, ID id)
VALUE rb_public_const_get(VALUE klass, ID id)
void rb_vm_change_state(void)
ID rb_check_id(volatile VALUE *namep)
Returns ID for the given name if it is interned already, or 0.
ID rb_check_id_cstr(const char *ptr, long len, rb_encoding *enc)
int(* func)(ID key, VALUE val, st_data_t arg)
VALUE rb_str_append(VALUE, VALUE)
VALUE rb_str_new_frozen(VALUE)
VALUE rb_gvar_set(struct global_entry *entry, VALUE val)
static void rb_trace_eval(VALUE cmd, VALUE val)
void rb_name_error_str(VALUE str, const char *fmt,...)
RUBY_FUNC_EXPORTED size_t rb_generic_ivar_memsize(VALUE obj)
void rb_name_error(ID id, const char *fmt,...)
VALUE rb_autoload_load(VALUE mod, ID id)
#define CVAR_LOOKUP(v, r)
int rb_feature_provided(const char *, const char **)
static int list_i(st_data_t key, st_data_t value, VALUE ary)
void st_foreach_safe(struct st_table *, int(*)(ANYARGS), st_data_t)
int st_delete(st_table *, st_data_t *, st_data_t *)
int rb_is_const_id(ID id)
int rb_is_instance_id(ID id)
VALUE rb_cvar_defined(VALUE klass, ID id)
void rb_const_set(VALUE klass, ID id, VALUE val)
static void autoload_free(void *ptr)
VALUE rb_block_proc(void)
static void autoload_delete(VALUE mod, ID id)
void rb_define_readonly_variable(const char *name, VALUE *var)
static int cv_list_i(st_data_t key, st_data_t value, VALUE ary)
VALUE rb_class_path(VALUE klass)
#define rb_intern_str(string)
VALUE rb_gvar_get(struct global_entry *entry)
VALUE rb_f_untrace_var(int argc, VALUE *argv)
VALUE rb_mod_constants(int argc, VALUE *argv, VALUE mod)
void(* func)(VALUE arg, VALUE val)
VALUE rb_str_cat2(VALUE, const char *)
const char * rb_obj_classname(VALUE obj)
static VALUE generic_ivar_get(VALUE obj, ID id, int warn)
#define TypedData_Wrap_Struct(klass, data_type, sval)
VALUE rb_gv_get(const char *name)
void rb_cv_set(VALUE klass, const char *name, VALUE val)
#define RUBY_FUNC_EXPORTED
int rb_const_defined(VALUE klass, ID id)
void rb_set_class_path(VALUE klass, VALUE under, const char *name)
static ID global_id(const char *name)
#define ALLOCA_N(type, n)
VALUE rb_f_trace_var(int argc, VALUE *argv)
VALUE rb_ivar_set(VALUE obj, ID id, VALUE val)
int rb_public_const_defined_from(VALUE klass, ID id)
VALUE rb_class_name(VALUE klass)
int st_foreach(st_table *, int(*)(ANYARGS), st_data_t)
static void * mod_cvar_at(VALUE mod, void *data)
SSL_METHOD *(* func)(void)
VALUE rb_thread_current(void)
int rb_const_defined_at(VALUE klass, ID id)
VALUE rb_sprintf(const char *format,...)
static void * mod_cvar_of(VALUE mod, void *data)
VALUE rb_attr_get(VALUE obj, ID id)
#define CONST_ID(var, str)
VALUE rb_obj_remove_instance_variable(VALUE obj, VALUE name)
st_table * rb_generic_ivar_table(VALUE obj)
VALUE rb_mod_public_constant(int argc, VALUE *argv, VALUE obj)
void Init_var_tables(void)
int rb_scan_args(int argc, const VALUE *argv, const char *fmt,...)
unsigned char buf[MIME_BUF_SIZE]
VALUE rb_const_get_at(VALUE klass, ID id)
static int ivar_i(st_data_t k, st_data_t v, st_data_t a)
static VALUE const_missing(VALUE klass, ID id)
int rb_autoloading_value(VALUE mod, ID id, VALUE *value)
VALUE rb_obj_frozen_p(VALUE)
void rb_set_safe_level_force(int)
VALUE rb_public_const_get_from(VALUE klass, ID id)
VALUE rb_gvar_defined(struct global_entry *entry)
static int generic_ivar_remove(VALUE obj, ID id, st_data_t *valp)
VALUE rb_ensure(VALUE(*b_proc)(ANYARGS), VALUE data1, VALUE(*e_proc)(ANYARGS), VALUE data2)
static const rb_data_type_t autoload_data_i_type
static int sv_i(st_data_t k, st_data_t v, st_data_t a)
void rb_jump_tag(int tag)
static void generic_ivar_set(VALUE obj, ID id, VALUE val)
void rb_define_class_variable(VALUE klass, const char *name, VALUE val)
void rb_gc_mark_maybe(VALUE)
#define RCLASS_CONST_TBL(c)
VALUE rb_mod_private_constant(int argc, VALUE *argv, VALUE obj)
#define MEMCPY(p1, p2, type, n)
VALUE rb_obj_instance_variables(VALUE obj)
static VALUE autoload_data(VALUE mod, ID id)
int rb_is_const_name(VALUE name)
rb_encoding * rb_enc_get(VALUE obj)
static VALUE trace_ev(struct trace_data *data)
st_index_t rb_ivar_count(VALUE obj)
void rb_name_class(VALUE klass, ID id)
struct global_entry * rb_global_entry(ID id)
void rb_ivar_foreach(VALUE obj, int(*func)(ANYARGS), st_data_t arg)
VALUE rb_iv_set(VALUE obj, const char *name, VALUE val)
VALUE rb_iv_get(VALUE obj, const char *name)
VALUE rb_cvar_get(VALUE klass, ID id)
VALUE rb_gv_set(const char *name, VALUE val)
VALUE rb_path_to_class(VALUE pathname)
static const rb_data_type_t autoload_data_type
VALUE rb_const_get_from(VALUE klass, ID id)
static void autoload_i_free(void *ptr)
RUBY_EXTERN VALUE rb_cObject
static VALUE fc_path(struct fc_result *fc, ID name)
struct rb_encoding_entry * list
void rb_alias_variable(ID name1, ID name2)
static int fc_i(st_data_t k, st_data_t v, st_data_t a)
static VALUE null_cache(VALUE obj, ID id, VALUE val)
void rb_cvar_set(VALUE klass, ID id, VALUE val)
int st_insert(st_table *, st_data_t, st_data_t)
static int rb_const_defined_0(VALUE klass, ID id, int exclude, int recurse, int visibility)
VALUE rb_ary_new2(long capa)
static int mark_global_entry(st_data_t k, st_data_t v, st_data_t a)
int rb_is_class_id(ID id)
VALUE rb_mod_remove_cvar(VALUE mod, VALUE name)
#define RCLASS_IV_INDEX_TBL(c)
static VALUE reset_safe(VALUE safe)
static size_t autoload_memsize(const void *ptr)
#define rb_enc_asciicompat(enc)
static VALUE check_autoload_required(VALUE mod, ID id, const char **loadingpath)
int rb_is_instance_name(VALUE name)
static void autoload_i_mark(void *ptr)
VALUE rb_class_real(VALUE)
static int gvar_i(st_data_t k, st_data_t v, st_data_t a)
static size_t autoload_i_memsize(const void *ptr)
void rb_warning(const char *fmt,...)
#define ROBJECT_IV_INDEX_TBL(o)
st_table * st_copy(st_table *)
static void obj_ivar_each(VALUE obj, int(*func)(ANYARGS), st_data_t arg)
VALUE rb_class_path_no_cache(VALUE klass)
static VALUE ivar_get(VALUE obj, ID id, int warn)
#define SPECIAL_CONST_P(x)
ID rb_intern2(const char *name, long len)
static VALUE original_module(VALUE c)
void * rb_mod_const_of(VALUE mod, void *data)
#define REALLOC_N(var, type, n)
void rb_mark_generic_ivar_tbl(void)
VALUE rb_const_remove(VALUE mod, ID id)
void rb_clear_cache_by_class(VALUE)
void rb_warn(const char *fmt,...)
static void autoload_mark(void *ptr)
static void check_before_mod_set(VALUE klass, ID id, VALUE val, const char *dest)
void st_free_table(st_table *)
void rb_free_generic_ivar(VALUE obj)
void rb_copy_generic_ivar(VALUE clone, VALUE obj)
int rb_const_defined_from(VALUE klass, ID id)
VALUE rb_sourcefilename(void)