1#ifndef INTERNAL_CLASS_H
2#define INTERNAL_CLASS_H
12#include "internal/gc.h"
13#include "internal/serial.h"
18#include "ruby_assert.h"
34 rb_serial_t global_cvar_state;
45 size_t superclass_depth;
56 const VALUE refined_class;
59 uint32_t max_iv_count;
60 uint32_t variation_count;
61#if !SHAPE_IN_BASIC_FLAGS
70#if SIZE_POOL_COUNT == 1
78#if RCLASS_EXT_EMBEDDED
79# define RCLASS_EXT(c) ((rb_classext_t *)((char *)(c) + sizeof(struct RClass)))
81# define RCLASS_EXT(c) (RCLASS(c)->ptr)
83#define RCLASS_CONST_TBL(c) (RCLASS_EXT(c)->const_tbl)
84#define RCLASS_M_TBL(c) (RCLASS(c)->m_tbl)
85#define RCLASS_IVPTR(c) (RCLASS_EXT(c)->iv_ptr)
86#define RCLASS_CALLABLE_M_TBL(c) (RCLASS_EXT(c)->callable_m_tbl)
87#define RCLASS_CC_TBL(c) (RCLASS_EXT(c)->cc_tbl)
88#define RCLASS_CVC_TBL(c) (RCLASS_EXT(c)->cvc_tbl)
89#define RCLASS_ORIGIN(c) (RCLASS_EXT(c)->origin_)
90#define RCLASS_REFINED_CLASS(c) (RCLASS_EXT(c)->refined_class)
91#define RCLASS_INCLUDER(c) (RCLASS_EXT(c)->includer)
92#define RCLASS_SUBCLASS_ENTRY(c) (RCLASS_EXT(c)->subclass_entry)
93#define RCLASS_MODULE_SUBCLASS_ENTRY(c) (RCLASS_EXT(c)->module_subclass_entry)
94#define RCLASS_ALLOCATOR(c) (RCLASS_EXT(c)->allocator)
95#define RCLASS_SUBCLASSES(c) (RCLASS_EXT(c)->subclasses)
96#define RCLASS_SUPERCLASS_DEPTH(c) (RCLASS_EXT(c)->superclass_depth)
97#define RCLASS_SUPERCLASSES(c) (RCLASS_EXT(c)->superclasses)
99#define RICLASS_IS_ORIGIN FL_USER0
100#define RCLASS_CLONED FL_USER1
101#define RCLASS_SUPERCLASSES_INCLUDE_SELF FL_USER2
102#define RICLASS_ORIGIN_SHARED_MTBL FL_USER3
105void rb_class_subclass_add(
VALUE super,
VALUE klass);
106void rb_class_remove_from_super_subclasses(
VALUE);
107void rb_class_update_superclasses(
VALUE);
108size_t rb_class_superclasses_memsize(
VALUE);
109void rb_class_remove_subclass_head(
VALUE);
110int rb_singleton_class_internal_p(
VALUE sklass);
114void rb_module_set_initialized(
VALUE module);
115void rb_module_check_initializable(
VALUE module);
119void rb_class_detach_subclasses(
VALUE);
120void rb_class_detach_module_subclasses(
VALUE);
121void rb_class_remove_from_module_subclasses(
VALUE);
126VALUE rb_class_undefined_instance_methods(
VALUE mod);
130void rb_undef_methods_from(
VALUE klass,
VALUE super);
132static inline void RCLASS_SET_ORIGIN(
VALUE klass,
VALUE origin);
133static inline void RICLASS_SET_ORIGIN_SHARED_MTBL(
VALUE iclass);
136static inline void RCLASS_SET_INCLUDER(
VALUE iclass,
VALUE klass);
138MJIT_SYMBOL_EXPORT_BEGIN
140VALUE rb_keyword_error_new(
const char *,
VALUE);
141MJIT_SYMBOL_EXPORT_END
147 if (klass != origin)
FL_SET(origin, RICLASS_IS_ORIGIN);
151RICLASS_SET_ORIGIN_SHARED_MTBL(
VALUE iclass)
153 FL_SET(iclass, RICLASS_ORIGIN_SHARED_MTBL);
157RICLASS_OWNS_M_TBL_P(
VALUE iclass)
159 return FL_TEST_RAW(iclass, RICLASS_IS_ORIGIN | RICLASS_ORIGIN_SHARED_MTBL) == RICLASS_IS_ORIGIN;
171 return RCLASS(klass)->super;
178 rb_class_remove_from_super_subclasses(klass);
179 rb_class_subclass_add(super, klass);
182 rb_class_update_superclasses(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.