Ruby: Core objects and their operations

Ruby 3.2.5p208 (2024-07-26 revision 31d0f1a2e7dbfb60731d1f05b868e1d578cda493)

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

## Macros
#define | RUBY_INTEGER_UNIFICATION 1
#define | case_equal rb_equal
| call-seq: obj === other -> true or false
#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)
#define | opts_exception_p(opts)

## Functions
static VALUE | rb_class_of (VALUE obj)
| Object to class mapping function.
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_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 (VALUE obj)
| Produces a shallow copy of the given object.
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)
static VALUE | block_given_p (rb_execution_context_t *ec, VALUE self)
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 (st_data_t k, st_data_t v, 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_integer (int argc, VALUE *argv, VALUE obj)
static double | rb_cstr_to_dbl_raise (const char *p, 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 _)
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
| `Sumbol` 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

call-seq: obj === other -> true or false

Case Equality – For class Object, effectively the same as calling `#==`, but typically overridden by descendants to provide meaningful semantics in +case+ statements.

Definition at line 118 of file object.c.

## ◆ false_or

#define false_or true_and

Definition at line 1408 of file object.c.

## ◆ false_xor

#define false_xor true_and

Definition at line 1421 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 2032 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 2030 of file object.c.

## ◆ IMPLICIT_CONVERSIONS

#define IMPLICIT_CONVERSIONS 7

Definition at line 2869 of file object.c.

## ◆ opts_exception_p

#define opts_exception_p | ( |  | opts | ) |

Value:
rb_opts_exception_p((opts), TRUE)

Definition at line 3142 of file object.c.

## ◆ rb_obj_class_inherited

#define rb_obj_class_inherited rb_obj_dummy1

Definition at line 881 of file object.c.

## ◆ rb_obj_initialize

#define rb_obj_initialize rb_obj_dummy0

Definition at line 1134 of file object.c.

## ◆ rb_obj_mod_const_added

#define rb_obj_mod_const_added rb_obj_dummy1

Definition at line 1061 of file object.c.

## ◆ rb_obj_mod_extended

#define rb_obj_mod_extended rb_obj_dummy1

Definition at line 1081 of file object.c.

## ◆ rb_obj_mod_included

#define rb_obj_mod_included rb_obj_dummy1

Definition at line 1104 of file object.c.

## ◆ rb_obj_mod_method_added

#define rb_obj_mod_method_added rb_obj_dummy1

Definition at line 904 of file object.c.

## ◆ rb_obj_mod_method_removed

#define rb_obj_mod_method_removed rb_obj_dummy1

Definition at line 931 of file object.c.

## ◆ rb_obj_mod_method_undefined

#define rb_obj_mod_method_undefined rb_obj_dummy1

Definition at line 958 of file object.c.

## ◆ rb_obj_mod_prepended

#define rb_obj_mod_prepended rb_obj_dummy1

Definition at line 1124 of file object.c.

## ◆ rb_obj_singleton_method_added

#define rb_obj_singleton_method_added rb_obj_dummy1

Definition at line 985 of file object.c.

## ◆ rb_obj_singleton_method_removed

#define rb_obj_singleton_method_removed rb_obj_dummy1

Definition at line 1014 of file object.c.

## ◆ rb_obj_singleton_method_undefined

#define rb_obj_singleton_method_undefined rb_obj_dummy1

Definition at line 1039 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 3010 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 2992 of file object.c.

## ◆ wrong_constant_name

#define wrong_constant_name bad_const_name

Definition at line 2027 of file object.c.

## Function Documentation

## ◆ basic_to_f_p()

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

Definition at line 3582 of file object.c.

## ◆ block_given_p()

static VALUE block_given_p | ( | rb_execution_context_t * | ec,
|  | VALUE | self )
| static

Definition at line 526 of file object.c.

## ◆ check_setter_id()

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

Definition at line 2035 of file object.c.

## ◆ class_call_alloc_func()

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

Definition at line 1925 of file object.c.

## ◆ class_get_alloc_func()

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

Definition at line 1907 of file object.c.

## ◆ class_or_module_required()

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

Definition at line 698 of file object.c.

## ◆ class_search_ancestor()

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

Definition at line 834 of file object.c.

## ◆ class_search_class_ancestor()

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

Definition at line 741 of file object.c.

## ◆ conv_method_index()

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

Definition at line 2872 of file object.c.

## ◆ conversion_to_float()

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

Definition at line 3451 of file object.c.

## ◆ convert_type()

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

Definition at line 2915 of file object.c.

## ◆ convert_type_to_float_protected()

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

Definition at line 3497 of file object.c.

## ◆ convert_type_with_id()

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

Definition at line 2890 of file object.c.

## ◆ dig_basic_p()

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

Definition at line 3782 of file object.c.

## ◆ f_sprintf()

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

Definition at line 3855 of file object.c.

## ◆ false_and()

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

Definition at line 1393 of file object.c.

## ◆ id_for_attr()

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

Definition at line 2062 of file object.c.

## ◆ immutable_obj_clone()

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

Definition at line 370 of file object.c.

## ◆ implicit_conversion_to_float()

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

Definition at line 3457 of file object.c.

## ◆ init_copy()

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

Definition at line 281 of file object.c.

## ◆ Init_Object()

void Init_Object | ( | void |  | ) |

Definition at line 4447 of file object.c.

## ◆ inspect_i()

static int inspect_i | ( | st_data_t | k,
|  | st_data_t | v,
|  | st_data_t | a )
| static

Definition at line 618 of file object.c.

## ◆ inspect_obj()

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

Definition at line 641 of file object.c.

## ◆ mutable_obj_clone()

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

Definition at line 379 of file object.c.

## ◆ nil_inspect()

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

Definition at line 1262 of file object.c.

## ◆ nil_match()

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

Definition at line 1277 of file object.c.

## ◆ nil_to_a()

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

Definition at line 1232 of file object.c.

## ◆ nil_to_h()

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

Definition at line 1249 of file object.c.

## ◆ no_dig_method()

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

Definition at line 3793 of file object.c.

## ◆ numeric_to_float()

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

Definition at line 3552 of file object.c.

## ◆ obj_freeze_opt()

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

Definition at line 319 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 590 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 3688 of file object.c.

## ◆ rb_bool_expected()

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

Definition at line 3114 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 2962 of file object.c.

## ◆ rb_check_integer_type()

VALUE rb_check_integer_type | ( | VALUE | val | ) |

Definition at line 3108 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 3572 of file object.c.

## ◆ rb_check_to_i()

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

Definition at line 3042 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 3033 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 3014 of file object.c.

Referenced by rb_io_extract_modeenc().

## ◆ rb_class_alloc()

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

Definition at line 1900 of file object.c.

## ◆ rb_class_alloc_m()

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

Definition at line 1889 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 2018 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 1611 of file object.c.

## ◆ rb_class_initialize()

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

Definition at line 1830 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 1981 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 1969 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 1958 of file object.c.

## ◆ rb_class_of()

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

## ◆ 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 181 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 1996 of file object.c.

## ◆ rb_convert_to_float()

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

Definition at line 3503 of file object.c.

## ◆ rb_convert_to_integer()

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

Definition at line 3051 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 2935 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 3376 of file object.c.

## ◆ rb_cstr_to_dbl_raise()

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

Definition at line 3260 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 136 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 123 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()

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

Definition at line 3722 of file object.c.

## ◆ rb_f_float()

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

Definition at line 3545 of file object.c.

## ◆ rb_f_float1()

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

Definition at line 3539 of file object.c.

## ◆ rb_f_hash()

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

Definition at line 3768 of file object.c.

## ◆ rb_f_integer()

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

Definition at line 3233 of file object.c.

## ◆ rb_f_string()

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

Definition at line 3682 of file object.c.

## ◆ rb_false()

VALUE rb_false | ( | VALUE | obj | ) |

Definition at line 1448 of file object.c.

## ◆ rb_false_to_s()

VALUE rb_false_to_s | ( | VALUE | obj | ) |

Definition at line 1377 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 3533 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 351 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 3731 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 601 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 3102 of file object.c.

Referenced by rb_str_format().

## ◆ rb_is_attr_id()

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

Definition at line 2056 of file object.c.

## ◆ rb_is_attr_name()

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

Definition at line 2050 of file object.c.

## ◆ rb_mod_attr_accessor()

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

Definition at line 2161 of file object.c.

## ◆ rb_mod_attr_reader()

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

Definition at line 2084 of file object.c.

## ◆ rb_mod_attr_writer()

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

Definition at line 2129 of file object.c.

## ◆ rb_mod_cmp()

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

Definition at line 1727 of file object.c.

## ◆ rb_mod_const_defined()

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

Definition at line 2390 of file object.c.

## ◆ rb_mod_const_get()

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

Definition at line 2217 of file object.c.

## ◆ rb_mod_const_set()

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

Definition at line 2339 of file object.c.

## ◆ rb_mod_const_source_location()

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

Definition at line 2550 of file object.c.

## ◆ rb_mod_cvar_defined()

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

Definition at line 2820 of file object.c.

## ◆ rb_mod_cvar_get()

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

Definition at line 2763 of file object.c.

## ◆ rb_mod_cvar_set()

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

Definition at line 2795 of file object.c.

## ◆ rb_mod_eqq()

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

Definition at line 1594 of file object.c.

## ◆ rb_mod_freeze()

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

Definition at line 1577 of file object.c.

## ◆ rb_mod_ge()

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

Definition at line 1685 of file object.c.

## ◆ rb_mod_gt()

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

Definition at line 1708 of file object.c.

## ◆ rb_mod_initialize()

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

Definition at line 1773 of file object.c.

## ◆ rb_mod_initialize_clone()

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

Definition at line 1789 of file object.c.

## ◆ rb_mod_initialize_exec()

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

Definition at line 1779 of file object.c.

## ◆ rb_mod_lt()

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

Definition at line 1665 of file object.c.

## ◆ rb_mod_singleton_p()

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

Definition at line 2844 of file object.c.

## ◆ rb_mod_to_s()

VALUE rb_mod_to_s | ( | VALUE | klass | ) |

Definition at line 1533 of file object.c.

## ◆ rb_nil_to_s()

VALUE rb_nil_to_s | ( | VALUE | obj | ) |

Definition at line 1215 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 3624 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 rb_newobj_of(), 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()
  rb_newobj_of()
  TypedData_Make_Struct

Definition at line 1940 of file object.c.

Referenced by rb_catch(), 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 191 of file object.c.

Referenced by rb_check_inheritable(), rb_cmperr(), rb_define_class(), rb_define_module(), rb_define_module_id_under(), rb_hash_dup(), 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 442 of file object.c.

Referenced by rb_eval_string_wrap().

## ◆ rb_obj_clone2()

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

Definition at line 334 of file object.c.

## ◆ rb_obj_cmp()

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

Definition at line 1488 of file object.c.

## ◆ rb_obj_dummy()

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

Definition at line 1141 of file object.c.

## ◆ rb_obj_dummy0()

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

Definition at line 1147 of file object.c.

## ◆ rb_obj_dummy1()

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

Definition at line 1153 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 488 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 1183 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 1195 of file object.c.

## ◆ rb_obj_hash()

VALUE rb_obj_hash | ( | VALUE | obj | ) |

Definition at line 296 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 84 of file object.c.

Referenced by ruby_init_loadpath().

## ◆ rb_obj_init_clone()

static 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 568 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 537 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 554 of file object.c.

## ◆ rb_obj_inspect()

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

Definition at line 683 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 732 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 788 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()

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

Definition at line 514 of file object.c.

## ◆ rb_obj_ivar_defined()

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

Definition at line 2736 of file object.c.

## ◆ rb_obj_ivar_get()

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

Definition at line 2674 of file object.c.

## ◆ rb_obj_ivar_set_m()

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

Definition at line 2708 of file object.c.

## ◆ rb_obj_not_match()

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

Definition at line 1462 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 93 of file object.c.

## ◆ rb_obj_setup()

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

Fills common fields in the object.

Note
  Prefer rb_newobj_of() to this function.

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 102 of file object.c.

## ◆ rb_obj_singleton_class()

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

Definition at line 214 of file object.c.

## ◆ rb_obj_size()

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

Definition at line 520 of file object.c.

## ◆ rb_opts_exception_p()

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

Definition at line 3133 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 3417 of file object.c.

## ◆ rb_str_to_dbl_raise()

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

Definition at line 3382 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 3656 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 3562 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 3027 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()

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

Definition at line 2998 of file object.c.

## ◆ rb_true()

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

Definition at line 1431 of file object.c.

## ◆ rb_true_to_s()

VALUE rb_true_to_s | ( | VALUE | obj | ) |

Definition at line 1300 of file object.c.

## ◆ to_float()

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

Definition at line 3463 of file object.c.

## ◆ true_and()

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

Definition at line 1315 of file object.c.

## ◆ true_or()

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

Definition at line 1337 of file object.c.

## ◆ true_xor()

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

Definition at line 1353 of file object.c.

## Variable Documentation

## ◆ bad_attr_name

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

Definition at line 2026 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 2024 of file object.c.

## ◆ bad_const_name

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

Definition at line 2025 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 2023 of file object.c.

## ◆ id_dig

ID id_dig
| static

Definition at line 3779 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 50 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 50 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 51 of file proc.c.

## ◆ rb_cClass [1/2]

VALUE rb_cClass
| extern

`Class` class.

Definition at line 54 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 54 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 38 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 458 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 158 of file enumerator.c.

Referenced by rb_enumeratorize_with_size_kw().

## ◆ rb_cFalseClass [1/2]

VALUE rb_cFalseClass
| extern

`FalseClass` class.

Definition at line 59 of file object.c.

Referenced by rb_class_of().

## ◆ rb_cFalseClass [2/2]

VALUE rb_cFalseClass

`FalseClass` class.

Definition at line 59 of file object.c.

Referenced by rb_class_of().

## ◆ rb_cFalseClass_to_s

VALUE rb_cFalseClass_to_s
| static

Definition at line 63 of file object.c.

## ◆ rb_cFile

VALUE rb_cFile
| extern

`File` class.

Definition at line 176 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 191 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 94 of file hash.c.

Referenced by rb_extract_keywords(), and rb_hash_new().

## ◆ rb_cInteger

VALUE rb_cInteger
| extern

`Module` class.

Definition at line 192 of file numeric.c.

Referenced by rb_class_of().

## ◆ rb_cIO

VALUE rb_cIO
| extern

`IO` class.

Definition at line 180 of file io.c.

Referenced by rb_io_fdopen().

## ◆ rb_cMatch

VALUE rb_cMatch
| extern

`MatchData` class.

Definition at line 960 of file re.c.

## ◆ rb_cMethod

VALUE rb_cMethod
| extern

`Method` class.

Definition at line 50 of file proc.c.

## ◆ rb_cModule [1/2]

VALUE rb_cModule
| extern

`Module` class.

Definition at line 53 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 53 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 1103 of file error.c.

## ◆ rb_cNilClass [1/2]

VALUE rb_cNilClass
| extern

`NilClass` class.

Definition at line 57 of file object.c.

Referenced by rb_class_of().

## ◆ rb_cNilClass [2/2]

VALUE rb_cNilClass

`NilClass` class.

Definition at line 57 of file object.c.

Referenced by rb_class_of().

## ◆ rb_cNilClass_to_s

VALUE rb_cNilClass_to_s
| static

Definition at line 61 of file object.c.

## ◆ rb_cNumeric

VALUE rb_cNumeric
| extern

`Numeric` class.

Definition at line 190 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 52 of file object.c.

## ◆ rb_cObject [2/2]

VALUE rb_cObject

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

`Object` class.

Definition at line 52 of file object.c.

## ◆ rb_cProc

VALUE rb_cProc
| extern

`Proc` class.

Definition at line 52 of file proc.c.

Referenced by rb_block_lambda(), and rb_block_proc().

## ◆ rb_cRactor

VALUE rb_cRactor
| extern

`Ractor` class.

Definition at line 22 of file ractor.c.

## ◆ rb_cRandom

VALUE rb_cRandom
| extern

`Random` class.

Definition at line 229 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 47 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 55 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 55 of file object.c.

Referenced by Init_class_hierarchy(), and rb_refinement_new().

## ◆ rb_cRegexp

VALUE rb_cRegexp
| extern

`Regexp` class.

Definition at line 2544 of file re.c.

## ◆ rb_cStat

VALUE rb_cStat
| extern

`File::Stat` class.

Definition at line 178 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_static(), rb_utf8_str_new(), and rb_utf8_str_new_static().

## ◆ rb_cStruct

VALUE rb_cStruct
| extern

`Struct` class.

Definition at line 34 of file struct.c.

Referenced by rb_struct_define(), and rb_struct_define_under().

## ◆ rb_cSymbol

VALUE rb_cSymbol
| extern

`Sumbol` 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 466 of file vm.c.

Referenced by rb_thread_create().

## ◆ rb_cTime

VALUE rb_cTime
| extern

`Time` class.

Definition at line 672 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 58 of file object.c.

Referenced by rb_class_of().

## ◆ rb_cTrueClass [2/2]

VALUE rb_cTrueClass

`TrueClass` class.

Definition at line 58 of file object.c.

Referenced by rb_class_of().

## ◆ rb_cTrueClass_to_s

VALUE rb_cTrueClass_to_s
| static

Definition at line 62 of file object.c.

## ◆ rb_cUnboundMethod

VALUE rb_cUnboundMethod
| extern

`UnboundMethod` class.

Definition at line 49 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 1112 of file error.c.

## ◆ rb_mFileTest

VALUE rb_mFileTest
| extern

`FileTest` module.

Definition at line 177 of file file.c.

## ◆ rb_mGC

VALUE rb_mGC
| extern

`GC` module.

Definition at line 1209 of file gc.c.

## ◆ rb_mKernel [1/2]

VALUE rb_mKernel
| extern

`Kernel` module.

Definition at line 51 of file object.c.

Referenced by rb_define_global_function().

## ◆ rb_mKernel [2/2]

VALUE rb_mKernel

`Kernel` module.

Definition at line 51 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 8784 of file process.c.

Referenced by ruby_prog_init().

## ◆ rb_mWaitReadable

VALUE rb_mWaitReadable
| extern

`IO::WaitReadable` module.

Definition at line 184 of file io.c.

Referenced by rb_readwrite_syserr_fail().

## ◆ rb_mWaitWritable

VALUE rb_mWaitWritable
| extern

`IO::WaitReadable` module.

Definition at line 185 of file io.c.

Referenced by rb_readwrite_syserr_fail().

## ◆ rb_stderr

VALUE rb_stderr
| extern

`STDERR` constant.

Definition at line 194 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 194 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 194 of file io.c.

Referenced by rb_ractor_stdout(), and rb_ractor_stdout_set().