1 #ifndef INTERNAL_CLASS_H
2 #define INTERNAL_CLASS_H
12 #include "internal/gc.h"
13 #include "internal/serial.h"
30 rb_serial_t class_serial;
36 rb_serial_t global_cvar_state;
43 #if SIZEOF_SERIAL_T == SIZEOF_VALUE
58 #if SIZEOF_SERIAL_T != SIZEOF_VALUE
59 rb_serial_t class_serial;
62 const VALUE refined_class;
73 #if SIZEOF_SERIAL_T == SIZEOF_VALUE
75 rb_serial_t class_serial;
86 # define RCLASS_EXT(c) ((rb_classext_t *)((char *)c + sizeof(struct RClass)))
88 # define RCLASS_EXT(c) (RCLASS(c)->ptr)
90 #define RCLASS_IV_TBL(c) (RCLASS_EXT(c)->iv_tbl)
91 #define RCLASS_CONST_TBL(c) (RCLASS_EXT(c)->const_tbl)
92 #if SIZEOF_SERIAL_T == SIZEOF_VALUE
93 # define RCLASS_M_TBL(c) (RCLASS_EXT(c)->m_tbl)
95 # define RCLASS_M_TBL(c) (RCLASS(c)->m_tbl)
97 #define RCLASS_CALLABLE_M_TBL(c) (RCLASS_EXT(c)->callable_m_tbl)
98 #define RCLASS_CC_TBL(c) (RCLASS_EXT(c)->cc_tbl)
99 #define RCLASS_CVC_TBL(c) (RCLASS_EXT(c)->cvc_tbl)
100 #define RCLASS_IV_INDEX_TBL(c) (RCLASS_EXT(c)->iv_index_tbl)
101 #define RCLASS_ORIGIN(c) (RCLASS_EXT(c)->origin_)
102 #define RCLASS_REFINED_CLASS(c) (RCLASS_EXT(c)->refined_class)
103 #if SIZEOF_SERIAL_T == SIZEOF_VALUE
104 # define RCLASS_SERIAL(c) (RCLASS(c)->class_serial)
106 # define RCLASS_SERIAL(c) (RCLASS_EXT(c)->class_serial)
108 #define RCLASS_INCLUDER(c) (RCLASS_EXT(c)->includer)
109 #define RCLASS_SUBCLASS_ENTRY(c) (RCLASS_EXT(c)->subclass_entry)
110 #define RCLASS_MODULE_SUBCLASS_ENTRY(c) (RCLASS_EXT(c)->module_subclass_entry)
111 #define RCLASS_ALLOCATOR(c) (RCLASS_EXT(c)->allocator)
112 #define RCLASS_SUBCLASSES(c) (RCLASS_EXT(c)->subclasses)
114 #define RICLASS_IS_ORIGIN FL_USER5
115 #define RCLASS_CLONED FL_USER6
116 #define RICLASS_ORIGIN_SHARED_MTBL FL_USER8
119 void rb_class_subclass_add(
VALUE super,
VALUE klass);
120 void rb_class_remove_from_super_subclasses(
VALUE);
121 void rb_class_remove_subclass_head(
VALUE);
122 int rb_singleton_class_internal_p(
VALUE sklass);
126 void rb_module_set_initialized(
VALUE module);
127 void rb_module_check_initializable(
VALUE module);
131 void rb_class_detach_subclasses(
VALUE);
132 void rb_class_detach_module_subclasses(
VALUE);
133 void rb_class_remove_from_module_subclasses(
VALUE);
135 VALUE rb_obj_protected_methods(
int argc,
const VALUE *argv,
VALUE obj);
141 void rb_undef_methods_from(
VALUE klass,
VALUE super);
143 static inline void RCLASS_SET_ORIGIN(
VALUE klass,
VALUE origin);
144 static inline void RICLASS_SET_ORIGIN_SHARED_MTBL(
VALUE iclass);
147 static inline void RCLASS_SET_INCLUDER(
VALUE iclass,
VALUE klass);
149 MJIT_SYMBOL_EXPORT_BEGIN
151 VALUE rb_keyword_error_new(
const char *,
VALUE);
152 MJIT_SYMBOL_EXPORT_END
158 if (klass != origin)
FL_SET(origin, RICLASS_IS_ORIGIN);
162 RICLASS_SET_ORIGIN_SHARED_MTBL(
VALUE iclass)
164 FL_SET(iclass, RICLASS_ORIGIN_SHARED_MTBL);
168 RICLASS_OWNS_M_TBL_P(
VALUE iclass)
170 return FL_TEST_RAW(iclass, RICLASS_IS_ORIGIN | RICLASS_ORIGIN_SHARED_MTBL) == RICLASS_IS_ORIGIN;
174 RCLASS_SET_INCLUDER(
VALUE iclass,
VALUE klass)
182 return RCLASS(klass)->super;
189 rb_class_remove_from_super_subclasses(klass);
190 rb_class_subclass_add(super, klass);
VALUE rb_class_boot(VALUE)
A utility function that wraps class_alloc.
VALUE rb_class_inherited(VALUE, VALUE)
Calls Class::inherited.
VALUE rb_singleton_class_get(VALUE obj)
Returns the singleton class of obj, or nil if obj is not a singleton object.
#define FL_TEST_RAW
Old name of RB_FL_TEST_RAW.
#define FL_SET
Old name of RB_FL_SET.
#define RB_OBJ_WRITE(old, slot, young)
Declaration of a "back" pointer.
VALUE(* rb_alloc_func_t)(VALUE klass)
This is the type of functions that ruby calls when trying to allocate an object.
#define RCLASS_SUPER
Just another name of rb_class_get_superclass.
#define RCLASS(obj)
Convenient casting macro.
Ruby's object's, base components.
struct rb_subclass_entry * module_subclass_entry
In the case that this is an ICLASS, module_subclasses points to the link in the module's subclasses l...
Internal header for Class.
uintptr_t VALUE
Type that represents a Ruby object.