Ruby 3.3.6p108 (2024-11-05 revision 75015d4c1f6965b5e85e96fb309f1f2129f933c0)
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_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 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 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 142 of file object.c.

◆ false_or

#define false_or   true_and

Definition at line 1523 of file object.c.

◆ false_xor

#define false_xor   true_and

Definition at line 1538 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))
VALUE type(ANYARGS)
ANYARGS-ed function type.

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

◆ IMPLICIT_CONVERSIONS

#define IMPLICIT_CONVERSIONS   7

Definition at line 2987 of file object.c.

◆ rb_obj_class_inherited

#define rb_obj_class_inherited   rb_obj_dummy1

Definition at line 923 of file object.c.

◆ rb_obj_initialize

#define rb_obj_initialize   rb_obj_dummy0

Definition at line 1176 of file object.c.

◆ rb_obj_mod_const_added

#define rb_obj_mod_const_added   rb_obj_dummy1

Definition at line 1103 of file object.c.

◆ rb_obj_mod_extended

#define rb_obj_mod_extended   rb_obj_dummy1

Definition at line 1123 of file object.c.

◆ rb_obj_mod_included

#define rb_obj_mod_included   rb_obj_dummy1

Definition at line 1146 of file object.c.

◆ rb_obj_mod_method_added

#define rb_obj_mod_method_added   rb_obj_dummy1

Definition at line 946 of file object.c.

◆ rb_obj_mod_method_removed

#define rb_obj_mod_method_removed   rb_obj_dummy1

Definition at line 973 of file object.c.

◆ rb_obj_mod_method_undefined

#define rb_obj_mod_method_undefined   rb_obj_dummy1

Definition at line 1000 of file object.c.

◆ rb_obj_mod_prepended

#define rb_obj_mod_prepended   rb_obj_dummy1

Definition at line 1166 of file object.c.

◆ rb_obj_singleton_method_added

#define rb_obj_singleton_method_added   rb_obj_dummy1

Definition at line 1027 of file object.c.

◆ rb_obj_singleton_method_removed

#define rb_obj_singleton_method_removed   rb_obj_dummy1

Definition at line 1056 of file object.c.

◆ rb_obj_singleton_method_undefined

#define rb_obj_singleton_method_undefined   rb_obj_dummy1

Definition at line 1081 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 3128 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 3110 of file object.c.

◆ wrong_constant_name

#define wrong_constant_name   bad_const_name

Definition at line 2145 of file object.c.

Function Documentation

◆ basic_to_f_p()

static int basic_to_f_p ( VALUE klass)
inlinestatic

Definition at line 3597 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 2153 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 2043 of file object.c.

◆ class_get_alloc_func()

static rb_alloc_func_t class_get_alloc_func ( VALUE klass)
static

Definition at line 2025 of file object.c.

◆ class_or_module_required()

static VALUE class_or_module_required ( VALUE c)
static

Definition at line 740 of file object.c.

◆ class_search_ancestor()

static VALUE class_search_ancestor ( VALUE cl,
VALUE c )
static

Definition at line 876 of file object.c.

◆ class_search_class_ancestor()

static VALUE class_search_class_ancestor ( VALUE cl,
VALUE c )
static

Definition at line 783 of file object.c.

◆ conv_method_index()

static int conv_method_index ( const char * method)
static

Definition at line 2990 of file object.c.

◆ conversion_to_float()

static void conversion_to_float ( VALUE val)
inlinestatic

Definition at line 3466 of file object.c.

◆ convert_type()

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

Definition at line 3033 of file object.c.

◆ convert_type_to_float_protected()

static VALUE convert_type_to_float_protected ( VALUE val)
static

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

◆ dig_basic_p()

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

Definition at line 3797 of file object.c.

◆ f_sprintf()

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

Definition at line 3867 of file object.c.

◆ false_and()

static VALUE false_and ( VALUE obj,
VALUE obj2 )
static

Definition at line 1504 of file object.c.

◆ id_for_attr()

static ID id_for_attr ( VALUE obj,
VALUE name )
static

