Ruby 3.5.0dev (2025-01-10 revision 5fab31b15e32622c4b71d1d347a41937e9f9c212)
object.h
1#ifndef INTERNAL_OBJECT_H /*-*-C-*-vi:se ft=c:*/
2#define INTERNAL_OBJECT_H
11#include "ruby/ruby.h" /* for VALUE */
12
13/* object.c */
14size_t rb_obj_embedded_size(uint32_t numiv);
15VALUE rb_class_allocate_instance(VALUE klass);
16VALUE rb_class_search_ancestor(VALUE klass, VALUE super);
17NORETURN(void rb_undefined_alloc(VALUE klass));
18double rb_num_to_dbl(VALUE val);
19VALUE rb_obj_dig(int argc, VALUE *argv, VALUE self, VALUE notfound);
20VALUE rb_obj_clone_setup(VALUE obj, VALUE clone, VALUE kwfreeze);
21VALUE rb_obj_dup_setup(VALUE obj, VALUE dup);
22VALUE rb_immutable_obj_clone(int, VALUE *, VALUE);
23VALUE rb_check_convert_type_with_id(VALUE,int,const char*,ID);
24int rb_bool_expected(VALUE, const char *, int raise);
25static inline void RBASIC_CLEAR_CLASS(VALUE obj);
26static inline void RBASIC_SET_CLASS_RAW(VALUE obj, VALUE klass);
27static inline void RBASIC_SET_CLASS(VALUE obj, VALUE klass);
28
29RUBY_SYMBOL_EXPORT_BEGIN
30/* object.c (export) */
31int rb_opts_exception_p(VALUE opts, int default_value);
32RUBY_SYMBOL_EXPORT_END
33
34CONSTFUNC(VALUE rb_obj_equal(VALUE obj1, VALUE obj2));
35CONSTFUNC(VALUE rb_obj_not(VALUE obj));
36VALUE rb_obj_not_equal(VALUE obj1, VALUE obj2);
37void rb_obj_copy_ivar(VALUE dest, VALUE obj);
38VALUE rb_false(VALUE obj);
39VALUE rb_convert_type_with_id(VALUE v, int t, const char* nam, ID mid);
40VALUE rb_obj_size(VALUE self, VALUE args, VALUE obj);
41VALUE rb_get_freeze_opt(int argc, VALUE *argv);
42
43static inline void
44RBASIC_SET_CLASS_RAW(VALUE obj, VALUE klass)
45{
46 const VALUE *ptr = &RBASIC(obj)->klass;
47 *(VALUE *)ptr = klass;
48}
49
50static inline void
51RBASIC_CLEAR_CLASS(VALUE obj)
52{
53 RBASIC_SET_CLASS_RAW(obj, 0);
54}
55
56static inline void
57RBASIC_SET_CLASS(VALUE obj, VALUE klass)
58{
59 VALUE oldv = RBASIC_CLASS(obj);
60 RBASIC_SET_CLASS_RAW(obj, klass);
61 RB_OBJ_WRITTEN(obj, oldv, klass);
62}
63#endif /* INTERNAL_OBJECT_H */
size_t rb_obj_embedded_size(uint32_t numiv)
Internal header for Object.
Definition object.c:98
#define RB_OBJ_WRITTEN(old, oldv, young)
Identical to RB_OBJ_WRITE(), except it doesn't write any values, but only a WB declaration.
Definition gc.h:615
static VALUE RBASIC_CLASS(VALUE obj)
Queries the class of an object.
Definition rbasic.h:150
#define RBASIC(obj)
Convenient casting macro.
Definition rbasic.h:40
uintptr_t ID
Type that represents a Ruby identifier such as a variable name.
Definition value.h:52
uintptr_t VALUE
Type that represents a Ruby object.
Definition value.h:40