4 #define PERL_NO_GET_CONTEXT
11 #ifndef newSVpvs_share
12 #define newSVpvs_share(s) Perl_newSVpvn_share(aTHX_ s, sizeof(s)-1, 0U)
15 #ifndef mro_get_linear_isa
16 #define no_mro_get_linear_isa
17 #define mro_get_linear_isa(stash) mouse_mro_get_linear_isa(aTHX_ stash)
18 AV* mouse_mro_get_linear_isa(pTHX_ HV* const stash)
19 #endif /* !mro_get_linear_isa */
21 #ifndef mro_get_pkg_gen
22 #ifdef no_mro_get_linear_isa
23 #define mro_get_pkg_gen(stash) ((void)stash, PL_sub_generation)
25 #define mro_get_pkg_gen(stash) (HvAUX(stash)->xhv_mro_meta ? HvAUX(stash)->xhv_mro_meta->pkg_gen : (U32)0)
26 #endif /* !no_mro_get_linear_isa */
27 #endif /* mro_get_package_gen */
29 #define MOUSE_CALL_BOOT(name) STMT_START { \
30 EXTERN_C XS(CAT2(boot_, name)); \
32 CALL_FPTR(CAT2(boot_, name))(aTHX_ cv); \
35 extern SV* mouse_package;
36 extern SV* mouse_namespace;
39 mouse_throw_error(SV* const metaobject, SV* const data /* not used */, const char* const fmt, ...)
40 #ifdef __attribute__format__
41 __attribute__format__(__printf__, 3, 4);
46 #define is_class_loaded(sv) mouse_is_class_loaded(aTHX_ sv)
47 bool mouse_is_class_loaded(pTHX_ SV*);
49 #define is_instance_of(sv, klass) mouse_is_instance_of(aTHX_ sv, klass)
50 bool mouse_is_instance_of(pTHX_ SV* const sv, SV* const klass);
52 #define IsObject(sv) (SvROK(sv) && SvOBJECT(SvRV(sv)))
54 #define mcall0(invocant, m) mouse_call0(aTHX_ (invocant), (m))
55 #define mcall1(invocant, m, arg1) mouse_call1(aTHX_ (invocant), (m), (arg1))
56 #define mcall0s(invocant, m) mcall0((invocant), newSVpvs_flags(m, SVs_TEMP))
57 #define mcall1s(invocant, m, arg1) mcall1((invocant), newSVpvs_flags(m, SVs_TEMP), (arg1))
59 SV* mouse_call0(pTHX_ SV *const self, SV *const method);
60 SV* mouse_call1(pTHX_ SV *const self, SV *const method, SV* const arg1);
62 #define MOUSEf_DIE_ON_FAIL 0x01
63 MAGIC* mouse_mg_find(pTHX_ SV* const sv, const MGVTBL* const vtbl, I32 const flags);
65 /* MOUSE_av_at(av, ix) is the safer version of AvARRAY(av)[ix] if perl is compiled with -DDEBUGGING */
67 #define MOUSE_av_at(av, ix) *mouse_av_at_safe(aTHX_ (av) , (ix))
68 SV** mouse_av_at_safe(pTHX_ AV* const mi, I32 const ix);
70 #define MOUSE_av_at(av, ix) AvARRAY(av)[ix]
73 #define dMOUSE_self SV* const self = mouse_accessor_get_self(aTHX_ ax, items, cv)
74 SV* mouse_accessor_get_self(pTHX_ I32 const ax, I32 const items, CV* const cv);
76 #define MOUSE_mg_obj(mg) ((mg)->mg_obj)
77 #define MOUSE_mg_ptr(mg) ((mg)->mg_ptr)
78 #define MOUSE_mg_flags(mg) ((mg)->mg_private)
79 #define MOUSE_mg_virtual(mg) ((mg)->mg_virtual)
81 #define MOUSE_mg_slot(mg) MOUSE_mg_obj(mg)
82 #define MOUSE_mg_xa(mg) ((AV*)MOUSE_mg_ptr(mg))
85 /* mouse_instance.xs stuff */
86 SV* mouse_instance_create (pTHX_ HV* const stash);
87 SV* mouse_instance_clone (pTHX_ SV* const instance);
88 bool mouse_instance_has_slot (pTHX_ SV* const instance, SV* const slot);
89 SV* mouse_instance_get_slot (pTHX_ SV* const instance, SV* const slot);
90 SV* mouse_instance_set_slot (pTHX_ SV* const instance, SV* const slot, SV* const value);
91 SV* mouse_instance_delete_slot(pTHX_ SV* const instance, SV* const slot);
92 void mouse_instance_weaken_slot(pTHX_ SV* const instance, SV* const slot);
95 /* mouse_simle_accessor.xs */
96 #define INSTALL_SIMPLE_READER(klass, name) INSTALL_SIMPLE_READER_WITH_KEY(klass, name, name)
97 #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)
99 #define INSTALL_SIMPLE_WRITER(klass, name) INSTALL_SIMPLE_WRITER_WITH_KEY(klass, name, name)
100 #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)
102 #define INSTALL_SIMPLE_PREDICATE(klass, name) INSTALL_SIMPLE_PREDICATE_WITH_KEY(klass, name, name)
103 #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)
105 CV* mouse_install_simple_accessor(pTHX_ const char* const fq_name, const char* const key, I32 const keylen, XSUBADDR_t const accessor_impl);
107 XS(mouse_xs_simple_reader);
108 XS(mouse_xs_simple_writer);
109 XS(mouse_xs_simple_clearer);
110 XS(mouse_xs_simple_predicate);
112 CV* mouse_instantiate_xs_accessor(pTHX_ SV* const attr, XSUBADDR_t const accessor_impl);
114 XS(mouse_xs_accessor);
118 typedef enum mouse_tc{
143 /* type constraints */
145 int mouse_tc_check(pTHX_ mouse_tc const tc, SV* sv);
147 int mouse_tc_Any (pTHX_ SV* const sv);
148 int mouse_tc_Bool (pTHX_ SV* const sv);
149 int mouse_tc_Undef (pTHX_ SV* const sv);
150 int mouse_tc_Defined (pTHX_ SV* const sv);
151 int mouse_tc_Value (pTHX_ SV* const sv);
152 int mouse_tc_Num (pTHX_ SV* const sv);
153 int mouse_tc_Int (pTHX_ SV* const sv);
154 int mouse_tc_Str (pTHX_ SV* const sv);
155 int mouse_tc_ClassName (pTHX_ SV* const sv);
156 int mouse_tc_RoleName (pTHX_ SV* const sv);
157 int mouse_tc_Ref (pTHX_ SV* const sv);
158 int mouse_tc_ScalarRef (pTHX_ SV* const sv);
159 int mouse_tc_ArrayRef (pTHX_ SV* const sv);
160 int mouse_tc_HashRef (pTHX_ SV* const sv);
161 int mouse_tc_CodeRef (pTHX_ SV* const sv);
162 int mouse_tc_RegexpRef (pTHX_ SV* const sv);
163 int mouse_tc_GlobRef (pTHX_ SV* const sv);
164 int mouse_tc_FileHandle(pTHX_ SV* const sv);
165 int mouse_tc_Object (pTHX_ SV* const sv);
168 #endif /* !MOUSE_H */