#define NEED_newSVpvn_flags_GLOBAL
#include "mouse.h"
+/* keywords for methods/keys */
SV* mouse_package;
SV* mouse_namespace;
SV* mouse_methods;
SV* mouse_name;
SV* mouse_get_attribute;
SV* mouse_get_attribute_list;
+SV* mouse_coerce;
#define MOUSE_xc_flags(a) SvUVX(MOUSE_av_at((a), MOUSE_XC_FLAGS))
#define MOUSE_xc_gen(a) MOUSE_av_at((a), MOUSE_XC_GEN)
assert(args);
assert(SvTYPE(args) == SVt_PVHV);
- ENTER;
- SAVETMPS;
+ if(mg_find((SV*)args, PERL_MAGIC_tied)){
+ croak("You cannot use tied HASH reference as initializing arguments");
+ }
if(!ignore_triggers){
triggers_queue = newAV_mortal();
if(flags & MOUSEf_ATTR_HAS_TC){
value = mouse_xa_apply_type_constraint(aTHX_ xa, value, flags);
}
- set_slot(object, slot, value);
+ value = set_slot(object, slot, value);
if(SvROK(value) && flags & MOUSEf_ATTR_IS_WEAK_REF){
weaken_slot(object, slot);
}
}
if(MOUSE_xc_flags(xc) & MOUSEf_XC_IS_ANON){
- set_slot(object, newSVpvs_flags("__METACLASS__", SVs_TEMP), meta);
+ (void)set_slot(object, newSVpvs_flags("__METACLASS__", SVs_TEMP), meta);
}
- FREETMPS;
- LEAVE;
}
static SV*
PUSHs(args);
PUTBACK;
- call_sv(AvARRAY(buildall)[i], G_VOID | G_DISCARD);
+ call_sv(AvARRAY(buildall)[i], G_VOID);
+
+ /* discard a scalar which G_VOID returns */
+ SPAGAIN;
+ (void)POPs;
+ PUTBACK;
}
}
mouse_namespace = newSVpvs_share("namespace");
mouse_methods = newSVpvs_share("methods");
mouse_name = newSVpvs_share("name");
+ mouse_coerce = newSVpvs_share("coerce");
mouse_get_attribute = newSVpvs_share("get_attribute");
mouse_get_attribute_list = newSVpvs_share("get_attribute_list");
}
sv_setsv_mg((SV*)gv, code_ref); /* *gv = $code_ref */
- set_slot(methods, name, code); /* $self->{methods}{$name} = $code */
+ (void)set_slot(methods, name, code); /* $self->{methods}{$name} = $code */
/* name the CODE ref if it's anonymous */
{
CV* const code_entity = (CV*)SvRV(code_ref);
if(CvANON(code_entity)
&& CvGV(code_entity) /* a cv under construction has no gv */ ){
+ HV* dbsub;
+
+ /* update %DB::sub to make NYTProf happy */
+ if((PL_perldb & (PERLDBf_SUBLINE|PERLDB_NAMEANON))
+ && PL_DBsub && (dbsub = GvHV(PL_DBsub))
+ ){
+ /* see Perl_newATTRSUB() in op.c */
+ SV* const subname = sv_newmortal();
+ HE* orig;
+
+ gv_efullname3(subname, CvGV(code_entity), NULL);
+ orig = hv_fetch_ent(dbsub, subname, FALSE, 0U);
+ if(orig){
+ gv_efullname3(subname, gv, NULL);
+ (void)hv_store_ent(dbsub, subname, HeVAL(orig), 0U);
+ SvREFCNT_inc_simple_void_NN(HeVAL(orig));
+ }
+ }
CvGV(code_entity) = gv;
CvANON_off(code_entity);
AV* demolishall;
I32 len, i;
- PERL_UNUSED_VAR(ix);
-
if(!IsObject(object)){
- croak("You must not call DESTROY as a class method");
+ croak("You must not call %s as a class method",
+ ix == 0 ? "DESTROY" : "DEMOLISHALL");
}
if(SvOK(meta)){
PUSHMARK(SP);
XPUSHs(object);
+ XPUSHs(boolSV(PL_dirty));
+ PUTBACK;
+
+ call_sv(AvARRAY(demolishall)[i], G_VOID | G_EVAL);
+
+ /* discard a scalar which G_VOID returns */
+ SPAGAIN;
+ (void)POPs;
PUTBACK;
- call_sv(AvARRAY(demolishall)[i], G_VOID | G_DISCARD | G_EVAL);
- if(SvTRUE(ERRSV)){
+ if(sv_true(ERRSV)){
SV* const e = newSVsv(ERRSV);
FREETMPS;
if(!IsHashRef(args)){
croak("You must pass a HASH reference to BUILDALL");
}
- if(mg_find(SvRV(args), PERL_MAGIC_tied)){
- croak("You cannot use tie HASH reference as args");
- }
mouse_buildall(aTHX_ xc, self, args);
}