ruby-changes:59496
From: =E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3 <ko1@a...>
Date: Thu, 26 Dec 2019 23:13:37 +0900 (JST)
Subject: [ruby-changes:59496] 63c9f620cf (master): internal/class.h rework
https://git.ruby-lang.org/ruby.git/commit/?id=63c9f620cf From 63c9f620cf87fb5fa08cdb7b0b4cc70e787f5cb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3?= <shyouhei@r...> Date: Tue, 3 Dec 2019 13:49:14 +0900 Subject: internal/class.h rework This file has almost nothing to do. Added some #ifdef lines and rearranged file contents. Those macros are unable to translate into inline functions, because they are used as lvalues of assignments. diff --git a/internal/class.h b/internal/class.h index 8ba64a0..254094e 100644 --- a/internal/class.h +++ b/internal/class.h @@ -9,17 +9,23 @@ https://github.com/ruby/ruby/blob/trunk/internal/class.h#L9 * modify this file, provided that the conditions mentioned in the * file COPYING are met. Consult the file for details. */ +#include "id_table.h" /* for struct rb_id_table */ +#include "internal/gc.h" /* for RB_OBJ_WRITE */ +#include "internal/serial.h" /* for rb_serial_t */ +#include "internal/stdbool.h" /* for bool */ +#include "ruby/intern.h" /* for rb_alloc_func_t */ +#include "ruby/ruby.h" /* for struct RBasic */ + +#undef RClass /* See also include/ruby/backward.h */ +#undef RCLASS_SUPER struct rb_deprecated_classext_struct { char conflict[sizeof(VALUE) * 3]; }; -struct rb_subclass_entry; -typedef struct rb_subclass_entry rb_subclass_entry_t; - struct rb_subclass_entry { VALUE klass; - rb_subclass_entry_t *next; + struct rb_subclass_entry *next; }; struct rb_classext_struct { @@ -30,14 +36,14 @@ struct rb_classext_struct { https://github.com/ruby/ruby/blob/trunk/internal/class.h#L36 #endif struct rb_id_table *const_tbl; struct rb_id_table *callable_m_tbl; - rb_subclass_entry_t *subclasses; - rb_subclass_entry_t **parent_subclasses; + struct rb_subclass_entry *subclasses; + struct rb_subclass_entry **parent_subclasses; /** * In the case that this is an `ICLASS`, `module_subclasses` points to the link * in the module's `subclasses` list that indicates that the klass has been * included. Hopefully that makes sense. */ - rb_subclass_entry_t **module_subclasses; + struct rb_subclass_entry **module_subclasses; #if SIZEOF_SERIAL_T != SIZEOF_VALUE /* otherwise class_serial is in struct RClass */ rb_serial_t class_serial; #endif @@ -47,13 +53,10 @@ struct rb_classext_struct { https://github.com/ruby/ruby/blob/trunk/internal/class.h#L53 const VALUE includer; }; -typedef struct rb_classext_struct rb_classext_t; - -#undef RClass struct RClass { struct RBasic basic; VALUE super; - rb_classext_t *ptr; + struct rb_classext_struct *ptr; #if SIZEOF_SERIAL_T == SIZEOF_VALUE /* Class serial is as wide as VALUE. Place it here. */ rb_serial_t class_serial; @@ -63,28 +66,8 @@ struct RClass { https://github.com/ruby/ruby/blob/trunk/internal/class.h#L66 #endif }; -void rb_class_subclass_add(VALUE super, VALUE klass); -void rb_class_remove_from_super_subclasses(VALUE); -int rb_singleton_class_internal_p(VALUE sklass); -/* class.c */ -VALUE rb_class_boot(VALUE); -VALUE rb_class_inherited(VALUE, VALUE); -VALUE rb_make_metaclass(VALUE, VALUE); -VALUE rb_include_class_new(VALUE, VALUE); -void rb_class_foreach_subclass(VALUE klass, void (*f)(VALUE, VALUE), VALUE); -void rb_class_detach_subclasses(VALUE); -void rb_class_detach_module_subclasses(VALUE); -void rb_class_remove_from_module_subclasses(VALUE); -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_special_singleton_class(VALUE); -VALUE rb_singleton_class_clone_and_attach(VALUE obj, VALUE attach); -VALUE rb_singleton_class_get(VALUE obj); - -int rb_class_has_methods(VALUE c); -void rb_undef_methods_from(VALUE klass, VALUE super); +typedef struct rb_subclass_entry rb_subclass_entry_t; +typedef struct rb_classext_struct rb_classext_t; #define RCLASS_EXT(c) (RCLASS(c)->ptr) #define RCLASS_IV_TBL(c) (RCLASS_EXT(c)->iv_tbl) @@ -109,6 +92,36 @@ void rb_undef_methods_from(VALUE klass, VALUE super); https://github.com/ruby/ruby/blob/trunk/internal/class.h#L92 #define RICLASS_IS_ORIGIN FL_USER5 #define RCLASS_REFINED_BY_ANY FL_USER7 +/* class.c */ +void rb_class_subclass_add(VALUE super, VALUE klass); +void rb_class_remove_from_super_subclasses(VALUE); +int rb_singleton_class_internal_p(VALUE sklass); +VALUE rb_class_boot(VALUE); +VALUE rb_make_metaclass(VALUE, VALUE); +VALUE rb_include_class_new(VALUE, VALUE); +void rb_class_foreach_subclass(VALUE klass, void (*f)(VALUE, VALUE), VALUE); +void rb_class_detach_subclasses(VALUE); +void rb_class_detach_module_subclasses(VALUE); +void rb_class_remove_from_module_subclasses(VALUE); +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_special_singleton_class(VALUE); +VALUE rb_singleton_class_clone_and_attach(VALUE obj, VALUE attach); +VALUE rb_singleton_class_get(VALUE obj); +int rb_class_has_methods(VALUE c); +void rb_undef_methods_from(VALUE klass, VALUE super); +static inline void RCLASS_SET_ORIGIN(VALUE klass, VALUE origin); +static inline VALUE RCLASS_SUPER(VALUE klass); +static inline VALUE RCLASS_SET_SUPER(VALUE klass, VALUE super); +static inline void RCLASS_SET_INCLUDER(VALUE iclass, VALUE klass); + +MJIT_SYMBOL_EXPORT_BEGIN +VALUE rb_class_inherited(VALUE, VALUE); +VALUE rb_keyword_error_new(const char *, VALUE); +MJIT_SYMBOL_EXPORT_END + static inline void RCLASS_SET_ORIGIN(VALUE klass, VALUE origin) { @@ -122,7 +135,6 @@ RCLASS_SET_INCLUDER(VALUE iclass, VALUE klass) https://github.com/ruby/ruby/blob/trunk/internal/class.h#L135 RB_OBJ_WRITE(iclass, &RCLASS_INCLUDER(iclass), klass); } -#undef RCLASS_SUPER static inline VALUE RCLASS_SUPER(VALUE klass) { -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/