Ruby: Core objects and their operations

Ruby 3.4.9p82 (2026-03-11 revision 76cca827ab52ab1d346a728f068d5b8da3e2952b)

Data Structures | Macros | Functions | Variables
Core objects and their operations

## Macros
#define | RUBY_INTEGER_UNIFICATION 1
#define | case_equal rb_equal
#define | rb_obj_class_inherited rb_obj_dummy1
#define | rb_obj_mod_method_added rb_obj_dummy1
#define | rb_obj_mod_method_removed rb_obj_dummy1
#define | rb_obj_mod_method_undefined rb_obj_dummy1
#define | rb_obj_singleton_method_added rb_obj_dummy1
#define | rb_obj_singleton_method_removed rb_obj_dummy1
#define | rb_obj_singleton_method_undefined rb_obj_dummy1
#define | rb_obj_mod_const_added rb_obj_dummy1
#define | rb_obj_mod_extended rb_obj_dummy1
#define | rb_obj_mod_included rb_obj_dummy1
#define | rb_obj_mod_prepended rb_obj_dummy1
#define | rb_obj_initialize rb_obj_dummy0
#define | false_or true_and
#define | false_xor true_and
#define | wrong_constant_name bad_const_name
#define | id_for_var(obj, name, type)
#define | id_for_setter(obj, name, type, message)
#define | IMPLICIT_CONVERSIONS 7
#define | try_to_int(val, mid, raise)
#define | rb_to_integer(val, method, mid)

## Functions
static VALUE | rb_class_of (VALUE obj)
| Object to class mapping function.
size_t | rb_obj_embedded_size (uint32_t numiv)
| Internal header for Object.
VALUE | rb_obj_hide (VALUE obj)
| Make the object invisible from Ruby code.
VALUE | rb_obj_reveal (VALUE obj, VALUE klass)
| Make a hidden object visible again.
VALUE | rb_class_allocate_instance (VALUE klass)
VALUE | rb_obj_setup (VALUE obj, VALUE klass, VALUE type)
| Fills common fields in the object.
VALUE | rb_equal (VALUE obj1, VALUE obj2)
| This function is an optimised version of calling #==.
int | rb_eql (VALUE obj1, VALUE obj2)
| Checks for equality of the passed objects, in terms of Object#eql?.
VALUE | rb_obj_hash (VALUE obj)
VALUE | rb_class_real (VALUE cl)
| Finds a "real" class.
VALUE | rb_obj_class (VALUE obj)
| Queries the class of an object.
static VALUE | rb_obj_singleton_class (VALUE obj)
static void | init_copy (VALUE dest, VALUE obj)
static VALUE | immutable_obj_clone (VALUE obj, VALUE kwfreeze)
static VALUE | mutable_obj_clone (VALUE obj, VALUE kwfreeze)
static VALUE | obj_freeze_opt (VALUE freeze)
static VALUE | rb_obj_clone2 (rb_execution_context_t *ec, VALUE obj, VALUE freeze)
VALUE | rb_get_freeze_opt (int argc, VALUE *argv)
VALUE | rb_obj_clone_setup (VALUE obj, VALUE clone, VALUE kwfreeze)
VALUE | rb_obj_clone (VALUE obj)
| Produces a shallow copy of the given object.
VALUE | rb_obj_dup_setup (VALUE obj, VALUE dup)
VALUE | rb_obj_dup (VALUE obj)
| Duplicates the given object.
static VALUE | rb_obj_itself (VALUE obj)
VALUE | rb_obj_size (VALUE self, VALUE args, VALUE obj)
VALUE | rb_obj_init_copy (VALUE obj, VALUE orig)
| Default implementation of #initialize_copy.
VALUE | rb_obj_init_dup_clone (VALUE obj, VALUE orig)
| Default implementation of #initialize_dup.
static VALUE | rb_obj_init_clone (int argc, VALUE *argv, VALUE obj)
| Default implementation of #initialize_clone.
VALUE | rb_any_to_s (VALUE obj)
| Generates a textual representation of the given object.
VALUE | rb_inspect (VALUE obj)
| Generates a human-readable textual representation of the given object.
static int | inspect_i (ID id, VALUE value, st_data_t a)
static VALUE | inspect_obj (VALUE obj, VALUE str, int recur)
static VALUE | rb_obj_inspect (VALUE obj)
static VALUE | class_or_module_required (VALUE c)
static VALUE | class_search_ancestor (VALUE cl, VALUE c)
VALUE | rb_obj_is_instance_of (VALUE obj, VALUE c)
| Queries if the given object is a direct instance of the given class.
static VALUE | class_search_class_ancestor (VALUE cl, VALUE c)
VALUE | rb_obj_is_kind_of (VALUE obj, VALUE c)
| Queries if the given object is an instance (of possibly descendants) of the given class.
static VALUE | rb_obj_dummy (void)
static VALUE | rb_obj_dummy0 (VALUE _)
static VALUE | rb_obj_dummy1 (VALUE _x, VALUE _y)
VALUE | rb_obj_freeze (VALUE obj)
| Just calls rb_obj_freeze_inline() inside.
VALUE | rb_obj_frozen_p (VALUE obj)
| Just calls RB_OBJ_FROZEN() inside.
VALUE | rb_nil_to_s (VALUE obj)
static VALUE | nil_to_a (VALUE obj)
static VALUE | nil_to_h (VALUE obj)
static VALUE | nil_inspect (VALUE obj)
static VALUE | nil_match (VALUE obj1, VALUE obj2)
VALUE | rb_true_to_s (VALUE obj)
static VALUE | true_and (VALUE obj, VALUE obj2)
static VALUE | true_or (VALUE obj, VALUE obj2)
static VALUE | true_xor (VALUE obj, VALUE obj2)
VALUE | rb_false_to_s (VALUE obj)
static VALUE | false_and (VALUE obj, VALUE obj2)
static VALUE | rb_true (VALUE obj)
VALUE | rb_false (VALUE obj)
static VALUE | rb_obj_not_match (VALUE obj1, VALUE obj2)
static VALUE | rb_obj_cmp (VALUE obj1, VALUE obj2)
VALUE | rb_mod_to_s (VALUE klass)
static VALUE | rb_mod_freeze (VALUE mod)
static VALUE | rb_mod_eqq (VALUE mod, VALUE arg)
VALUE | rb_class_inherited_p (VALUE mod, VALUE arg)
| Determines if the given two modules are relatives.
static VALUE | rb_mod_lt (VALUE mod, VALUE arg)
static VALUE | rb_mod_ge (VALUE mod, VALUE arg)
static VALUE | rb_mod_gt (VALUE mod, VALUE arg)
static VALUE | rb_mod_cmp (VALUE mod, VALUE arg)
static VALUE | rb_mod_initialize_exec (VALUE module)
static VALUE | rb_mod_initialize (VALUE module)
static VALUE | rb_mod_initialize_clone (int argc, VALUE *argv, VALUE clone)
static VALUE | rb_class_initialize (int argc, VALUE *argv, VALUE klass)
static rb_alloc_func_t | class_get_alloc_func (VALUE klass)
static VALUE | class_call_alloc_func (rb_alloc_func_t allocator, VALUE klass)
static VALUE | rb_class_alloc_m (VALUE klass)
static VALUE | rb_class_alloc (VALUE klass)
VALUE | rb_obj_alloc (VALUE klass)
| Allocates an instance of the given class.
VALUE | rb_class_new_instance_pass_kw (int argc, const VALUE *argv, VALUE klass)
| Identical to rb_class_new_instance(), except it passes the passed keywords if any to the #initialize method.
VALUE | rb_class_new_instance_kw (int argc, const VALUE *argv, VALUE klass, int kw_splat)
| Identical to rb_class_new_instance(), except you can specify how to handle the last element of the given array.
VALUE | rb_class_new_instance (int argc, const VALUE *argv, VALUE klass)
| Allocates, then initialises an instance of the given class.
VALUE | rb_class_superclass (VALUE klass)
| Returns the superclass of klass.
VALUE | rb_class_get_superclass (VALUE klass)
| Returns the superclass of a class.
static ID | check_setter_id (VALUE obj, VALUE *pname, int(*valid_id_p)(ID), int(*valid_name_p)(VALUE), const char *message, size_t message_len)
static int | rb_is_attr_name (VALUE name)
static int | rb_is_attr_id (ID id)
static ID | id_for_attr (VALUE obj, VALUE name)
static VALUE | rb_mod_attr_reader (int argc, VALUE *argv, VALUE klass)
static VALUE | rb_mod_attr_writer (int argc, VALUE *argv, VALUE klass)
static VALUE | rb_mod_attr_accessor (int argc, VALUE *argv, VALUE klass)
static VALUE | rb_mod_const_get (int argc, VALUE *argv, VALUE mod)
static VALUE | rb_mod_const_set (VALUE mod, VALUE name, VALUE value)
static VALUE | rb_mod_const_defined (int argc, VALUE *argv, VALUE mod)
static VALUE | rb_mod_const_source_location (int argc, VALUE *argv, VALUE mod)
static VALUE | rb_obj_ivar_get (VALUE obj, VALUE iv)
static VALUE | rb_obj_ivar_set_m (VALUE obj, VALUE iv, VALUE val)
static VALUE | rb_obj_ivar_defined (VALUE obj, VALUE iv)
static VALUE | rb_mod_cvar_get (VALUE obj, VALUE iv)
static VALUE | rb_mod_cvar_set (VALUE obj, VALUE iv, VALUE val)
static VALUE | rb_mod_cvar_defined (VALUE obj, VALUE iv)
static VALUE | rb_mod_singleton_p (VALUE klass)
static int | conv_method_index (const char *method)
static VALUE | convert_type_with_id (VALUE val, const char *tname, ID method, int raise, int index)
static VALUE | convert_type (VALUE val, const char *tname, const char *method, int raise)
VALUE | rb_convert_type (VALUE val, int type, const char *tname, const char *method)
| Converts an object into another type.
VALUE | rb_check_convert_type (VALUE val, int type, const char *tname, const char *method)
| Identical to rb_convert_type(), except it returns RUBY_Qnil instead of raising exceptions, in case of conversion failure.
static VALUE | rb_to_integer_with_id_exception (VALUE val, const char *method, ID mid, int raise)
VALUE | rb_check_to_integer (VALUE val, const char *method)
| Identical to rb_check_convert_type(), except the return value type is fixed to rb_cInteger.
VALUE | rb_to_int (VALUE val)
| Identical to rb_check_to_int(), except it raises in case of conversion mismatch.
VALUE | rb_check_to_int (VALUE val)
| Identical to rb_check_to_integer(), except it uses #to_int for conversion.
static VALUE | rb_check_to_i (VALUE val)
static VALUE | rb_convert_to_integer (VALUE val, int base, int raise_exception)
VALUE | rb_Integer (VALUE val)
| This is the logic behind Kernel#Integer.
VALUE | rb_check_integer_type (VALUE val)
int | rb_bool_expected (VALUE obj, const char *flagname, int raise)
int | rb_opts_exception_p (VALUE opts, int default_value)
static VALUE | rb_f_integer1 (rb_execution_context_t *ec, VALUE obj, VALUE arg)
static VALUE | rb_f_integer (rb_execution_context_t *ec, VALUE obj, VALUE arg, VALUE base, VALUE exception)
static bool | is_digit_char (unsigned char c, int base)
static double | rb_cstr_to_dbl_raise (const char *p, rb_encoding *enc, int badcheck, int raise, int *error)
double | rb_cstr_to_dbl (const char *p, int badcheck)
| Converts a textual representation of a real number into a numeric, which is the nearest value that the return type can represent, of the value that the argument represents.
static double | rb_str_to_dbl_raise (VALUE str, int badcheck, int raise, int *error)
| FUNC_MINIMIZED (double rb_str_to_dbl(VALUE str, int badcheck))
double | rb_str_to_dbl (VALUE str, int badcheck)
| Identical to rb_cstr_to_dbl(), except it accepts a Ruby's string instead of C's.
static void | conversion_to_float (VALUE val)
static void | implicit_conversion_to_float (VALUE val)
static int | to_float (VALUE *valp, int raise_exception)
static VALUE | convert_type_to_float_protected (VALUE val)
static VALUE | rb_convert_to_float (VALUE val, int raise_exception)
| FUNC_MINIMIZED (VALUE rb_Float(VALUE val))
VALUE | rb_Float (VALUE val)
| This is the logic behind Kernel#Float.
static VALUE | rb_f_float1 (rb_execution_context_t *ec, VALUE obj, VALUE arg)
static VALUE | rb_f_float (rb_execution_context_t *ec, VALUE obj, VALUE arg, VALUE opts)
static VALUE | numeric_to_float (VALUE val)
VALUE | rb_to_float (VALUE val)
| Identical to rb_check_to_float(), except it raises on error.
VALUE | rb_check_to_float (VALUE val)
| This is complicated.
static int | basic_to_f_p (VALUE klass)
double | rb_num2dbl (VALUE val)
| Converts an instance of rb_cNumeric into C's double.
VALUE | rb_String (VALUE val)
| This is the logic behind Kernel#String.
static VALUE | rb_f_string (VALUE obj, VALUE arg)
VALUE | rb_Array (VALUE val)
| This is the logic behind Kernel#Array.
static VALUE | rb_f_array (VALUE obj, VALUE arg)
VALUE | rb_Hash (VALUE val)
| Equivalent to `Kernel#Hash` in Ruby.
static VALUE | rb_f_hash (VALUE obj, VALUE arg)
static int | dig_basic_p (VALUE obj, struct dig_method *cache)
static void | no_dig_method (int found, VALUE recv, ID mid, int argc, const VALUE *argv, VALUE data)
static VALUE | f_sprintf (int c, const VALUE *v, VALUE _)
static VALUE | rb_f_loop_size (VALUE self, VALUE args, VALUE eobj)
void | InitVM_Object (void)
void | Init_Object (void)

## Variables
VALUE | rb_cEncoding
| Encoding class.
VALUE | rb_mKernel
| Kernel module.
VALUE | rb_mComparable
| Comparable module.
VALUE | rb_mEnumerable
| Enumerable module.
VALUE | rb_mErrno
| Errno module.
VALUE | rb_mFileTest
| FileTest module.
VALUE | rb_mGC
| GC module.
VALUE | rb_mMath
| Math module.
VALUE | rb_mProcess
| Process module.
VALUE | rb_mWaitReadable
| IO::WaitReadable module.
VALUE | rb_mWaitWritable
| IO::WaitReadable module.
VALUE | rb_cBasicObject
| BasicObject class.
VALUE | rb_cObject
| Object class.
VALUE | rb_cArray
| Array class.
VALUE | rb_cBinding
| Binding class.
VALUE | rb_cClass
| Class class.
VALUE | rb_cDir
| Dir class.
VALUE | rb_cEncoding
| Encoding class.
VALUE | rb_cEnumerator
| Enumerator class.
VALUE | rb_cFalseClass
| FalseClass class.
VALUE | rb_cFile
| File class.
VALUE | rb_cComplex
| Complex class.
VALUE | rb_cFloat
| Float class.
VALUE | rb_cHash
| Hash class.
VALUE | rb_cIO
| IO class.
VALUE | rb_cInteger
| Module class.
VALUE | rb_cMatch
| MatchData class.
VALUE | rb_cMethod
| Method class.
VALUE | rb_cModule
| Module class.
VALUE | rb_cRefinement
| Refinement class.
VALUE | rb_cNameErrorMesg
| NameError::Message class.
VALUE | rb_cNilClass
| NilClass class.
VALUE | rb_cNumeric
| Numeric class.
VALUE | rb_cProc
| Proc class.
VALUE | rb_cRandom
| Random class.
VALUE | rb_cRange
| Range class.
VALUE | rb_cRational
| Rational class.
VALUE | rb_cRegexp
| Regexp class.
VALUE | rb_cStat
| File::Stat class.
VALUE | rb_cString
| String class.
VALUE | rb_cStruct
| Struct class.
VALUE | rb_cSymbol
| Symbol class.
VALUE | rb_cThread
| Thread class.
VALUE | rb_cTime
| Time class.
VALUE | rb_cTrueClass
| TrueClass class.
VALUE | rb_cUnboundMethod
| UnboundMethod class.
VALUE | rb_stdin
| STDIN constant.
VALUE | rb_stdout
| STDOUT constant.
VALUE | rb_stderr
| STDERR constant.
VALUE | rb_cRactor
| Ractor class.
VALUE | rb_cBasicObject
| BasicObject class.
VALUE | rb_mKernel
| Kernel module.
VALUE | rb_cObject
| Documented in include/ruby/internal/globals.h.
VALUE | rb_cModule
| Module class.
VALUE | rb_cClass
| Class class.
VALUE | rb_cRefinement
| Refinement class.
VALUE | rb_cNilClass
| NilClass class.
VALUE | rb_cTrueClass
| TrueClass class.
VALUE | rb_cFalseClass
| FalseClass class.
static VALUE | rb_cNilClass_to_s
static VALUE | rb_cTrueClass_to_s
static VALUE | rb_cFalseClass_to_s
static const char | bad_instance_name [] = "'%1$s' is not allowed as an instance variable name"
static const char | bad_class_name [] = "'%1$s' is not allowed as a class variable name"
static const char | bad_const_name [] = "wrong constant name %1$s"
static const char | bad_attr_name [] = "invalid attribute name '%1$s'"
static ID | id_dig

## Detailed Description

## Macro Definition Documentation

## ◆ case_equal

#define case_equal rb_equal

Definition at line 174 of file object.c.

## ◆ false_or

#define false_or true_and

Definition at line 1562 of file object.c.

## ◆ false_xor

#define false_xor true_and

Definition at line 1577 of file object.c.

## ◆ id_for_setter

#define id_for_setter | ( |  | obj,
|  |  | name,
|  |  | type,
|  |  | message )

Value:
check_setter_id(obj, &(name), rb_is_##type##_id, rb_is_##type##_name, message, strlen(message))
ruby::backward::cxxanyargs::type
VALUE type(ANYARGS)
ANYARGS-ed function type.
Definition cxxanyargs.hpp:56

Definition at line 2189 of file object.c.

## ◆ id_for_var

#define id_for_var | ( |  | obj,
|  |  | name,
|  |  | type )

