X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=mouse.h;h=20415de633f1069fe157d29e21696e4bb8576d37;hb=da4b12142dc69cb45de375a01fd28a4b9d3d4a25;hp=5fab08f0adbab7ee3d554ca8e09782b782f7dd77;hpb=ace983091fce7b49aae4f514e83730cf83dc902a;p=gitmo%2FMouse.git diff --git a/mouse.h b/mouse.h index 5fab08f..20415de 100644 --- a/mouse.h +++ b/mouse.h @@ -29,6 +29,7 @@ #define no_mro_get_linear_isa #define mro_get_linear_isa(stash) mouse_mro_get_linear_isa(aTHX_ stash) AV* mouse_mro_get_linear_isa(pTHX_ HV* const stash); +#define mro_method_changed_in(stash) ((void)++PL_sub_generation) #endif /* !mro_get_linear_isa */ #ifndef mro_get_pkg_gen @@ -60,6 +61,7 @@ extern SV* mouse_package; extern SV* mouse_namespace; extern SV* mouse_methods; extern SV* mouse_name; +extern SV* mouse_coerce; void mouse_throw_error(SV* const metaobject, SV* const data /* not used */, const char* const fmt, ...) @@ -69,6 +71,15 @@ mouse_throw_error(SV* const metaobject, SV* const data /* not used */, const cha ; #endif +/* workaround RT #69939 */ +I32 +mouse_call_sv_safe(pTHX_ SV*, I32); + +#define call_sv_safe(sv, flags) mouse_call_sv_safe(aTHX_ sv, flags) +#define call_method_safe(m, flags) mouse_call_sv_safe(aTHX_ newSVpvn_flags(m, strlen(m), SVs_TEMP), flags | G_METHOD) +#define call_method_safes(m, flags) mouse_call_sv_safe(aTHX_ newSVpvs_flags(m, SVs_TEMP), flags | G_METHOD) + + #define is_class_loaded(sv) mouse_is_class_loaded(aTHX_ sv) bool mouse_is_class_loaded(pTHX_ SV*); @@ -100,6 +111,13 @@ GV* mouse_stash_fetch(pTHX_ HV* const stash, const char* const name, I32 const n #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)) +void mouse_install_sub(pTHX_ GV* const gv, SV* const code_ref); + +void mouse_must_defined(pTHX_ SV* const value, const char* const name); +void mouse_must_ref(pTHX_ SV* const value, const char* const name, svtype const t); + +#define must_defined(sv, name) mouse_must_defined(aTHX_ sv, name) +#define must_ref(sv, name, svt) mouse_must_ref(aTHX_ sv, name, svt) #define MOUSEf_DIE_ON_FAIL 0x01 MAGIC* mouse_mg_find(pTHX_ SV* const sv, const MGVTBL* const vtbl, I32 const flags); @@ -145,30 +163,31 @@ void mouse_instance_weaken_slot(pTHX_ SV* const instance, SV* const slot); #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, XS_Mouse_simple_reader, NULL, 0) -#define INSTALL_SIMPLE_READER_WITH_DEFAULTSV(klass, name, dsv) \ - (void)mouse_install_simple_accessor(aTHX_ "Mouse::Meta::" #klass "::" #name, #name, sizeof(#name)-1, XS_Mouse_simple_reader, (dsv), HEf_SVKEY) -#define INSTALL_SIMPLE_READER_WITH_DEFAULTS(klass, name, ds) \ - INSTALL_SIMPLE_READER_WITH_DEFAULTSV(klass, name, newSVpvs(ds)) + (void)mouse_simple_accessor_generate(aTHX_ "Mouse::Meta::" #klass "::" #name, #key, sizeof(#key)-1, XS_Mouse_simple_reader, NULL, 0) + +#define INSTALL_CLASS_HOLDER_SV(klass, name, dsv) \ + (void)mouse_simple_accessor_generate(aTHX_ "Mouse::Meta::" #klass "::" #name, #name, sizeof(#name)-1, XS_Mouse_simple_reader, (dsv), HEf_SVKEY) +#define INSTALL_CLASS_HOLDER(klass, name, ds) \ + INSTALL_CLASS_HOLDER_SV(klass, name, newSVpvs(ds)) #define INSTALL_SIMPLE_WRITER(klass, name) \ NSTALL_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, XS_Mouse_simple_writer, NULL, 0) + (void)mouse_simple_accessor_generate(aTHX_ "Mouse::Meta::" #klass "::" #name, #key, sizeof(#key)-1, XS_Mouse_simple_writer, NULL, 0) #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, XS_Mouse_simple_predicate, NULL, 0) + (void)mouse_simple_accessor_generate(aTHX_ "Mouse::Meta::" #klass "::" #name, #key, sizeof(#key)-1, XS_Mouse_simple_predicate, NULL, 0) -CV* mouse_install_simple_accessor(pTHX_ const char* const fq_name, const char* const key, I32 const keylen, XSUBADDR_t const accessor_impl, void* const dptr, I32 const dlen); +CV* mouse_simple_accessor_generate(pTHX_ const char* const fq_name, const char* const key, I32 const keylen, XSUBADDR_t const accessor_impl, void* const dptr, I32 const dlen); 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); +CV* mouse_accessor_generate(pTHX_ SV* const attr, XSUBADDR_t const accessor_impl); XS(XS_Mouse_accessor); XS(XS_Mouse_reader); @@ -199,6 +218,7 @@ 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); +CV* mouse_generate_can_predicate_for(pTHX_ SV* const klass, const char* const predicate_name); int mouse_is_an_instance_of(pTHX_ HV* const stash, SV* const instance);