Definition at line 2180 of file object.c.

◆ immutable_obj_clone()

static VALUE immutable_obj_clone ( VALUE obj,
VALUE kwfreeze )
static

Definition at line 398 of file object.c.

◆ implicit_conversion_to_float()

static void implicit_conversion_to_float ( VALUE val)
inlinestatic

Definition at line 3472 of file object.c.

◆ init_copy()

static void init_copy ( VALUE dest,
VALUE obj )
static

Definition at line 309 of file object.c.

◆ Init_Object()

void Init_Object ( void )

Definition at line 4439 of file object.c.

◆ InitVM_Object()

void InitVM_Object ( void )

Definition at line 4106 of file object.c.

◆ inspect_i()

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

Definition at line 662 of file object.c.

◆ inspect_obj()

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

Definition at line 683 of file object.c.

◆ mutable_obj_clone()

static VALUE mutable_obj_clone ( VALUE obj,
VALUE kwfreeze )
static

Definition at line 479 of file object.c.

◆ nil_inspect()

static VALUE nil_inspect ( VALUE obj)
static

Definition at line 1339 of file object.c.

◆ nil_match()

static VALUE nil_match ( VALUE obj1,
VALUE obj2 )
static

Definition at line 1359 of file object.c.

◆ nil_to_a()

static VALUE nil_to_a ( VALUE obj)
static

Definition at line 1305 of file object.c.

◆ nil_to_h()

static VALUE nil_to_h ( VALUE obj)
static

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

◆ numeric_to_float()

static VALUE numeric_to_float ( VALUE val)
static

Definition at line 3567 of file object.c.

◆ obj_freeze_opt()

static VALUE obj_freeze_opt ( VALUE freeze)
static

Definition at line 347 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]objArbitrary 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 634 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]valAn object to convert.
Returns
An instance of rb_cArray.

Definition at line 3703 of file object.c.

◆ rb_bool_expected()

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

Definition at line 3232 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]valAn object to convert.
[in]typeA value of enum ruby_value_type.
[in]nameName to display on error (e.g. "Array").
[in]midConversion method (e.g. "to_ary").
Exceptions
rb_eTypeErrorThe `mid` does not generate `type`.
Return values
RUBY_QnilNo conversion defined.
otherwiseAn object of the specified type.

Definition at line 3080 of file object.c.

◆ rb_check_integer_type()

VALUE rb_check_integer_type ( VALUE val)

Definition at line 3226 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]valAn object to convert.
Return values
RUBY_QnilConversion from val to float is undefined.
otherwiseConverted result.

Definition at line 3587 of file object.c.

◆ rb_check_to_i()

static VALUE rb_check_to_i ( VALUE val)
static

Definition at line 3160 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]valAn object to convert.
Exceptions
rb_eTypeError`#to_int` does not return an integer.
Return values
RUBY_QnilNo conversion defined.
otherwiseAn instance of rb_cInteger.

Definition at line 3151 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]valAn object to convert.
[in]midConversion method (e.g. "to_ary").
Exceptions
rb_eTypeErrorThe `mid` does not generate an integer.
Return values
RUBY_QnilNo conversion defined.
otherwiseAn instance of rb_cInteger.

Definition at line 3132 of file object.c.

Referenced by rb_io_extract_modeenc().

◆ rb_class_alloc()

static VALUE rb_class_alloc ( VALUE klass)
static

Definition at line 2018 of file object.c.

◆ rb_class_alloc_m()

static VALUE rb_class_alloc_m ( VALUE klass)
static

Definition at line 2007 of file object.c.

◆ rb_class_get_superclass()

VALUE rb_class_get_superclass ( VALUE klass)

Returns the superclass of a class.

Parameters
[in]klassAn object of RClass.
Return values
RUBY_Qfalseklass has no super class.
otherwiseRaw 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 2136 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]scionPossible subclass.
[in]ascendantPossible superclass.
Exceptions
rb_eTypeError`ascendant` is not a module.
Return values
RUBY_Qtruescion inherits, or is equal to ascendant.
RUBY_Qfalseascendant inherits scion.
RUBY_QnilThey are not relatives.

Definition at line 1729 of file object.c.

◆ rb_class_initialize()

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

Definition at line 1948 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]argcNumber of objects of argv.
[in]argvArguments passed to #initialize.
[in]klassAn instance of rb_cClass.
Exceptions
rb_eTypeError`klass`'s allocator is undefined.
rb_eExceptionAny exceptions can happen inside.
Returns
An allocated new instance of klass.

Definition at line 2099 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]argcNumber of objects of argv.
[in]argvArbitrary number of method arguments.
[in]klassAn instance of rb_cClass.
[in]kw_splatHandling 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_eExceptionAny exceptions can happen inside.
Returns
An allocated new instance of klass.

Definition at line 2087 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]argcNumber of objects of argv.
[in]argvArbitrary number of method arguments.
[in]klassAn instance of rb_cClass.
Exceptions
rb_eTypeError`klass`'s allocator is undefined.
rb_eExceptionAny exceptions can happen inside.
Returns
An allocated new instance of klass.
Note
This is the implementation of Object.new.

Definition at line 2076 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]objTarget 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]klassAn instance of rb_cClass.
Return values
RUBY_QfalseNo real class in klass' ancestry tree.
klassklass itself is a real class.
otherwiseNearest ancestor of klass who is real.

Definition at line 205 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]klassa Class object
Returns
the superclass, or Qnil if klass does not have a parent class.
See also
rb_class_get_superclass

Definition at line 2114 of file object.c.

◆ rb_convert_to_float()

static VALUE rb_convert_to_float ( VALUE val,
int raise_exception )
static

Definition at line 3518 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 3169 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]valAn object to convert.
[in]typeA value of enum ruby_value_type.
[in]nameName to display on error (e.g. "Array").
[in]midConversion method (e.g. "to_ary").
Exceptions
rb_eTypeErrorFailed to convert.
Returns
An object of the specified type.

