ruby-changes:65107
From: Matt <ko1@a...>
Date: Tue, 2 Feb 2021 01:43:18 +0900 (JST)
Subject: [ruby-changes:65107] 7341b01465 (master): Add RCLASS_ALLOCATOR Macro
https://git.ruby-lang.org/ruby.git/commit/?id=7341b01465 From 7341b0146557bccd783484b279569b530c888a14 Mon Sep 17 00:00:00 2001 From: Matt Valentine-House <matt@e...> Date: Tue, 26 Jan 2021 16:29:09 +0000 Subject: Add RCLASS_ALLOCATOR Macro --- class.c | 8 ++++---- internal/class.h | 1 + vm_method.c | 4 ++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/class.c b/class.c index 22f1208..2a18eab 100644 --- a/class.c +++ b/class.c @@ -188,7 +188,7 @@ class_alloc(VALUE flags, VALUE klass) https://github.com/ruby/ruby/blob/trunk/class.c#L188 RCLASS_SET_ORIGIN((VALUE)obj, (VALUE)obj); RCLASS_SERIAL(obj) = rb_next_class_serial(); RB_OBJ_WRITE(obj, &RCLASS_REFINED_CLASS(obj), Qnil); - RCLASS_EXT(obj)->allocator = 0; + RCLASS_ALLOCATOR(obj) = 0; return (VALUE)obj; } @@ -372,7 +372,7 @@ rb_mod_init_copy(VALUE clone, VALUE orig) https://github.com/ruby/ruby/blob/trunk/class.c#L372 RBASIC_SET_CLASS(clone, rb_singleton_class_clone(orig)); rb_singleton_class_attached(RBASIC(clone)->klass, (VALUE)clone); } - RCLASS_EXT(clone)->allocator = RCLASS_EXT(orig)->allocator; + RCLASS_ALLOCATOR(clone) = RCLASS_ALLOCATOR(orig); copy_tables(clone, orig); if (RCLASS_M_TBL(orig)) { struct clone_method_arg arg; @@ -409,7 +409,7 @@ rb_mod_init_copy(VALUE clone, VALUE orig) https://github.com/ruby/ruby/blob/trunk/class.c#L409 RCLASS_M_TBL(clone_p) = RCLASS_M_TBL(p); RCLASS_CONST_TBL(clone_p) = RCLASS_CONST_TBL(p); RCLASS_IV_TBL(clone_p) = RCLASS_IV_TBL(p); - RCLASS_EXT(clone_p)->allocator = RCLASS_EXT(p)->allocator; + RCLASS_ALLOCATOR(clone_p) = RCLASS_ALLOCATOR(p); if (RB_TYPE_P(clone, T_CLASS)) { RCLASS_SET_INCLUDER(clone_p, clone); } @@ -492,7 +492,7 @@ rb_singleton_class_clone_and_attach(VALUE obj, VALUE attach) https://github.com/ruby/ruby/blob/trunk/class.c#L492 } RCLASS_SET_SUPER(clone, RCLASS_SUPER(klass)); - RCLASS_EXT(clone)->allocator = RCLASS_EXT(klass)->allocator; + RCLASS_ALLOCATOR(clone) = RCLASS_ALLOCATOR(klass); if (RCLASS_IV_TBL(klass)) { rb_iv_tbl_copy(clone, klass); } diff --git a/internal/class.h b/internal/class.h index 1697ae1..b05e264 100644 --- a/internal/class.h +++ b/internal/class.h @@ -94,6 +94,7 @@ typedef struct rb_classext_struct rb_classext_t; https://github.com/ruby/ruby/blob/trunk/internal/class.h#L94 #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 RCLASS_ALLOCATOR(c) (RCLASS_EXT(c)->allocator) #define RICLASS_IS_ORIGIN FL_USER5 #define RCLASS_CLONED FL_USER6 diff --git a/vm_method.c b/vm_method.c index 0064488..19852b0 100644 --- a/vm_method.c +++ b/vm_method.c @@ -941,7 +941,7 @@ void https://github.com/ruby/ruby/blob/trunk/vm_method.c#L941 rb_define_alloc_func(VALUE klass, VALUE (*func)(VALUE)) { Check_Type(klass, T_CLASS); - RCLASS_EXT(klass)->allocator = func; + RCLASS_ALLOCATOR(klass) = func; } void @@ -956,7 +956,7 @@ rb_get_alloc_func(VALUE klass) https://github.com/ruby/ruby/blob/trunk/vm_method.c#L956 Check_Type(klass, T_CLASS); for (; klass; klass = RCLASS_SUPER(klass)) { - rb_alloc_func_t allocator = RCLASS_EXT(klass)->allocator; + rb_alloc_func_t allocator = RCLASS_ALLOCATOR(klass); if (allocator == UNDEF_ALLOC_FUNC) break; if (allocator) return allocator; } -- cgit v1.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/