Value:
id_for_setter(obj, name, type, bad_##type##_name)

Definition at line 2187 of file object.c.

## ◆ IMPLICIT_CONVERSIONS

#define IMPLICIT_CONVERSIONS 7

Definition at line 3026 of file object.c.

## ◆ rb_obj_class_inherited

#define rb_obj_class_inherited rb_obj_dummy1

Definition at line 958 of file object.c.

## ◆ rb_obj_initialize

#define rb_obj_initialize rb_obj_dummy0

Definition at line 1211 of file object.c.

## ◆ rb_obj_mod_const_added

#define rb_obj_mod_const_added rb_obj_dummy1

Definition at line 1138 of file object.c.

## ◆ rb_obj_mod_extended

#define rb_obj_mod_extended rb_obj_dummy1

Definition at line 1158 of file object.c.

## ◆ rb_obj_mod_included

#define rb_obj_mod_included rb_obj_dummy1

Definition at line 1181 of file object.c.

## ◆ rb_obj_mod_method_added

#define rb_obj_mod_method_added rb_obj_dummy1

Definition at line 981 of file object.c.

## ◆ rb_obj_mod_method_removed

#define rb_obj_mod_method_removed rb_obj_dummy1

Definition at line 1008 of file object.c.

## ◆ rb_obj_mod_method_undefined

#define rb_obj_mod_method_undefined rb_obj_dummy1

Definition at line 1035 of file object.c.

## ◆ rb_obj_mod_prepended

#define rb_obj_mod_prepended rb_obj_dummy1

Definition at line 1201 of file object.c.

## ◆ rb_obj_singleton_method_added

#define rb_obj_singleton_method_added rb_obj_dummy1

Definition at line 1062 of file object.c.

## ◆ rb_obj_singleton_method_removed

#define rb_obj_singleton_method_removed rb_obj_dummy1

Definition at line 1091 of file object.c.

## ◆ rb_obj_singleton_method_undefined

#define rb_obj_singleton_method_undefined rb_obj_dummy1

Definition at line 1116 of file object.c.

## ◆ rb_to_integer

#define rb_to_integer | ( |  | val,
|  |  | method,
|  |  | mid )

Value:
rb_to_integer_with_id_exception(val, method, mid, TRUE)

Definition at line 3175 of file object.c.

## ◆ RUBY_INTEGER_UNIFICATION

#define RUBY_INTEGER_UNIFICATION 1

Deprecated
  This macro once was a thing in the old days, but makes no sense any longer today. Exists here for backwards compatibility only. You can safely forget about it.

Definition at line 54 of file globals.h.

## ◆ try_to_int

#define try_to_int | ( |  | val,
|  |  | mid,
|  |  | raise )

Value:
convert_type_with_id(val, "Integer", mid, raise, -1)

Definition at line 3149 of file object.c.

## ◆ wrong_constant_name

#define wrong_constant_name bad_const_name

Definition at line 2184 of file object.c.

## Function Documentation

## ◆ basic_to_f_p()

int basic_to_f_p | ( | VALUE | klass | ) |
| inlinestatic

Definition at line 3673 of file object.c.

## ◆ check_setter_id()

ID check_setter_id | ( | VALUE | obj,
|  | VALUE * | pname,
|  | int(* | valid_id_p )(ID),
|  | int(* | valid_name_p )(VALUE),
|  | const char * | message,
|  | size_t | message_len )
| static

Definition at line 2192 of file object.c.

## ◆ class_call_alloc_func()

VALUE class_call_alloc_func | ( | rb_alloc_func_t | allocator,
|  | VALUE | klass )
| static

Definition at line 2082 of file object.c.

## ◆ class_get_alloc_func()

rb_alloc_func_t class_get_alloc_func | ( | VALUE | klass | ) |
| static

Definition at line 2064 of file object.c.

## ◆ class_or_module_required()

VALUE class_or_module_required | ( | VALUE | c | ) |
| static

Definition at line 775 of file object.c.

## ◆ class_search_ancestor()

VALUE class_search_ancestor | ( | VALUE | cl,
|  | VALUE | c )
| static

Definition at line 911 of file object.c.

## ◆ class_search_class_ancestor()

VALUE class_search_class_ancestor | ( | VALUE | cl,
|  | VALUE | c )
| static

Definition at line 818 of file object.c.

## ◆ conv_method_index()

int conv_method_index | ( | const char * | method | ) |
| static

Definition at line 3029 of file object.c.

## ◆ conversion_to_float()

void conversion_to_float | ( | VALUE | val | ) |
| inlinestatic

Definition at line 3542 of file object.c.

## ◆ convert_type()

VALUE convert_type | ( | VALUE | val,
|  | const char * | tname,
|  | const char * | method,
|  | int | raise )
| static

Definition at line 3072 of file object.c.

## ◆ convert_type_to_float_protected()

VALUE convert_type_to_float_protected | ( | VALUE | val | ) |
| static

Definition at line 3588 of file object.c.

## ◆ convert_type_with_id()

VALUE convert_type_with_id | ( | VALUE | val,
|  | const char * | tname,
|  | ID | method,
|  | int | raise,
|  | int | index )
| static

Definition at line 3047 of file object.c.

## ◆ dig_basic_p()

int dig_basic_p | ( | VALUE | obj,
|  | struct dig_method * | cache )
| static

Definition at line 3873 of file object.c.

## ◆ f_sprintf()

VALUE f_sprintf | ( | int | c,
|  | const VALUE * | v,
|  | VALUE | _ )
| static

Definition at line 3943 of file object.c.

## ◆ false_and()

VALUE false_and | ( | VALUE | obj,
|  | VALUE | obj2 )
| static

Definition at line 1543 of file object.c.

## ◆ id_for_attr()

ID id_for_attr | ( | VALUE | obj,
|  | VALUE | name )
| static

Definition at line 2219 of file object.c.

## ◆ immutable_obj_clone()

VALUE immutable_obj_clone | ( | VALUE | obj,
|  | VALUE | kwfreeze )
| static

Definition at line 428 of file object.c.

## ◆ implicit_conversion_to_float()

void implicit_conversion_to_float | ( | VALUE | val | ) |
| inlinestatic

Definition at line 3548 of file object.c.

## ◆ init_copy()

void init_copy | ( | VALUE | dest,
|  | VALUE | obj )
| static

Definition at line 341 of file object.c.

## ◆ Init_Object()

void Init_Object | ( | void |  | ) |

Definition at line 4518 of file object.c.

## ◆ InitVM_Object()

void InitVM_Object | ( | void |  | ) |

Definition at line 4185 of file object.c.

## ◆ inspect_i()

int inspect_i | ( | ID | id,
|  | VALUE | value,
|  | st_data_t | a )
| static

Definition at line 697 of file object.c.

## ◆ inspect_obj()

VALUE inspect_obj | ( | VALUE | obj,
|  | VALUE | str,
|  | int | recur )
| static

Definition at line 718 of file object.c.

## ◆ is_digit_char()

bool is_digit_char | ( | unsigned char | c,
|  | int | base )
| static

Definition at line 3321 of file object.c.

## ◆ mutable_obj_clone()

VALUE mutable_obj_clone | ( | VALUE | obj,
|  | VALUE | kwfreeze )
| static

Definition at line 514 of file object.c.

## ◆ nil_inspect()

VALUE nil_inspect | ( | VALUE | obj | ) |
| static

Definition at line 1378 of file object.c.

## ◆ nil_match()

VALUE nil_match | ( | VALUE | obj1,
|  | VALUE | obj2 )
| static

Definition at line 1398 of file object.c.

## ◆ nil_to_a()

VALUE nil_to_a | ( | VALUE | obj | ) |
| static

Definition at line 1344 of file object.c.

## ◆ nil_to_h()

VALUE nil_to_h | ( | VALUE | obj | ) |
| static

Definition at line 1362 of file object.c.

## ◆ no_dig_method()

void no_dig_method | ( | int | found,
|  | VALUE | recv,
|  | ID | mid,
|  | int | argc,
|  | const VALUE * | argv,
|  | VALUE | data )
| static

Definition at line 3884 of file object.c.

## ◆ numeric_to_float()

VALUE numeric_to_float | ( | VALUE | val | ) |
| static

Definition at line 3643 of file object.c.

## ◆ obj_freeze_opt()

VALUE obj_freeze_opt | ( | VALUE | freeze | ) |
| static

Definition at line 377 of file object.c.

## ◆ rb_any_to_s()

VALUE rb_any_to_s | ( | VALUE | obj | ) |

Generates a textual representation of the given object.

Parameters

  [in] | obj | Arbitrary ruby object.

Returns
  An instance of rb_cString that represents obj.

Note
  This is the default implementation of Object#to_s that each subclasses want to override.

Definition at line 669 of file object.c.

## ◆ rb_Array()

VALUE rb_Array | ( | VALUE | val | ) |

This is the logic behind Kernel#Array.

Arguments are converted by first trying #to_ary, then #to_a, and if both failed, returns an array of length 1 that contains the passed argument as the sole contents.

Parameters

  [in] | val | An object to convert.

Returns
  An instance of rb_cArray.

Definition at line 3779 of file object.c.

## ◆ rb_bool_expected()

int rb_bool_expected | ( | VALUE | obj,
|  | const char * | flagname,
|  | int | raise )

Definition at line 3279 of file object.c.

## ◆ rb_check_convert_type()

VALUE rb_check_convert_type | ( | VALUE | val,
|  | int | type,
|  | const char * | name,
|  | const char * | mid )

Identical to rb_convert_type(), except it returns RUBY_Qnil instead of raising exceptions, in case of conversion failure.

