зеркало из https://github.com/github/ruby.git
Add RCLASS_ALLOCATOR Macro
This commit is contained in:
Родитель
6edd425674
Коммит
7341b01465
8
class.c
8
class.c
|
@ -188,7 +188,7 @@ class_alloc(VALUE flags, VALUE klass)
|
|||
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)
|
|||
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)
|
|||
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)
|
|||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -94,6 +94,7 @@ typedef struct rb_classext_struct rb_classext_t;
|
|||
#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
|
||||
|
|
|
@ -941,7 +941,7 @@ void
|
|||
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)
|
|||
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;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче