41 #define id_match idEqTilde 42 #define id_inspect idInspect 43 #define id_init_copy idInitialize_copy 44 #define id_init_clone idInitialize_clone 45 #define id_init_dup idInitialize_dup 46 #define id_const_missing idConst_missing 48 #define CLASS_OR_MODULE_P(obj) \ 49 (!SPECIAL_CONST_P(obj) && \ 50 (BUILTIN_TYPE(obj) == T_CLASS || BUILTIN_TYPE(obj) == T_MODULE)) 93 if (obj1 == obj2)
return Qtrue;
144 if (obj1 == obj2)
return Qtrue;
166 #if SIZEOF_LONG == SIZEOF_VOIDP 168 #elif SIZEOF_LONG_LONG == SIZEOF_VOIDP 171 # error not supported 259 ROBJECT(dest)->as.heap.ivptr = 0;
260 ROBJECT(dest)->as.heap.numiv = 0;
261 ROBJECT(dest)->as.heap.iv_index_tbl = 0;
268 long len =
ROBJECT(obj)->as.heap.numiv;
274 ROBJECT(dest)->as.heap.ivptr = ptr;
275 ROBJECT(dest)->as.heap.numiv = len;
276 ROBJECT(dest)->as.heap.iv_index_tbl =
ROBJECT(obj)->as.heap.iv_index_tbl;
424 if (obj == orig)
return obj;
1007 rb_warning(
"untrusted? is deprecated and its behavior is same as tainted?");
1021 rb_warning(
"untrust is deprecated and its behavior is same as taint");
1036 rb_warning(
"trust is deprecated and its behavior is same as untaint");
1438 if (obj1 == obj2 ||
rb_equal(obj1, obj2))
1484 VALUE refined_class, defined_at;
1501 if (!
NIL_P(refined_class)) {
1506 CONST_ID(id_defined_at,
"__defined_at__");
1820 #if !defined(DTRACE_PROBES_DISABLED) || !DTRACE_PROBES_DISABLED 1829 obj = (*allocator)(klass);
1907 return RCLASS(klass)->super;
1910 #define id_for_setter(name, type, message) \ 1911 check_setter_id(name, rb_is_##type##_id, rb_is_##type##_name, message) 1914 const char *message)
1919 if (!valid_id_p(
id)) {
1929 if (!valid_name_p(str)) {
1984 for (i=0; i<
argc; i++) {
1994 rb_warning(
"optional boolean argument is obsoleted");
2016 for (i=0; i<
argc; i++) {
2044 for (i=0; i<
argc; i++) {
2095 const char *pbeg, *p, *path, *pend;
2122 if (p >= pend || !*p) {
2128 if (p + 2 < pend && p[0] ==
':' && p[1] ==
':') {
2138 while (p < pend && *p !=
':') p++;
2140 if (pbeg == p)
goto wrong_name;
2145 if (p < pend && p[0] ==
':') {
2146 if (p + 2 >= pend || p[1] !=
':')
goto wrong_name;
2256 const char *pbeg, *p, *path, *pend;
2283 if (p >= pend || !*p) {
2289 if (p + 2 < pend && p[0] ==
':' && p[1] ==
':') {
2299 while (p < pend && *p !=
':') p++;
2301 if (pbeg == p)
goto wrong_name;
2306 if (p < pend && p[0] ==
':') {
2307 if (p + 2 >= pend || p[1] !=
':')
goto wrong_name;
2602 #define IMPLICIT_CONVERSIONS 7 2623 ?
"no implicit conversion of %s into %s" 2624 :
"can't convert %s into %s",
2718 if (base != 0)
goto arg_error;
2727 if (base != 0)
goto arg_error;
2735 if (base != 0)
goto arg_error;
2744 if (!
NIL_P(tmp))
goto string_conv;
2811 const char *ellipsis =
"";
2813 enum {max_width = 20};
2814 #define OutOfRange() ((end - p > max_width) ? \ 2815 (w = max_width, ellipsis = "...") : \ 2816 (w = (int)(end - p), ellipsis = "")) 2822 if (!badcheck && p[0] ==
'0' && (p[1] ==
'x' || p[1] ==
'X')) {
2827 if (
errno == ERANGE) {
2829 rb_warning(
"Float %.*s%s out of range", w, p, ellipsis);
2842 char *e =
buf +
sizeof(
buf) - 1;
2845 while (p < end && n < e) prev = *n++ = *p++;
2855 while (*++p ==
'_');
2860 if (n < e) *n++ = prev;
2865 if (!badcheck && p[0] ==
'0' && (p[1] ==
'x' || p[1] ==
'X')) {
2870 if (
errno == ERANGE) {
2872 rb_warning(
"Float %.*s%s out of range", w, p, ellipsis);
2876 if (!end || p == end)
goto bad;
2877 while (*end &&
ISSPACE(*end)) end++;
2881 if (
errno == ERANGE) {
2901 if (badcheck && memchr(s,
'\0', len)) {
2905 char *p =
ALLOCV(v, len);
3272 #define rb_intern(str) rb_intern_const(str) void rb_define_global_const(const char *, VALUE)
#define RBASIC_CLEAR_CLASS(obj)
VALUE rb_check_to_float(VALUE val)
VALUE rb_cvar_get(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 VALUE rb_mod_cmp(VALUE mod, VALUE arg)
VALUE rb_mod_include_p(VALUE mod, VALUE mod2)
void rb_check_inheritable(VALUE super)
Ensures a class can be derived from super.
int rb_is_class_name(VALUE name)
VALUE rb_obj_id(VALUE obj)
#define RCLASS_CONST_TBL(c)
VALUE rb_obj_private_methods(int argc, VALUE *argv, VALUE obj)
VALUE rb_inspect(VALUE obj)
static VALUE rb_convert_to_integer(VALUE val, int base)
void rb_undef_alloc_func(VALUE)
double rb_cstr_to_dbl(const char *p, int badcheck)
double rb_str_to_dbl(VALUE str, int badcheck)
VALUE rb_f_sprintf(int, const VALUE *)
void rb_obj_copy_ivar(VALUE dest, VALUE obj)
#define rb_usascii_str_new2
VALUE rb_class_private_instance_methods(int argc, VALUE *argv, VALUE mod)
int st_insert(st_table *, st_data_t, st_data_t)
static VALUE rb_mod_ge(VALUE mod, VALUE arg)
static VALUE rb_mod_cvar_set(VALUE obj, VALUE iv, VALUE val)
VALUE rb_equal(VALUE obj1, VALUE obj2)
VALUE rb_mod_ancestors(VALUE mod)
VALUE rb_refinement_module_get_refined_class(VALUE module)
static VALUE rb_mod_lt(VALUE mod, VALUE arg)
void rb_define_private_method(VALUE klass, const char *name, VALUE(*func)(ANYARGS), int argc)
VALUE rb_obj_tap(VALUE obj)
static VALUE rb_mod_attr_reader(int argc, VALUE *argv, VALUE klass)
VALUE rb_obj_taint(VALUE obj)
void rb_cvar_set(VALUE, ID, VALUE)
void st_free_table(st_table *)
VALUE rb_str_concat(VALUE, VALUE)
static void init_copy(VALUE dest, VALUE obj)
VALUE rb_convert_type(VALUE val, int type, const char *tname, const char *method)
static VALUE false_and(VALUE obj, VALUE obj2)
#define RUBY_DTRACE_OBJECT_CREATE_ENABLED()
VALUE rb_mod_init_copy(VALUE clone, VALUE orig)
#define rb_check_trusted(obj)
static VALUE nil_inspect(VALUE obj)
VALUE rb_obj_trust(VALUE obj)
static VALUE rb_mod_attr_writer(int argc, VALUE *argv, VALUE klass)
VALUE rb_funcall(VALUE, ID, int,...)
Calls a method.
static VALUE rb_obj_ivar_get(VALUE obj, VALUE iv)
void Init_class_hierarchy(void)
ID rb_check_attr_id(ID id)
#define RBASIC_SET_CLASS(obj, cls)
void rb_raise(VALUE exc, const char *fmt,...)
double rb_num2dbl(VALUE val)
VALUE rb_ivar_get(VALUE, ID)
static struct conv_method_tbl conv_method_names[]
VALUE rb_exec_recursive(VALUE(*)(VALUE, VALUE, int), VALUE, VALUE)
static VALUE rb_obj_cmp(VALUE obj1, VALUE obj2)
void rb_define_alloc_func(VALUE, rb_alloc_func_t)
int rb_const_defined(VALUE, ID)
#define RCLASS_M_TBL_WRAPPER(c)
void rb_include_module(VALUE klass, VALUE module)
VALUE rb_to_float(VALUE val)
static VALUE rb_mod_singleton_p(VALUE klass)
static VALUE rb_obj_match(VALUE obj1, VALUE obj2)
static VALUE rb_mod_const_get(int argc, VALUE *argv, VALUE mod)
static const char invalid_attribute_name[]
VALUE rb_Integer(VALUE val)
double rb_big2dbl(VALUE x)
static VALUE class_search_ancestor(VALUE cl, VALUE c)
#define RGENGC_WB_PROTECTED_OBJECT
void rb_define_global_function(const char *name, VALUE(*func)(ANYARGS), int argc)
Defines a global function.
static int rb_is_attr_name(VALUE name)
VALUE rb_to_int(VALUE val)
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_obj_untaint(VALUE obj)
static VALUE nil_to_i(VALUE obj)
void rb_undef_method(VALUE klass, const char *name)
VALUE rb_mod_module_exec(int, VALUE *, VALUE)
VALUE rb_ivar_defined(VALUE, ID)
static VALUE rb_obj_not_match(VALUE obj1, VALUE obj2)
static VALUE rb_obj_dummy(void)
VALUE rb_mod_remove_cvar(VALUE, VALUE)
void rb_ivar_foreach(VALUE, int(*)(ANYARGS), st_data_t)
const char * rb_obj_classname(VALUE)
void rb_name_error_str(VALUE str, const char *fmt,...)
#define id_for_setter(name, type, message)
RUBY_SYMBOL_EXPORT_BEGIN typedef unsigned long st_data_t
void rb_name_error(ID id, const char *fmt,...)
static VALUE rb_f_array(VALUE obj, VALUE arg)
#define NEWOBJ_OF(obj, type, klass, flags)
static VALUE rb_mod_cvar_get(VALUE obj, VALUE iv)
VALUE rb_singleton_class(VALUE obj)
Returns the singleton class of obj.
int rb_is_const_id(ID id)
VALUE rb_obj_class(VALUE obj)
int rb_is_instance_id(ID id)
VALUE rb_obj_dup(VALUE obj)
#define RB_TYPE_P(obj, type)
int st_lookup(st_table *, st_data_t, st_data_t *)
static VALUE true_or(VALUE obj, VALUE obj2)
VALUE rb_obj_not(VALUE obj)
rb_encoding * rb_default_external_encoding(void)
static VALUE false_or(VALUE obj, VALUE obj2)
VALUE rb_cvar_defined(VALUE, ID)
VALUE rb_class_inherited(VALUE super, VALUE klass)
Calls Class::inherited.
static VALUE rb_to_integer(VALUE val, const char *method)
#define rb_intern_str(string)
VALUE rb_class_name(VALUE)
VALUE rb_obj_reveal(VALUE obj, VALUE klass)
VALUE rb_dbl2big(double d)
VALUE rb_class_new_instance(int argc, VALUE *argv, VALUE klass)
int rb_block_given_p(void)
static VALUE rb_class_allocate_instance(VALUE klass)
static VALUE rb_f_hash(VALUE obj, VALUE arg)
void rb_gc_copy_finalizer(VALUE dest, VALUE obj)
static VALUE nil_to_f(VALUE obj)
static VALUE rb_true(VALUE obj)
VALUE rb_str_to_inum(VALUE str, int base, int badcheck)
void rb_attr(VALUE, ID, int, int, int)
VALUE rb_str_cat2(VALUE, const char *)
VALUE rb_obj_as_string(VALUE)
VALUE rb_mod_attr(int argc, VALUE *argv, VALUE klass)
static VALUE rb_mod_freeze(VALUE mod)
VALUE rb_check_to_integer(VALUE val, const char *method)
long rb_objid_hash(st_index_t index)
VALUE rb_mod_private_constant(int argc, VALUE *argv, VALUE obj)
static VALUE RCLASS_SET_SUPER(VALUE klass, VALUE super)
VALUE rb_define_class(const char *name, VALUE super)
Defines a top-level class.
VALUE rb_class_get_superclass(VALUE klass)
static VALUE rb_obj_singleton_class(VALUE obj)
VALUE rb_obj_freeze(VALUE obj)
static VALUE rb_class_initialize(int argc, VALUE *argv, VALUE klass)
static int rb_is_attr_id(ID id)
VALUE rb_class_search_ancestor(VALUE cl, VALUE c)
VALUE rb_Float(VALUE val)
VALUE rb_obj_setup(VALUE obj, VALUE klass, VALUE type)
static VALUE false_xor(VALUE obj, VALUE obj2)
void rb_undefined_alloc(VALUE klass)
#define MEMCPY(p1, p2, type, n)
rb_alloc_func_t rb_get_alloc_func(VALUE)
VALUE rb_obj_protected_methods(int argc, VALUE *argv, VALUE obj)
VALUE rb_mod_constants(int, VALUE *, VALUE)
VALUE rb_obj_equal(VALUE obj1, VALUE obj2)
static VALUE rb_f_float(VALUE obj, VALUE arg)
VALUE rb_const_get(VALUE, ID)
VALUE rb_str_subseq(VALUE, long, long)
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)
static ID check_setter_id(VALUE name, int(*valid_id_p)(ID), int(*valid_name_p)(VALUE), const char *message)
VALUE rb_obj_untrusted(VALUE obj)
VALUE rb_mod_class_variables(int, VALUE *, VALUE)
VALUE rb_obj_hash(VALUE obj)
VALUE rb_sprintf(const char *format,...)
static VALUE true_to_s(VALUE obj)
VALUE rb_class_superclass(VALUE klass)
int rb_is_local_id(ID id)
int rb_scan_args(int argc, const VALUE *argv, const char *fmt,...)
VALUE rb_ivar_set(VALUE, ID, VALUE)
VALUE rb_check_hash_type(VALUE hash)
unsigned char buf[MIME_BUF_SIZE]
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)
static VALUE nil_to_s(VALUE obj)
const char * rb_class2name(VALUE)
RUBY_EXTERN VALUE rb_cInteger
VALUE rb_make_metaclass(VALUE obj, VALUE unused)
VALUE rb_check_funcall(VALUE, ID, int, const VALUE *)
VALUE rb_check_convert_type(VALUE val, int type, const char *tname, const char *method)
#define rb_enc_asciicompat(enc)
VALUE rb_obj_untrust(VALUE obj)
VALUE rb_String(VALUE val)
#define IMPLICIT_CONVERSIONS
RUBY_EXTERN VALUE rb_cNumeric
st_table * st_init_numtable(void)
VALUE rb_obj_remove_instance_variable(VALUE, VALUE)
VALUE rb_check_to_int(VALUE val)
void Init_Object(void)
Initializes the world of objects and classes.
VALUE rb_class_instance_methods(int argc, VALUE *argv, VALUE mod)
VALUE rb_class_real(VALUE cl)
void rb_free_const_table(st_table *tbl)
static VALUE rb_obj_ivar_set(VALUE obj, VALUE iv, VALUE val)
static VALUE true_xor(VALUE obj, VALUE obj2)
int rb_is_const_name(VALUE name)
int rb_is_local_name(VALUE name)
VALUE rb_obj_alloc(VALUE klass)
VALUE rb_class_protected_instance_methods(int argc, VALUE *argv, VALUE mod)
int rb_const_defined_at(VALUE, ID)
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_module_new(void)
static VALUE convert_type(VALUE val, const char *tname, const char *method, int raise)
VALUE rb_obj_singleton_methods(int argc, VALUE *argv, VALUE obj)
#define ROBJECT_EMBED_LEN_MAX
static VALUE true_and(VALUE obj, VALUE obj2)
VALUE rb_check_array_type(VALUE ary)
static VALUE rb_f_string(VALUE obj, VALUE arg)
static VALUE rb_obj_inspect(VALUE obj)
static VALUE nil_to_a(VALUE obj)
VALUE rb_check_string_type(VALUE)
static int rb_special_const_p(VALUE obj)
VALUE rb_obj_init_dup_clone(VALUE obj, VALUE orig)
VALUE rb_mod_remove_const(VALUE, VALUE)
st_table * rb_st_copy(VALUE obj, struct st_table *orig_tbl)
VALUE rb_obj_methods(int argc, VALUE *argv, VALUE obj)
int rb_method_basic_definition_p(VALUE, ID)
VALUE rb_mod_const_missing(VALUE, VALUE)
static VALUE inspect_obj(VALUE obj, VALUE str, int recur)
VALUE rb_obj_is_kind_of(VALUE obj, VALUE c)
void rb_obj_infect(VALUE obj1, VALUE obj2)
VALUE rb_obj_init_copy(VALUE obj, VALUE orig)
VALUE rb_Array(VALUE val)
static VALUE rb_mod_cvar_defined(VALUE obj, VALUE iv)
static VALUE rb_class_s_alloc(VALUE klass)
static VALUE rb_mod_to_s(VALUE klass)
int rb_is_class_id(ID id)
static VALUE rb_mod_const_set(VALUE mod, VALUE name, VALUE value)
VALUE rb_const_get_at(VALUE, ID)
static int inspect_i(st_data_t k, st_data_t v, st_data_t a)
VALUE rb_obj_tainted(VALUE obj)
static VALUE rb_mod_const_defined(int argc, VALUE *argv, VALUE mod)
int rb_is_instance_name(VALUE name)
const char * rb_id2name(ID id)
#define StringValuePtr(v)
VALUE rb_obj_not_equal(VALUE obj1, VALUE obj2)
VALUE rb_mod_included_modules(VALUE mod)
static VALUE rb_false(VALUE obj)
static VALUE rb_f_integer(int argc, VALUE *argv, VALUE obj)
void rb_warning(const char *fmt,...)
#define rb_check_frozen(obj)
#define CONST_ID(var, str)
int rb_eql(VALUE obj1, VALUE obj2)
static VALUE false_to_s(VALUE obj)
void rb_copy_generic_ivar(VALUE, VALUE)
#define SPECIAL_CONST_P(x)
static ID id_for_attr(VALUE name)
VALUE rb_define_module(const char *name)
int rb_enc_str_asciionly_p(VALUE)
VALUE rb_usascii_str_new(const char *, long)
static VALUE rb_mod_gt(VALUE mod, VALUE arg)
static st_table * immediate_frozen_tbl
VALUE rb_obj_clone(VALUE obj)
static VALUE class_or_module_required(VALUE c)
VALUE(* rb_alloc_func_t)(VALUE)
VALUE rb_obj_hide(VALUE obj)
void rb_obj_call_init(VALUE obj, int argc, VALUE *argv)
VALUE rb_class_inherited_p(VALUE mod, VALUE arg)
void rb_define_method(VALUE klass, const char *name, VALUE(*func)(ANYARGS), int argc)
VALUE rb_str_append(VALUE, VALUE)
void rb_invalid_str(const char *str, const char *type)
VALUE rb_class_boot(VALUE super)
A utility function that wraps class_alloc.
VALUE rb_obj_frozen_p(VALUE obj)
#define rb_obj_instance_variables(object)
st_index_t rb_ivar_count(VALUE)
#define RUBY_DTRACE_OBJECT_CREATE(arg0, arg1, arg2)
VALUE rb_any_to_s(VALUE obj)
VALUE rb_attr_get(VALUE, ID)
VALUE rb_singleton_class_clone_and_attach(VALUE obj, VALUE attach)
VALUE rb_obj_is_instance_of(VALUE obj, VALUE c)
static VALUE rb_module_s_alloc(VALUE klass)
#define CLASS_OR_MODULE_P(obj)