diff options
author | Ben Morrow <ben@morrow.me.uk> | 2009-12-07 11:52:23 +0000 |
---|---|---|
committer | Rafael Garcia-Suarez <rgs@consttype.org> | 2010-07-12 10:40:47 +0200 |
commit | 52db365a88f7ab3b9b091f983a05054164499982 (patch) | |
tree | b4c8cfb606ca59bff9d00fd9263e797771fb5e3e /op.h | |
parent | 03569ecfc8c82939dcc47b586a8e22c613c158b2 (diff) | |
download | perl-52db365a88f7ab3b9b091f983a05054164499982.tar.gz |
Macroify the block_hooks structure.
Add a flags member, so it can be extended later if necessary. Add a
bhk_eval member, called from doeval to catch requires and string evals.
Diffstat (limited to 'op.h')
-rw-r--r-- | op.h | 28 |
1 files changed, 23 insertions, 5 deletions
@@ -646,27 +646,45 @@ struct loop { #endif struct block_hooks { + U32 bhk_flags; void (*bhk_start) (pTHX_ int full); void (*bhk_pre_end) (pTHX_ OP **seq); void (*bhk_post_end) (pTHX_ OP **seq); + void (*bhk_eval) (pTHX_ OP *const saveop); }; +#define BhkFLAGS(hk) ((hk)->bhk_flags) + +#define BHKf_start 0x01 +#define BHKf_pre_end 0x02 +#define BHKf_post_end 0x04 +#define BHKf_eval 0x08 + +#define BhkENTRY(hk, which) \ + ((BhkFLAGS(hk) & BHKf_ ## which) ? ((hk)->bhk_ ## which) : NULL) + +#define BhkENTRY_set(hk, which, ptr) \ + STMT_START { \ + (hk)->bhk_ ## which = ptr; \ + (hk)->bhk_flags |= BHKf_ ## which; \ + } STMT_END + #define CALL_BLOCK_HOOKS(which, arg) \ STMT_START { \ if (PL_blockhooks) { \ I32 i; \ for (i = av_len(PL_blockhooks); i >= 0; i--) { \ SV *sv = AvARRAY(PL_blockhooks)[i]; \ - struct block_hooks *hk; \ + BHK *hk; \ \ assert(SvIOK(sv)); \ if (SvUOK(sv)) \ - hk = INT2PTR(struct block_hooks *, SvUVX(sv)); \ + hk = INT2PTR(BHK *, SvUVX(sv)); \ else \ - hk = INT2PTR(struct block_hooks *, SvIVX(sv)); \ + hk = INT2PTR(BHK *, SvIVX(sv)); \ \ - if (hk->bhk_ ## which) \ - CALL_FPTR(hk->bhk_ ## which)(aTHX_ arg); \ + if (BhkENTRY(hk, which)) \ + CALL_FPTR(BhkENTRY(hk, which))(aTHX_ arg); \ } \ } \ } STMT_END |