108 res->
path = arg.path;
195 rb_bug(
"class path is not set properly");
236 const char *s =
"Class";
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 513 if (!var)
return Qnil;
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);
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;
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;
1308 for (
i =
count = 0;
i < num; ++
i) {
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;
1794 if (ele->value !=
Qundef) {
1799 args.value = ele->value;
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;
2209 rb_warn(
"rb_define_const: invalid name `%s' for constant",
name);
2232 "Insecure: can't change constant visibility");
2318 #define CVAR_FOREACH_ANCESTORS(klass, v, r) \ 2319 for (klass = cvar_front_klass(klass); klass; klass = RCLASS_SUPER(klass)) { \ 2320 if (cvar_lookup_at(klass, id, (v))) { \ 2325 #define CVAR_LOOKUP(v,r) do {\ 2326 if (cvar_lookup_at(klass, id, (v))) {r;}\ 2327 CVAR_FOREACH_ANCESTORS(klass, v, r);\ 2333 VALUE tmp, front = 0, target = 0;
2336 CVAR_LOOKUP(0, {
if (!front) front = klass; target = klass;});
2338 if (front && target != front) {
2366 VALUE tmp, front = 0, target = 0;
2370 CVAR_LOOKUP(&value, {
if (!front) front = klass; target = klass;});
2375 if (front && target != front) {
2387 return (
VALUE)value;
2393 if (!klass)
return Qfalse;
2522 if (
RTEST(inherit)) {
void rb_mark_generic_ivar(VALUE obj)
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)
void rb_vm_inc_const_missing_count(void)
void rb_bug(const char *fmt,...)
int rb_is_class_name(VALUE name)
size_t strlen(const char *)
VALUE rb_mod_const_missing(VALUE klass, VALUE name)
void * rb_mod_const_at(VALUE mod, void *data)
#define RCLASS_CONST_TBL(c)
static void uninitialized_constant(VALUE klass, ID id)
VALUE rb_mod_class_variables(int argc, VALUE *argv, VALUE mod)
VALUE rb_f_global_variables(void)
static VALUE generic_ivar_defined(VALUE obj, ID id)
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)
VALUE rb_ivar_defined(VALUE obj, ID id)
int st_insert(st_table *, st_data_t, st_data_t)
static VALUE autoload_require(VALUE arg)
static void remove_trace(struct global_variable *var)
void rb_error_frozen(const char *what)
#define TypedData_Wrap_Struct(klass, data_type, sval)
static VALUE rb_tmp_class_path(VALUE klass, int *permanent, path_cache_func cache_path)
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)
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)
SSL_METHOD *(* func)(void)
void st_free_table(st_table *)
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)
VALUE rb_funcall(VALUE, ID, int,...)
Calls a method.
void rb_gc_mark_global_tbl(void)
static VALUE cvar_front_klass(VALUE klass)
#define ROBJECT_IV_INDEX_TBL(o)
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_mod_name(VALUE mod)
VALUE rb_cv_get(VALUE klass, const char *name)
void rb_raise(VALUE exc, const char *fmt,...)
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)
int rb_public_const_defined(VALUE klass, ID id)
VALUE rb_ary_new3(long n,...)
static VALUE autoload_provided(VALUE arg)
void rb_gc_mark(VALUE ptr)
int rb_feature_provided(const char *, const char **)
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)
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_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,...)
void(* func)(VALUE arg, VALUE val)
VALUE rb_autoload_load(VALUE mod, ID id)
#define CVAR_LOOKUP(v, r)
static int list_i(st_data_t key, st_data_t value, VALUE ary)
int rb_is_const_id(ID id)
int rb_is_instance_id(ID id)
#define RB_TYPE_P(obj, type)
void rb_vm_change_state(void)
VALUE rb_cvar_defined(VALUE klass, ID id)
int st_lookup(st_table *, st_data_t, st_data_t *)
void rb_const_set(VALUE klass, ID id, VALUE val)
static void autoload_free(void *ptr)
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)
RUBY_EXTERN VALUE rb_cObject
VALUE rb_class_real(VALUE)
VALUE rb_str_cat2(VALUE, const char *)
void rb_clear_cache_by_class(VALUE)
VALUE rb_f_untrace_var(int argc, VALUE *argv)
VALUE rb_mod_constants(int argc, VALUE *argv, VALUE mod)
VALUE rb_thread_current(void)
void st_add_direct(st_table *, st_data_t, st_data_t)
int st_delete(st_table *, st_data_t *, st_data_t *)
const char * rb_obj_classname(VALUE obj)
VALUE rb_require_safe(VALUE, int)
#define ALLOCA_N(type, n)
static VALUE generic_ivar_get(VALUE obj, ID id, int warn)
RUBY_EXTERN VALUE rb_cModule
VALUE rb_gv_get(const char *name)
void rb_cv_set(VALUE klass, const char *name, VALUE val)
#define RUBY_FUNC_EXPORTED
#define MEMCPY(p1, p2, type, n)
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)
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)
void st_foreach_safe(st_table *table, int(*func)(ANYARGS), st_data_t a)
static void * mod_cvar_at(VALUE mod, void *data)
#define REALLOC_N(var, type, n)
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)
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]
void rb_vm_pop_cfunc_frame(void)
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_public_const_get_from(VALUE klass, ID id)
void rb_mark_tbl(st_table *tbl)
VALUE rb_gvar_defined(struct global_entry *entry)
#define rb_enc_asciicompat(enc)
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)
VALUE rb_str_new_cstr(const char *)
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)
st_table * st_init_numtable(void)
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)
VALUE rb_mod_private_constant(int argc, VALUE *argv, VALUE obj)
void rb_set_safe_level_force(int)
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)
VALUE rb_block_proc(void)
VALUE(* path_cache_func)(VALUE obj, ID id, VALUE val)
size_t st_memsize(const st_table *)
#define ROBJECT_EMBED_LEN_MAX
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_obj_frozen_p(VALUE)
VALUE rb_path_to_class(VALUE pathname)
static const rb_data_type_t autoload_data_type
#define RCLASS_IV_INDEX_TBL(c)
VALUE rb_const_get_from(VALUE klass, ID id)
static void autoload_i_free(void *ptr)
static int rb_special_const_p(VALUE obj)
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)
VALUE rb_eval_cmd(VALUE, VALUE, int)
void rb_cvar_set(VALUE klass, ID id, VALUE val)
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)
void rb_gc_mark_maybe(VALUE obj)
static VALUE reset_safe(VALUE safe)
static size_t autoload_memsize(const void *ptr)
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_str_new_frozen(VALUE)
st_table * st_copy(st_table *)
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 rb_check_frozen(obj)
#define CONST_ID(var, str)
static void obj_ivar_each(VALUE obj, int(*func)(ANYARGS), st_data_t arg)
VALUE rb_class_path_no_cache(VALUE klass)
#define SPECIAL_CONST_P(x)
static VALUE ivar_get(VALUE obj, ID id, int warn)
int(* func)(ID key, VALUE val, st_data_t arg)
ID rb_intern2(const char *name, long len)
static VALUE original_module(VALUE c)
void * rb_mod_const_of(VALUE mod, void *data)
void rb_mark_generic_ivar_tbl(void)
VALUE rb_str_append(VALUE, VALUE)
int st_foreach(st_table *, int(*)(ANYARGS), st_data_t)
VALUE rb_const_remove(VALUE mod, ID id)
VALUE rb_str_new2(const char *)
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 rb_free_generic_ivar(VALUE obj)
VALUE rb_sourcefilename(void)
void rb_copy_generic_ivar(VALUE clone, VALUE obj)
int rb_const_defined_from(VALUE klass, ID id)
VALUE rb_obj_class(VALUE)