Skip to content

Commit c77326c

Browse files
committed
No need to gate hook with enabledebug
1 parent ac528a8 commit c77326c

4 files changed

Lines changed: 9 additions & 12 deletions

File tree

CHANGES

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
XXXX-XX-XX
22

33
* The bearer bars were reworked to render as filled paths rather than stroked lines, matching the border and the data bars for consistent rendering at small scales.
4+
* The hooks framework was amended so that hook procedures are activated by the presence of a hooks dictionary in the global context, without requiring the enabledebug option.
45

56

67
2026-05-31

CONTRIBUTING.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ large values at define time from small operands and reference via `//name`.
119119
containing optional keys that affect the behaviour of BWIPP:
120120

121121
- `preload` - Perform eager initialisation of normally lazy variables during resource definition
122-
- `enabledebug` - Allow the user to set debug options (e.g. `debugcws`), for development purposes including activation of hooks
122+
- `enabledebug` - Allow the user to set debug options (e.g. `debugcws`), for development purposes
123123
- `enabledontdraw` - Allow the user to set dontdraw, in case they are providing custom renderers
124124
- `hooks` - Dictionary of hook procedures for debugging purposes, including profiling
125125
- `default_*` - Defaults for certain renderer options set by the user, e.g. `default_barcolor`
@@ -1074,13 +1074,12 @@ By default hooks will do nothing other than pop the parameter.
10741074
The above pair of hooks is intended to allow measurement of time spent in each
10751075
phase via the definition of suitable procedures within global context.
10761076

1077-
The global context must be configured with `enabledebug` set and a `hooks`
1078-
dictionary containing custom procedures related to the hooks, for example:
1077+
The global context must be configured with a `hooks` dictionary containing
1078+
custom procedures related to the hooks, for example:
10791079

10801080
```postscript
10811081
currentglobal true setglobal
10821082
/uk.co.terryburton.bwipp.global_ctx <<
1083-
/enabledebug true
10841083
/hooks <<
10851084
/before {20 string cvs print ( before ) print print ( ) print realtime =}
10861085
/after {20 string cvs print ( after ) print print ( ) print realtime =}

src/setuphooks.ps.src

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,11 @@ begin
4949
/targetdict exch def
5050

5151
%
52-
% Get hooks dict from global_ctx if enabledebug is set
52+
% Get hooks dict from global_ctx, if present
5353
%
5454
/hooksdict null def
5555
/uk.co.terryburton.bwipp.global_ctx dup where {
56-
exch get dup /enabledebug known {
57-
/hooks 2 copy known {get /hooksdict exch def} {pop pop} ifelse
58-
} {pop} ifelse
56+
exch get /hooks 2 copy known {get /hooksdict exch def} {pop pop} ifelse
5957
} {pop} ifelse
6058

6159
hooks {

tests/ps_tests/setuphooks.ps.test

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,19 +101,18 @@
101101

102102

103103
%
104-
% Without enabledebug, hooks are default no-ops
104+
% Hooks activate from the presence of a hooks dict; enabledebug is not required
105105
%
106106
/uk.co.terryburton.bwipp.global_ctx <<
107-
/hooks << /_test.nodebug.hook { pop pop /_test.nodebug.hook_wrong } >>
107+
/hooks << /_test.nodebug.hook { pop pop /_test.nodebug.hook_ran } >>
108108
>> def
109109

110110
{
111111
10 dict begin
112112
/_test.nodebug.enc [/_test.nodebug.hook] setuphooks
113113
(phase) _test.nodebug.enc._test.nodebug.hook
114-
true
115114
end
116-
} true isEqual
115+
} /_test.nodebug.hook_ran isEqual
117116

118117

119118
%

0 commit comments

Comments
 (0)