From: gfx Date: Mon, 16 Nov 2009 09:03:18 +0000 (+0900) Subject: Add mouse_initialize_metaclass() X-Git-Tag: 0.40_06~5 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=1bbf836974b126038c8cfc3155a265c9f8d9d385;p=gitmo%2FMouse.git Add mouse_initialize_metaclass() --- diff --git a/xs-src/Mouse.xs b/xs-src/Mouse.xs index 90a0972..1dd44b3 100644 --- a/xs-src/Mouse.xs +++ b/xs-src/Mouse.xs @@ -308,6 +308,28 @@ mouse_class_initialize_object(pTHX_ SV* const meta, SV* const object, HV* const LEAVE; } +SV* +mouse_initialize_metaclass(pTHX_ SV* const klass) { + SV* meta = get_metaclass(klass); + + if(!SvOK(meta)){ + dSP; + PUSHMARK(SP); + + EXTEND(SP, 2); + mPUSHp("Mouse::Meta::Class", sizeof("Mouse::Meta::Class")-1); + PUSHs(klass); + PUTBACK; + + call_method("initialize", G_SCALAR); + SPAGAIN; + meta = POPs; + PUTBACK; + } + + return meta; +} + MODULE = Mouse PACKAGE = Mouse PROTOTYPES: DISABLE @@ -485,7 +507,7 @@ SV* new(SV* klass, ...) CODE: { - SV* const meta = get_metaclass(klass); + SV* const meta = mouse_initialize_metaclass(aTHX_ klass); AV* const xc = mouse_get_xc(aTHX_ meta); UV const flags = MOUSE_xc_flags(xc); SV* args;