It still raises exceptions for various reasons, like when the conversion method itself raises, though.

Parameters

  [in] | val | An object to convert.
  [in] | type | A value of enum ruby_value_type.
  [in] | name | Name to display on error (e.g. "Array").
  [in] | mid | Conversion method (e.g. "to_ary").

Exceptions

  rb_eTypeError | The `mid` does not generate `type`.

Return values

  RUBY_Qnil | No conversion defined.
  otherwise | An object of the specified type.

Definition at line 3119 of file object.c.

## ◆ rb_check_integer_type()

VALUE rb_check_integer_type | ( | VALUE | val | ) |

Definition at line 3273 of file object.c.

## ◆ rb_check_to_float()

VALUE rb_check_to_float | ( | VALUE | val | ) |

This is complicated.

- When the passed object is already an instance of rb_cFloat, just returns it as-is.
- When the passed object is something numeric, the function tries to convert it using #to_f method.
  - If that conversion fails (this happens for instance when the numeric is a complex) it returns RUBY_Qnil.
  - Otherwise returns the conversion result.
- Otherwise it also returns RUBY_Qnil.

Parameters

  [in] | val | An object to convert.

Return values

  RUBY_Qnil | Conversion from val to float is undefined.
  otherwise | Converted result.

Definition at line 3663 of file object.c.

## ◆ rb_check_to_i()

VALUE rb_check_to_i | ( | VALUE | val | ) |
| static

Definition at line 3207 of file object.c.

## ◆ rb_check_to_int()

VALUE rb_check_to_int | ( | VALUE | val | ) |

Identical to rb_check_to_integer(), except it uses #to_int for conversion.

Parameters

  [in] | val | An object to convert.

Exceptions

  rb_eTypeError | `#to_int` does not return an integer.

Return values

  RUBY_Qnil | No conversion defined.
  otherwise | An instance of rb_cInteger.

Definition at line 3198 of file object.c.

## ◆ rb_check_to_integer()

VALUE rb_check_to_integer | ( | VALUE | val,
|  | const char * | mid )

Identical to rb_check_convert_type(), except the return value type is fixed to rb_cInteger.

Parameters

  [in] | val | An object to convert.
  [in] | mid | Conversion method (e.g. "to_ary").

Exceptions

  rb_eTypeError | The `mid` does not generate an integer.

Return values

  RUBY_Qnil | No conversion defined.
  otherwise | An instance of rb_cInteger.

Definition at line 3179 of file object.c.

Referenced by rb_io_extract_modeenc().

## ◆ rb_class_alloc()

VALUE rb_class_alloc | ( | VALUE | klass | ) |
| static

Definition at line 2057 of file object.c.

## ◆ rb_class_alloc_m()

VALUE rb_class_alloc_m | ( | VALUE | klass | ) |
| static

Definition at line 2046 of file object.c.

## ◆ rb_class_allocate_instance()

VALUE rb_class_allocate_instance | ( | VALUE | klass | ) |

Definition at line 122 of file object.c.

## ◆ rb_class_get_superclass()

VALUE rb_class_get_superclass | ( | VALUE | klass | ) |

Returns the superclass of a class.

Parameters

  [in] | klass | An object of RClass.

Return values

  RUBY_Qfalse | klass has no super class.
  otherwise | Raw superclass of klass

See also
  rb_class_superclass

### Q&A

- Q: How can a class have no super class?
- A: klass could be a module. Or it could be rb_cBasicObject.
- Q: What do you mean by "raw" superclass?
- A: This is a really good question. The answer is that this function returns something different from what you would normally expect. On occasions ruby inserts hidden classes in a hierarchy of class inheritance behind-the-scene. Such classes are called "iclass"es and distinguished using RUBY_T_ICLASS in C level. They are truly transparent from Ruby level but can be accessed from C, by using this API.

Definition at line 2175 of file object.c.

## ◆ rb_class_inherited_p()

VALUE rb_class_inherited_p | ( | VALUE | scion,
|  | VALUE | ascendant )

Determines if the given two modules are relatives.

Parameters

  [in] | scion | Possible subclass.
  [in] | ascendant | Possible superclass.

Exceptions

  rb_eTypeError | `ascendant` is not a module.

Return values

  RUBY_Qtrue | scion inherits, or is equal to ascendant.
  RUBY_Qfalse | ascendant inherits scion.
  RUBY_Qnil | They are not relatives.

Definition at line 1768 of file object.c.

## ◆ rb_class_initialize()

VALUE rb_class_initialize | ( | int | argc,
|  | VALUE * | argv,
|  | VALUE | klass )
| static

Definition at line 1987 of file object.c.

## ◆ rb_class_new_instance()

VALUE rb_class_new_instance | ( | int | argc,
|  | const VALUE * | argv,
|  | VALUE | klass )

Allocates, then initialises an instance of the given class.

It first calls the passed class' allocator to obtain an uninitialised object, then calls its initialiser with the remaining arguments.

Parameters

  [in] | argc | Number of objects of argv.
  [in] | argv | Arguments passed to #initialize.
  [in] | klass | An instance of rb_cClass.

Exceptions

  rb_eTypeError | `klass`'s allocator is undefined.
  rb_eException | Any exceptions can happen inside.

Returns
  An allocated new instance of klass.

Definition at line 2138 of file object.c.

Referenced by rb_exc_new(), rb_exc_new_str(), rb_exit(), rb_f_abort(), rb_name_error(), rb_name_error_str(), rb_readwrite_syserr_fail(), rb_struct_alloc(), rb_struct_new(), rb_syserr_new_str(), and rb_throw_obj().

## ◆ rb_class_new_instance_kw()

VALUE rb_class_new_instance_kw | ( | int | argc,
|  | const VALUE * | argv,
|  | VALUE | klass,
|  | int | kw_splat )

Identical to rb_class_new_instance(), except you can specify how to handle the last element of the given array.

Parameters

  [in] | argc | Number of objects of argv.
  [in] | argv | Arbitrary number of method arguments.
  [in] | klass | An instance of rb_cClass.
  [in] | kw_splat | Handling of keyword parameters: RB_NO_KEYWORDS argv's last is not a keyword argument. RB_PASS_KEYWORDS argv's last is a keyword argument. RB_PASS_CALLED_KEYWORDS it depends if there is a passed block.

Exceptions

  rb_eTypeError | `klass`'s allocator is undefined.
  rb_eException | Any exceptions can happen inside.

Returns
  An allocated new instance of klass.

Definition at line 2126 of file object.c.

Referenced by rb_class_new_instance().

## ◆ rb_class_new_instance_pass_kw()

VALUE rb_class_new_instance_pass_kw | ( | int | argc,
|  | const VALUE * | argv,
|  | VALUE | klass )

Identical to rb_class_new_instance(), except it passes the passed keywords if any to the #initialize method.

Parameters

  [in] | argc | Number of objects of argv.
  [in] | argv | Arbitrary number of method arguments.
  [in] | klass | An instance of rb_cClass.

Exceptions

  rb_eTypeError | `klass`'s allocator is undefined.
  rb_eException | Any exceptions can happen inside.

Returns
  An allocated new instance of klass.

Note
  This is the implementation of Object.new.

Definition at line 2115 of file object.c.

## ◆ rb_class_of()

VALUE rb_class_of | ( | VALUE | obj | ) |
| inlinestatic

Object to class mapping function.

Every object have its class. This function obtains that.

Parameters

  [in] | obj | Target object to query.

Returns
  The class of the given object.

Definition at line 172 of file globals.h.

Referenced by rb_class_of().

## ◆ rb_class_real()

VALUE rb_class_real | ( | VALUE | klass | ) |

Finds a "real" class.

As the name implies there are class objects that are surreal. This function takes a class, traverses its ancestry tree, and returns its nearest ancestor which is neither a module nor a singleton class.

Parameters

  [in] | klass | An instance of rb_cClass.

Return values

  RUBY_Qfalse | No real class in klass' ancestry tree.
  klass | klass itself is a real class.
  otherwise | Nearest ancestor of klass who is real.

Definition at line 237 of file object.c.

Referenced by make_singleton_class(), rb_class2name(), rb_class_name(), rb_define_class(), and rb_obj_class().

## ◆ rb_class_superclass()

VALUE rb_class_superclass | ( | VALUE | klass | ) |

Returns the superclass of klass.

Queries the parent of the given class.

Equivalent to Class#superclass in Ruby.

It skips modules.

Parameters

  [in] | klass | a Class object

Returns
  the superclass, or Qnil if klass does not have a parent class.

See also
  rb_class_get_superclass

Definition at line 2153 of file object.c.

## ◆ rb_convert_to_float()

VALUE rb_convert_to_float | ( | VALUE | val,
|  | int | raise_exception )
| static

Definition at line 3594 of file object.c.

## ◆ rb_convert_to_integer()

VALUE rb_convert_to_integer | ( | VALUE | val,
|  | int | base,
|  | int | raise_exception )
| static

Definition at line 3216 of file object.c.

## ◆ rb_convert_type()

VALUE rb_convert_type | ( | VALUE | val,
|  | int | type,
|  | const char * | name,
|  | const char * | mid )

Converts an object into another type.

Calls the specified conversion method if necessary.

Parameters

  [in] | val | An object to convert.
  [in] | type | A value of enum ruby_value_type.
  [in] | name | Name to display on error (e.g. "Array").
  [in] | mid | Conversion method (e.g. "to_ary").

Exceptions

  rb_eTypeError | Failed to convert.

Returns
  An object of the specified type.

Definition at line 3092 of file object.c.

## ◆ rb_cstr_to_dbl()

double rb_cstr_to_dbl | ( | const char * | str,
|  | int | mode )

Converts a textual representation of a real number into a numeric, which is the nearest value that the return type can represent, of the value that the argument represents.

This is in fact a 2-in-1 function whose behaviour can be controlled using the second (mode) argument. If the mode is zero, this function is in "historical" mode which only understands "floating-constant" defined at ISO/IEC 9899:1990 section 6.1.3.1. If the mode is nonzero, it is in "extended" mode, which also accepts "hexadecimal-floating-constant" defined at ISO/IEC 9899:2018 section 6.4.4.2.

Parameters

  [in] | str | A textual representation of a real number.
  [in] | mode | Conversion mode, as described above.

Exceptions

  rb_eArgError | Malformed `str` passed.

See also
  https://bugs.ruby-lang.org/issues/2969

Note
  Null pointers are allowed, and it returns 0.0 then.

Definition at line 3464 of file object.c.

## ◆ rb_cstr_to_dbl_raise()

double rb_cstr_to_dbl_raise | ( | const char * | p,
|  | rb_encoding * | enc,
|  | int | badcheck,
|  | int | raise,
|  | int * | error )
| static

Definition at line 3328 of file object.c.

## ◆ rb_eql()

int rb_eql | ( | VALUE | lhs,
|  | VALUE | rhs )

Checks for equality of the passed objects, in terms of Object#eql?.

Parameters

  [in] | lhs | Comparison left hand side.
  [in] | rhs | Comparison right hand side.

Return values

  non-zero | They are equal.
  0 | Otherwise.

Note
  This function actually calls lhs.eql?(rhs) so you cannot implement your class' #eql? method using it.

Definition at line 192 of file object.c.

## ◆ rb_equal()

VALUE rb_equal | ( | VALUE | lhs,
|  | VALUE | rhs )

This function is an optimised version of calling #==.

It checks equality between two objects by first doing a fast identity check using using C's == (same as BasicObject#equal?). If that check fails, it calls #== dynamically. This optimisation actually affects semantics, because when #== returns false for the same object obj, rb_equal(obj, obj) would still return true. This happens for Float::NAN, where Float::NAN == Float::NAN is false, but rb_equal(Float::NAN, Float::NAN) is true.

Parameters

  [in] | lhs | Comparison LHS.
  [in] | rhs | Comparison RHS.

Return values

  RUBY_Qtrue | They are the same.
  RUBY_Qfalse | They are different.

Definition at line 179 of file object.c.

Referenced by rb_ary_assoc(), rb_ary_delete(), rb_ary_includes(), rb_ary_rassoc(), rb_big_eq(), and rb_str_equal().

## ◆ rb_f_array()

VALUE rb_f_array | ( | VALUE | obj,
|  | VALUE | arg )
| static

Definition at line 3813 of file object.c.

## ◆ rb_f_float()

VALUE rb_f_float | ( | rb_execution_context_t * | ec,
|  | VALUE | obj,
|  | VALUE | arg,
|  | VALUE | opts )
| static

Definition at line 3636 of file object.c.

## ◆ rb_f_float1()

VALUE rb_f_float1 | ( | rb_execution_context_t * | ec,
|  | VALUE | obj,
|  | VALUE | arg )
| static

Definition at line 3630 of file object.c.

## ◆ rb_f_hash()

VALUE rb_f_hash | ( | VALUE | obj,
|  | VALUE | arg )
| static

Definition at line 3859 of file object.c.

## ◆ rb_f_integer()

VALUE rb_f_integer | ( | rb_execution_context_t * | ec,
|  | VALUE | obj,
|  | VALUE | arg,
|  | VALUE | base,
|  | VALUE | exception )
| static

Definition at line 3314 of file object.c.

## ◆ rb_f_integer1()

VALUE rb_f_integer1 | ( | rb_execution_context_t * | ec,
|  | VALUE | obj,
|  | VALUE | arg )
| static

Definition at line 3308 of file object.c.

## ◆ rb_f_loop_size()

VALUE rb_f_loop_size | ( | VALUE | self,
|  | VALUE | args,
|  | VALUE | eobj )
| static

Definition at line 3949 of file object.c.

## ◆ rb_f_string()

VALUE rb_f_string | ( | VALUE | obj,
|  | VALUE | arg )
| static

Definition at line 3773 of file object.c.

## ◆ rb_false()

VALUE rb_false | ( | VALUE | obj | ) |

Definition at line 1605 of file object.c.

## ◆ rb_false_to_s()

VALUE rb_false_to_s | ( | VALUE | obj | ) |

Definition at line 1522 of file object.c.

## ◆ rb_Float()

VALUE rb_Float | ( | VALUE | val | ) |

This is the logic behind Kernel#Float.

Numeric types are converted directly to the nearest value that a Float can represent. Strings are interpreted strictly; only leading/trailing whitespaces are allowed except what strtod understands. Anything else are converted using #to_f.

This is slightly stricter than String#to_f.

Parameters

  [in] | val | An object to convert.

Exceptions

  rb_eArgError | Malformed `val` passed.
  rb_eTypeError | No conversion defined.

Returns
  An instance of rb_cFloat.

Definition at line 3624 of file object.c.

Referenced by rb_str_format().

## ◆ rb_get_freeze_opt()

VALUE rb_get_freeze_opt | ( | int | argc,
|  | VALUE * | argv )

Definition at line 409 of file object.c.

## ◆ rb_Hash()

VALUE rb_Hash | ( | VALUE | val | ) |

Equivalent to `Kernel#Hash` in Ruby.

This is the logic behind Kernel#Hash.

Definition at line 3822 of file object.c.

## ◆ rb_inspect()

VALUE rb_inspect | ( | VALUE | obj | ) |

Generates a human-readable textual representation of the given object.

This is largely similar to Ruby level Object#inspect but not the same; it additionally escapes the inspection result so that the string be compatible with that of default internal (or default external, if absent).

Parameters

  [in] | obj | Arbitrary ruby object.

Returns
  An instance of rb_cString that represents obj.

Definition at line 680 of file object.c.

Referenced by rb_cmperr(), rb_p(), and rb_str_format().

## ◆ rb_Integer()

VALUE rb_Integer | ( | VALUE | val | ) |

This is the logic behind Kernel#Integer.

Numeric types are converted directly, with floating point numbers being truncated. Strings are interpreted strictly; only leading/trailing whitespaces, plus/minus sign, radix indicators such as 0x, digits, and underscores are allowed. Anything else are converted by first trying #to_int, then #to_i.

This is slightly stricter than String#to_i.

Parameters

  [in] | val | An object to convert.

Exceptions

  rb_eArgError | Malformed `val` passed.
  rb_eTypeError | No conversion defined.

Returns
  An instance of rb_cInteger.

Definition at line 3267 of file object.c.

Referenced by rb_str_format().

## ◆ rb_is_attr_id()

int rb_is_attr_id | ( | ID | id | ) |
| static

Definition at line 2213 of file object.c.

## ◆ rb_is_attr_name()

int rb_is_attr_name | ( | VALUE | name | ) |
| static

Definition at line 2207 of file object.c.

## ◆ rb_mod_attr_accessor()

VALUE rb_mod_attr_accessor | ( | int | argc,
|  | VALUE * | argv,
|  | VALUE | klass )
| static

Definition at line 2318 of file object.c.

## ◆ rb_mod_attr_reader()

VALUE rb_mod_attr_reader | ( | int | argc,
|  | VALUE * | argv,
|  | VALUE | klass )
| static

Definition at line 2241 of file object.c.

## ◆ rb_mod_attr_writer()

VALUE rb_mod_attr_writer | ( | int | argc,
|  | VALUE * | argv,
|  | VALUE | klass )
| static

Definition at line 2286 of file object.c.

## ◆ rb_mod_cmp()

VALUE rb_mod_cmp | ( | VALUE | mod,
|  | VALUE | arg )
| static

Definition at line 1884 of file object.c.

## ◆ rb_mod_const_defined()

VALUE rb_mod_const_defined | ( | int | argc,
|  | VALUE * | argv,
|  | VALUE | mod )
| static

Definition at line 2547 of file object.c.

## ◆ rb_mod_const_get()

VALUE rb_mod_const_get | ( | int | argc,
|  | VALUE * | argv,
|  | VALUE | mod )
| static

Definition at line 2374 of file object.c.

## ◆ rb_mod_const_set()

VALUE rb_mod_const_set | ( | VALUE | mod,
|  | VALUE | name,
|  | VALUE | value )
| static

Definition at line 2496 of file object.c.

## ◆ rb_mod_const_source_location()

VALUE rb_mod_const_source_location | ( | int | argc,
|  | VALUE * | argv,
|  | VALUE | mod )
| static

Definition at line 2707 of file object.c.

## ◆ rb_mod_cvar_defined()

VALUE rb_mod_cvar_defined | ( | VALUE | obj,
|  | VALUE | iv )
| static

Definition at line 2977 of file object.c.

## ◆ rb_mod_cvar_get()

VALUE rb_mod_cvar_get | ( | VALUE | obj,
|  | VALUE | iv )
| static

