De-tabify
[gitmo/Class-MOP.git] / xs / Class.xs
index 911e97d..c638d41 100644 (file)
@@ -1,12 +1,5 @@
 #include "mop.h"
 
-NEEDS_KEY(name);
-NEEDS_KEY(body);
-NEEDS_KEY(methods);
-NEEDS_KEY(package);
-NEEDS_KEY(package_name);
-NEEDS_KEY(package_cache_flag);
-
 static void
 mop_update_method_map(pTHX_ SV *const self, SV *const class_name, HV *const stash, HV *const map)
 {
@@ -18,7 +11,7 @@ mop_update_method_map(pTHX_ SV *const self, SV *const class_name, HV *const stas
     HV   *symbols;
     dSP;
 
-    symbols = get_all_package_symbols(stash, TYPE_FILTER_CODE);
+    symbols = mop_get_all_package_symbols(stash, TYPE_FILTER_CODE);
 
     (void)hv_iterinit(symbols);
     while ( (coderef = hv_iternextsv(symbols, &method_name, &method_name_len)) ) {
@@ -28,7 +21,7 @@ mop_update_method_map(pTHX_ SV *const self, SV *const class_name, HV *const stas
         SV *method_slot;
         SV *method_object;
 
-        if (!get_code_info(coderef, &cvpkg_name, &cv_name)) {
+        if (!mop_get_code_info(coderef, &cvpkg_name, &cv_name)) {
             continue;
         }
 
@@ -41,13 +34,13 @@ mop_update_method_map(pTHX_ SV *const self, SV *const class_name, HV *const stas
 
         method_slot = *hv_fetch(map, method_name, method_name_len, TRUE);
         if ( SvOK(method_slot) ) {
-            SV *const body = mop_call0(aTHX_ method_slot, key_body); /* $method_object->body() */
+            SV *const body = mop_call0(aTHX_ method_slot, KEY_FOR(body)); /* $method_object->body() */
             if ( SvROK(body) && ((CV *) SvRV(body)) == cv ) {
                 continue;
             }
         }
 
-        method_metaclass_name = mop_call0(aTHX_ self, method_metaclass); /* $self->method_metaclass() */
+        method_metaclass_name = mop_call0(aTHX_ self, mop_method_metaclass); /* $self->method_metaclass() */
 
         /*
             $method_object = $method_metaclass->wrap(
@@ -64,15 +57,15 @@ mop_update_method_map(pTHX_ SV *const self, SV *const class_name, HV *const stas
         EXTEND(SP, 8);
         PUSHs(method_metaclass_name); /* invocant */
         mPUSHs(newRV_inc((SV *)cv));
-        PUSHs(associated_metaclass);
+        PUSHs(mop_associated_metaclass);
         PUSHs(self);
-        PUSHs(key_package_name);
+        PUSHs(KEY_FOR(package_name));
         PUSHs(class_name);
-        PUSHs(key_name);
+        PUSHs(KEY_FOR(name));
         mPUSHs(newSVpv(method_name, method_name_len));
         PUTBACK;
 
-        call_sv(wrap, G_SCALAR | G_METHOD);
+        call_sv(mop_wrap, G_SCALAR | G_METHOD);
         SPAGAIN;
         method_object = POPs;
         PUTBACK;
@@ -93,13 +86,22 @@ get_method_map(self)
     SV *self
     PREINIT:
         HV *const obj        = (HV *)SvRV(self);
-        SV *const class_name = HeVAL( hv_fetch_ent(obj, key_package, 0, hash_package) );
+        SV *const class_name = HeVAL( hv_fetch_ent(obj, KEY_FOR(package), 0, HASH_FOR(package)) );
         HV *const stash      = gv_stashsv(class_name, 0);
-        UV  const current    = mop_check_package_cache_flag(aTHX_ stash);
-        SV *const cache_flag = HeVAL( hv_fetch_ent(obj, key_package_cache_flag, TRUE, hash_package_cache_flag));
-        SV *const map_ref    = HeVAL( hv_fetch_ent(obj, key_methods, TRUE, hash_methods));
+        UV current;
+        SV *cache_flag;
+        SV *map_ref;
+    PPCODE:
+        if (!stash) {
+             mXPUSHs(newRV_noinc((SV *)newHV()));
+             return;
+        }
+
+        current    = mop_check_package_cache_flag(aTHX_ stash);
+        cache_flag = HeVAL( hv_fetch_ent(obj, KEY_FOR(package_cache_flag), TRUE, HASH_FOR(package_cache_flag)));
+        map_ref    = HeVAL( hv_fetch_ent(obj, KEY_FOR(methods), TRUE, HASH_FOR(methods)));
     PPCODE:
-        /* in  $self->{methods} does not yet exist (or got deleted) */
+        /* $self->{methods} does not yet exist (or got deleted) */
         if ( !SvROK(map_ref) || SvTYPE(SvRV(map_ref)) != SVt_PVHV ) {
             SV *new_map_ref = newRV_noinc((SV *)newHV());
             sv_2mortal(new_map_ref);