Ruby: include/ruby/internal/intern/object.h Source File

Ruby 3.4.6p54 (2025-09-16 revision dbd83256b1cec76c69756ecb8758b9e1079833de)

object.h
Go to the documentation of this file.
1#ifndef RBIMPL_INTERN_OBJECT_H /*-*-C++-*-vi:se ft=cpp:*/
2#define RBIMPL_INTERN_OBJECT_H
23#include "ruby/internal/attr/const.h"
24#include "ruby/internal/attr/deprecated.h"
25#include "ruby/internal/attr/nonnull.h"
26#include "ruby/internal/attr/pure.h"
27#include "ruby/internal/dllexport.h"
28#include "ruby/internal/value.h"
29
30 RBIMPL_SYMBOL_EXPORT_BEGIN()
31
32
38#define RB_OBJ_INIT_COPY(obj, orig) \
39 ((obj) != (orig) && (rb_obj_init_copy((obj), (orig)), 1))
40
41#define OBJ_INIT_COPY(obj, orig) RB_OBJ_INIT_COPY(obj, orig)
42
43/* object.c */
44
57 VALUE rb_class_new_instance_pass_kw(int argc, const VALUE *argv, VALUE klass);
58
71 VALUE rb_class_new_instance(int argc, const VALUE *argv, VALUE klass);
72
88 VALUE rb_class_new_instance_kw(int argc, const VALUE *argv, VALUE klass, int kw_splat);
89
100int rb_eql(VALUE lhs, VALUE rhs);
101
110 VALUE rb_any_to_s(VALUE obj);
111
121 VALUE rb_inspect(VALUE obj);
122
132 VALUE rb_obj_is_instance_of(VALUE obj, VALUE klass);
133
144 VALUE rb_obj_is_kind_of(VALUE obj, VALUE klass);
145
162 VALUE rb_obj_alloc(VALUE klass);
163
178 VALUE rb_obj_clone(VALUE obj);
179
189 VALUE rb_obj_dup(VALUE obj);
190
202 VALUE rb_obj_init_copy(VALUE src, VALUE dst);
203
211 VALUE rb_obj_freeze(VALUE obj);
212
213 RBIMPL_ATTR_PURE()
222 VALUE rb_obj_frozen_p(VALUE obj);
223
224/* gc.c */
225
244 VALUE rb_obj_id(VALUE obj);
245
246 RBIMPL_ATTR_CONST()
265 VALUE rb_memory_id(VALUE obj);
266
267/* object.c */
268
269 RBIMPL_ATTR_PURE()
281 VALUE rb_class_real(VALUE klass);
282
283 RBIMPL_ATTR_PURE()
294 VALUE rb_class_inherited_p(VALUE scion, VALUE ascendant);
295
296 RBIMPL_ATTR_PURE()
309 VALUE rb_class_superclass(VALUE klass);
310
311 RBIMPL_ATTR_NONNULL(())
323 VALUE rb_convert_type(VALUE val, int type, const char *name, const char *mid);
324
325 RBIMPL_ATTR_NONNULL(())
340 VALUE rb_check_convert_type(VALUE val, int type, const char *name, const char *mid);
341
342 RBIMPL_ATTR_NONNULL(())
353 VALUE rb_check_to_integer(VALUE val, const char *mid);
354
375 VALUE rb_check_to_float(VALUE val);
376
385 VALUE rb_to_int(VALUE val);
386
395 VALUE rb_check_to_int(VALUE val);
396
411 VALUE rb_Integer(VALUE val);
412
420 VALUE rb_to_float(VALUE val);
421
435 VALUE rb_Float(VALUE val);
436
445 VALUE rb_String(VALUE val);
446
455 VALUE rb_Array(VALUE val);
456
466 VALUE rb_Hash(VALUE val);
467
468 RBIMPL_ATTR_NONNULL(())
485double rb_cstr_to_dbl(const char *str, int mode);
486
496double rb_str_to_dbl(VALUE str, int mode);
497
498 RBIMPL_SYMBOL_EXPORT_END()
499
500#endif /* RBIMPL_INTERN_OBJECT_H */
const.h
Defines RBIMPL_ATTR_CONST.
RBIMPL_ATTR_CONST
#define RBIMPL_ATTR_CONST()
Wraps (or simulates) __attribute__((const))
Definition const.h:36
deprecated.h
Defines RBIMPL_ATTR_DEPRECATED.
dllexport.h
Tweaking visibility of C variables/functions.
RBIMPL_SYMBOL_EXPORT_END
#define RBIMPL_SYMBOL_EXPORT_END()
Counterpart of RBIMPL_SYMBOL_EXPORT_BEGIN.
Definition dllexport.h:74
RBIMPL_SYMBOL_EXPORT_BEGIN
#define RBIMPL_SYMBOL_EXPORT_BEGIN()
Shortcut macro equivalent to RUBY_SYMBOL_EXPORT_BEGIN extern "C" {.
Definition dllexport.h:65
rb_class_superclass
VALUE rb_class_superclass(VALUE klass)
Queries the parent of the given class.
Definition object.c:2153
rb_convert_type
VALUE rb_convert_type(VALUE val, int type, const char *name, const char *mid)
Converts an object into another type.
Definition object.c:3092
rb_Float
VALUE rb_Float(VALUE val)
This is the logic behind Kernel#Float.
Definition object.c:3624
rb_check_to_int
VALUE rb_check_to_int(VALUE val)
Identical to rb_check_to_integer(), except it uses #to_int for conversion.
Definition object.c:3198
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,...
Definition object.c:3119
rb_any_to_s
VALUE rb_any_to_s(VALUE obj)
Generates a textual representation of the given object.
Definition object.c:669
rb_obj_alloc
VALUE rb_obj_alloc(VALUE klass)
Allocates an instance of the given class.
Definition object.c:2097
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.
Definition object.c:2138
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 gi...
Definition object.c:2126
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 ...
Definition object.c:2115
rb_check_to_float
VALUE rb_check_to_float(VALUE val)
This is complicated.
Definition object.c:3663
rb_Hash
VALUE rb_Hash(VALUE val)
This is the logic behind Kernel#Hash.
Definition object.c:3822
rb_obj_frozen_p
VALUE rb_obj_frozen_p(VALUE obj)
Just calls RB_OBJ_FROZEN() inside.
Definition object.c:1272
rb_obj_init_copy
VALUE rb_obj_init_copy(VALUE src, VALUE dst)
Default implementation of #initialize_copy, #initialize_dup and #initialize_clone.
Definition object.c:616
rb_eql
int rb_eql(VALUE lhs, VALUE rhs)
Checks for equality of the passed objects, in terms of Object#eql?.
Definition object.c:192
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.
Definition object.c:3508
rb_Integer
VALUE rb_Integer(VALUE val)
This is the logic behind Kernel#Integer.
Definition object.c:3267
rb_Array
VALUE rb_Array(VALUE val)
This is the logic behind Kernel#Array.
Definition object.c:3779
rb_obj_dup
VALUE rb_obj_dup(VALUE obj)
Duplicates the given object.
Definition object.c:576
rb_inspect
VALUE rb_inspect(VALUE obj)
Generates a human-readable textual representation of the given object.
Definition object.c:680
rb_class_inherited_p
VALUE rb_class_inherited_p(VALUE scion, VALUE ascendant)
Determines if the given two modules are relatives.
Definition object.c:1768
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.
Definition object.c:809
rb_class_real
VALUE rb_class_real(VALUE klass)
Finds a "real" class.
Definition object.c:237
rb_to_float
VALUE rb_to_float(VALUE val)
Identical to rb_check_to_float(), except it raises on error.
Definition object.c:3653
rb_obj_clone
VALUE rb_obj_clone(VALUE obj)
Produces a shallow copy of the given object.
Definition object.c:521
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.
Definition object.c:865
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 th...
Definition object.c:3464
rb_obj_freeze
VALUE rb_obj_freeze(VALUE obj)
Just calls rb_obj_freeze_inline() inside.
Definition object.c:1260
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.
Definition object.c:3179
rb_String
VALUE rb_String(VALUE val)
This is the logic behind Kernel#String.
Definition object.c:3747
rb_to_int
VALUE rb_to_int(VALUE val)
Identical to rb_check_to_int(), except it raises in case of conversion mismatch.
Definition object.c:3192
nonnull.h
Defines RBIMPL_ATTR_NONNULL.
RBIMPL_ATTR_NONNULL
#define RBIMPL_ATTR_NONNULL(list)
Wraps (or simulates) __attribute__((nonnull))
Definition nonnull.h:30
pure.h
Defines RBIMPL_ATTR_PURE.
RBIMPL_ATTR_PURE
#define RBIMPL_ATTR_PURE()
Wraps (or simulates) __attribute__((pure))
Definition pure.h:33
value.h
Defines VALUE and ID.
VALUE
uintptr_t VALUE
Type that represents a Ruby object.
Definition value.h:40