Definition at line 3053 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]strA textual representation of a real number.
[in]modeConversion mode, as described above.
Exceptions
rb_eArgErrorMalformed `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 3390 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 3274 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]lhsComparison left hand side.
[in]rhsComparison right hand side.
Return values
non-zeroThey are equal.
0Otherwise.
Note
This function actually calls lhs.eql?(rhs) so you cannot implement your class' #eql? method using it.

Definition at line 160 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]lhsComparison LHS.
[in]rhsComparison RHS.
Return values
RUBY_QtrueThey are the same.
RUBY_QfalseThey are different.

Definition at line 147 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 3737 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 3560 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 3554 of file object.c.

◆ rb_f_hash()

static VALUE rb_f_hash ( VALUE obj,
VALUE arg )
static

Definition at line 3783 of file object.c.

◆ rb_f_integer()

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

Definition at line 3267 of file object.c.

◆ rb_f_integer1()

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

Definition at line 3261 of file object.c.

◆ rb_f_string()

static VALUE rb_f_string ( VALUE obj,
VALUE arg )
static

Definition at line 3697 of file object.c.

◆ rb_false()

VALUE rb_false ( VALUE obj)

Definition at line 1566 of file object.c.

◆ rb_false_to_s()

VALUE rb_false_to_s ( VALUE obj)

Definition at line 1483 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]valAn object to convert.
Exceptions
rb_eArgErrorMalformed `val` passed.
rb_eTypeErrorNo conversion defined.
Returns
An instance of rb_cFloat.

Definition at line 3548 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 379 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 3746 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]objArbitrary ruby object.
Returns
An instance of rb_cString that represents obj.

Definition at line 645 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]valAn object to convert.
Exceptions
rb_eArgErrorMalformed `val` passed.
rb_eTypeErrorNo conversion defined.
Returns
An instance of rb_cInteger.

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

◆ rb_is_attr_name()

static int rb_is_attr_name ( VALUE name)
static

Definition at line 2168 of file object.c.

◆ rb_mod_attr_accessor()

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

Definition at line 2279 of file object.c.

◆ rb_mod_attr_reader()

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

Definition at line 2202 of file object.c.

◆ rb_mod_attr_writer()

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

Definition at line 2247 of file object.c.

◆ rb_mod_cmp()

static VALUE rb_mod_cmp ( VALUE mod,
VALUE arg )
static

Definition at line 1845 of file object.c.

◆ rb_mod_const_defined()

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

Definition at line 2508 of file object.c.

◆ rb_mod_const_get()

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

Definition at line 2335 of file object.c.

◆ rb_mod_const_set()

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

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

◆ rb_mod_cvar_defined()

static VALUE rb_mod_cvar_defined ( VALUE obj,
VALUE iv )
static

Definition at line 2938 of file object.c.

◆ rb_mod_cvar_get()

static VALUE rb_mod_cvar_get ( VALUE obj,
VALUE iv )
static

Definition at line 2881 of file object.c.

◆ rb_mod_cvar_set()

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

Definition at line 2913 of file object.c.

◆ rb_mod_eqq()

static VALUE rb_mod_eqq ( VALUE mod,
VALUE arg )
static

Definition at line 1712 of file object.c.

◆ rb_mod_freeze()

static VALUE rb_mod_freeze ( VALUE mod)
static

Definition at line 1695 of file object.c.

◆ rb_mod_ge()

static VALUE rb_mod_ge ( VALUE mod,
VALUE arg )
static

Definition at line 1803 of file object.c.

◆ rb_mod_gt()

static VALUE rb_mod_gt ( VALUE mod,
VALUE arg )
static

Definition at line 1826 of file object.c.

◆ rb_mod_initialize()

static VALUE rb_mod_initialize ( VALUE module)
static

Definition at line 1891 of file object.c.

◆ rb_mod_initialize_clone()

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

Definition at line 1907 of file object.c.

◆ rb_mod_initialize_exec()

static VALUE rb_mod_initialize_exec ( VALUE module)
static

Definition at line 1897 of file object.c.

◆ rb_mod_lt()

static VALUE rb_mod_lt ( VALUE mod,
VALUE arg )
static

Definition at line 1783 of file object.c.

◆ rb_mod_singleton_p()

static VALUE rb_mod_singleton_p ( VALUE klass)
static

Definition at line 2962 of file object.c.

◆ rb_mod_to_s()

VALUE rb_mod_to_s ( VALUE klass)

Definition at line 1651 of file object.c.

◆ rb_nil_to_s()

VALUE rb_nil_to_s ( VALUE obj)

Definition at line 1287 of file object.c.

◆ rb_num2dbl()

double rb_num2dbl ( VALUE num)

Converts an instance of rb_cNumeric into C's double.

Parameters
[in]numSomething numeric.
Exceptions
rb_eTypeError`num` is not a numeric.
Returns
The passed value converted into C's double.

Definition at line 3639 of file object.c.

◆ rb_obj_alloc()

VALUE rb_obj_alloc ( VALUE klass)

Allocates an instance of the given class.

Parameters
[in]klassA 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 2058 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]objObject in question.
Returns
The object's class, in a normal sense.

Definition at line 215 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]objArbitrary ruby object.
Exceptions
rb_eException`#initialize_copy` can raise anything.
Returns
A "clone" of obj.

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

◆ rb_obj_clone_setup()

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

Definition at line 407 of file object.c.

◆ rb_obj_cmp()

static VALUE rb_obj_cmp ( VALUE obj1,
VALUE obj2 )
static

Definition at line 1606 of file object.c.

◆ rb_obj_dummy()

static VALUE rb_obj_dummy ( void )
static

Definition at line 1183 of file object.c.

◆ rb_obj_dummy0()

static VALUE rb_obj_dummy0 ( VALUE _)
static

Definition at line 1189 of file object.c.

◆ rb_obj_dummy1()

static VALUE rb_obj_dummy1 ( VALUE _x,
VALUE _y )
static

Definition at line 1195 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]objArbitrary ruby object.
Exceptions
rb_eException`#initialize_copy` can raise anything.
Returns
A shallow copy of obj.

