108 res->
path = arg.path;
190 rb_bug(
"class path is not set properly");
231 const char *
s =
"Class";
245 path =
rb_sprintf(
"#<%s:%p>", s, (
void*)klass);
248 cache_path(klass, tmp_classpath, path);
337 if (path[0] ==
'#') {
342 while (*p && *p !=
':') p++;
345 if (p[1] !=
':')
goto undefined_class;
352 (
int)(p-path), pathname);
396 #define global_variable rb_global_variable
397 #define global_entry rb_global_entry
399 #define gvar_getter_t rb_gvar_getter_t
400 #define gvar_setter_t rb_gvar_setter_t
401 #define gvar_marker_t rb_gvar_marker_t
420 #define undef_getter rb_gvar_undef_getter
421 #define undef_setter rb_gvar_undef_setter
422 #define undef_marker rb_gvar_undef_marker
424 #define val_getter rb_gvar_val_getter
425 #define val_setter rb_gvar_val_setter
426 #define val_marker rb_gvar_val_marker
428 #define var_getter rb_gvar_var_getter
429 #define var_setter rb_gvar_var_setter
430 #define var_marker rb_gvar_var_marker
432 #define readonly_setter rb_gvar_readonly_setter
477 var->
data = (
void*)val;
494 var->
data = (
void*)val;
508 if (!var)
return Qnil;
515 *(
VALUE *)data = val;
558 if (name[0] ==
'$')
id =
rb_intern(name);
580 gvar->
data = (
void*)var;
659 trace->
next = entry->var->trace;
663 entry->var->trace = trace;
677 while (trace->
next) {
719 trace = (entry = (
struct global_entry *)data)->var->trace;
735 if (trace->
data == cmd) {
787 (*var->
setter)(val, entry->id, var->
data, var);
850 for (i = 1; i <= 9; ++
i) {
851 buf[1] = (char)(i +
'0');
872 else if ((entry1 = (
struct global_entry *)data1)->var != entry2->var) {
891 entry2->var->counter++;
892 entry1->var = entry2->var;
904 if (!generic_iv_tbl)
return 0;
914 if (generic_iv_tbl) {
935 special_generic_ivar = 1;
937 if (!generic_iv_tbl) {
956 if (!generic_iv_tbl)
return Qfalse;
972 if (!generic_iv_tbl)
return 0;
989 if (!generic_iv_tbl)
return;
1017 if (!generic_iv_tbl)
return;
1018 if (special_generic_ivar == 0)
return;
1027 if (!generic_iv_tbl)
return;
1046 if (!generic_iv_tbl)
return;
1086 if (!iv_index_tbl)
break;
1088 if (len <= (
long)index)
break;
1137 if (!iv_index_tbl) {
1140 if (!iv_index_tbl) {
1151 if (len <= (
long)index) {
1162 long newsize = (index+1) + (index+1)/4;
1163 if (!ivar_extended &&
1171 ROBJECT(obj)->as.heap.ivptr = newptr;
1175 newptr =
ROBJECT(obj)->as.heap.ivptr;
1177 for (; len < newsize; len++)
1179 ROBJECT(obj)->as.heap.numiv = newsize;
1180 ROBJECT(obj)->as.heap.iv_index_tbl = iv_index_tbl;
1208 if (!iv_index_tbl)
break;
1242 return (data->
func)((
ID)key, val, data->
arg);
1281 if (!generic_iv_tbl)
break;
1303 for (i = count = 0; i < num; ++
i) {
1304 if (ivptr[i] !=
Qundef) {
1319 if (!generic_iv_tbl)
break;
1425 if (!iv_index_tbl)
break;
1545 #define check_autoload_table(av) \
1546 (struct st_table *)rb_check_typeddata((av), &autoload_data_type)
1595 #define check_autoload_data(av) \
1596 (struct autoload_data_i *)rb_check_typeddata((av), &autoload_data_i_type)
1610 if (!file || !*file) {
1665 const char **
p = (
const char **)arg;
1681 const char *loading;
1698 if (loadingpath && loading) {
1699 *loadingpath = loading;
1717 *value = ele->
value;
1763 const char *loading = 0, *
src;
1769 if (!load)
return Qfalse;
1771 if (
src && loading && strcmp(
src, loading) == 0)
return Qfalse;
1787 if (
RTEST(result)) {
1789 if (ele->value !=
Qundef) {
1794 args.
value = ele->value;
1812 if (!mod)
return Qnil;
1815 if (!load)
return Qnil;
1827 while (
RTEST(tmp)) {
1838 if (am == tmp)
break;
1850 if (!recurse)
break;
2052 if (
RTEST(inherit)) {
2080 if (!recurse)
break;
2171 visibility = ce->
flag;
2179 "previous definition of %"PRIsVALUE
" was here", name);
2202 rb_warn(
"rb_define_const: invalid name `%s' for constant", name);
2225 "Insecure: can't change constant visibility");
2233 for (i = 0; i <
argc; i++) {
2311 #define CVAR_FOREACH_ANCESTORS(klass, v, r) \
2312 for (klass = cvar_front_klass(klass); klass; klass = RCLASS_SUPER(klass)) { \
2313 if (cvar_lookup_at(klass, id, (v))) { \
2318 #define CVAR_LOOKUP(v,r) do {\
2319 if (cvar_lookup_at(klass, id, (v))) {r;}\
2320 CVAR_FOREACH_ANCESTORS(klass, v, r);\
2331 if (front &&
target != front) {
2368 if (front &&
target != front) {
2386 if (!klass)
return Qfalse;
2514 if (
RTEST(inherit)) {
#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)
VALUE rb_const_list(void *)
VALUE rb_const_get_at(VALUE, ID)
VALUE rb_class_path_no_cache(VALUE _klass)
static VALUE rb_const_get_0(VALUE klass, ID id, int exclude, int recurse, int visibility)
VALUE rb_f_trace_var(int, VALUE *)
static VALUE cvar_list(void *data)
static int rb_special_const_p(VALUE obj)
void rb_set_class_path(VALUE, VALUE, const char *)
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 *)
const char * rb_obj_classname(VALUE)
void * rb_mod_const_at(VALUE, void *)
VALUE rb_iv_set(VALUE, const char *, VALUE)
static void uninitialized_constant(VALUE klass, ID id)
VALUE rb_eval_cmd(VALUE, VALUE, int)
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)
VALUE rb_gv_set(const char *, VALUE)
static st_table * generic_iv_tbl
void rb_mark_generic_ivar(VALUE)
static int cv_i(st_data_t k, st_data_t v, st_data_t a)
st_table * st_init_numtable(void)
SSL_METHOD *(* func)(void)
VALUE rb_const_get(VALUE, ID)
VALUE rb_obj_remove_instance_variable(VALUE, VALUE)
void rb_define_global_const(const char *, VALUE)
static VALUE autoload_require(VALUE arg)
static void remove_trace(struct global_variable *var)
void rb_error_frozen(const char *what)
VALUE rb_gvar_set(struct rb_global_entry *, VALUE)
static VALUE rb_tmp_class_path(VALUE klass, int *permanent, path_cache_func cache_path)
#define rb_check_frozen(obj)
VALUE rb_gv_get(const char *)
VALUE(* path_cache_func)(VALUE obj, ID id, VALUE val)
#define ROBJECT_EMBED_LEN_MAX
VALUE rb_str_new_cstr(const char *)
void rb_gc_mark_global_tbl(void)
VALUE rb_iv_get(VALUE, 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)
int rb_public_const_defined(VALUE klass, ID id)
void rb_define_hooked_variable(const char *, VALUE *, VALUE(*)(ANYARGS), void(*)(ANYARGS))
void rb_vm_inc_const_missing_count(void)
VALUE rb_mod_remove_cvar(VALUE, VALUE)
VALUE rb_ary_push(VALUE ary, VALUE item)
static int cvar_lookup_at(VALUE klass, ID id, st_data_t *v)
static VALUE trace_en(struct global_variable *var)
#define check_autoload_table(av)
static int obj_ivar_i(st_data_t key, st_data_t index, st_data_t arg)
static VALUE cvar_front_klass(VALUE klass)
void rb_mark_generic_ivar_tbl(void)
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_autoload_p(VALUE, ID)
VALUE rb_funcall(VALUE, ID, int,...)
Calls a method.
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_class_name(VALUE)
size_t st_memsize(const st_table *)
VALUE rb_cvar_defined(VALUE, ID)
VALUE rb_ary_new3(long n,...)
static VALUE autoload_provided(VALUE arg)
int rb_public_const_defined_at(VALUE klass, ID id)
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)
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)
VALUE rb_path2class(const char *)
VALUE rb_path_to_class(VALUE)
VALUE rb_class_path(VALUE)
int(* func)(ID key, VALUE val, st_data_t arg)
VALUE rb_str_append(VALUE, VALUE)
VALUE rb_str_new_frozen(VALUE)
VALUE rb_ivar_get(VALUE, ID)
static void rb_trace_eval(VALUE cmd, VALUE val)
void rb_name_error_str(VALUE str, const char *fmt,...)
void rb_copy_generic_ivar(VALUE, VALUE)
VALUE rb_autoload_load(VALUE, ID)
VALUE rb_cvar_get(VALUE, ID)
void rb_name_error(ID id, const char *fmt,...)
#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)
void rb_define_readonly_variable(const char *, VALUE *)
VALUE rb_f_untrace_var(int, VALUE *)
static void autoload_free(void *ptr)
VALUE rb_block_proc(void)
static void autoload_delete(VALUE mod, ID id)
struct rb_global_entry * rb_global_entry(ID)
static int cv_list_i(st_data_t key, st_data_t value, VALUE ary)
#define rb_intern_str(string)
VALUE rb_mod_private_constant(int argc, VALUE *argv, VALUE obj)
void rb_define_class_variable(VALUE, const char *, VALUE)
void rb_define_const(VALUE, const char *, VALUE)
void(* func)(VALUE arg, VALUE val)
VALUE rb_str_cat2(VALUE, const char *)
VALUE rb_mod_class_variables(int, VALUE *, VALUE)
int rb_public_const_defined_from(VALUE klass, ID id)
static VALUE generic_ivar_get(VALUE obj, ID id, int warn)
#define TypedData_Wrap_Struct(klass, data_type, sval)
#define RUBY_FUNC_EXPORTED
unsigned char buf[MIME_BUF_SIZE]
STATIC void C_block perm[64/CHUNKBITS][1<< CHUNKBITS]
static ID global_id(const char *name)
#define ALLOCA_N(type, n)
int st_foreach(st_table *, int(*)(ANYARGS), st_data_t)
static void * mod_cvar_at(VALUE mod, void *data)
VALUE rb_thread_current(void)
void * rb_mod_const_of(VALUE, void *)
VALUE rb_sprintf(const char *format,...)
static void * mod_cvar_of(VALUE mod, void *data)
int rb_const_defined(VALUE, ID)
#define CONST_ID(var, str)
void Init_var_tables(void)
int rb_scan_args(int argc, const VALUE *argv, const char *fmt,...)
VALUE rb_f_global_variables(void)
static int ivar_i(st_data_t k, st_data_t v, st_data_t a)
void rb_const_set(VALUE, ID, VALUE)
VALUE rb_mod_public_constant(int argc, VALUE *argv, VALUE obj)
static VALUE const_missing(VALUE klass, ID id)
int rb_autoloading_value(VALUE mod, ID id, VALUE *value)
int rb_const_defined_at(VALUE, ID)
VALUE rb_obj_frozen_p(VALUE)
void rb_set_safe_level_force(int)
int rb_const_defined_from(VALUE, ID)
VALUE rb_attr_get(VALUE, ID)
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)
VALUE rb_mod_constants(int, VALUE *, VALUE)
static void generic_ivar_set(VALUE obj, ID id, VALUE val)
void rb_gc_mark_maybe(VALUE)
VALUE rb_ivar_defined(VALUE, ID)
#define RCLASS_CONST_TBL(c)
#define MEMCPY(p1, p2, type, n)
struct rb_global_variable * var
struct st_table * rb_generic_ivar_table(VALUE)
static VALUE autoload_data(VALUE mod, ID id)
int rb_is_const_name(VALUE name)
const char * rb_class2name(VALUE)
VALUE rb_ivar_set(VALUE, ID, VALUE)
rb_encoding * rb_enc_get(VALUE obj)
VALUE rb_public_const_get(VALUE klass, ID id)
static VALUE trace_ev(struct trace_data *data)
VALUE rb_cv_get(VALUE, const char *)
void rb_cvar_set(VALUE, ID, VALUE)
VALUE rb_gvar_get(struct rb_global_entry *)
VALUE rb_mod_remove_const(VALUE, VALUE)
static const rb_data_type_t autoload_data_type
static void autoload_i_free(void *ptr)
VALUE rb_mod_const_missing(VALUE, VALUE)
RUBY_EXTERN VALUE rb_cObject
VALUE rb_const_remove(VALUE, ID)
static VALUE fc_path(struct fc_result *fc, ID name)
void rb_cv_set(VALUE, const char *, VALUE)
struct rb_encoding_entry * list
void rb_define_variable(const char *, VALUE *)
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)
int st_insert(st_table *, st_data_t, st_data_t)
void rb_define_virtual_variable(const char *, VALUE(*)(ANYARGS), void(*)(ANYARGS))
VALUE rb_public_const_get_at(VALUE klass, ID id)
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)
void rb_set_class_path_string(VALUE, VALUE, VALUE)
int rb_is_class_id(ID id)
#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)
VALUE rb_const_get_from(VALUE, ID)
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)
st_index_t rb_ivar_count(VALUE)
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_public_const_get_from(VALUE klass, ID id)
static VALUE ivar_get(VALUE obj, ID id, int warn)
#define SPECIAL_CONST_P(x)
void rb_name_class(VALUE, ID)
VALUE rb_gvar_defined(struct rb_global_entry *)
void rb_ivar_foreach(VALUE, int(*)(ANYARGS), st_data_t)
ID rb_intern2(const char *name, long len)
size_t rb_generic_ivar_memsize(VALUE)
static VALUE original_module(VALUE c)
#define REALLOC_N(var, type, n)
void rb_free_generic_ivar(VALUE)
void rb_clear_cache_by_class(VALUE)
void rb_warn(const char *fmt,...)
#define rb_obj_instance_variables(object)
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_alias_variable(ID, ID)
VALUE rb_sourcefilename(void)
void rb_autoload(VALUE, ID, const char *)