Ruby 2.7.6p219 (2022-04-12 revision c9c2245c0a25176072e02db9254f0e0c84c805cd)
|
Macros | |
#define | wrong_constant_name bad_const_name |
#define | id_for_var(obj, name, type) id_for_setter(obj, name, type, bad_##type##_name) |
#define | id_for_setter(obj, name, type, message) check_setter_id(obj, &(name), rb_is_##type##_id, rb_is_##type##_name, message, strlen(message)) |
#define | IMPLICIT_CONVERSIONS 7 |
#define | try_to_int(val, mid, raise) convert_type_with_id(val, "Integer", mid, raise, -1) |
#define | opts_exception_p(opts) rb_opts_exception_p((opts), TRUE) |
Functions | |
void | rb_obj_call_init (VALUE obj, int argc, const VALUE *argv) |
Calls #initialize method of obj with the given arguments. More... | |
VALUE | rb_obj_hide (VALUE obj) |
Make the object invisible from Ruby code. More... | |
VALUE | rb_obj_reveal (VALUE obj, VALUE klass) |
Make a hidden object visible again. More... | |
VALUE | rb_obj_setup (VALUE obj, VALUE klass, VALUE type) |
Fills common (RBasic ) fields in obj. More... | |
VALUE | rb_equal (VALUE obj1, VALUE obj2) |
Same as Object#=== , case equality. More... | |
int | rb_eql (VALUE obj1, VALUE obj2) |
Determines if obj1 and obj2 are equal in terms of Object::eql ?. More... | |
VALUE | rb_obj_hash (VALUE obj) |
VALUE | rb_class_real (VALUE cl) |
Looks up the nearest ancestor of cl, skipping singleton classes or module inclusions. More... | |
VALUE | rb_obj_class (VALUE obj) |
Equivalent to Object#class in Ruby. More... | |
VALUE | rb_obj_clone (VALUE obj) |
Almost same as Object::clone . More... | |
VALUE | rb_obj_dup (VALUE obj) |
Equivalent to Object#dup in Ruby. More... | |
VALUE | rb_obj_init_copy (VALUE obj, VALUE orig) |
Default implementation of #initialize_copy . More... | |
VALUE | rb_obj_init_dup_clone (VALUE obj, VALUE orig) |
Default implementation of #initialize_dup and #initialize_clone . More... | |
VALUE | rb_any_to_s (VALUE obj) |
Default implementation of #to_s . More... | |
VALUE | rb_str_escape (VALUE str) |
VALUE | rb_inspect (VALUE obj) |
Convenient wrapper of Object::inspect . More... | |
VALUE | rb_obj_is_instance_of (VALUE obj, VALUE c) |
Determines if obj is an instance of c. More... | |
VALUE | rb_obj_is_kind_of (VALUE obj, VALUE c) |
Determines if obj is a kind of c. More... | |
VALUE | rb_obj_tainted (VALUE obj) |
call-seq: obj.tainted? -> false More... | |
VALUE | rb_obj_taint (VALUE obj) |
call-seq: obj.taint -> obj More... | |
VALUE | rb_obj_untaint (VALUE obj) |
call-seq: obj.untaint -> obj More... | |
VALUE | rb_obj_untrusted (VALUE obj) |
call-seq: obj.untrusted? -> false More... | |
VALUE | rb_obj_untrust (VALUE obj) |
call-seq: obj.untrust -> obj More... | |
VALUE | rb_obj_trust (VALUE obj) |
call-seq: obj.trust -> obj More... | |
void | rb_obj_infect (VALUE victim, VALUE carrier) |
Does nothing. More... | |
VALUE | rb_obj_freeze (VALUE obj) |
Make the object unmodifiable. More... | |
VALUE | rb_obj_frozen_p (VALUE obj) |
Determines if the object is frozen. More... | |
MJIT_FUNC_EXPORTED VALUE | rb_false (VALUE obj) |
VALUE | rb_class_inherited_p (VALUE mod, VALUE arg) |
Determines if mod inherits arg. More... | |
VALUE | rb_obj_alloc (VALUE klass) |
Allocates an instance of klass. More... | |
VALUE | rb_class_new_instance_kw (int argc, const VALUE *argv, VALUE klass, int kw_splat) |
VALUE | rb_class_new_instance (int argc, const VALUE *argv, VALUE klass) |
Allocates and initializes an instance of klass. More... | |
VALUE | rb_class_superclass (VALUE klass) |
Returns the superclass of klass. More... | |
VALUE | rb_class_get_superclass (VALUE klass) |
Returns the superclass of klass The return value might be an iclass of a module, unlike rb_class_superclass. More... | |
VALUE | rb_convert_type (VALUE val, int type, const char *tname, const char *method) |
Converts an object into another type. More... | |
VALUE | rb_check_convert_type (VALUE val, int type, const char *tname, const char *method) |
Tries to convert an object into another type. More... | |
ALWAYS_INLINE (static VALUE rb_to_integer(VALUE val, const char *method, ID mid)) | |
VALUE | rb_check_to_integer (VALUE val, const char *method) |
Tries to convert val into Integer . More... | |
VALUE | rb_to_int (VALUE val) |
Converts val into Integer . More... | |
VALUE | rb_check_to_int (VALUE val) |
Tries to convert val into Integer. More... | |
VALUE | rb_Integer (VALUE val) |
Equivalent to Kernel#Integer in Ruby. More... | |
int | rb_bool_expected (VALUE obj, const char *flagname) |
int | rb_opts_exception_p (VALUE opts, int default_value) |
double | rb_cstr_to_dbl (const char *p, int badcheck) |
Parses a string representation of a floating point number. More... | |
FUNC_MINIMIZED (double rb_str_to_dbl(VALUE str, int badcheck)) | |
double | rb_str_to_dbl (VALUE str, int badcheck) |
Parses a string representation of a floating point number. More... | |
FUNC_MINIMIZED (VALUE rb_Float(VALUE val)) | |
VALUE | rb_Float (VALUE val) |
Equivalent to Kernel#Float in Ruby. More... | |
VALUE | rb_to_float (VALUE val) |
Converts a Numeric object into Float . More... | |
VALUE | rb_check_to_float (VALUE val) |
Tries to convert an object into Float . More... | |
double | rb_num2dbl (VALUE val) |
Converts a Numeric object to double . More... | |
VALUE | rb_String (VALUE val) |
Equivalent to Kernel#String in Ruby. More... | |
VALUE | rb_Array (VALUE val) |
Equivalent to Kernel#Array in Ruby. More... | |
VALUE | rb_Hash (VALUE val) |
Equivalent to Kernel#Hash in Ruby. More... | |
void | Init_Object (void) |
Variables | |
VALUE | rb_cBasicObject |
BasicObject class. More... | |
VALUE | rb_mKernel |
Kernel module. More... | |
VALUE | rb_cObject |
Object class. More... | |
VALUE | rb_cModule |
Module class. More... | |
VALUE | rb_cClass |
Class class. More... | |
VALUE | rb_cData |
Data class. More... | |
VALUE | rb_cNilClass |
NilClass class. More... | |
VALUE | rb_cTrueClass |
TrueClass class. More... | |
VALUE | rb_cFalseClass |
FalseClass class. More... | |
#define id_for_var | ( | obj, | |
name, | |||
type | |||
) | id_for_setter(obj, name, type, bad_##type##_name) |
#define opts_exception_p | ( | opts | ) | rb_opts_exception_p((opts), TRUE) |
ALWAYS_INLINE | ( | static VALUE | rb_to_integerVALUE val, const char *method, ID mid | ) |
FUNC_MINIMIZED | ( | double | rb_str_to_dblVALUE str, int badcheck | ) |
FUNC_MINIMIZED | ( | VALUE | rb_FloatVALUE val | ) |
Default implementation of #to_s
.
Definition at line 527 of file object.c.
References CLASS_OF, obj, PRIsVALUE, rb_class_name(), rb_sprintf(), and str.
Referenced by rb_int2str(), and rb_obj_as_string_result().
Equivalent to Kernel#Array
in Ruby.
Definition at line 3684 of file object.c.
References NIL_P, rb_ary_new3, rb_check_array_type(), and rb_check_to_array().
Definition at line 3112 of file object.c.
References obj, PRIsVALUE, Qfalse, Qtrue, rb_eArgError, and rb_raise().
Referenced by rb_opts_exception_p().
Tries to convert an object into another type.
Calls the specified conversion method if necessary.
[in] | val | the object to be converted |
[in] | type | a value of ruby_value_type |
[in] | tname | name of the target type. only used for error messages. |
[in] | method | name of the method |
TypeError | if the conversion method returns an unexpected type of value. |
Definition at line 2941 of file object.c.
References T_DATA, TYPE, and v.
Referenced by rb_check_regexp_type().
Tries to convert an object into Float
.
It calls #to_f
if necessary.
It returns Qnil
if the object is not a Numeric
or #to_f
is not defined on the object.
Definition at line 3559 of file object.c.
References Qnil, rb_cNumeric, rb_obj_is_kind_of(), RB_TYPE_P, and T_FLOAT.
Tries to convert val into Integer.
It calls #to_int
method if necessary.
[in] | val | a Ruby object |
Qnil
if #to_int
is not defined. TypeError | if #to_int returns a non-Integer object. |
Definition at line 3036 of file object.c.
References FALSE, idTo_int, Qnil, RB_INTEGER_TYPE_P, and try_to_int.
Tries to convert val into Integer
.
It calls the specified conversion method if necessary.
[in] | val | a Ruby object |
[in] | method | a name of a method |
Integer
object on success, or Qnil
if no such conversion method defined. TypeError | if the conversion method returns a non-Integer object. |
Returns the superclass of klass The return value might be an iclass of a module, unlike rb_class_superclass.
Also it returns Qfalse when klass does not have a parent class.
Determines if mod inherits arg.
Equivalent to Module#<=
in Ruby
[in] | mod | a Module object |
[in] | arg | another Module object or an iclass of a module |
Qtrue | if mod inherits arg, or mod equals arg |
Qfalse | if arg inherits mod |
Qnil | if otherwise |
Definition at line 1574 of file object.c.
References arg, CLASS_OR_MODULE_P, mod, Qtrue, rb_eTypeError, rb_raise(), RB_TYPE_P, and T_ICLASS.
Allocates and initializes an instance of klass.
Equivalent to Class#new
in Ruby
[in] | argc | the number of arguments to #initialize |
[in] | argv | a pointer to an array of arguments to #initialize |
[in] | klass | a Class object |
Definition at line 1955 of file object.c.
References Check_Type, klass, obj, and T_CLASS.
Referenced by Init_Exception(), rb_exc_new(), rb_exc_new_str(), rb_exit(), rb_f_abort(), rb_fiddle_new_function(), rb_name_error(), rb_name_error_str(), rb_struct_alloc(), rb_syserr_new_str(), and rb_throw_obj().
Looks up the nearest ancestor of cl, skipping singleton classes or module inclusions.
It returns the cl itself if it is neither a singleton class or a module.
[in] | cl | a Class object. |
Definition at line 202 of file object.c.
References BUILTIN_TYPE, FL_SINGLETON, RBASIC, RCLASS_SUPER, and T_ICLASS.
Referenced by rb_class_name(), rb_define_class(), rb_define_class_id_under(), rb_obj_class(), rb_vm_bugreport(), and ruby_vm_special_exception_copy().
Returns the superclass of klass.
Equivalent to Class#superclass
in Ruby.
It skips modules.
[in] | klass | a Class object |
Qnil
if klass does not have a parent class. Definition at line 1976 of file object.c.
References klass, Qnil, rb_cBasicObject, rb_eTypeError, rb_raise(), RB_TYPE_P, RCLASS_SUPER, and T_ICLASS.
Converts an object into another type.
Calls the specified conversion method if necessary.
[in] | val | the object to be converted |
[in] | type | a value of ruby_value_type |
[in] | tname | name of the target type. only used for error messages. |
[in] | method | name of the method |
TypeError | on failure |
Definition at line 2900 of file object.c.
Referenced by rb_numeric_quo().
Parses a string representation of a floating point number.
[in] | p | a string representation of a floating number |
[in] | badcheck | raises an exception on parse error if badcheck is non-zero. |
Same as Object#===
, case equality.
Definition at line 124 of file object.c.
Referenced by rb_ary_assoc(), rb_ary_delete(), rb_ary_includes(), rb_ary_rassoc(), and rb_str_equal().
MJIT_FUNC_EXPORTED VALUE rb_false | ( | VALUE | obj | ) |
Equivalent to Kernel#Hash
in Ruby.
Definition at line 3727 of file object.c.
References NIL_P, RARRAY_LEN, rb_check_hash_type(), rb_eTypeError, rb_hash_new(), rb_obj_classname(), rb_raise(), RB_TYPE_P, and T_ARRAY.
Convenient wrapper of Object::inspect
.
Returns a human-readable string representation of obj, similarly to Object::inspect
.
Unlike Ruby-level #inspect
, it escapes characters to keep the result compatible to the default internal or external encoding. If the default internal or external encoding is ASCII compatible, the encoding of the inspected result must be compatible with it. If the default internal or external encoding is ASCII incompatible, the result must be ASCII only.
Definition at line 551 of file object.c.
References NULL, obj, rb_default_external_encoding(), rb_default_internal_encoding(), rb_enc_asciicompat, rb_enc_get(), rb_enc_str_asciionly_p(), rb_funcallv, rb_obj_as_string(), rb_str_escape(), and str.
Referenced by rb_keyword_error_new(), rb_p(), rb_vmdebug_debug_print_post(), and rb_vmdebug_proc_dump_raw().
Equivalent to Kernel#Integer
in Ruby.
Converts val into Integer
in a slightly more strict manner than #to_i
.
Definition at line 3106 of file object.c.
Referenced by ossl_time_split(), and value_to_generic().
Converts a Numeric
object to double
.
[in] | val | a Numeric object |
TypeError | if val is not a Numeric or it does not support conversion to a floating point number. |
Definition at line 3616 of file object.c.
References FIXNUM_P, FLONUM_P, and SPECIAL_CONST_P.
Allocates an instance of klass.
[in] | klass | a Class object |
Definition at line 1895 of file object.c.
References Check_Type, klass, and T_CLASS.
Referenced by Init_top_self(), rb_catch(), rb_key_err_new(), rb_last_status_set(), rb_name_err_new(), rb_nomethod_err_new(), rb_range_new(), and ruby_vm_special_exception_copy().
Calls #initialize
method of obj with the given arguments.
It also forwards the given block to #initialize
if given.
[in] | obj | the receiver object |
[in] | argc | the number of arguments |
[in] | argv | a pointer to the array of arguments |
Definition at line 1681 of file eval.c.
References argc, argv, idInitialize, obj, PASS_PASSED_BLOCK_HANDLER, rb_funcallv_kw(), and RB_NO_KEYWORDS.
Equivalent to Object#class
in Ruby.
Returns the class of obj
, skipping singleton classes or module inclusions.
Definition at line 217 of file object.c.
References CLASS_OF, obj, and rb_class_real().
Referenced by rb_ary_subseq(), rb_block_to_s(), rb_check_inheritable(), rb_define_class(), rb_define_class_id_under(), rb_define_module(), rb_define_module_id_under(), rb_obj_init_copy(), rb_struct_members(), and rb_vm_bugreport().
Almost same as Object::clone
.
Definition at line 410 of file object.c.
Referenced by rb_eval_string_wrap().
Make the object unmodifiable.
Equivalent to Object#freeze
in Ruby.
[in,out] | obj | the object to be frozen |
Definition at line 1080 of file object.c.
References obj, OBJ_FREEZE, OBJ_FROZEN, rb_bug(), and SPECIAL_CONST_P.
Referenced by rb_ary_freeze(), rb_insns_name_array(), rb_iseq_pathobj_new(), rb_str_freeze(), and rb_vm_register_special_exception_str().
Make the object invisible from Ruby code.
It is useful to let Ruby's GC manage your internal data structure – The object keeps being managed by GC, but ObjectSpace.each_object
never yields the object.
Note that the object also lose a way to call a method on it.
[in] | obj | a Ruby object |
Definition at line 78 of file object.c.
References obj, RBASIC_CLEAR_CLASS, and SPECIAL_CONST_P.
Referenced by Init_sym().
Does nothing.
This method is deprecated and will be removed in Ruby 3.2.
Definition at line 1068 of file object.c.
References rb_warning().
Default implementation of #initialize_copy
.
[in,out] | obj | the receiver being initialized |
[in] | orig | the object to be copied from. |
Definition at line 500 of file object.c.
References obj, rb_check_frozen, rb_eTypeError, rb_obj_class(), rb_raise(), and TYPE.
Default implementation of #initialize_dup
and #initialize_clone
.
[in,out] | obj | the receiver being initialized |
[in] | orig | the object to be dup or cloned from. |
Definition at line 517 of file object.c.
References obj, and rb_funcall.
Determines if obj is a kind of c.
Equivalent to Object#kind_of
? in Ruby.
[in] | obj | the object to be determined |
[in] | c | a Module object. |
Definition at line 692 of file object.c.
Referenced by ole_val2variant(), ossl_evp_get_cipherbyname(), rb_arithmetic_sequence_extract(), rb_check_to_float(), rb_enumeratorize_with_size(), rb_enumeratorize_with_size_kw(), rb_node_case_when_optimizable_literal(), rb_range_values(), and rb_set_errinfo().
Make a hidden object visible again.
It is the caller's responsibility to pass the right klass which obj originally used to belong to.
Definition at line 95 of file object.c.
References klass, obj, RBASIC_SET_CLASS, and SPECIAL_CONST_P.
Fills common (RBasic
) fields in obj.
[in,out] | obj | a Ruby object to be set up. |
[in] | klass | obj will belong to this class. |
[in] | type | one of ruby_value_type |
Definition at line 112 of file object.c.
References klass, obj, RBASIC, and RBASIC_SET_CLASS.
call-seq: obj.taint -> obj
Returns object. This method is deprecated and will be removed in Ruby 3.2.
Definition at line 999 of file object.c.
References obj, and rb_warning().
call-seq: obj.tainted? -> false
Returns false. This method is deprecated and will be removed in Ruby 3.2.
Definition at line 985 of file object.c.
References Qfalse, and rb_warning().
call-seq: obj.trust -> obj
Returns object. This method is deprecated and will be removed in Ruby 3.2.
Definition at line 1057 of file object.c.
References obj, and rb_warning().
call-seq: obj.untaint -> obj
Returns object. This method is deprecated and will be removed in Ruby 3.2.
Definition at line 1014 of file object.c.
References obj, and rb_warning().
call-seq: obj.untrust -> obj
Returns object. This method is deprecated and will be removed in Ruby 3.2.
Definition at line 1042 of file object.c.
References obj, and rb_warning().
call-seq: obj.untrusted? -> false
Returns false. This method is deprecated and will be removed in Ruby 3.2.
Definition at line 1028 of file object.c.
References Qfalse, and rb_warning().
Definition at line 3125 of file object.c.
References idException, rb_bool_expected(), and rb_get_kwargs().
Definition at line 5866 of file string.c.
References buf, CHAR_ESC_LEN, ENCODING_GET, rb_enc_from_index(), RSTRING_END, RSTRING_PTR, and str.
Referenced by rb_inspect().
Parses a string representation of a floating point number.
[in] | str | a String object representation of a floating number |
[in] | badcheck | raises an exception on parse error if badcheck is non-zero. |
Equivalent to Kernel#String
in Ruby.
Converts val into String
by trying #to_str
at first and then trying #to_s
.
Definition at line 3652 of file object.c.
References NIL_P, and rb_check_string_type().
Converts val into Integer
.
It calls #to_int method if necessary.
[in] | val | a Ruby object |
Integer
object TypeError | on failure |
Definition at line 3021 of file object.c.
Referenced by rb_absint_singlebit_p(), rb_absint_size(), rb_fix_aref(), rb_integer_pack(), and rb_num2long().
VALUE rb_cBasicObject |
BasicObject class.
Definition at line 32 of file object.c.
Referenced by Init_class_hierarchy(), rb_class_superclass(), and rb_clear_method_cache_by_class().
VALUE rb_cClass |
VALUE rb_cData |
Data class.
Definition at line 37 of file object.c.
Referenced by Init_stringio(), and rsock_init_sockifaddr().
VALUE rb_cObject |
Object class.
Definition at line 34 of file object.c.
Referenced by Init_Array(), Init_Bignum(), Init_Binding(), Init_cparse(), Init_Dir(), Init_Encoding(), Init_Exception(), Init_fiddle_closure(), Init_fiddle_function(), Init_fiddle_handle(), Init_ISeq(), Init_monitor(), Init_objspace(), Init_ossl_bn(), Init_ossl_cipher(), Init_ossl_config(), Init_ossl_dh(), Init_ossl_dsa(), Init_ossl_ec(), Init_ossl_engine(), Init_ossl_hmac(), Init_ossl_ns_spki(), Init_ossl_ocsp(), Init_ossl_pkcs12(), Init_ossl_pkcs7(), Init_ossl_pkey(), Init_ossl_rsa(), Init_ossl_ssl_session(), Init_ossl_x509attr(), Init_ossl_x509cert(), Init_ossl_x509crl(), Init_ossl_x509ext(), Init_ossl_x509req(), Init_ossl_x509revoked(), Init_Proc(), Init_psych_emitter(), Init_psych_parser(), Init_psych_to_ruby(), Init_psych_yaml_tree(), Init_String(), Init_top_self(), Init_VM(), Init_win32ole_method(), Init_win32ole_param(), Init_win32ole_record(), Init_win32ole_type(), Init_win32ole_typelib(), Init_win32ole_variable(), Init_win32ole_variant(), InitVM_Struct(), rb_catch(), rb_class_inherited(), rb_clear_method_cache_by_class(), rb_const_warn_if_deprecated(), rb_define_class(), rb_define_class_id(), rb_define_global_const(), rb_define_module(), rb_mod_const_of(), rb_path_to_class(), rb_uninterruptible(), rsock_init_ancdata(), and rsock_init_sockopt().
VALUE rb_mKernel |
Kernel module.
Definition at line 33 of file object.c.
Referenced by Init_eval_method(), InitVM_Enumerator(), rb_clear_method_cache_by_class(), and rb_define_global_function().