[Moose-commits] r7181 - Class-MOP/trunk

rafl at code2.0beta.co.uk rafl at code2.0beta.co.uk
Thu Dec 25 13:39:35 GMT 2008


Author: rafl
Date: 2008-12-25 05:39:35 -0800 (Thu, 25 Dec 2008)
New Revision: 7181

Modified:
   Class-MOP/trunk/MOP.xs
Log:
Avoid macro expansion of 'name' in PREHASH_KEY.

Modified: Class-MOP/trunk/MOP.xs
===================================================================
--- Class-MOP/trunk/MOP.xs	2008-12-25 13:22:20 UTC (rev 7180)
+++ Class-MOP/trunk/MOP.xs	2008-12-25 13:39:35 UTC (rev 7181)
@@ -21,8 +21,17 @@
     PERL_HASH(hash_##name, value, sizeof(value) - 1); \
 } while (0)
 
-#define PREHASH_KEY(name) PREHASH_KEY_WITH_VALUE(name, #name)
+/* this is basically the same as the above macro, except that the value will be
+ * the stringified name. However, we can't just implement this in terms of
+ * PREHASH_KEY_WITH_VALUE as that'd cause macro expansion on the value of
+ * 'name' when it's being passed to the other macro. suggestions on how to make
+ * this more elegant would be much appreciated */
 
+#define PREHASH_KEY(name) do { \
+    key_##name = newSVpvs(#name); \
+    PERL_HASH(hash_##name, #name, sizeof(#name) - 1); \
+} while (0)
+
 DECLARE_KEY(name);
 DECLARE_KEY(package);
 DECLARE_KEY(package_name);
@@ -310,9 +319,8 @@
     PREHASH_KEY(package_name);
     PREHASH_KEY(methods);
     PREHASH_KEY(ISA);
+    PREHASH_KEY(VERSION);
     PREHASH_KEY_WITH_VALUE(package_cache_flag, "_package_cache_flag");
-    /* we can't stringify VERSION as it's a define already */
-    PREHASH_KEY_WITH_VALUE(VERSION, "VERSION");
 
     method_metaclass     = newSVpvs("method_metaclass");
     wrap                 = newSVpvs("wrap");




More information about the Moose-commits mailing list