X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=Parameters.xs;h=762ed3fad3846a31f7437f08d7d3c18206dacd98;hb=f6a45a63e0f39a9c306b49d303575aa574fef102;hp=ba28c0e3dc04771a6cf79d664e016ef8ab08b4af;hpb=5cf69cd2971747fcdf9118fcfdf5b6d1869ad508;p=p5sagit%2FFunction-Parameters.git diff --git a/Parameters.xs b/Parameters.xs index ba28c0e..762ed3f 100644 --- a/Parameters.xs +++ b/Parameters.xs @@ -157,39 +157,6 @@ static SV *sentinel_mortalize(Sentinel sen, SV *sv) { return sv; } -static void my_safefree(void *p) { - Safefree(p); -} - -#define SENTINEL_ALLOC(SEN, P, N, T) STMT_START { \ - Newx(P, N, T); \ - sentinel_register(SEN, P, my_safefree); \ -} STMT_END - -#define SENTINEL_MDUP(SEN, P, O, N, T) STMT_START { \ - void *const _sentinel_mdup_tmp_ = (P); \ - SENTINEL_ALLOC(SEN, P, N, T); \ - memcpy(P, _sentinel_mdup_tmp_, O * sizeof (T)); \ -} STMT_END - -#define SENTINEL_REALLOC(SEN, P, N, T) STMT_START { \ - assert((N) > 0); \ - if (!(P)) { \ - SENTINEL_ALLOC(SEN, P, N, T); \ - } else { \ - Resource **_sentinel_realloc_tmp_ = (SEN); \ - for (;;) { \ - assert(*_sentinel_realloc_tmp_ != NULL); \ - if ((*_sentinel_realloc_tmp_)->data == (P)) { \ - Renew((*_sentinel_realloc_tmp_)->data, N, T); \ - (P) = (*_sentinel_realloc_tmp_)->data; \ - break; \ - } \ - _sentinel_realloc_tmp_ = &(*_sentinel_realloc_tmp_)->next; \ - } \ - } \ -} STMT_END - static int kw_flags(pTHX_ Sentinel sen, const char *kw_ptr, STRLEN kw_len, KWSpec *spec) { HV *hints; SV *sv, **psv; @@ -577,6 +544,9 @@ static SV *reify_type(pTHX_ Sentinel sen, const SV *declarator, SV *name) { SPAGAIN; assert(n == 1); + /* don't warn about n being unused if assert() is compiled out */ + n = n; + t = sentinel_mortalize(sen, SvREFCNT_inc(POPs)); PUTBACK; @@ -966,7 +936,7 @@ static OP *mkconstpv(pTHX_ const char *p, size_t n) { static OP *mktypecheck(pTHX_ const SV *declarator, int nr, SV *name, PADOFFSET padoff, SV *type) { /* $type->check($value) or Carp::croak "...: " . $type->get_message($value) */ - OP *chk, *cond, *err, *msg, *xcroak; + OP *chk, *err, *msg, *xcroak; err = mkconstsv(aTHX_ newSVpvf("In %"SVf": parameter %d (%"SVf"): ", SVfARG(declarator), nr, SVfARG(name))); { @@ -1037,7 +1007,7 @@ static void register_info(pTHX_ UV key, SV *declarator, const KWSpec *kws, const size_t n; char *p = SvPV(declarator, n); char *q = memchr(p, ' ', n); - mPUSHp(p, q ? q - p : n); + mPUSHp(p, q ? (size_t)(q - p) : n); } if (!ps) { if (SvTRUE(kws->shift)) { @@ -1936,9 +1906,9 @@ static int parse_fun(pTHX_ Sentinel sen, OP **pop, const char *keyword_ptr, STRL if (param_spec->slurpy.type) { /* $type->valid($_) or croak $type->get_message($_) for @rest / values %rest */ - OP *body, *list, *loop; + OP *check, *list, *loop; - body = mktypecheck(aTHX_ declarator, base, param_spec->slurpy.name, NOT_IN_PAD, param_spec->slurpy.type); + check = mktypecheck(aTHX_ declarator, base, param_spec->slurpy.name, NOT_IN_PAD, param_spec->slurpy.type); if (SvPV_nolen(param_spec->slurpy.name)[0] == '@') { list = my_var_g(aTHX_ OP_PADAV, 0, param_spec->slurpy.padoff); @@ -1947,7 +1917,7 @@ static int parse_fun(pTHX_ Sentinel sen, OP **pop, const char *keyword_ptr, STRL list = newUNOP(OP_VALUES, 0, list); } - loop = newFOROP(0, NULL, list, body, NULL); + loop = newFOROP(0, NULL, list, check, NULL); *prelude_sentinel = op_append_list(OP_LINESEQ, *prelude_sentinel, newSTATEOP(0, NULL, loop)); } @@ -2035,12 +2005,12 @@ UV fp__cv_root(sv) SV * sv PREINIT: - CV *cv; + CV *xcv; HV *hv; GV *gv; CODE: - cv = sv_2cv(sv, &hv, &gv, 0); - RETVAL = PTR2UV(cv ? CvROOT(cv) : NULL); + xcv = sv_2cv(sv, &hv, &gv, 0); + RETVAL = PTR2UV(xcv ? CvROOT(xcv) : NULL); OUTPUT: RETVAL