Tweaks for coercions
[gitmo/Mouse.git] / xs-src / Mouse.xs
index 6a571e6..eff6ab7 100644 (file)
@@ -184,7 +184,7 @@ mouse_get_xc_wo_check(pTHX_ SV* const metaclass) {
 }
 
 static int
-mouse_xc_is_fresh(aTHX_ AV* const xc) {
+mouse_xc_is_fresh(pTHX_ AV* const xc) {
     HV* const stash = MOUSE_xc_stash(xc);
     SV* const gen   = MOUSE_xc_gen(xc);
     if(SvUVX(gen) != 0U && MOUSE_xc_flags(xc) & MOUSEf_XC_IS_IMMUTABLE) {
@@ -193,7 +193,7 @@ mouse_xc_is_fresh(aTHX_ AV* const xc) {
     return SvUVX(gen) == mro_get_pkg_gen(stash);
 }
 
-static AV*
+STATIC_INLINE AV*
 mouse_get_xc(pTHX_ SV* const metaclass) {
     AV* const xc = mouse_get_xc_wo_check(aTHX_ metaclass);
     return mouse_xc_is_fresh(aTHX_ xc)
@@ -624,6 +624,19 @@ CODE:
     mouse_class_initialize_object(aTHX_ meta, object, args, is_cloning);
 }
 
+void
+_invalidate_metaclass_cache(SV* meta)
+CODE:
+{
+    AV* const xc = mouse_get_xc_if_fresh(aTHX_ meta);
+    if(xc) {
+        SV* const gen = MOUSE_xc_gen(xc);
+        sv_setuv(gen, 0U);
+    }
+    delete_slot(meta, newSVpvs_flags("_mouse_cache_", SVs_TEMP));
+}
+
+
 MODULE = Mouse  PACKAGE = Mouse::Meta::Role
 
 BOOT: