summaryrefslogtreecommitdiff
path: root/op.h
diff options
context:
space:
mode:
authorBen Morrow <ben@morrow.me.uk>2010-07-13 22:20:21 +0100
committerRafael Garcia-Suarez <rgs@consttype.org>2010-07-15 12:28:01 +0200
commita3e07c8779a37a0cc0a4e5ceac72eec0b30c0c0c (patch)
tree5fc7bc44bcb9ba1ef71075cb23a8d41abd37cf24 /op.h
parent53c0f7b3da3c1d6006f40558f6011132074df828 (diff)
downloadperl-a3e07c8779a37a0cc0a4e5ceac72eec0b30c0c0c.tar.gz
Macros to en/disable blockhook entries.
This allows the individual callbacks to be switched on and off as necessary, without removing the entry from PL_blockhooks.
Diffstat (limited to 'op.h')
-rw-r--r--op.h24
1 files changed, 23 insertions, 1 deletions
diff --git a/op.h b/op.h
index 30a41c8edd..2ea1dce395 100644
--- a/op.h
+++ b/op.h
@@ -670,6 +670,17 @@ Set an entry in the BHK structure, and set the flags to indicate it is
valid. I<which> is a preprocessing token indicating which entry to set.
The type of I<ptr> depends on the entry.
+=for apidoc Am|void|BhkDISABLE|BHK *hk|which
+Temporarily disable an entry in this BHK structure, by clearing the
+appropriate flag. I<which> is a preprocessor token indicating which
+entry to disable.
+
+=for apidoc Am|void|BhkENABLE|BHK *hk|which
+Re-enable an entry in this BHK structure, by setting the appropriate
+flag. I<which> is a preprocessor token indicating which entry to enable.
+This will assert (under -DDEBUGGING) if the entry doesn't contain a valid
+pointer.
+
=for apidoc m|void|CALL_BLOCK_HOOKS|which|arg
Call all the registered block hooks for type I<which>. I<which> is a
preprocessing token; the type of I<arg> depends on I<which>.
@@ -687,10 +698,21 @@ preprocessing token; the type of I<arg> depends on I<which>.
#define BhkENTRY(hk, which) \
((BhkFLAGS(hk) & BHKf_ ## which) ? ((hk)->bhk_ ## which) : NULL)
+#define BhkENABLE(hk, which) \
+ STMT_START { \
+ BhkFLAGS(hk) |= BHKf_ ## which; \
+ assert(BhkENTRY(hk, which)); \
+ } STMT_END
+
+#define BhkDISABLE(hk, which) \
+ STMT_START { \
+ BhkFLAGS(hk) &= ~(BHKf_ ## which); \
+ } STMT_END
+
#define BhkENTRY_set(hk, which, ptr) \
STMT_START { \
(hk)->bhk_ ## which = ptr; \
- (hk)->bhk_flags |= BHKf_ ## which; \
+ BhkENABLE(hk, which); \
} STMT_END
#define CALL_BLOCK_HOOKS(which, arg) \