Definition at line 2920 of file object.c.

## ◆ rb_mod_cvar_set()

VALUE rb_mod_cvar_set | ( | VALUE | obj,
|  | VALUE | iv,
|  | VALUE | val )
| static

Definition at line 2952 of file object.c.

## ◆ rb_mod_eqq()

VALUE rb_mod_eqq | ( | VALUE | mod,
|  | VALUE | arg )
| static

Definition at line 1751 of file object.c.

## ◆ rb_mod_freeze()

VALUE rb_mod_freeze | ( | VALUE | mod | ) |
| static

Definition at line 1734 of file object.c.

## ◆ rb_mod_ge()

VALUE rb_mod_ge | ( | VALUE | mod,
|  | VALUE | arg )
| static

Definition at line 1842 of file object.c.

## ◆ rb_mod_gt()

VALUE rb_mod_gt | ( | VALUE | mod,
|  | VALUE | arg )
| static

Definition at line 1865 of file object.c.

## ◆ rb_mod_initialize()

VALUE rb_mod_initialize | ( | VALUE | module | ) |
| static

Definition at line 1930 of file object.c.

## ◆ rb_mod_initialize_clone()

VALUE rb_mod_initialize_clone | ( | int | argc,
|  | VALUE * | argv,
|  | VALUE | clone )
| static

Definition at line 1946 of file object.c.

## ◆ rb_mod_initialize_exec()

VALUE rb_mod_initialize_exec | ( | VALUE | module | ) |
| static

Definition at line 1936 of file object.c.

## ◆ rb_mod_lt()

VALUE rb_mod_lt | ( | VALUE | mod,
|  | VALUE | arg )
| static

Definition at line 1822 of file object.c.

## ◆ rb_mod_singleton_p()

VALUE rb_mod_singleton_p | ( | VALUE | klass | ) |
| static

Definition at line 3001 of file object.c.

## ◆ rb_mod_to_s()

VALUE rb_mod_to_s | ( | VALUE | klass | ) |

Definition at line 1690 of file object.c.

## ◆ rb_nil_to_s()

VALUE rb_nil_to_s | ( | VALUE | obj | ) |

Definition at line 1326 of file object.c.

## ◆ rb_num2dbl()

double rb_num2dbl | ( | VALUE | num | ) |

Converts an instance of rb_cNumeric into C's double.

Parameters

  [in] | num | Something numeric.

Exceptions

  rb_eTypeError | `num` is not a numeric.

Returns
  The passed value converted into C's double.

Definition at line 3715 of file object.c.

## ◆ rb_obj_alloc()

VALUE rb_obj_alloc | ( | VALUE | klass | ) |

Allocates an instance of the given class.

Parameters

  [in] | klass | A class to instantiate.

Exceptions

  rb_eTypeError | `klass` is not a class.

Returns
  An allocated, not yet initialised instance of klass.

Note
  It calls the allocator defined by rb_define_alloc_func(). You cannot use this function to define an allocator. Use TypedData_Make_Struct or others, instead.
  Usually prefer rb_class_new_instance() to rb_obj_alloc() and rb_obj_call_init().

See also
  rb_class_new_instance()
  rb_obj_call_init()
  rb_define_alloc_func()
  TypedData_Make_Struct

Definition at line 2097 of file object.c.

Referenced by rb_obj_dup(), and rb_range_new().

## ◆ rb_obj_class()

VALUE rb_obj_class | ( | VALUE | obj | ) |

Queries the class of an object.

This is not always identical to RBASIC_CLASS(obj). It searches for the nearest ancestor skipping singleton classes or included modules.

Parameters

  [in] | obj | Object in question.

Returns
  The object's class, in a normal sense.

Definition at line 247 of file object.c.

Referenced by rb_check_inheritable(), rb_cmperr(), rb_define_class(), rb_define_module(), rb_define_module_id_under(), rb_gc_register_address(), rb_hash_dup(), rb_io_descriptor(), rb_obj_dup(), rb_obj_init_copy(), rb_obj_is_instance_of(), rb_profile_frame_classpath(), rb_str_drop_bytes(), rb_str_dup(), rb_str_new_frozen(), rb_str_new_shared(), rb_str_new_with_class(), and rb_struct_members().

## ◆ rb_obj_clone()

VALUE rb_obj_clone | ( | VALUE | obj | ) |

Produces a shallow copy of the given object.

Its list of instance variables are copied, but not the objects they reference. It also copies the frozen value state.

Parameters

  [in] | obj | Arbitrary ruby object.

Exceptions

  rb_eException | `#initialize_copy` can raise anything.

Returns
  A "clone" of obj.

Definition at line 521 of file object.c.

Referenced by rb_eval_string_wrap().

## ◆ rb_obj_clone2()

VALUE rb_obj_clone2 | ( | rb_execution_context_t * | ec,
|  | VALUE | obj,
|  | VALUE | freeze )
| static

Definition at line 392 of file object.c.

## ◆ rb_obj_clone_setup()

VALUE rb_obj_clone_setup | ( | VALUE | obj,
|  | VALUE | clone,
|  | VALUE | kwfreeze )

Definition at line 437 of file object.c.

## ◆ rb_obj_cmp()

VALUE rb_obj_cmp | ( | VALUE | obj1,
|  | VALUE | obj2 )
| static

Definition at line 1645 of file object.c.

## ◆ rb_obj_dummy()

VALUE rb_obj_dummy | ( | void |  | ) |
| static

Definition at line 1218 of file object.c.

## ◆ rb_obj_dummy0()

VALUE rb_obj_dummy0 | ( | VALUE | _ | ) |
| static

Definition at line 1224 of file object.c.

## ◆ rb_obj_dummy1()

VALUE rb_obj_dummy1 | ( | VALUE | _x,
|  | VALUE | _y )
| static

Definition at line 1230 of file object.c.

## ◆ rb_obj_dup()

VALUE rb_obj_dup | ( | VALUE | obj | ) |

Duplicates the given object.

This does almost the same thing as rb_obj_clone() do. However it does not copy the singleton class (if any). It also doesn't copy frozen-ness.

Parameters

  [in] | obj | Arbitrary ruby object.

Exceptions

  rb_eException | `#initialize_copy` can raise anything.

Returns
  A shallow copy of obj.

Definition at line 576 of file object.c.

Referenced by rb_io_path().

## ◆ rb_obj_dup_setup()

VALUE rb_obj_dup_setup | ( | VALUE | obj,
|  | VALUE | dup )

Definition at line 528 of file object.c.

## ◆ rb_obj_embedded_size()

size_t rb_obj_embedded_size | ( | uint32_t | numiv | ) |

Internal header for Object.

Author
  Ruby developers ruby-.nosp@m.core.nosp@m.@ruby.nosp@m.-lan.nosp@m.g.org

Copyright
  This file is a part of the programming language Ruby. Permission is hereby granted, to either redistribute and/or modify this file, provided that the conditions mentioned in the file COPYING are met. Consult the file for details.

Definition at line 98 of file object.c.

## ◆ rb_obj_freeze()

VALUE rb_obj_freeze | ( | VALUE | obj | ) |

Just calls rb_obj_freeze_inline() inside.

Does this make any sens to extension libraries?

Parameters

  [out] | obj | Object to freeze.

Returns
  Verbatim obj.

Definition at line 1260 of file object.c.

Referenced by rb_ary_freeze(), rb_hash_freeze(), and rb_str_freeze().

## ◆ rb_obj_frozen_p()

VALUE rb_obj_frozen_p | ( | VALUE | obj | ) |

Just calls RB_OBJ_FROZEN() inside.

Does this make any sens to extension libraries?

Parameters

  [in] | obj | Object in question.

Return values

  RUBY_Qtrue | Yes it is.
  RUBY_Qfalse | No it isn't.

Definition at line 1272 of file object.c.

## ◆ rb_obj_hash()

VALUE rb_obj_hash | ( | VALUE | obj | ) |

Definition at line 332 of file hash.c.

## ◆ rb_obj_hide()

VALUE rb_obj_hide | ( | VALUE | obj | ) |

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.

Parameters

  [out] | obj | A Ruby object.

Returns
  The passed object.

Postcondition
  The object is destructively modified to be invisible.

See also
  rb_obj_reveal

Definition at line 104 of file object.c.

## ◆ rb_obj_init_clone()

VALUE rb_obj_init_clone | ( | int | argc,
|  | VALUE * | argv,
|  | VALUE | obj )
| static

Default implementation of #initialize_clone.

Parameters

  [in] | The | number of arguments
  [in] | The | array of arguments
  [in] | obj | the receiver being initialized

Definition at line 647 of file object.c.

## ◆ rb_obj_init_copy()

VALUE rb_obj_init_copy | ( | VALUE | obj,
|  | VALUE | orig )

Default implementation of #initialize_copy.

Default implementation of #initialize_copy, #initialize_dup and #initialize_clone.

Parameters

  [in,out] | obj | the receiver being initialized
  [in] | orig | the object to be copied from.

Definition at line 616 of file object.c.

## ◆ rb_obj_init_dup_clone()

VALUE rb_obj_init_dup_clone | ( | VALUE | obj,
|  | VALUE | orig )

Default implementation of #initialize_dup.

Parameters

  [in,out] | obj | the receiver being initialized
  [in] | orig | the object to be dup from.