Definition at line 541 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 493 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

Definition at line 96 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]objObject to freeze.
Returns
Verbatim obj.

Definition at line 1225 of file object.c.

◆ 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]objObject in question.
Return values
RUBY_QtrueYes it is.
RUBY_QfalseNo it isn't.

Definition at line 1237 of file object.c.

◆ rb_obj_hash()

VALUE rb_obj_hash ( VALUE obj)

Definition at line 312 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]objA Ruby object.
Returns
The passed object.
Postcondition
The object is destructively modified to be invisible.
See also
rb_obj_reveal

Definition at line 102 of file object.c.

◆ rb_obj_init_clone()

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

Default implementation of #initialize_clone.

Parameters
[in]Thenumber of arguments
[in]Thearray of arguments
[in]objthe receiver being initialized

Definition at line 612 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]objthe receiver being initialized
[in]origthe object to be copied from.

Definition at line 581 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]objthe receiver being initialized
[in]origthe object to be dup from.

Definition at line 598 of file object.c.

◆ rb_obj_inspect()

static VALUE rb_obj_inspect ( VALUE obj)
static

Definition at line 725 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]objArbitrary ruby object.
[in]klassAn instance of rb_cModule.
Exceptions
rb_eTypeError`klass` is neither module nor class.
Return values
RUBY_Qtrueobj is an instance of klass.
RUBY_QfalseOtherwise.

Definition at line 774 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]objArbitrary ruby object.
[in]klassAn instance of rb_cModule.
Exceptions
rb_eTypeError`klass` is neither module nor class.
Return values
RUBY_Qtrueobj is a klass.
RUBY_QfalseOtherwise.

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

◆ rb_obj_ivar_defined()

static VALUE rb_obj_ivar_defined ( VALUE obj,
VALUE iv )
static

Definition at line 2854 of file object.c.

◆ rb_obj_ivar_get()

static VALUE rb_obj_ivar_get ( VALUE obj,
VALUE iv )
static

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

◆ rb_obj_not_match()

static VALUE rb_obj_not_match ( VALUE obj1,
VALUE obj2 )
static

Definition at line 1580 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]objA Ruby object.
[in]klassClass of obj.
Returns
Passed obj.
Precondition
obj was previously hidden.
Postcondition
obj's class is klass.
See also
rb_obj_hide

Definition at line 111 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]objA Ruby object to be set up.
[in]klassobj will belong to this class.
[in]typeOne of ruby_value_type.
Returns
The passed object.

Definition at line 120 of file object.c.

◆ rb_obj_singleton_class()

static VALUE rb_obj_singleton_class ( VALUE obj)
static

Definition at line 238 of file object.c.

◆ rb_obj_size()

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

Definition at line 570 of file object.c.

◆ rb_opts_exception_p()

int rb_opts_exception_p ( VALUE opts,
int default_value )

Definition at line 3251 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]strA textual representation of a real number.
[in]modeConversion mode, as described in rb_cstr_to_dbl().
Exceptions
rb_eArgErrorMalformed `str` passed.
See also
https://bugs.ruby-lang.org/issues/2969

Definition at line 3432 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 3396 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]valAn object to convert.
Exceptions
rb_eTypeErrorNo conversion defined.
Returns
An instance of rb_cString.

Definition at line 3671 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]valAn object to convert.
Exceptions
rb_eTypeErrorNo conversion defined.
Returns
An instance of rb_cFloat.

Definition at line 3577 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]valAn object to convert.
Exceptions
rb_eTypeError`#to_int` does not generate an integer.
Returns
An instance of rb_cInteger.

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

◆ rb_true()

static VALUE rb_true ( VALUE obj)
static

Definition at line 1549 of file object.c.

◆ rb_true_to_s()

VALUE rb_true_to_s ( VALUE obj)

Definition at line 1396 of file object.c.

◆ to_float()

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

Definition at line 3478 of file object.c.

◆ true_and()

static VALUE true_and ( VALUE obj,
VALUE obj2 )
static

