#define NEED_sv_2pv_nolen
#include "ppport.h"
-#define MOP_CALL_BOOT(name) \
- { \
- EXTERN_C XS(name); \
- mop_call_xs(aTHX_ name, cv, mark); \
- }
+#define MOP_CALL_BOOT(name) mop_call_xs(aTHX_ name, cv, mark);
+
+#ifndef XSPROTO
+#define XSPROTO(name) XS(name)
+#endif
-void mop_call_xs (pTHX_ void (*subaddr) (pTHX_ CV *), CV *cv, SV **mark);
+void mop_call_xs (pTHX_ XSPROTO(subaddr), CV *cv, SV **mark);
-#define DECLARE_KEY(name) SV *key_##name; U32 hash_##name;
-#define NEEDS_KEY(name) extern SV *key_##name; extern U32 hash_##name;
+typedef enum {
+ KEY__expected_method_class,
+ KEY_ISA,
+ KEY_VERSION,
+ KEY_accessor,
+ KEY_associated_class,
+ KEY_associated_metaclass,
+ KEY_associated_methods,
+ KEY_attribute_metaclass,
+ KEY_attributes,
+ KEY_body,
+ KEY_builder,
+ KEY_clearer,
+ KEY_constructor_class,
+ KEY_constructor_name,
+ KEY_definition_context,
+ KEY_destructor_class,
+ KEY_immutable_trait,
+ KEY_init_arg,
+ KEY_initializer,
+ KEY_insertion_order,
+ KEY_instance_metaclass,
+ KEY_is_inline,
+ KEY_method_metaclass,
+ KEY_methods,
+ KEY_name,
+ KEY_package,
+ KEY_package_name,
+ KEY_predicate,
+ KEY_reader,
+ KEY_wrapped_method_metaclass,
+ KEY_writer,
+ KEY_package_cache_flag,
+ KEY__version,
+ key_last,
+} mop_prehashed_key_t;
+
+#define KEY_FOR(name) mop_prehashed_key_for(KEY_ ##name)
+#define HASH_FOR(name) mop_prehashed_hash_for(KEY_ ##name)
-#define PREHASH_KEY_WITH_VALUE(name, value) do { \
- key_##name = newSVpvs(value); \
- PERL_HASH(hash_##name, value, sizeof(value) - 1); \
-} while (0)
+void mop_prehash_keys (void);
+SV *mop_prehashed_key_for (mop_prehashed_key_t key);
+U32 mop_prehashed_hash_for (mop_prehashed_key_t key);
-/* 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 INSTALL_SIMPLE_READER(klass, name) INSTALL_SIMPLE_READER_WITH_KEY(klass, name, name)
+#define INSTALL_SIMPLE_READER_WITH_KEY(klass, name, key) \
+ { \
+ CV *cv = newXS("Class::MOP::" #klass "::" #name, mop_xs_simple_reader, __FILE__); \
+ CvXSUBANY(cv).any_i32 = KEY_ ##key; \
+ }
-#define PREHASH_KEY(name) do { \
- key_##name = newSVpvs(#name); \
- PERL_HASH(hash_##name, #name, sizeof(#name) - 1); \
-} while (0)
+XS(mop_xs_simple_reader);
extern SV *mop_method_metaclass;
extern SV *mop_associated_metaclass;