Definition at line 633 of file object.c.

## ◆ rb_obj_inspect()

VALUE rb_obj_inspect | ( | VALUE | obj | ) |
| static

Definition at line 760 of file object.c.

## ◆ rb_obj_is_instance_of()

VALUE rb_obj_is_instance_of | ( | VALUE | obj,
|  | VALUE | klass )

Queries if the given object is a direct instance of the given class.

Parameters

  [in] | obj | Arbitrary ruby object.
  [in] | klass | An instance of rb_cModule.

Exceptions

  rb_eTypeError | `klass` is neither module nor class.

Return values

  RUBY_Qtrue | obj is an instance of klass.
  RUBY_Qfalse | Otherwise.

Definition at line 809 of file object.c.

## ◆ rb_obj_is_kind_of()

VALUE rb_obj_is_kind_of | ( | VALUE | obj,
|  | VALUE | klass )

Queries if the given object is an instance (of possibly descendants) of the given class.

Parameters

  [in] | obj | Arbitrary ruby object.
  [in] | klass | An instance of rb_cModule.

Exceptions

  rb_eTypeError | `klass` is neither module nor class.

Return values

  RUBY_Qtrue | obj is a klass.
  RUBY_Qfalse | Otherwise.

Definition at line 865 of file object.c.

Referenced by rb_arithmetic_sequence_extract(), rb_check_to_float(), rb_enumeratorize_with_size_kw(), rb_range_values(), rb_set_errinfo(), rb_struct_initialize(), and rb_vrescue2().

## ◆ rb_obj_itself()

VALUE rb_obj_itself | ( | VALUE | obj | ) |
| static

Definition at line 599 of file object.c.

## ◆ rb_obj_ivar_defined()

VALUE rb_obj_ivar_defined | ( | VALUE | obj,
|  | VALUE | iv )
| static

Definition at line 2893 of file object.c.

## ◆ rb_obj_ivar_get()

VALUE rb_obj_ivar_get | ( | VALUE | obj,
|  | VALUE | iv )
| static

Definition at line 2831 of file object.c.

## ◆ rb_obj_ivar_set_m()

VALUE rb_obj_ivar_set_m | ( | VALUE | obj,
|  | VALUE | iv,
|  | VALUE | val )
| static

Definition at line 2865 of file object.c.

## ◆ rb_obj_not_match()

VALUE rb_obj_not_match | ( | VALUE | obj1,
|  | VALUE | obj2 )
| static

Definition at line 1619 of file object.c.

## ◆ rb_obj_reveal()

VALUE rb_obj_reveal | ( | VALUE | obj,
|  | VALUE | klass )

Make a hidden object visible again.

It is the caller's responsibility to pass the right klass which obj originally used to belong to.

Parameters

  [out] | obj | A Ruby object.
  [in] | klass | Class of obj.

Returns
  Passed obj.

Precondition
  obj was previously hidden.

Postcondition
  obj's class is klass.

See also
  rb_obj_hide

Definition at line 113 of file object.c.

## ◆ rb_obj_setup()

VALUE rb_obj_setup | ( | VALUE | obj,
|  | VALUE | klass,
|  | VALUE | type )

Fills common fields in the object.

Parameters

  [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.

Returns
  The passed object.

Definition at line 152 of file object.c.

## ◆ rb_obj_singleton_class()

VALUE rb_obj_singleton_class | ( | VALUE | obj | ) |
| static

Definition at line 270 of file object.c.

## ◆ rb_obj_size()

VALUE rb_obj_size | ( | VALUE | self,
|  | VALUE | args,
|  | VALUE | obj )

Definition at line 605 of file object.c.

## ◆ rb_opts_exception_p()

int rb_opts_exception_p | ( | VALUE | opts,
|  | int | default_value )

Definition at line 3298 of file object.c.

## ◆ rb_str_to_dbl()

double rb_str_to_dbl | ( | VALUE | str,
|  | int | mode )

Identical to rb_cstr_to_dbl(), except it accepts a Ruby's string instead of C's.

Parameters

  [in] | str | A textual representation of a real number.
  [in] | mode | Conversion mode, as described in rb_cstr_to_dbl().

Exceptions

  rb_eArgError | Malformed `str` passed.

See also
  https://bugs.ruby-lang.org/issues/2969

Definition at line 3508 of file object.c.

## ◆ rb_str_to_dbl_raise()

double rb_str_to_dbl_raise | ( | VALUE | str,
|  | int | badcheck,
|  | int | raise,
|  | int * | error )
| static

Definition at line 3470 of file object.c.

## ◆ rb_String()

VALUE rb_String | ( | VALUE | val | ) |

This is the logic behind Kernel#String.

Arguments are converted by first trying #to_str, then #to_s.

Parameters

  [in] | val | An object to convert.

Exceptions

  rb_eTypeError | No conversion defined.

Returns
  An instance of rb_cString.

Definition at line 3747 of file object.c.

## ◆ rb_to_float()

VALUE rb_to_float | ( | VALUE | val | ) |

Identical to rb_check_to_float(), except it raises on error.

Parameters

  [in] | val | An object to convert.

Exceptions

  rb_eTypeError | No conversion defined.

Returns
  An instance of rb_cFloat.

Definition at line 3653 of file object.c.

## ◆ rb_to_int()

VALUE rb_to_int | ( | VALUE | val | ) |

Identical to rb_check_to_int(), except it raises in case of conversion mismatch.

Parameters

  [in] | val | An object to convert.

Exceptions

  rb_eTypeError | `#to_int` does not generate an integer.

Returns
  An instance of rb_cInteger.

Definition at line 3192 of file object.c.

Referenced by rb_absint_singlebit_p(), rb_absint_size(), rb_big_lshift(), rb_big_rshift(), rb_integer_pack(), rb_io_extract_modeenc(), rb_num2long(), rb_random_ulong_limited(), and rb_rational_raw().

## ◆ rb_to_integer_with_id_exception()

VALUE rb_to_integer_with_id_exception | ( | VALUE | val,
|  | const char * | method,
|  | ID | mid,
|  | int | raise )
| inlinestatic

Definition at line 3155 of file object.c.

## ◆ rb_true()

VALUE rb_true | ( | VALUE | obj | ) |
| static

Definition at line 1588 of file object.c.

## ◆ rb_true_to_s()

VALUE rb_true_to_s | ( | VALUE | obj | ) |

Definition at line 1435 of file object.c.

## ◆ to_float()

int to_float | ( | VALUE * | valp,
|  | int | raise_exception )
| static

Definition at line 3554 of file object.c.

## ◆ true_and()

VALUE true_and | ( | VALUE | obj,
|  | VALUE | obj2 )
| static

Definition at line 1454 of file object.c.

## ◆ true_or()

VALUE true_or | ( | VALUE | obj,
|  | VALUE | obj2 )
| static

Definition at line 1479 of file object.c.

## ◆ true_xor()

VALUE true_xor | ( | VALUE | obj,
|  | VALUE | obj2 )
| static

Definition at line 1498 of file object.c.

## Variable Documentation

## ◆ bad_attr_name

const char bad_attr_name[] = "invalid attribute name '%1$s'"
| static

Definition at line 2183 of file object.c.

## ◆ bad_class_name

const char bad_class_name[] = "'%1$s' is not allowed as a class variable name"
| static

Definition at line 2181 of file object.c.

## ◆ bad_const_name

const char bad_const_name[] = "wrong constant name %1$s"
| static

Definition at line 2182 of file object.c.

## ◆ bad_instance_name

const char bad_instance_name[] = "'%1$s' is not allowed as an instance variable name"
| static

Definition at line 2180 of file object.c.

## ◆ id_dig

ID id_dig
| static

Definition at line 3870 of file object.c.

## ◆ rb_cArray

VALUE rb_cArray
| extern

Array class.

Definition at line 40 of file array.c.

Referenced by rb_ary_new_capa(), rb_ary_new_from_values(), rb_ary_resurrect(), and rb_ary_sort_bang().

## ◆ rb_cBasicObject [1/2]

VALUE rb_cBasicObject
| extern

BasicObject class.

Definition at line 64 of file object.c.

Referenced by Init_class_hierarchy(), rb_class_new(), and rb_class_superclass().

## ◆ rb_cBasicObject [2/2]

VALUE rb_cBasicObject

BasicObject class.

Definition at line 64 of file object.c.

Referenced by Init_class_hierarchy(), rb_class_new(), and rb_class_superclass().

## ◆ rb_cBinding

VALUE rb_cBinding
| extern

Binding class.

Definition at line 44 of file proc.c.

## ◆ rb_cClass [1/2]

VALUE rb_cClass
| extern

Class class.

Definition at line 68 of file object.c.

Referenced by Init_class_hierarchy(), make_metaclass(), rb_check_inheritable(), and rb_class_boot().

## ◆ rb_cClass [2/2]

VALUE rb_cClass

Class class.

Definition at line 68 of file object.c.

Referenced by Init_class_hierarchy(), make_metaclass(), rb_check_inheritable(), and rb_class_boot().

## ◆ rb_cComplex

VALUE rb_cComplex
| extern

Complex class.

Definition at line 39 of file complex.c.

Referenced by rb_Complex(), rb_complex_new(), rb_complex_new_polar(), and rb_complex_raw().

## ◆ rb_cDir

VALUE rb_cDir
| extern

Dir class.

Definition at line 504 of file dir.c.

## ◆ rb_cEncoding [1/2]

VALUE rb_cEncoding
| extern

Encoding class.

Definition at line 57 of file encoding.c.

## ◆ rb_cEncoding [2/2]

VALUE rb_cEncoding
| extern

Encoding class.

Definition at line 57 of file encoding.c.

## ◆ rb_cEnumerator

VALUE rb_cEnumerator
| extern

Enumerator class.

Definition at line 164 of file enumerator.c.

Referenced by rb_enumeratorize_with_size_kw().

## ◆ rb_cFalseClass [1/2]

VALUE rb_cFalseClass
| extern

FalseClass class.

Definition at line 73 of file object.c.

Referenced by rb_class_of().

## ◆ rb_cFalseClass [2/2]

VALUE rb_cFalseClass

FalseClass class.

Definition at line 73 of file object.c.

Referenced by rb_class_of().

## ◆ rb_cFalseClass_to_s

VALUE rb_cFalseClass_to_s
| static

Definition at line 77 of file object.c.

## ◆ rb_cFile

VALUE rb_cFile
| extern

File class.

Definition at line 175 of file file.c.

Referenced by rb_file_open(), rb_file_open_str(), and rb_io_fdopen().

## ◆ rb_cFloat

VALUE rb_cFloat
| extern

Float class.

Definition at line 197 of file numeric.c.

Referenced by rb_class_of(), and rb_float_new_in_heap().

## ◆ rb_cHash

VALUE rb_cHash
| extern

Hash class.

Definition at line 113 of file hash.c.

Referenced by rb_extract_keywords(), and rb_hash_new().

## ◆ rb_cInteger

VALUE rb_cInteger
| extern

Module class.

Definition at line 198 of file numeric.c.

Referenced by rb_class_of().

## ◆ rb_cIO

VALUE rb_cIO
| extern

IO class.

Definition at line 187 of file io.c.

Referenced by rb_io_fdopen().

## ◆ rb_cMatch

VALUE rb_cMatch
| extern

MatchData class.

Definition at line 967 of file re.c.

## ◆ rb_cMethod

VALUE rb_cMethod
| extern

Method class.

Definition at line 43 of file proc.c.

## ◆ rb_cModule [1/2]

VALUE rb_cModule
| extern

Module class.

Definition at line 67 of file object.c.

Referenced by Init_class_hierarchy(), and rb_module_new().

## ◆ rb_cModule [2/2]

VALUE rb_cModule

Module class.

Definition at line 67 of file object.c.

Referenced by Init_class_hierarchy(), and rb_module_new().

## ◆ rb_cNameErrorMesg

VALUE rb_cNameErrorMesg
| extern

NameError::Message class.

Definition at line 1442 of file error.c.

## ◆ rb_cNilClass [1/2]

VALUE rb_cNilClass
| extern

NilClass class.

Definition at line 71 of file object.c.

Referenced by rb_class_of().

## ◆ rb_cNilClass [2/2]

VALUE rb_cNilClass

NilClass class.

Definition at line 71 of file object.c.

Referenced by rb_class_of().

## ◆ rb_cNilClass_to_s

VALUE rb_cNilClass_to_s
| static

Definition at line 75 of file object.c.

## ◆ rb_cNumeric

VALUE rb_cNumeric
| extern

Numeric class.

Definition at line 196 of file numeric.c.

Referenced by rb_check_to_float().

## ◆ rb_cObject [1/2]

VALUE rb_cObject
| extern

Object class.

Object class.

Definition at line 66 of file object.c.

## ◆ rb_cObject [2/2]

VALUE rb_cObject

Documented in include/ruby/internal/globals.h.

Object class.

Definition at line 66 of file object.c.

## ◆ rb_cProc

VALUE rb_cProc
| extern

Proc class.

Definition at line 45 of file proc.c.

Referenced by rb_block_lambda(), and rb_block_proc().

## ◆ rb_cRactor

VALUE rb_cRactor
| extern

Ractor class.

Definition at line 23 of file ractor.c.

## ◆ rb_cRandom

VALUE rb_cRandom
| extern

Random class.

Definition at line 236 of file random.c.

## ◆ rb_cRange

VALUE rb_cRange
| extern

Range class.

Definition at line 31 of file range.c.

Referenced by rb_range_new(), and rb_range_values().

## ◆ rb_cRational

VALUE rb_cRational
| extern

Rational class.

Definition at line 53 of file rational.c.

Referenced by rb_Rational(), rb_rational_new(), and rb_rational_raw().

## ◆ rb_cRefinement [1/2]

VALUE rb_cRefinement
| extern

Refinement class.

Definition at line 69 of file object.c.

Referenced by Init_class_hierarchy(), and rb_refinement_new().

## ◆ rb_cRefinement [2/2]

VALUE rb_cRefinement

Refinement class.

Definition at line 69 of file object.c.

Referenced by Init_class_hierarchy(), and rb_refinement_new().

## ◆ rb_cRegexp

VALUE rb_cRegexp
| extern

Regexp class.

Definition at line 2640 of file re.c.

## ◆ rb_cStat

VALUE rb_cStat
| extern

File::Stat class.

Definition at line 177 of file file.c.

Referenced by rb_stat_new().

## ◆ rb_cString

VALUE rb_cString
| extern

String class.

Definition at line 79 of file string.c.

Referenced by rb_enc_str_new(), rb_enc_str_new_static(), rb_str_buf_new(), rb_str_new(), rb_str_new_static(), rb_str_plus(), rb_str_resurrect(), rb_str_times(), rb_sym_to_s(), rb_usascii_str_new(), rb_usascii_str_new_static(), rb_utf8_str_new(), and rb_utf8_str_new_static().

## ◆ rb_cStruct

VALUE rb_cStruct
| extern

Struct class.

Definition at line 33 of file struct.c.

Referenced by rb_struct_define(), and rb_struct_define_under().

## ◆ rb_cSymbol

VALUE rb_cSymbol
| extern

Symbol class.

Definition at line 80 of file string.c.

Referenced by rb_class_of(), and rb_str_intern().

## ◆ rb_cThread

VALUE rb_cThread
| extern

Thread class.

Definition at line 544 of file vm.c.

Referenced by rb_thread_create().

## ◆ rb_cTime

VALUE rb_cTime
| extern

Time class.

Definition at line 678 of file time.c.

Referenced by rb_time_nano_new(), rb_time_new(), rb_time_num_new(), and rb_time_timespec_new().

## ◆ rb_cTrueClass [1/2]

VALUE rb_cTrueClass
| extern

TrueClass class.

Definition at line 72 of file object.c.

Referenced by rb_class_of().

## ◆ rb_cTrueClass [2/2]

VALUE rb_cTrueClass

TrueClass class.

Definition at line 72 of file object.c.

Referenced by rb_class_of().

## ◆ rb_cTrueClass_to_s

VALUE rb_cTrueClass_to_s
| static

Definition at line 76 of file object.c.

## ◆ rb_cUnboundMethod

VALUE rb_cUnboundMethod
| extern

UnboundMethod class.

Definition at line 42 of file proc.c.

## ◆ rb_mComparable

VALUE rb_mComparable
| extern

Comparable module.

Definition at line 19 of file compar.c.

## ◆ rb_mEnumerable

VALUE rb_mEnumerable
| extern

Enumerable module.

Definition at line 27 of file enum.c.

## ◆ rb_mErrno

VALUE rb_mErrno
| extern

Errno module.

Definition at line 1451 of file error.c.

## ◆ rb_mFileTest

VALUE rb_mFileTest
| extern

FileTest module.

Definition at line 176 of file file.c.

## ◆ rb_mGC

VALUE rb_mGC
| extern

GC module.

Definition at line 431 of file gc.c.

## ◆ rb_mKernel [1/2]

VALUE rb_mKernel
| extern

Kernel module.

Definition at line 65 of file object.c.

Referenced by rb_define_global_function().

## ◆ rb_mKernel [2/2]

VALUE rb_mKernel

Kernel module.

Definition at line 65 of file object.c.

Referenced by rb_define_global_function().

## ◆ rb_mMath

VALUE rb_mMath
| extern

Math module.

Definition at line 29 of file math.c.

## ◆ rb_mProcess

VALUE rb_mProcess
| extern

Process module.

Definition at line 8825 of file process.c.

Referenced by ruby_prog_init().

## ◆ rb_mWaitReadable

VALUE rb_mWaitReadable
| extern

IO::WaitReadable module.

Definition at line 191 of file io.c.

Referenced by rb_readwrite_syserr_fail().

## ◆ rb_mWaitWritable

VALUE rb_mWaitWritable
| extern

IO::WaitReadable module.

Definition at line 192 of file io.c.

Referenced by rb_readwrite_syserr_fail().

## ◆ rb_stderr

VALUE rb_stderr
| extern

STDERR constant.

Definition at line 201 of file io.c.

Referenced by rb_ractor_stderr(), and rb_ractor_stderr_set().

## ◆ rb_stdin

VALUE rb_stdin
| extern

STDIN constant.

Definition at line 201 of file io.c.

Referenced by rb_ractor_stdin(), and rb_ractor_stdin_set().

## ◆ rb_stdout

VALUE rb_stdout
| extern

STDOUT constant.

Definition at line 201 of file io.c.

Referenced by rb_ractor_stdout(), and rb_ractor_stdout_set().