Ruby 3.0.5p211 (2022-11-24 revision ba5cf0f7c52d4d35cc6a173c89eda98ceffa2dcf)
|
Data Structures | |
struct | clone_method_arg |
struct | clone_const_arg |
struct | method_entry_arg |
Macros | |
#define | id_attached id__attached__ |
#define | METACLASS_OF(k) RBASIC(k)->klass |
#define | SET_METACLASS_OF(k, cls) RBASIC_SET_CLASS(k, cls) |
#define | META_CLASS_OF_CLASS_CLASS_P(k) (METACLASS_OF(k) == (k)) |
whether k is a meta^(n)-class of Class class More... | |
#define | HAVE_METACLASS_P(k) |
whether k has a metaclass More... | |
#define | ENSURE_EIGENCLASS(klass) (HAVE_METACLASS_P(klass) ? METACLASS_OF(klass) : make_metaclass(klass)) |
ensures klass belongs to its own eigenclass. More... | |
#define ENSURE_EIGENCLASS | ( | klass | ) | (HAVE_METACLASS_P(klass) ? METACLASS_OF(klass) : make_metaclass(klass)) |
#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 | ) | (METACLASS_OF(k) == (k)) |
void Init_class_hierarchy | ( | void | ) |
Definition at line 648 of file class.c.
References rb_cBasicObject, rb_cClass, rb_cModule, rb_cObject, rb_const_set(), rb_fstring_lit, rb_gc_register_mark_object(), and rb_set_class_path_string().
void rb_check_inheritable | ( | VALUE | super | ) |
Ensures a class can be derived from super.
super | a reference to an object. |
TypeError | if super is not a Class or super is a singleton class. |
Definition at line 231 of file class.c.
References FL_SINGLETON, PRIsVALUE, rb_cClass, rb_eTypeError, rb_obj_class(), rb_raise(), RBASIC, and T_CLASS.
Referenced by rb_class_new().
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 213 of file class.c.
References rb_cClass, and T_CLASS.
Referenced by rb_class_new().
void rb_class_detach_module_subclasses | ( | VALUE | klass | ) |
Definition at line 157 of file class.c.
References Qnil, and rb_class_foreach_subclass().
void rb_class_detach_subclasses | ( | VALUE | klass | ) |
Definition at line 145 of file class.c.
References Qnil, and rb_class_foreach_subclass().
Definition at line 125 of file class.c.
References f, rb_subclass_entry::klass, rb_subclass_entry::next, and RCLASS_EXT.
Referenced by rb_class_detach_module_subclasses(), rb_class_detach_subclasses(), and rb_clear_method_cache().
Calls Class::inherited.
super | A class which will be called #inherited. NULL means Object class. |
klass | A Class object which derived from super |
Class::inherited's
returns Class
object. Definition at line 722 of file class.c.
References CONST_ID, rb_cObject, and rb_funcall().
Referenced by rb_define_class(), and rb_define_class_id_under().
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 477 of file eval.c.
References BUILTIN_TYPE, FL_SINGLETON, FL_TEST, OBJ_FROZEN, PRIsVALUE, rb_frozen_error_raise(), rb_ivar_get(), SPECIAL_CONST_P, T_CLASS, T_ICLASS, T_MODULE, and UNREACHABLE.
Referenced by rb_alias(), rb_deprecate_constant(), and rb_undef().
Creates a new class.
super | a class from which the new class derives. |
TypeError | super is not inheritable. |
TypeError | super is the Class class. |
Definition at line 253 of file class.c.
References rb_check_inheritable(), rb_class_boot(), and T_CLASS.
Referenced by Init_IO(), Init_VM(), and rb_define_class_id().
void rb_class_remove_from_module_subclasses | ( | VALUE | klass | ) |
Definition at line 106 of file class.c.
References rb_subclass_entry::klass, rb_subclass_entry::next, NULL, RCLASS_EXT, and xfree.
void rb_class_remove_from_super_subclasses | ( | VALUE | klass | ) |
Definition at line 88 of file class.c.
References rb_subclass_entry::klass, rb_subclass_entry::next, NULL, RCLASS_EXT, and xfree.
Definition at line 48 of file class.c.
References ALLOC, rb_subclass_entry::klass, rb_subclass_entry::next, NULL, Qundef, and RCLASS_EXT.
Defines a top-level class.
name | name of the class |
super | a class from which the new class will derive. |
TypeError | if the constant name name is already taken but the constant is not a Class . |
TypeError | if the class is already defined but the class can not be reopened because its superclass is not super. |
ArgumentError | if the super is NULL. |
Definition at line 748 of file class.c.
References id, name, PRIsVALUE, rb_class_inherited(), rb_class_real(), rb_cObject, rb_const_defined(), rb_const_get(), rb_const_set(), rb_define_class_id(), rb_eArgError, rb_eTypeError, rb_intern(), rb_obj_class(), rb_raise(), rb_vm_add_root_module(), RCLASS_SUPER, and T_CLASS.
Referenced by Init_Array(), Init_bigdecimal(), Init_Binding(), Init_Complex(), Init_Cont(), Init_date_core(), Init_dbm(), Init_Dir(), Init_Encoding(), Init_Exception(), Init_File(), Init_gdbm(), Init_Hash(), Init_IO(), Init_monitor(), Init_Numeric(), Init_pathname(), Init_Proc(), Init_Ractor(), Init_Rational(), Init_Regexp(), Init_socket(), Init_String(), Init_stringio(), Init_strscan(), Init_Thread(), Init_Time(), Init_VM(), Init_vm_eval(), Init_vm_trace(), Init_win32ole(), Init_win32ole_error(), Init_win32ole_event(), Init_win32ole_method(), Init_win32ole_param(), Init_win32ole_record(), Init_win32ole_type(), Init_win32ole_typelib(), Init_win32ole_variable(), Init_win32ole_variant(), InitVM_Enumerator(), InitVM_escape(), InitVM_Random(), InitVM_Struct(), rsock_init_addrinfo(), rsock_init_basicsocket(), rsock_init_ipsocket(), rsock_init_socket_init(), rsock_init_sockssocket(), rsock_init_tcpserver(), rsock_init_tcpsocket(), rsock_init_udpsocket(), rsock_init_unixserver(), rsock_init_unixsocket(), and ruby_Init_Continuation_body().
Defines a new class.
id | ignored |
super | A class from which the new class will derive. NULL means Object class. |
TypeError | if super is not a Class object. |
Definition at line 701 of file class.c.
References rb_class_new(), rb_cObject, rb_make_metaclass(), and RBASIC.
Referenced by InitVM_Random(), rb_define_class(), and rb_define_class_id_under().
Defines a class under the namespace of outer.
outer | a class which contains the new class. |
id | name of the new class |
super | a class from which the new class will derive. NULL means Object class. |
TypeError | if the constant name name is already taken but the constant is not a Class . |
TypeError | if the class is already defined but the class can not be reopened because its superclass is not super. |
Definition at line 820 of file class.c.
References PRIsVALUE, rb_class_inherited(), rb_class_path(), rb_class_real(), rb_const_defined_at(), rb_const_get_at(), rb_const_set(), rb_define_class_id(), rb_eArgError, rb_eTypeError, rb_id2str, rb_obj_class(), rb_raise(), rb_set_class_path_string(), rb_vm_add_root_module(), RCLASS_SUPER, and T_CLASS.
Referenced by rb_define_class_under().
Defines a class under the namespace of outer.
outer | a class which contains the new class. |
name | name of the new class |
super | a class from which the new class will derive. NULL means Object class. |
TypeError | if the constant name name is already taken but the constant is not a Class . |
TypeError | if the class is already defined but the class can not be reopened because its superclass is not super. |
Definition at line 797 of file class.c.
References name, rb_define_class_id_under(), and rb_intern().
Referenced by exp2(), Init_ast(), Init_bubblebabble(), Init_Complex(), Init_Cont(), Init_cparse(), Init_date_core(), Init_Exception(), Init_fiddle(), Init_fiddle_closure(), Init_fiddle_function(), Init_fiddle_handle(), Init_fiddle_pinned(), Init_fiddle_pointer(), Init_File(), Init_GC(), Init_generator(), Init_IO(), Init_ISeq(), Init_md5(), Init_objspace(), Init_openssl(), Init_ossl_asn1(), Init_ossl_bn(), Init_ossl_cipher(), Init_ossl_config(), Init_ossl_dh(), Init_ossl_digest(), Init_ossl_dsa(), Init_ossl_ec(), Init_ossl_engine(), Init_ossl_hmac(), Init_ossl_kdf(), Init_ossl_ns_spki(), Init_ossl_ocsp(), Init_ossl_pkcs12(), Init_ossl_pkcs7(), Init_ossl_pkey(), Init_ossl_rand(), Init_ossl_rsa(), Init_ossl_ssl(), Init_ossl_ssl_session(), Init_ossl_ts(), Init_ossl_x509attr(), Init_ossl_x509cert(), Init_ossl_x509crl(), Init_ossl_x509ext(), Init_ossl_x509name(), Init_ossl_x509req(), Init_ossl_x509revoked(), Init_ossl_x509store(), Init_parser(), Init_psych_emitter(), Init_psych_parser(), Init_psych_to_ruby(), Init_psych_yaml_tree(), Init_pty(), Init_Ractor(), Init_Rational(), Init_rmd160(), Init_sha1(), Init_strscan(), Init_vm_backtrace(), Init_zlib(), InitVM_console(), InitVM_digest(), InitVM_Enumerator(), InitVM_process(), InitVM_transcode(), rb_struct_define_under(), rsock_init_ancdata(), rsock_init_sockifaddr(), and rsock_init_sockopt().
Definition at line 871 of file class.c.
References id, name, PRIsVALUE, rb_cObject, rb_const_defined(), rb_const_get(), rb_const_set(), rb_eTypeError, rb_intern(), rb_module_new(), rb_obj_class(), rb_raise(), rb_vm_add_root_module(), and T_MODULE.
Referenced by exp2(), Init_bigdecimal(), Init_bubblebabble(), Init_Comparable(), Init_coverage(), Init_cparse(), Init_Enumerable(), Init_etc(), Init_Exception(), Init_fcntl(), Init_fiddle(), Init_fiddle_closure(), Init_File(), Init_GC(), Init_generator(), Init_limits(), Init_md5(), Init_nkf(), Init_object_tracing(), Init_objspace(), Init_objspace_dump(), Init_openssl(), Init_ossl_asn1(), Init_ossl_bn(), Init_ossl_cipher(), Init_ossl_config(), Init_ossl_digest(), Init_ossl_engine(), Init_ossl_hmac(), Init_ossl_kdf(), Init_ossl_ns_spki(), Init_ossl_ocsp(), Init_ossl_pkcs12(), Init_ossl_pkcs7(), Init_ossl_pkey(), Init_ossl_rand(), Init_ossl_ssl(), Init_ossl_ssl_session(), Init_ossl_ts(), Init_ossl_x509(), Init_ossl_x509attr(), Init_ossl_x509cert(), Init_ossl_x509crl(), Init_ossl_x509ext(), Init_ossl_x509name(), Init_ossl_x509req(), Init_ossl_x509revoked(), Init_ossl_x509store(), Init_parser(), Init_psych(), Init_psych_emitter(), Init_psych_parser(), Init_psych_to_ruby(), Init_psych_yaml_tree(), Init_pty(), Init_readline(), Init_rmd160(), Init_sha1(), Init_signal(), Init_sizeof(), Init_String(), Init_syslog(), Init_zlib(), InitVM_digest(), InitVM_process(), and InitVM_resolv().
Definition at line 865 of file class.c.
References rb_module_new().
Definition at line 901 of file class.c.
References PRIsVALUE, rb_const_defined_at(), rb_const_get_at(), rb_const_set(), rb_eTypeError, rb_gc_register_mark_object(), rb_id2str, rb_module_new(), rb_obj_class(), rb_raise(), rb_set_class_path_string(), and T_MODULE.
Referenced by rb_define_module_under().
Definition at line 895 of file class.c.
References name, rb_define_module_id_under(), and rb_intern().
Referenced by Init_ast(), Init_bubblebabble(), Init_File(), Init_GC(), Init_generator(), Init_IO(), Init_ossl_asn1(), Init_ossl_dh(), Init_ossl_dsa(), Init_ossl_ec(), Init_ossl_kdf(), Init_ossl_ns_spki(), Init_ossl_ocsp(), Init_ossl_pkey(), Init_ossl_rand(), Init_ossl_rsa(), Init_ossl_ssl(), Init_ossl_ssl_session(), Init_ossl_ts(), Init_ossl_x509(), Init_ossl_x509attr(), Init_ossl_x509cert(), Init_ossl_x509crl(), Init_ossl_x509ext(), Init_ossl_x509name(), Init_ossl_x509req(), Init_ossl_x509revoked(), Init_ossl_x509store(), Init_parser(), Init_psych_to_ruby(), Init_psych_yaml_tree(), Init_stringio(), Init_syslog(), Init_VM(), Init_win32ole_variant_m(), InitVM_console(), InitVM_digest(), InitVM_escape(), InitVM_process(), InitVM_Random(), and InitVM_resolv().
Extend the object with the module.
Same as Module#extend_object
.
Definition at line 1730 of file eval.c.
References rb_include_module(), and rb_singleton_class().
Referenced by Init_etc(), Init_Exception(), Init_Hash(), Init_readline(), InitVM_escape(), InitVM_Random(), rb_eval_string_wrap(), rb_mod_sys_fail(), rb_mod_sys_fail_str(), rb_mod_syserr_fail(), and rb_mod_syserr_fail_str().
void rb_freeze_singleton_class | ( | VALUE | x | ) |
Definition at line 1873 of file class.c.
References FL_FREEZE, FL_SINGLETON, FL_TEST, OBJ_FREEZE_RAW, RBASIC, RBASIC_CLASS, and RCLASS_ORIGIN.
Definition at line 923 of file class.c.
References BUILTIN_TYPE, rb_cClass, rb_id_table_create(), RBASIC, RCLASS_CONST_TBL, RCLASS_IV_TBL, RCLASS_M_TBL, RUBY_ASSERT, st_init_numtable, and T_ICLASS.
Referenced by rb_prepend_module().
Definition at line 962 of file class.c.
References rb_subclass_entry::klass, rb_subclass_entry::next, rb_eArgError, rb_objspace_garbage_object_p(), rb_raise(), RBASIC, RCLASS_EXT, RCLASS_ORIGIN, RCLASS_SUPER, T_ICLASS, T_MODULE, and TRUE.
Referenced by Init_Array(), Init_date_core(), Init_dbm(), Init_Dir(), Init_File(), Init_GC(), Init_gdbm(), Init_Hash(), Init_IO(), Init_Numeric(), Init_ossl_asn1(), Init_ossl_ssl(), Init_ossl_x509name(), Init_Range(), Init_String(), Init_stringio(), Init_syslog(), Init_Time(), Init_zlib(), InitVM_digest(), InitVM_Enumerator(), InitVM_Random(), InitVM_Struct(), and rb_extend_object().
Definition at line 679 of file class.c.
References BUILTIN_TYPE, and T_CLASS.
Referenced by rb_define_class_id().
Definition at line 1301 of file class.c.
References BUILTIN_TYPE, mod, rb_ary_new(), rb_ary_push(), RBASIC, RCLASS_ORIGIN, RCLASS_SUPER, and T_ICLASS.
Definition at line 1269 of file class.c.
References BUILTIN_TYPE, FL_TEST, mod, Qfalse, Qtrue, RBASIC, RCLASS_SUPER, RICLASS_IS_ORIGIN, T_ICLASS, and T_MODULE.
Definition at line 1233 of file class.c.
References BUILTIN_TYPE, mod, rb_ary_new(), rb_ary_push(), RBASIC, RCLASS_ORIGIN, RCLASS_SUPER, T_ICLASS, and T_MODULE.
Definition at line 359 of file class.c.
References BUILTIN_TYPE, CLASS_OF, FALSE, FL_SET, FL_SINGLETON, FL_TEST, clone_const_arg::klass, clone_method_arg::new_klass, OBJ_INIT_COPY, clone_method_arg::old_klass, RARRAY_AREF, RARRAY_LEN, rb_ary_cat(), rb_ary_resize(), rb_ary_tmp_new(), rb_bug(), rb_id_table_foreach(), rb_singleton_class_attached(), rb_singleton_class_clone(), RBASIC, RCLASS_CLONED, RCLASS_CONST_TBL, RCLASS_EXT, RCLASS_IV_TBL, RCLASS_M_TBL, RCLASS_ORIGIN, RCLASS_SUPER, T_CLASS, T_ICLASS, and TRUE.
VALUE rb_module_new | ( | void | ) |
Definition at line 856 of file class.c.
References rb_cModule, and T_MODULE.
Referenced by rb_define_module(), rb_define_module_id(), rb_define_module_id_under(), and rb_eval_string_wrap().
Definition at line 1563 of file class.c.
References argc, argv, CLASS_OF, rb_check_arity, rb_obj_singleton_methods(), and RTEST.
Definition at line 1651 of file class.c.
References argc, argv, CLASS_OF, FL_SINGLETON, FL_TEST, method_entry_arg::list, st_table::num_entries, rb_ary_new2, rb_check_arity, rb_id_table_foreach(), rb_singleton_class(), RCLASS_M_TBL, RCLASS_ORIGIN, RCLASS_SUPER, method_entry_arg::recur, recur, RTEST, st_foreach, st_free_table, st_init_numtable, T_CLASS, T_ICLASS, and TRUE.
Referenced by rb_obj_methods().
Definition at line 1170 of file class.c.
References FALSE, rb_subclass_entry::klass, rb_subclass_entry::next, rb_eArgError, rb_id_table_foreach(), rb_include_class_new(), rb_objspace_garbage_object_p(), rb_raise(), rb_vm_check_redefinition_by_prepend(), RCLASS_EXT, RCLASS_INCLUDER, RCLASS_M_TBL, RCLASS_ORIGIN, RCLASS_SUPER, and T_MODULE.
Referenced by InitVM_escape().
Returns the singleton class of obj.
Creates it if necessary.
obj | an arbitrary object. |
TypeError | if obj is an Integer or a Symbol. |
Definition at line 1924 of file class.c.
References ENSURE_EIGENCLASS, and T_CLASS.
Referenced by Init_date_core(), Init_eval(), Init_eval_method(), Init_nkf(), Init_ossl_rand(), Init_Proc(), Init_Time(), Init_top_self(), Init_VM(), InitVM_process(), InitVM_resolv(), rb_extend_object(), and rb_obj_singleton_methods().
Attach a object to a singleton class.
Definition at line 530 of file class.c.
References FL_SINGLETON, FL_TEST, id_attached, rb_class_ivar_set(), RCLASS_IV_TBL, and st_init_numtable.
Referenced by rb_mod_init_copy(), and rb_singleton_class_clone_and_attach().
Definition at line 459 of file class.c.
References Qundef, and rb_singleton_class_clone_and_attach().
Referenced by rb_mod_init_copy(), and rb_singleton_class_clone_and_attach().
Definition at line 466 of file class.c.
References BUILTIN_TYPE, FL_SET, FL_SINGLETON, FL_TEST, id_attached, clone_const_arg::klass, METACLASS_OF, clone_method_arg::new_klass, clone_method_arg::old_klass, Qundef, rb_attr_get(), rb_id_table_create(), rb_id_table_foreach(), rb_iv_tbl_copy(), rb_singleton_class_attached(), rb_singleton_class_clone(), RBASIC, RCLASS_CONST_TBL, RCLASS_EXT, RCLASS_IV_TBL, RCLASS_M_TBL, RCLASS_SUPER, T_CLASS, and clone_const_arg::tbl.
Referenced by rb_singleton_class_clone().
Returns the singleton class of obj, or nil if obj is not a singleton object.
obj | an arbitrary object. |
Definition at line 1893 of file class.c.
References FL_SINGLETON, FL_TEST, id_attached, Qnil, rb_attr_get(), rb_special_singleton_class(), RBASIC, and SPECIAL_CONST_P.
Referenced by rb_obj_singleton_method().
Definition at line 554 of file class.c.
References id_attached, rb_attr_get(), and T_CLASS.
Definition at line 1819 of file class.c.
Referenced by rb_singleton_class_get().