ruby-changes:65108
From: Matt <ko1@a...>
Date: Tue, 2 Feb 2021 01:43:18 +0900 (JST)
Subject: [ruby-changes:65108] 6edd425674 (master): Add PARENT_MODULE_SUBCLASSES Macro
https://git.ruby-lang.org/ruby.git/commit/?id=6edd425674 From 6edd4256744c5ee6a73af660cb2bcb63ca94b254 Mon Sep 17 00:00:00 2001 From: Matt Valentine-House <matt@e...> Date: Tue, 26 Jan 2021 16:12:29 +0000 Subject: Add PARENT_MODULE_SUBCLASSES Macro --- class.c | 16 ++++++++-------- internal/class.h | 1 + 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/class.c b/class.c index 2e084d1..22f1208 100644 --- a/class.c +++ b/class.c @@ -76,11 +76,11 @@ rb_module_add_to_subclasses_list(VALUE module, VALUE iclass) https://github.com/ruby/ruby/blob/trunk/class.c#L76 head = RCLASS_EXT(module)->subclasses; if (head) { entry->next = head; - RCLASS_EXT(head->klass)->module_subclasses = &entry->next; + RCLASS_MODULE_SUBCLASSES(head->klass) = &entry->next; } RCLASS_EXT(module)->subclasses = entry; - RCLASS_EXT(iclass)->module_subclasses = &RCLASS_EXT(module)->subclasses; + RCLASS_MODULE_SUBCLASSES(iclass) = &RCLASS_EXT(module)->subclasses; } void @@ -106,18 +106,18 @@ rb_class_remove_from_module_subclasses(VALUE klass) https://github.com/ruby/ruby/blob/trunk/class.c#L106 { rb_subclass_entry_t *entry; - if (RCLASS_EXT(klass)->module_subclasses) { - entry = *RCLASS_EXT(klass)->module_subclasses; - *RCLASS_EXT(klass)->module_subclasses = entry->next; + if (RCLASS_MODULE_SUBCLASSES(klass)) { + entry = *RCLASS_MODULE_SUBCLASSES(klass); + *RCLASS_MODULE_SUBCLASSES(klass) = entry->next; if (entry->next) { - RCLASS_EXT(entry->next->klass)->module_subclasses = RCLASS_EXT(klass)->module_subclasses; + RCLASS_MODULE_SUBCLASSES(entry->next->klass) = RCLASS_MODULE_SUBCLASSES(klass); } xfree(entry); } - RCLASS_EXT(klass)->module_subclasses = NULL; + RCLASS_MODULE_SUBCLASSES(klass) = NULL; } void @@ -183,7 +183,7 @@ class_alloc(VALUE flags, VALUE klass) https://github.com/ruby/ruby/blob/trunk/class.c#L183 RCLASS_SET_SUPER((VALUE)obj, 0); RCLASS_EXT(obj)->subclasses = NULL; RCLASS_PARENT_SUBCLASSES(obj) = NULL; - RCLASS_EXT(obj)->module_subclasses = NULL; + RCLASS_MODULE_SUBCLASSES(obj) = NULL; */ RCLASS_SET_ORIGIN((VALUE)obj, (VALUE)obj); RCLASS_SERIAL(obj) = rb_next_class_serial(); diff --git a/internal/class.h b/internal/class.h index da1df19..1697ae1 100644 --- a/internal/class.h +++ b/internal/class.h @@ -93,6 +93,7 @@ typedef struct rb_classext_struct rb_classext_t; https://github.com/ruby/ruby/blob/trunk/internal/class.h#L93 #endif #define RCLASS_INCLUDER(c) (RCLASS_EXT(c)->includer) #define RCLASS_PARENT_SUBCLASSES(c) (RCLASS_EXT(c)->parent_subclasses) +#define RCLASS_MODULE_SUBCLASSES(c) (RCLASS_EXT(c)->module_subclasses) #define RICLASS_IS_ORIGIN FL_USER5 #define RCLASS_CLONED FL_USER6 -- cgit v1.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/