Definition at line 1415 of file object.c.

◆ true_or()

static VALUE true_or ( VALUE obj,
VALUE obj2 )
static

Definition at line 1440 of file object.c.

◆ true_xor()

static VALUE true_xor ( VALUE obj,
VALUE obj2 )
static

Definition at line 1459 of file object.c.

Variable Documentation

◆ bad_attr_name

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

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

◆ bad_const_name

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

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

◆ id_dig

ID id_dig
static

Definition at line 3794 of file object.c.

◆ rb_cArray

VALUE rb_cArray
extern

Array class.

Definition at line 39 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 62 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 62 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 43 of file proc.c.

◆ rb_cClass [1/2]

VALUE rb_cClass
extern

Class class.

Definition at line 66 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 66 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 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 163 of file enumerator.c.

Referenced by rb_enumeratorize_with_size_kw().

◆ rb_cFalseClass [1/2]

VALUE rb_cFalseClass
extern

FalseClass class.

Definition at line 71 of file object.c.

Referenced by rb_class_of().

◆ rb_cFalseClass [2/2]

VALUE rb_cFalseClass

FalseClass class.

Definition at line 71 of file object.c.

Referenced by rb_class_of().

◆ rb_cFalseClass_to_s

VALUE rb_cFalseClass_to_s
static

Definition at line 75 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 110 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 176 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 42 of file proc.c.

◆ rb_cModule [1/2]

VALUE rb_cModule
extern

Module class.

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

◆ rb_cNilClass [1/2]

VALUE rb_cNilClass
extern

NilClass class.

Definition at line 69 of file object.c.

Referenced by rb_class_of().

◆ rb_cNilClass [2/2]

VALUE rb_cNilClass

NilClass class.

Definition at line 69 of file object.c.

Referenced by rb_class_of().

◆ rb_cNilClass_to_s

VALUE rb_cNilClass_to_s
static

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

◆ rb_cObject [2/2]

VALUE rb_cObject

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

Object class.

Definition at line 64 of file object.c.

◆ rb_cProc

VALUE rb_cProc
extern

Proc class.

Definition at line 44 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 235 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 67 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 67 of file object.c.

Referenced by Init_class_hierarchy(), and rb_refinement_new().

◆ rb_cRegexp

VALUE rb_cRegexp
extern

Regexp class.

Definition at line 2592 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

◆ 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 79 of file string.c.

Referenced by rb_class_of(), and rb_str_intern().

◆ rb_cThread

VALUE rb_cThread
extern

Thread class.

Definition at line 524 of file vm.c.

Referenced by rb_thread_create().

◆ rb_cTime

VALUE rb_cTime
extern

Time class.

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

Referenced by rb_class_of().

◆ rb_cTrueClass [2/2]

VALUE rb_cTrueClass

TrueClass class.

Definition at line 70 of file object.c.

Referenced by rb_class_of().

◆ rb_cTrueClass_to_s

VALUE rb_cTrueClass_to_s
static

Definition at line 74 of file object.c.

◆ rb_cUnboundMethod

VALUE rb_cUnboundMethod
extern

UnboundMethod class.

Definition at line 41 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 1365 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 1342 of file gc.c.

◆ rb_mKernel [1/2]

VALUE rb_mKernel
extern

Kernel module.

Definition at line 63 of file object.c.

Referenced by rb_define_global_function().

◆ rb_mKernel [2/2]

VALUE rb_mKernel

Kernel module.

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

Referenced by ruby_prog_init().

◆ rb_mWaitReadable

VALUE rb_mWaitReadable
extern

IO::WaitReadable module.

Definition at line 180 of file io.c.

Referenced by rb_readwrite_syserr_fail().

◆ rb_mWaitWritable

VALUE rb_mWaitWritable
extern

IO::WaitReadable module.

Definition at line 181 of file io.c.

Referenced by rb_readwrite_syserr_fail().

◆ rb_stderr

VALUE rb_stderr
extern

STDERR constant.

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

Referenced by rb_ractor_stdout(), and rb_ractor_stdout_set().