42 #define CLASS_OR_MODULE_P(obj) \
43 (!SPECIAL_CONST_P(obj) && \
44 (BUILTIN_TYPE(obj) == T_CLASS || BUILTIN_TYPE(obj) == T_MODULE))
60 if (obj1 == obj2)
return Qtrue;
111 if (obj1 == obj2)
return Qtrue;
132 #if SIZEOF_LONG == SIZEOF_VOIDP
134 #elif SIZEOF_LONG_LONG == SIZEOF_VOIDP
137 # error not supported
227 ROBJECT(dest)->as.heap.ivptr = 0;
228 ROBJECT(dest)->as.heap.numiv = 0;
229 ROBJECT(dest)->as.heap.iv_index_tbl = 0;
244 ROBJECT(dest)->as.heap.iv_index_tbl =
ROBJECT(obj)->as.heap.iv_index_tbl;
245 RBASIC(dest)->flags &= ~ROBJECT_EMBED;
315 RBASIC(clone)->klass = singleton;
365 if (obj == orig)
return obj;
1020 if (!immediate_frozen_tbl) {
1045 if (!immediate_frozen_tbl)
return Qfalse;
1381 if (obj1 == obj2 ||
rb_equal(obj1, obj2))
1427 VALUE refined_class, defined_at;
1444 if (!
NIL_P(refined_class)) {
1449 CONST_ID(id_defined_at,
"__defined_at__");
1507 if (mod == arg)
return Qtrue;
1536 if (mod == arg)
return Qfalse;
1577 if (mod == arg)
return Qfalse;
1598 if (mod == arg)
return INT2FIX(0);
1757 #if !defined(DTRACE_PROBES_DISABLED) || !DTRACE_PROBES_DISABLED
1766 obj = (*allocator)(
klass);
1862 for (i=0; i<
argc; i++) {
1871 if (argc == 2 && (argv[1] ==
Qtrue || argv[1] ==
Qfalse)) {
1872 rb_warning(
"optional boolean argument is obsoleted");
1892 for (i=0; i<
argc; i++) {
1918 for (i=0; i<
argc; i++) {
1963 const char *pbeg, *
p, *
path, *pend;
1993 if (p >= pend || !*p) {
1999 if (p + 2 < pend && p[0] ==
':' && p[1] ==
':') {
2000 if (!nestable)
goto wrong_name;
2010 while (p < pend && *p !=
':') p++;
2012 if (pbeg == p)
goto wrong_name;
2017 if (p < pend && p[0] ==
':') {
2018 if (!nestable)
goto wrong_name;
2019 if (p + 2 >= pend || p[1] !=
':')
goto wrong_name;
2352 #define IMPLICIT_CONVERSIONS 7
2373 "no implicit conversion of" :
"can't convert";
2374 const char *cname =
NIL_P(val) ?
"nil" :
2375 val ==
Qtrue ?
"true" :
2376 val ==
Qfalse ?
"false" :
2404 if (
TYPE(val) == type)
return val;
2406 if (
TYPE(v) != type) {
2421 if (
TYPE(v) != type) {
2473 switch (
TYPE(val)) {
2475 if (base != 0)
goto arg_error;
2484 if (base != 0)
goto arg_error;
2492 if (base != 0)
goto arg_error;
2501 if (!
NIL_P(tmp))
goto string_conv;
2566 const char *ellipsis =
"";
2568 enum {max_width = 20};
2569 #define OutOfRange() ((end - p > max_width) ? \
2570 (w = max_width, ellipsis = "...") : \
2571 (w = (int)(end - p), ellipsis = ""))
2577 if (!badcheck && p[0] ==
'0' && (p[1] ==
'x' || p[1] ==
'X')) {
2582 if (
errno == ERANGE) {
2584 rb_warning(
"Float %.*s%s out of range", w, p, ellipsis);
2597 char *
e = buf +
sizeof(
buf) - 1;
2600 while (p < end && n < e) prev = *n++ = *p++;
2610 while (*++p ==
'_');
2615 if (n < e) *n++ = prev;
2620 if (!badcheck && p[0] ==
'0' && (p[1] ==
'x' || p[1] ==
'X')) {
2625 if (
errno == ERANGE) {
2627 rb_warning(
"Float %.*s%s out of range", w, p, ellipsis);
2631 if (!end || p == end)
goto bad;
2632 while (*end &&
ISSPACE(*end)) end++;
2636 if (
errno == ERANGE) {
2656 if (badcheck && memchr(s,
'\0', len)) {
2675 switch (
TYPE(val)) {
2723 NIL_P(val) ?
"nil" :
2724 val ==
Qtrue ?
"true" :
2725 val ==
Qfalse ?
"false" :
2744 switch (
TYPE(val)) {
3028 #define rb_intern(str) rb_intern_const(str)
#define RB_TYPE_P(obj, type)
VALUE rb_const_get_at(VALUE, ID)
static VALUE rb_obj_ivar_defined(VALUE obj, VALUE iv)
static VALUE nil_to_h(VALUE obj)
static VALUE rb_mod_attr_accessor(int argc, VALUE *argv, VALUE klass)
static void conversion_mismatch(VALUE val, const char *tname, const char *method, VALUE result)
static VALUE rb_mod_cmp(VALUE mod, VALUE arg)
RUBY_EXTERN VALUE rb_cBasicObject
VALUE rb_mod_include_p(VALUE mod, VALUE mod2)
static int rb_special_const_p(VALUE obj)
void rb_check_inheritable(VALUE super)
Ensures a class can be derived from super.
VALUE(* rb_alloc_func_t)(VALUE)
int rb_is_class_name(VALUE name)
RUBY_EXTERN VALUE rb_cNilClass
RUBY_EXTERN VALUE rb_cModule
VALUE rb_class_new_instance(int, VALUE *, VALUE)
const char * rb_obj_classname(VALUE)
VALUE rb_obj_private_methods(int argc, VALUE *argv, VALUE obj)
static VALUE rb_convert_to_integer(VALUE val, int base)
int st_lookup(st_table *, st_data_t, st_data_t *)
#define rb_check_trusted(obj)
st_table * st_init_numtable(void)
VALUE rb_class_private_instance_methods(int argc, VALUE *argv, VALUE mod)
double rb_cstr_to_dbl(const char *, int)
#define rb_usascii_str_new2
VALUE rb_const_get(VALUE, ID)
VALUE rb_obj_remove_instance_variable(VALUE, VALUE)
void rb_define_global_const(const char *, VALUE)
static VALUE rb_mod_ge(VALUE mod, VALUE arg)
#define rb_check_frozen(obj)
static VALUE rb_mod_cvar_set(VALUE obj, VALUE iv, VALUE val)
VALUE rb_mod_ancestors(VALUE mod)
VALUE rb_str_subseq(VALUE, long, long)
VALUE rb_refinement_module_get_refined_class(VALUE module)
#define ROBJECT_EMBED_LEN_MAX
static VALUE rb_mod_lt(VALUE mod, VALUE arg)
VALUE rb_iv_get(VALUE, const char *)
void rb_define_private_method(VALUE klass, const char *name, VALUE(*func)(ANYARGS), int argc)
VALUE rb_obj_freeze(VALUE)
void rb_define_alloc_func(VALUE, rb_alloc_func_t)
VALUE rb_obj_tap(VALUE obj)
VALUE rb_mod_remove_cvar(VALUE, VALUE)
static VALUE rb_mod_attr_reader(int argc, VALUE *argv, VALUE klass)
static void init_copy(VALUE dest, VALUE obj)
static VALUE false_and(VALUE obj, VALUE obj2)
RUBY_EXTERN VALUE rb_cTrueClass
#define RUBY_DTRACE_OBJECT_CREATE_ENABLED()
VALUE rb_mod_init_copy(VALUE clone, VALUE orig)
static VALUE nil_inspect(VALUE obj)
static VALUE rb_mod_attr_writer(int argc, VALUE *argv, VALUE klass)
void rb_gc_copy_finalizer(VALUE, VALUE)
VALUE rb_obj_tainted(VALUE)
static VALUE rb_obj_ivar_get(VALUE obj, VALUE iv)
void Init_class_hierarchy(void)
VALUE rb_funcall(VALUE, ID, int,...)
Calls a method.
void rb_raise(VALUE exc, const char *fmt,...)
VALUE rb_obj_class(VALUE)
static struct conv_method_tbl conv_method_names[]
VALUE rb_class_name(VALUE)
static VALUE rb_obj_cmp(VALUE obj1, VALUE obj2)
VALUE rb_cvar_defined(VALUE, ID)
VALUE rb_ary_new3(long n,...)
VALUE rb_obj_untrusted(VALUE)
void rb_include_module(VALUE klass, VALUE module)
static VALUE rb_obj_match(VALUE obj1, VALUE obj2)
static VALUE rb_mod_const_get(int argc, VALUE *argv, VALUE mod)
double rb_big2dbl(VALUE x)
static VALUE class_search_ancestor(VALUE cl, VALUE c)
void rb_define_global_function(const char *name, VALUE(*func)(ANYARGS), int argc)
Defines a global function.
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)
static VALUE nil_to_i(VALUE obj)
void rb_undef_method(VALUE klass, const char *name)
VALUE rb_str_append(VALUE, VALUE)
static VALUE rb_obj_not_match(VALUE obj1, VALUE obj2)
static VALUE rb_obj_dummy(void)
VALUE rb_f_sprintf(int, const VALUE *)
VALUE rb_ivar_get(VALUE, ID)
VALUE rb_equal(VALUE, VALUE)
VALUE rb_str_concat(VALUE, VALUE)
int rb_enc_symname2_p(const char *name, long len, rb_encoding *enc)
void rb_name_error_str(VALUE str, const char *fmt,...)
void rb_copy_generic_ivar(VALUE, VALUE)
VALUE rb_cvar_get(VALUE, ID)
void rb_name_error(ID id, const char *fmt,...)
static VALUE rb_f_array(VALUE obj, VALUE arg)
st_index_t rb_hash_start(st_index_t)
static VALUE rb_mod_cvar_get(VALUE obj, VALUE iv)
VALUE rb_usascii_str_new(const char *, long)
VALUE rb_singleton_class(VALUE obj)
Returns the singleton class of obj.
int rb_is_const_id(ID id)
int rb_is_instance_id(ID id)
VALUE rb_check_to_float(VALUE)
static VALUE true_or(VALUE obj, VALUE obj2)
VALUE rb_obj_not(VALUE obj)
rb_encoding * rb_default_external_encoding(void)
VALUE rb_obj_is_instance_of(VALUE, VALUE)
static VALUE false_or(VALUE obj, VALUE obj2)
VALUE rb_class_inherited(VALUE super, VALUE klass)
Calls Class::inherited.
static VALUE rb_to_integer(VALUE val, const char *method)
VALUE rb_obj_untrust(VALUE)
VALUE rb_dbl2big(double d)
int rb_block_given_p(void)
static VALUE rb_class_allocate_instance(VALUE klass)
static VALUE rb_f_hash(VALUE obj, VALUE arg)
static VALUE nil_to_f(VALUE obj)
static VALUE rb_true(VALUE obj)
VALUE rb_class_search_ancestor(VALUE klass, VALUE super)
VALUE rb_str_to_inum(VALUE str, int base, int badcheck)
RUBY_EXTERN VALUE rb_mKernel
VALUE rb_mod_attr(int argc, VALUE *argv, VALUE klass)
static VALUE rb_mod_freeze(VALUE mod)
VALUE rb_mod_private_constant(int argc, VALUE *argv, VALUE obj)
VALUE rb_str_cat2(VALUE, const char *)
VALUE rb_define_class(const char *name, VALUE super)
Defines a top-level class.
VALUE rb_check_to_integer(VALUE, const char *)
static VALUE rb_obj_singleton_class(VALUE obj)
VALUE rb_mod_class_variables(int, VALUE *, VALUE)
static VALUE rb_class_initialize(int argc, VALUE *argv, VALUE klass)
double rb_str_to_dbl(VALUE, int)
static VALUE false_xor(VALUE obj, VALUE obj2)
VALUE rb_check_hash_type(VALUE)
unsigned char buf[MIME_BUF_SIZE]
VALUE rb_obj_protected_methods(int argc, VALUE *argv, VALUE obj)
VALUE rb_check_funcall(VALUE, ID, int, VALUE *)
static VALUE rb_f_float(VALUE obj, VALUE arg)
VALUE rb_obj_as_string(VALUE)
RUBY_EXTERN VALUE rb_cInteger
void rb_define_alias(VALUE klass, const char *name1, const char *name2)
Defines an alias of a method.
static VALUE rb_mod_eqq(VALUE mod, VALUE arg)
static VALUE rb_mod_initialize(VALUE module)
VALUE rb_obj_clone(VALUE)
VALUE rb_obj_hash(VALUE obj)
VALUE rb_sprintf(const char *format,...)
static VALUE true_to_s(VALUE obj)
int rb_const_defined(VALUE, ID)
#define CONST_ID(var, str)
VALUE rb_class_inherited_p(VALUE, VALUE)
int rb_scan_args(int argc, const VALUE *argv, const char *fmt,...)
void rb_attr(VALUE, ID, int, int, int)
void rb_const_set(VALUE, ID, VALUE)
VALUE rb_mod_public_constant(int argc, VALUE *argv, VALUE obj)
VALUE rb_obj_public_methods(int argc, VALUE *argv, VALUE obj)
VALUE rb_obj_untaint(VALUE)
static VALUE nil_to_s(VALUE obj)
VALUE rb_obj_trust(VALUE)
int rb_const_defined_at(VALUE, ID)
VALUE rb_obj_frozen_p(VALUE)
void rb_undef_alloc_func(VALUE)
VALUE rb_make_metaclass(VALUE obj, VALUE unused)
VALUE rb_attr_get(VALUE, ID)
#define IMPLICIT_CONVERSIONS
VALUE rb_mod_constants(int, VALUE *, VALUE)
void Init_Object(void)
Initializes the world of objects and classes.
VALUE rb_class_instance_methods(int argc, VALUE *argv, VALUE mod)
VALUE rb_ivar_defined(VALUE, ID)
void rb_free_const_table(st_table *tbl)
static VALUE rb_obj_ivar_set(VALUE obj, VALUE iv, VALUE val)
#define RCLASS_CONST_TBL(c)
#define MEMCPY(p1, p2, type, n)
VALUE rb_obj_taint(VALUE)
static VALUE true_xor(VALUE obj, VALUE obj2)
VALUE rb_obj_equal(VALUE obj1, VALUE obj2)
int rb_is_const_name(VALUE name)
const char * rb_class2name(VALUE)
VALUE rb_ivar_set(VALUE, ID, VALUE)
VALUE rb_obj_init_copy(VALUE, VALUE)
VALUE rb_class_protected_instance_methods(int argc, VALUE *argv, VALUE mod)
#define NEWOBJ_OF(obj, type, klass, flags)
rb_encoding * rb_enc_get(VALUE obj)
VALUE rb_class_public_instance_methods(int argc, VALUE *argv, VALUE mod)
void rb_singleton_class_attached(VALUE klass, VALUE obj)
Attach a object to a singleton class.
VALUE rb_check_to_int(VALUE)
void rb_cvar_set(VALUE, ID, VALUE)
VALUE rb_module_new(void)
VALUE rb_obj_is_kind_of(VALUE, VALUE)
int rb_method_basic_definition_p(VALUE, ID)
static VALUE convert_type(VALUE val, const char *tname, const char *method, int raise)
int rb_enc_str_asciionly_p(VALUE)
VALUE rb_obj_singleton_methods(int argc, VALUE *argv, VALUE obj)
static VALUE true_and(VALUE obj, VALUE obj2)
VALUE rb_mod_remove_const(VALUE, VALUE)
VALUE rb_check_array_type(VALUE ary)
static VALUE rb_f_string(VALUE obj, VALUE arg)
static VALUE rb_obj_inspect(VALUE obj)
RUBY_EXTERN VALUE rb_cClass
static VALUE nil_to_a(VALUE obj)
VALUE rb_mod_const_missing(VALUE, VALUE)
RUBY_EXTERN VALUE rb_cObject
VALUE rb_obj_init_dup_clone(VALUE obj, VALUE orig)
VALUE rb_obj_methods(int argc, VALUE *argv, VALUE obj)
rb_alloc_func_t rb_get_alloc_func(VALUE)
static VALUE inspect_obj(VALUE obj, VALUE str, int recur)
int st_insert(st_table *, st_data_t, st_data_t)
static VALUE rb_mod_cvar_defined(VALUE obj, VALUE iv)
VALUE rb_exec_recursive(VALUE(*)(VALUE, VALUE, int), VALUE, VALUE)
static VALUE rb_class_s_alloc(VALUE klass)
static VALUE rb_mod_to_s(VALUE klass)
VALUE rb_ary_new2(long capa)
int rb_is_class_id(ID id)
void rb_obj_copy_ivar(VALUE dest, VALUE obj)
static VALUE rb_mod_const_set(VALUE mod, VALUE name, VALUE value)
static int inspect_i(st_data_t k, st_data_t v, st_data_t a)
static VALUE rb_mod_const_defined(int argc, VALUE *argv, VALUE mod)
#define rb_enc_asciicompat(enc)
int rb_is_instance_name(VALUE name)
VALUE rb_obj_alloc(VALUE)
const char * rb_id2name(ID id)
VALUE rb_obj_not_equal(VALUE obj1, VALUE obj2)
VALUE rb_mod_included_modules(VALUE mod)
VALUE rb_class_real(VALUE)
static VALUE rb_false(VALUE obj)
st_index_t rb_ivar_count(VALUE)
static VALUE rb_f_integer(int argc, VALUE *argv, VALUE obj)
void rb_warning(const char *fmt,...)
VALUE rb_class_get_superclass(VALUE)
ID rb_intern3(const char *name, long len, rb_encoding *enc)
st_table * st_copy(st_table *)
static VALUE false_to_s(VALUE obj)
#define SPECIAL_CONST_P(x)
VALUE rb_define_module(const char *name)
RUBY_EXTERN VALUE rb_cFalseClass
static VALUE rb_mod_gt(VALUE mod, VALUE arg)
void rb_ivar_foreach(VALUE, int(*)(ANYARGS), st_data_t)
RUBY_EXTERN VALUE rb_cData
static st_table * immediate_frozen_tbl
static VALUE class_or_module_required(VALUE c)
VALUE rb_check_string_type(VALUE)
void rb_obj_call_init(VALUE obj, int argc, VALUE *argv)
void rb_define_method(VALUE klass, const char *name, VALUE(*func)(ANYARGS), int argc)
void rb_invalid_str(const char *str, const char *type)
VALUE rb_class_boot(VALUE super)
A utility function that wraps class_alloc.
#define rb_obj_instance_variables(object)
RUBY_EXTERN VALUE rb_cNumeric
VALUE rb_convert_type(VALUE, int, const char *, const char *)
VALUE rb_check_convert_type(VALUE, int, const char *, const char *)
#define RUBY_DTRACE_OBJECT_CREATE(arg0, arg1, arg2)
void st_free_table(st_table *)
VALUE rb_mod_module_exec(int, VALUE *, VALUE)
VALUE rb_class_superclass(VALUE)
VALUE rb_singleton_class_clone_and_attach(VALUE obj, VALUE attach)
static ID id_const_missing
void rb_obj_infect(VALUE, VALUE)
static VALUE rb_module_s_alloc(VALUE klass)
#define CLASS_OR_MODULE_P(obj)