mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Additional patches to make this work
This commit is contained in:
committed by
Blaž Hrastnik
parent
97529c2a9a
commit
005cacf18b
@@ -248,6 +248,11 @@ mrb_singleton_class_clone(mrb_state *mrb, mrb_value obj)
|
||||
clone->c = mrb_singleton_class_clone(mrb, mrb_obj_value(klass));
|
||||
}
|
||||
|
||||
if (klass->origin != klass)
|
||||
clone->origin = klass->origin;
|
||||
else
|
||||
clone->origin = clone;
|
||||
|
||||
clone->super = klass->super;
|
||||
if (klass->iv) {
|
||||
mrb_iv_copy(mrb, mrb_obj_value(clone), mrb_obj_value(klass));
|
||||
@@ -269,6 +274,13 @@ copy_class(mrb_state *mrb, mrb_value dst, mrb_value src)
|
||||
{
|
||||
struct RClass *dc = mrb_class_ptr(dst);
|
||||
struct RClass *sc = mrb_class_ptr(src);
|
||||
/* if the origin is not the same as the class, then the origin and
|
||||
the current class need to be copied */
|
||||
if (sc->origin != sc) {
|
||||
dc->origin = mrb_class_ptr(mrb_obj_dup(mrb, mrb_obj_value(sc->origin)));
|
||||
} else {
|
||||
dc->origin = dc;
|
||||
}
|
||||
dc->mt = kh_copy(mt, mrb, sc->mt);
|
||||
dc->super = sc->super;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user