|
Ruby 4.0.5p0 (2026-05-20 revision 64336ffd0ee9e1f4c05891695a3d7b49cb709721)
|
Data Structures | |
| struct | rb_class_set_box_classext_args |
| struct | duplicate_id_tbl_data |
| struct | class_classext_foreach_arg |
| struct | clone_method_arg |
| struct | clone_const_arg |
| struct | cvc_table_copy_ctx |
| struct | subclass_traverse_data |
| struct | method_entry_arg |
Macros | |
| #define | METACLASS_OF(k) |
| #define | SET_METACLASS_OF(k, cls) |
| #define | META_CLASS_OF_CLASS_CLASS_P(k) |
| whether k is a meta^(n)-class of Class class | |
| #define | HAVE_METACLASS_P(k) |
| whether k has a metaclass | |
| #define | ENSURE_EIGENCLASS(klass) |
| ensures klass belongs to its own eigenclass. | |
Functions | |
| static void | rb_class_remove_from_super_subclasses (VALUE klass) |
| static void | rb_class_remove_from_module_subclasses (VALUE klass) |
| static void | rb_class_classext_free_subclasses (rb_classext_t *ext) |
| rb_classext_t * | rb_class_unlink_classext (VALUE klass, const rb_box_t *box) |
| void | rb_class_classext_free (VALUE klass, rb_classext_t *ext, bool is_prime) |
| void | rb_iclass_classext_free (VALUE klass, rb_classext_t *ext, bool is_prime) |
| static void | iclass_free_orphan_classext (VALUE klass, rb_classext_t *ext) |
| static int | set_box_classext_update (st_data_t *key_ptr, st_data_t *val_ptr, st_data_t a, int existing) |
| void | rb_class_set_box_classext (VALUE obj, const rb_box_t *box, rb_classext_t *ext) |
| static enum rb_id_table_iterator_result | duplicate_classext_m_tbl_i (ID key, VALUE value, void *data) |
| static struct rb_id_table * | duplicate_classext_m_tbl (struct rb_id_table *orig, VALUE klass, bool init_missing) |
| static rb_const_entry_t * | duplicate_classext_const_entry (rb_const_entry_t *src, VALUE klass) |
| static enum rb_id_table_iterator_result | duplicate_classext_const_tbl_i (ID key, VALUE value, void *data) |
| static struct rb_id_table * | duplicate_classext_const_tbl (struct rb_id_table *src, VALUE klass) |
| static void | class_duplicate_iclass_classext (VALUE iclass, rb_classext_t *mod_ext, const rb_box_t *box) |
| rb_classext_t * | rb_class_duplicate_classext (rb_classext_t *orig, VALUE klass, const rb_box_t *box) |
| void | rb_class_ensure_writable (VALUE klass) |
| static int | class_classext_foreach_i (st_data_t key, st_data_t value, st_data_t arg) |
| void | rb_class_classext_foreach (VALUE klass, rb_class_classext_foreach_callback_func *func, void *arg) |
| VALUE | rb_class_super_of (VALUE klass) |
| VALUE | rb_class_singleton_p (VALUE klass) |
| unsigned char | rb_class_variation_count (VALUE klass) |
| static rb_subclass_entry_t * | push_subclass_entry_to_list (VALUE super, VALUE klass) |
| void | rb_class_subclass_add (VALUE super, VALUE klass) |
| static void | rb_module_add_to_subclasses_list (VALUE module, VALUE iclass) |
| static void | rb_subclass_entry_remove (rb_subclass_entry_t *entry) |
| void | rb_class_foreach_subclass (VALUE klass, void(*f)(VALUE, VALUE), VALUE arg) |
| static void | class_detach_subclasses (VALUE klass, VALUE arg) |
| static void | class_switch_superclass (VALUE super, VALUE klass) |
| static VALUE | class_alloc0 (enum ruby_value_type type, VALUE klass, bool boxable) |
| Allocates a struct RClass for a new class, iclass, or module. | |
| static VALUE | class_alloc (enum ruby_value_type type, VALUE klass) |
| static VALUE | class_associate_super (VALUE klass, VALUE super, bool init) |
| VALUE | rb_class_set_super (VALUE klass, VALUE super) |
| static void | class_initialize_method_table (VALUE c) |
| static void | class_clear_method_table (VALUE c) |
| static VALUE | class_boot_boxable (VALUE super, bool boxable) |
| VALUE | rb_class_boot (VALUE super) |
| A utility function that wraps class_alloc. | |
| static VALUE * | class_superclasses_including_self (VALUE klass) |
| void | rb_class_update_superclasses (VALUE klass) |
| void | rb_check_inheritable (VALUE super) |
| Asserts that the given class can derive a child class. | |
| VALUE | rb_class_new (VALUE super) |
| Creates a new, anonymous class. | |
| VALUE | rb_class_s_alloc (VALUE klass) |
| static void | clone_method (VALUE old_klass, VALUE new_klass, ID mid, const rb_method_entry_t *me) |
| static enum rb_id_table_iterator_result | clone_method_i (ID key, VALUE value, void *data) |
| static int | clone_const (ID key, const rb_const_entry_t *ce, struct clone_const_arg *arg) |
| static enum rb_id_table_iterator_result | clone_const_i (ID key, VALUE value, void *data) |
| static void | class_init_copy_check (VALUE clone, VALUE orig) |
| static struct rb_cvar_class_tbl_entry * | cvc_table_entry_alloc (void) |
| static enum rb_id_table_iterator_result | cvc_table_copy (ID id, VALUE val, void *data) |
| static void | copy_tables (VALUE clone, VALUE orig) |
| static bool | ensure_origin (VALUE klass) |
| void | rb_class_set_initialized (VALUE klass) |
| void | rb_module_check_initializable (VALUE mod) |
| VALUE | rb_mod_init_copy (VALUE clone, VALUE orig) |
| The comment that comes with this function says :nodoc:. | |
| VALUE | rb_singleton_class_clone (VALUE obj) |
| Clones a singleton class. | |
| VALUE | rb_singleton_class_clone_and_attach (VALUE obj, VALUE attach) |
| void | rb_singleton_class_attached (VALUE klass, VALUE obj) |
| Attaches a singleton class to its corresponding object. | |
| static int | rb_singleton_class_has_metaclass_p (VALUE sklass) |
| int | rb_singleton_class_internal_p (VALUE sklass) |
| static VALUE | make_metaclass (VALUE klass) |
| Creates a metaclass of klass. | |
| static VALUE | make_singleton_class (VALUE obj) |
| Creates a singleton class for obj. | |
| static VALUE | boot_defclass (const char *name, VALUE super) |
| VALUE | rb_make_metaclass (VALUE obj, VALUE unused) |
| VALUE | rb_define_class_id (ID id, VALUE super) |
| This is a very badly designed API that creates an anonymous class. | |
| VALUE | rb_class_inherited (VALUE super, VALUE klass) |
| Calls Class#inherited. | |
| VALUE | rb_define_class (const char *name, VALUE super) |
| Defines a top-level class. | |
| VALUE | rb_define_class_under (VALUE outer, const char *name, VALUE super) |
| Defines a class under the namespace of outer. | |
| VALUE | rb_define_class_id_under_no_pin (VALUE outer, ID id, VALUE super) |
| VALUE | rb_define_class_id_under (VALUE outer, ID id, VALUE super) |
| Identical to rb_define_class_under(), except it takes the name in ID instead of C's string. | |
| VALUE | rb_module_s_alloc (VALUE klass) |
| static VALUE | module_new (VALUE klass) |
| VALUE | rb_module_new (void) |
| Creates a new, anonymous module. | |
| VALUE | rb_refinement_new (void) |
| Creates a new, anonymous refinement. | |
| VALUE | rb_define_module_id (ID id) |
| This is a very badly designed API that creates an anonymous module. | |
| VALUE | rb_define_module (const char *name) |
| Defines a top-level module. | |
| VALUE | rb_define_module_under (VALUE outer, const char *name) |
| Defines a module under the namespace of outer. | |
| VALUE | rb_define_module_id_under (VALUE outer, ID id) |
| Identical to rb_define_module_under(), except it takes the name in ID instead of C's string. | |
| VALUE | rb_include_class_new (VALUE module, VALUE super) |
| static int | include_modules_at (const VALUE klass, VALUE c, VALUE module, int search_super) |
| static void | ensure_includable (VALUE klass, VALUE module) |
| void | rb_include_module (VALUE klass, VALUE module) |
| Includes a module to a class. | |
| static enum rb_id_table_iterator_result | add_refined_method_entry_i (ID key, VALUE value, void *data) |
| static enum rb_id_table_iterator_result | clear_module_cache_i (ID id, VALUE val, void *data) |
| static bool | module_in_super_chain (const VALUE klass, VALUE module) |
| static enum rb_id_table_iterator_result | clear_constant_cache_i (ID id, VALUE value, void *data) |
| static int | do_include_modules_at (const VALUE klass, VALUE c, VALUE module, int search_super, bool check_cyclic) |
| static enum rb_id_table_iterator_result | move_refined_method (ID key, VALUE value, void *data) |
| static enum rb_id_table_iterator_result | cache_clear_refined_method (ID key, VALUE value, void *data) |
| void | rb_prepend_module (VALUE klass, VALUE module) |
| Identical to rb_include_module(), except it "prepends" the passed module to the klass, instead of includes. | |
| VALUE | rb_mod_included_modules (VALUE mod) |
| Queries the list of included modules. | |
| VALUE | rb_mod_include_p (VALUE mod, VALUE mod2) |
| Queries if the passed module is included by the module. | |
| VALUE | rb_mod_ancestors (VALUE mod) |
| Queries the module's ancestors. | |
| static void | class_descendants_recursive (VALUE klass, VALUE v) |
| static VALUE | class_descendants (VALUE klass, bool immediate_only) |
| VALUE | rb_class_subclasses (VALUE klass) |
| Queries the class's direct descendants. | |
| VALUE | rb_class_attached_object (VALUE klass) |
| Returns the attached object for a singleton class. | |
| static void | ins_methods_push (st_data_t name, st_data_t ary) |
| static int | ins_methods_i (st_data_t name, st_data_t type, st_data_t ary) |
| static int | ins_methods_type_i (st_data_t name, st_data_t type, st_data_t ary, rb_method_visibility_t visi) |
| static int | ins_methods_prot_i (st_data_t name, st_data_t type, st_data_t ary) |
| static int | ins_methods_priv_i (st_data_t name, st_data_t type, st_data_t ary) |
| static int | ins_methods_pub_i (st_data_t name, st_data_t type, st_data_t ary) |
| static int | ins_methods_undef_i (st_data_t name, st_data_t type, st_data_t ary) |
| static enum rb_id_table_iterator_result | method_entry_i (ID key, VALUE value, void *data) |
| static void | add_instance_method_list (VALUE mod, struct method_entry_arg *me_arg) |
| static bool | particular_class_p (VALUE mod) |
| static VALUE | class_instance_method_list (int argc, const VALUE *argv, VALUE mod, int obj, int(*func)(st_data_t, st_data_t, st_data_t)) |
| VALUE | rb_class_instance_methods (int argc, const VALUE *argv, VALUE mod) |
| Generates an array of symbols, which are the list of method names defined in the passed class. | |
| VALUE | rb_class_protected_instance_methods (int argc, const VALUE *argv, VALUE mod) |
| Identical to rb_class_instance_methods(), except it returns names of methods that are protected only. | |
| VALUE | rb_class_private_instance_methods (int argc, const VALUE *argv, VALUE mod) |
| Identical to rb_class_instance_methods(), except it returns names of methods that are private only. | |
| VALUE | rb_class_public_instance_methods (int argc, const VALUE *argv, VALUE mod) |
| Identical to rb_class_instance_methods(), except it returns names of methods that are public only. | |
| VALUE | rb_class_undefined_instance_methods (VALUE mod) |
| VALUE | rb_obj_methods (int argc, const VALUE *argv, VALUE obj) |
| VALUE | rb_obj_protected_methods (int argc, const VALUE *argv, VALUE obj) |
| VALUE | rb_obj_private_methods (int argc, const VALUE *argv, VALUE obj) |
| VALUE | rb_obj_public_methods (int argc, const VALUE *argv, VALUE obj) |
| VALUE | rb_obj_singleton_methods (int argc, const VALUE *argv, VALUE obj) |
| Identical to rb_class_instance_methods(), except it returns names of singleton methods instead of instance methods. | |
| static VALUE | special_singleton_class_of (VALUE obj) |
| VALUE | rb_special_singleton_class (VALUE obj) |
| static VALUE | singleton_class_of (VALUE obj, bool ensure_eigenclass) |
| void | rb_freeze_singleton_class (VALUE x) |
| This is an implementation detail of RB_OBJ_FREEZE(). | |
| VALUE | rb_singleton_class_get (VALUE obj) |
| Returns the singleton class of obj, or nil if obj is not a singleton object. | |
| VALUE | rb_singleton_class (VALUE obj) |
| Finds or creates the singleton class of the passed object. | |
| void | rb_class_modify_check (VALUE klass) |
| Asserts that klass is not a frozen class. | |
| void | rb_extend_object (VALUE obj, VALUE mod) |
| Extend the object with the module. | |
Variables | |
| rb_serial_t | ruby_vm_global_cvar_state |
| #define ENSURE_EIGENCLASS | ( | klass | ) |
ensures klass belongs to its own eigenclass.
Definition at line 1248 of file class.c.
Referenced by Init_class_hierarchy(), and make_metaclass().
| #define HAVE_METACLASS_P | ( | k | ) |
whether k has a metaclass
| 1 | if k has a metaclass |
| 0 | otherwise |
| #define META_CLASS_OF_CLASS_CLASS_P | ( | k | ) |
whether k is a meta^(n)-class of Class class
| 1 | if k is a meta^(n)-class of Class class (n >= 0) |
| 0 | otherwise |
Definition at line 1217 of file class.c.
Referenced by make_metaclass().
| #define METACLASS_OF | ( | k | ) |
| #define SET_METACLASS_OF | ( | k, | |
| cls ) |
|
static |
|
static |
|
static |
Allocates a struct RClass for a new class, iclass, or module.
| type | The type of the RClass (T_CLASS, T_ICLASS, or T_MODULE) |
| klass | value for basic.klass of the returned object. |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
Creates a metaclass of klass.
| klass | a class |
| void rb_check_inheritable | ( | VALUE | super | ) |
Asserts that the given class can derive a child class.
A class might or might not be able to do so; for instance a singleton class cannot.
| [in] | super | Possible super class. |
| rb_eTypeError | No it cannot. |
Definition at line 838 of file class.c.
Referenced by rb_class_new().
Returns the attached object for a singleton class.
If the given class is not a singleton class, raises a TypeError.
| [in] | klass | A class. |
Definition at line 2204 of file class.c.
Referenced by rb_class_descendants().
A utility function that wraps class_alloc.
allocates a class and initializes safely.
| super | a class from which the new class derives. |
Definition at line 771 of file class.c.
Referenced by rb_class_new().
| void rb_class_classext_foreach | ( | VALUE | klass, |
| rb_class_classext_foreach_callback_func * | func, | ||
| void * | arg ) |
| void rb_class_classext_free | ( | VALUE | klass, |
| rb_classext_t * | ext, | ||
| bool | is_prime ) |
|
static |
| rb_classext_t * rb_class_duplicate_classext | ( | rb_classext_t * | orig, |
| VALUE | klass, | ||
| const rb_box_t * | box ) |
Calls Class#inherited.
| super | A class which will be called #inherited. NULL means Object class. |
| klass | A Class object which derived from super |
Definition at line 1469 of file class.c.
Referenced by rb_define_class().
Generates an array of symbols, which are the list of method names defined in the passed class.
| [in] | argc | Number of objects of argv. |
| [in] | argv | Array of at most one object, which controls (if any) whether the return array includes the names of methods defined in ancestors or not. |
| [in] | mod | A module or a class. |
| rb_eArgError | `argc` out of range. |
Definition at line 2386 of file class.c.
Referenced by rb_class_descendants().
| void rb_class_modify_check | ( | VALUE | klass | ) |
Asserts that klass is not a frozen class.
| [in] | klass | a Module object |
| RuntimeError | if `klass` is not a class or frozen. |
Definition at line 421 of file eval.c.
Referenced by rb_alias(), rb_deprecate_constant(), and rb_undef().
Creates a new, anonymous class.
| [in] | super | What would become a parent class. |
| rb_eTypeError | `super` is not something inheritable. |
Definition at line 853 of file class.c.
Referenced by rb_define_class_id().
Identical to rb_class_instance_methods(), except it returns names of methods that are private only.
| [in] | argc | Number of objects of argv. |
| [in] | argv | Array of at most one object, which controls (if any) whether the return array includes the names of methods defined in ancestors or not. |
| [in] | mod | A module or a class. |
| rb_eArgError | `argc` out of range. |
Definition at line 2424 of file class.c.
Referenced by rb_class_descendants().
Identical to rb_class_instance_methods(), except it returns names of methods that are protected only.
| [in] | argc | Number of objects of argv. |
| [in] | argv | Array of at most one object, which controls (if any) whether the return array includes the names of methods defined in ancestors or not. |
| [in] | mod | A module or a class. |
| rb_eArgError | `argc` out of range. |
Definition at line 2401 of file class.c.
Referenced by rb_class_descendants().
Identical to rb_class_instance_methods(), except it returns names of methods that are public only.
| [in] | argc | Number of objects of argv. |
| [in] | argv | Array of at most one object, which controls (if any) whether the return array includes the names of methods defined in ancestors or not. |
| [in] | mod | A module or a class. |
| rb_eArgError | `argc` out of range. |
Definition at line 2439 of file class.c.
Referenced by rb_class_descendants().
|
static |
|
static |
| void rb_class_set_box_classext | ( | VALUE | obj, |
| const rb_box_t * | box, | ||
| rb_classext_t * | ext ) |
Queries the class's direct descendants.
This routine gathers classes that are direct subclasses of the given class, returning an array of classes that have the given class as a superclass. The returned array does not include singleton classes.
| [in] | klass | A class. |
Definition at line 2181 of file class.c.
Referenced by rb_class_descendants().
| rb_classext_t * rb_class_unlink_classext | ( | VALUE | klass, |
| const rb_box_t * | box ) |
Defines a top-level class.
| [in] | name | Name of the class. |
| [in] | super | A class from which the new class will derive. |
| rb_eTypeError | The constant name `name` is already taken but the constant is not a class. |
| rb_eTypeError | The class is already defined but the class can not be reopened because its superclass is not super. |
| rb_eArgError | `super` is NULL. |
This is a very badly designed API that creates an anonymous class.
| [in] | id | Discarded for no reason (why...). |
| [in] | super | What would become a parent class. 0 means rb_cObject. |
| rb_eTypeError | `super` is not something inheritable. |
Definition at line 1448 of file class.c.
Referenced by rb_define_class().
Identical to rb_define_class_under(), except it takes the name in ID instead of C's string.
| [out] | outer | A class which contains the new class. |
| [in] | id | Name of the new class |
| [in] | super | A class from which the new class will derive. 0 means rb_cObject. |
| rb_eTypeError | The constant name `id` is already taken but the constant is not a class. |
| rb_eTypeError | The class is already defined but the class can not be reopened because its superclass is not super. |
| rb_eArgError | `super` is NULL. |
Definition at line 1548 of file class.c.
Referenced by rb_define_class_under(), and rb_struct_define_under().
Defines a class under the namespace of outer.
| [out] | outer | A class which contains the new class. |
| [in] | name | Name of the new class |
| [in] | super | A class from which the new class will derive. 0 means rb_cObject. |
| rb_eTypeError | The constant name `name` is already taken but the constant is not a class. |
| rb_eTypeError | The class is already defined but the class can not be reopened because its superclass is not super. |
| rb_eArgError | `super` is NULL. |
| VALUE rb_define_module | ( | const char * | name | ) |
Defines a top-level module.
| [in] | name | Name of the module. |
| rb_eTypeError | The constant name `name` is already taken but the constant is not a module. |
Identical to rb_define_module_under(), except it takes the name in ID instead of C's string.
| [out] | outer | A class which contains the new module. |
| [in] | id | Name of the new module |
| rb_eTypeError | The constant name `id` is already taken but the constant is not a module. |
Definition at line 1620 of file class.c.
Referenced by rb_define_module_under().
Defines a module under the namespace of outer.
| [out] | outer | A class which contains the new module. |
| [in] | name | Name of the new module |
| rb_eTypeError | The constant name `name` is already taken but the constant is not a class. |
Extend the object with the module.
| [out] | obj | Object to extend. |
| [in] | mod | Module of extension. |
Definition at line 1860 of file eval.c.
Referenced by rb_eval_string_wrap().
| void rb_freeze_singleton_class | ( | VALUE | klass | ) |
This is an implementation detail of RB_OBJ_FREEZE().
People don't use it directly.
| [out] | klass | A singleton class. |
Definition at line 2765 of file class.c.
Referenced by rb_obj_freeze_inline().
| void rb_iclass_classext_free | ( | VALUE | klass, |
| rb_classext_t * | ext, | ||
| bool | is_prime ) |
Includes a module to a class.
| [out] | klass | Inclusion destination. |
| [in] | module | Inclusion source. |
| rb_eArgError | Cyclic inclusion. |
Definition at line 1685 of file class.c.
Referenced by rb_extend_object().
Queries the module's ancestors.
This routine gathers classes and modules that the passed module either inherits, includes, or prepends, then recursively applies that routine again and again to the collected entries until the list doesn't grow up.
| [in] | mod | A module or a class. |
Queries if the passed module is included by the module.
It can also be seen as a routine to first call rb_mod_included_modules(), then see if the return value contains the passed module.
| [in] | child | A Module. |
| [in] | parent | Another Module. |
| rb_eTypeError | `child` is not an instance of rb_cModule. |
| RUBY_Qtrue | parent is either included or prepended in any of child's ancestry tree (including itself). |
Queries the list of included modules.
It can also be seen as a routine to first call rb_mod_ancestors(), then rejects non-modules from the return value.
| [in] | mod | Class or Module. |
| VALUE rb_module_new | ( | void | ) |
Creates a new, anonymous module.
Definition at line 1572 of file class.c.
Referenced by rb_define_module_id(), and rb_eval_string_wrap().
Identical to rb_class_instance_methods(), except it returns names of singleton methods instead of instance methods.
| [in] | argc | Number of objects of argv. |
| [in] | argv | Array of at most one object, which controls (if any) whether the return array includes the names of methods defined in ancestors or not. |
| [in] | obj | Arbitrary ruby object. |
| rb_eArgError | `argc` out of range. |
Definition at line 2578 of file class.c.
Referenced by rb_class_descendants().
Identical to rb_include_module(), except it "prepends" the passed module to the klass, instead of includes.
This affects how super resolves. For instance:
| [out] | klass | Target class to modify. |
| [in] | module | Module to prepend. |
| rb_eArgError | Cyclic inclusion. |
| VALUE rb_refinement_new | ( | void | ) |
Finds or creates the singleton class of the passed object.
| [out] | obj | Arbitrary ruby object. |
| rb_eTypeError | `obj` cannot have its singleton class. |
Definition at line 2800 of file class.c.
Referenced by rb_class_descendants(), rb_extend_object(), and rb_obj_singleton_methods().
Attaches a singleton class to its corresponding object.
This is basically an implementation detail of rb_clone_setup(). People need not be aware of this working behind-the-scene.
| [in] | klass | The singleton class. |
| [out] | obj | The object to attach a class. |
Definition at line 1205 of file class.c.
Referenced by make_metaclass(), make_singleton_class(), and rb_mod_init_copy().
Clones a singleton class.
An object can have its own singleton class. OK. Then what happens when a program clones such object? The singleton class that is attached to the source object must also be cloned. Otherwise a singleton object gets shared with two objects, which breaks "singleton"-ness of such class.
This is basically an implementation detail of rb_clone_setup(). People need not be aware of this working behind-the-scene.
| [in] | obj | The object that has its own singleton class. |
Definition at line 1136 of file class.c.
Referenced by rb_mod_init_copy().
|
static |
|
static |
|
static |