#include <perl.h>
#include <XSUB.h>
-#define NEED_newSVpvn_flags
#include "ppport.h"
/* for portability */
#define newSVpvs_share(s) Perl_newSVpvn_share(aTHX_ s, sizeof(s)-1, 0U)
#endif
+#ifndef get_cvs
+#define get_cvs(name, flags) get_cv(name, flags)
+#endif
+
#ifndef GvNAME_get
#define GvNAME_get GvNAME
#endif
#define is_an_instance_of(klass, sv) mouse_is_an_instance_of(aTHX_ gv_stashpvs(klass, GV_ADD), (sv))
-#define IsObject(sv) (SvROK(sv) && SvOBJECT(SvRV(sv)))
+#define IsObject(sv) (SvROK(sv) && SvOBJECT(SvRV(sv)))
+#define IsArrayRef(sv) (SvROK(sv) && !SvOBJECT(SvRV(sv)) && SvTYPE(SvRV(sv)) == SVt_PVAV)
+#define IsHashRef(sv) (SvROK(sv) && !SvOBJECT(SvRV(sv)) && SvTYPE(SvRV(sv)) == SVt_PVHV)
+#define IsCodeRef(sv) (SvROK(sv) && !SvOBJECT(SvRV(sv)) && SvTYPE(SvRV(sv)) == SVt_PVCV)
#define mcall0(invocant, m) mouse_call0(aTHX_ (invocant), (m))
#define mcall1(invocant, m, arg1) mouse_call1(aTHX_ (invocant), (m), (arg1))
-#define mcall0s(invocant, m) mcall0((invocant), newSVpvs_flags(m, SVs_TEMP))
-#define mcall1s(invocant, m, arg1) mcall1((invocant), newSVpvs_flags(m, SVs_TEMP), (arg1))
+#define mcall0s(invocant, m) mcall0((invocant), sv_2mortal(newSVpvs_share(m)))
+#define mcall1s(invocant, m, arg1) mcall1((invocant), sv_2mortal(newSVpvs_share(m)), (arg1))
+
+#define get_metaclass_by_name(name) mouse_get_metaclass_by_name(aTHX_ name)
SV* mouse_call0(pTHX_ SV *const self, SV *const method);
SV* mouse_call1(pTHX_ SV *const self, SV *const method, SV* const arg1);
+SV* mouse_get_metaclass_by_name(pTHX_ SV* const metaclass_name);
+
+GV* mouse_stash_fetch(pTHX_ HV* const stash, const char* const name, I32 const namelen, I32 const create);
+#define stash_fetch(s, n, l, c) mouse_stash_fetch(aTHX_ (s), (n), (l), (c))
+#define stash_fetchs(s, n, c) mouse_stash_fetch(aTHX_ (s), STR_WITH_LEN(n), (c))
+
+
#define MOUSEf_DIE_ON_FAIL 0x01
MAGIC* mouse_mg_find(pTHX_ SV* const sv, const MGVTBL* const vtbl, I32 const flags);
SV* mouse_instance_delete_slot(pTHX_ SV* const instance, SV* const slot);
void mouse_instance_weaken_slot(pTHX_ SV* const instance, SV* const slot);
+#define has_slot(self, key) mouse_instance_has_slot(aTHX_ self, key)
+#define get_slot(self, key) mouse_instance_get_slot(aTHX_ self, key)
+#define set_slot(self, key, value) mouse_instance_set_slot(aTHX_ self, key, value)
+#define delete_slot(self, key) mouse_instance_delete_slot(aTHX_ self, key)
+#define weaken_slot(self, key) mouse_instance_weaken_slot(aTHX_ self, key)
+
+#define has_slots(self, key) has_slot(self, sv_2mortal(newSVpvs_share(key)))
+#define get_slots(self, key) get_slot(self, sv_2mortal(newSVpvs_share(key)))
+#define set_slots(self, key, value) set_slot(self, sv_2mortal(newSVpvs_share(key)), value)
/* mouse_simle_accessor.xs */
#define INSTALL_SIMPLE_READER(klass, name) INSTALL_SIMPLE_READER_WITH_KEY(klass, name, name)
-#define INSTALL_SIMPLE_READER_WITH_KEY(klass, name, key) (void)mouse_install_simple_accessor(aTHX_ "Mouse::Meta::" #klass "::" #name, #key, sizeof(#key)-1, mouse_xs_simple_reader)
+#define INSTALL_SIMPLE_READER_WITH_KEY(klass, name, key) (void)mouse_install_simple_accessor(aTHX_ "Mouse::Meta::" #klass "::" #name, #key, sizeof(#key)-1, XS_Mouse_simple_reader)
#define INSTALL_SIMPLE_WRITER(klass, name) INSTALL_SIMPLE_WRITER_WITH_KEY(klass, name, name)
-#define INSTALL_SIMPLE_WRITER_WITH_KEY(klass, name, key) (void)mouse_install_simple_accessor(aTHX_ "Mouse::Meta::" #klass "::" #name, #key, sizeof(#key)-1, mouse_xs_simple_writer)
+#define INSTALL_SIMPLE_WRITER_WITH_KEY(klass, name, key) (void)mouse_install_simple_accessor(aTHX_ "Mouse::Meta::" #klass "::" #name, #key, sizeof(#key)-1, XS_Mouse_simple_writer)
#define INSTALL_SIMPLE_PREDICATE(klass, name) INSTALL_SIMPLE_PREDICATE_WITH_KEY(klass, name, name)
-#define INSTALL_SIMPLE_PREDICATE_WITH_KEY(klass, name, key) (void)mouse_install_simple_accessor(aTHX_ "Mouse::Meta::" #klass "::" #name, #key, sizeof(#key)-1, mouse_xs_simple_predicate)
+#define INSTALL_SIMPLE_PREDICATE_WITH_KEY(klass, name, key) (void)mouse_install_simple_accessor(aTHX_ "Mouse::Meta::" #klass "::" #name, #key, sizeof(#key)-1, XS_Mouse_simple_predicate)
CV* mouse_install_simple_accessor(pTHX_ const char* const fq_name, const char* const key, I32 const keylen, XSUBADDR_t const accessor_impl);
-XS(mouse_xs_simple_reader);
-XS(mouse_xs_simple_writer);
-XS(mouse_xs_simple_clearer);
-XS(mouse_xs_simple_predicate);
+XS(XS_Mouse_simple_reader);
+XS(XS_Mouse_simple_writer);
+XS(XS_Mouse_simple_clearer);
+XS(XS_Mouse_simple_predicate);
CV* mouse_instantiate_xs_accessor(pTHX_ SV* const attr, XSUBADDR_t const accessor_impl);
-XS(mouse_xs_accessor);
-XS(mouse_xs_reader);
-XS(mouse_xs_writer);
-
-typedef enum mouse_tc{
- MOUSE_TC_ANY,
- MOUSE_TC_ITEM,
- MOUSE_TC_UNDEF,
- MOUSE_TC_DEFINED,
- MOUSE_TC_BOOL,
- MOUSE_TC_VALUE,
- MOUSE_TC_REF,
- MOUSE_TC_STR,
- MOUSE_TC_NUM,
- MOUSE_TC_INT,
- MOUSE_TC_SCALAR_REF,
- MOUSE_TC_ARRAY_REF,
- MOUSE_TC_HASH_REF,
- MOUSE_TC_CODE_REF,
- MOUSE_TC_GLOB_REF,
- MOUSE_TC_FILEHANDLE,
- MOUSE_TC_REGEXP_REF,
- MOUSE_TC_OBJECT,
- MOUSE_TC_CLASS_NAME,
- MOUSE_TC_ROLE_NAME,
-
- MOUSE_TC_last
-} mouse_tc;
+XS(XS_Mouse_accessor);
+XS(XS_Mouse_reader);
+XS(XS_Mouse_writer);
/* type constraints */
int mouse_tc_check(pTHX_ SV* const tc, SV* const sv);
-int mouse_builtin_tc_check(pTHX_ mouse_tc const tc, SV* const sv);
-
-int mouse_tc_Any (pTHX_ SV* const sv);
-int mouse_tc_Bool (pTHX_ SV* const sv);
-int mouse_tc_Undef (pTHX_ SV* const sv);
-int mouse_tc_Defined (pTHX_ SV* const sv);
-int mouse_tc_Value (pTHX_ SV* const sv);
-int mouse_tc_Num (pTHX_ SV* const sv);
-int mouse_tc_Int (pTHX_ SV* const sv);
-int mouse_tc_Str (pTHX_ SV* const sv);
-int mouse_tc_ClassName (pTHX_ SV* const sv);
-int mouse_tc_RoleName (pTHX_ SV* const sv);
-int mouse_tc_Ref (pTHX_ SV* const sv);
-int mouse_tc_ScalarRef (pTHX_ SV* const sv);
-int mouse_tc_ArrayRef (pTHX_ SV* const sv);
-int mouse_tc_HashRef (pTHX_ SV* const sv);
-int mouse_tc_CodeRef (pTHX_ SV* const sv);
-int mouse_tc_RegexpRef (pTHX_ SV* const sv);
-int mouse_tc_GlobRef (pTHX_ SV* const sv);
-int mouse_tc_FileHandle(pTHX_ SV* const sv);
-int mouse_tc_Object (pTHX_ SV* const sv);
+
+int mouse_tc_Any (pTHX_ SV*, SV* const sv);
+int mouse_tc_Bool (pTHX_ SV*, SV* const sv);
+int mouse_tc_Undef (pTHX_ SV*, SV* const sv);
+int mouse_tc_Defined (pTHX_ SV*, SV* const sv);
+int mouse_tc_Value (pTHX_ SV*, SV* const sv);
+int mouse_tc_Num (pTHX_ SV*, SV* const sv);
+int mouse_tc_Int (pTHX_ SV*, SV* const sv);
+int mouse_tc_Str (pTHX_ SV*, SV* const sv);
+int mouse_tc_ClassName (pTHX_ SV*, SV* const sv);
+int mouse_tc_RoleName (pTHX_ SV*, SV* const sv);
+int mouse_tc_Ref (pTHX_ SV*, SV* const sv);
+int mouse_tc_ScalarRef (pTHX_ SV*, SV* const sv);
+int mouse_tc_ArrayRef (pTHX_ SV*, SV* const sv);
+int mouse_tc_HashRef (pTHX_ SV*, SV* const sv);
+int mouse_tc_CodeRef (pTHX_ SV*, SV* const sv);
+int mouse_tc_RegexpRef (pTHX_ SV*, SV* const sv);
+int mouse_tc_GlobRef (pTHX_ SV*, SV* const sv);
+int mouse_tc_FileHandle(pTHX_ SV*, SV* const sv);
+int mouse_tc_Object (pTHX_ SV*, SV* const sv);
CV* mouse_generate_isa_predicate_for(pTHX_ SV* const klass, const char* const predicate_name);
int mouse_is_an_instance_of(pTHX_ HV* const stash, SV* const instance);
-XS(XS_Mouse_parameterized_check);
+XS(XS_Mouse_constraint_check);
#endif /* !MOUSE_H */