|
130 | 130 | : yourself, and from within it, refer to the function in its full |
131 | 131 | : 'Perl_' form with any necessary thread context parameter. |
132 | 132 | : |
| 133 | +: AUTOMATIC PARAMETER SANITY CHECKING |
| 134 | +: |
| 135 | +: regen/embed.pl generates macros for each entry (unless excluded by the G |
| 136 | +: flag) that do a bit of parameter validation. If your element is named |
| 137 | +: 'foo()', the generated macro will be named 'PERL_ARGS_ASSERT_FOO'. You |
| 138 | +: should place a call to that macro before any other code in foo(). It will |
| 139 | +: automatically expand to whatever checking is currently generated for foo |
| 140 | +: (often none). These are in the form of assert() calls, so only are |
| 141 | +: activated for DEBUGGING builds. |
| 142 | +: |
| 143 | +: You must specify what checking is needed for all pointer arguments. If the |
| 144 | +: pointer is allowed to point to NULL, prefix that argument with 'NULLOK' |
| 145 | +: (following the template of the many entries in this file that have that). |
| 146 | +: If it can't be NULL, use 'NN' (again many entries herein do that). |
| 147 | +: The reason for this requirement is to tell the maintainers that you have |
| 148 | +: considered the question about the argument, and this is the answer. |
| 149 | +: |
| 150 | +: For a numeric argument, you may specify that it can't be 0 by using 'NZ' |
| 151 | +: |
| 152 | +: regen/embed.pl may automatically add further checking for any argument as |
| 153 | +: it deems desirable. You can override this by specifying 'NOCHECK' |
| 154 | +: |
| 155 | +: Currently this further checking is just for pointer parameters that |
| 156 | +: point to AVs, CVs or HVs. The check is that the SV being pointed to is |
| 157 | +: of the intended type, by inspecting its SvTYPE(). For some functions |
| 158 | +: this check may be inappropriate, as in rare cases the arguments passed |
| 159 | +: may not be of the correct type. As already mentioned, NOCHECK |
| 160 | +: suppresses this check. |
| 161 | +: |
| 162 | +: Currently, it is optional to include an empty ARGS_ASSERT macro in your |
| 163 | +: functions. But a porting test enforces that a non-empty one is included. |
| 164 | +: The call should be at the top of your function so that the sanity checks |
| 165 | +: have passed before anything tries to use an argument. When writing a new |
| 166 | +: function, add the macro even if not required, and you'll never have to go |
| 167 | +: back and add one later when more checks do get added |
| 168 | +: |
| 169 | +: AUTOMATIC DOCUMENTATION GENERATION |
| 170 | +: |
133 | 171 | : Just below is a description of the relevant parts of the automatic |
134 | 172 | : documentation generation system which heavily involves this file. Below that |
135 | 173 | : is a description of all the flags used in this file. |
|
275 | 313 | : |
276 | 314 | : porting/diag.t checks some things for consistency based on this file. |
277 | 315 | : |
| 316 | +: FLAGS REFERENCE |
| 317 | +: |
278 | 318 | : The remainder of these introductory comments detail all the possible flags: |
279 | 319 | : |
280 | 320 | : 'A' Both long and short names are accessible fully everywhere (usually |
|
388 | 428 | : flag even on a format function is if the format would generate error: |
389 | 429 | : format string argument is not a string type |
390 | 430 | : |
391 | | -: 'G' Suppress empty PERL_ARGS_ASSERT_foo macro. Normally such a macro is |
392 | | -: generated for all entries for functions 'foo' in this file. If there |
393 | | -: is a pointer argument to 'foo', it needs to be declared in this file |
394 | | -: as either NN or NULLOK, and the function definition must call its |
395 | | -: corresponding PERL_ARGS_ASSERT_foo macro (a porting test ensures this) |
396 | | -: which asserts at runtime (under DEBUGGING builds) that NN arguments |
397 | | -: are not NULL. If there aren't NN arguments, use of this macro is |
398 | | -: optional. Rarely, a function will define its own PERL_ARGS_ASSERT_foo |
399 | | -: macro, and in those cases, adding this flag to its entry in this file |
400 | | -: will suppress the normal one. It is not possible to suppress the |
401 | | -: generated macro if it isn't optional, that is, if there is at least |
402 | | -: one NN argument. |
403 | | -: |
404 | | -: proto.h: PERL_ARGS_ASSERT macro is not defined unless the function |
405 | | -: has NN arguments |
| 431 | +: 'G' Suppress empty PERL_ARGS_ASSERT_foo macro. Normally such a macro is |
| 432 | +: generated for all entries for functions 'foo' in this file. The macro |
| 433 | +: is empty unless regen/embed.pl deems that there should be assert() |
| 434 | +: calls to verify the sanity of some or all of foo's arguments. |
| 435 | +: |
| 436 | +: proto.h: An empty PERL_ARGS_ASSERT macro is not defined |
406 | 437 | : |
407 | 438 | : 'h' Hide any documentation that would normally go into perlapi or |
408 | 439 | : perlintern. This is typically used when the documentation is actually |
|
623 | 654 | : indicate that it does not have enough information to generate a |
624 | 655 | : proper test case. |
625 | 656 | : |
626 | | -: In this file, pointer parameters that must not be passed NULLs should be |
627 | | -: prefixed with NN. |
628 | | -: |
629 | | -: And, pointer parameters that may be NULL should be prefixed with NULLOK. |
630 | | -: This has no effect on output yet. It's a notation for the maintainers to |
631 | | -: know "I have defined whether NULL is OK or not" rather than having neither |
632 | | -: NULL or NULLOK, which is ambiguous. |
633 | | -: |
634 | | -: Pointer parameters that point to AVs, CVs or HVs will generate additional |
635 | | -: checks in the arguments assertion macro, that check on entry to the |
636 | | -: function that the SV being pointed to is of the intended type, by |
637 | | -: inspecting its SvTYPE(). For some functions this check may be inappropriate |
638 | | -: as in rare cases the arguments passed may not be of the correct type. To |
639 | | -: skip checking on an argument type, prefix its type with NOCHECK. |
640 | | -: |
641 | | -: Numeric arguments may also be prefixed with NZ, which will cause the |
642 | | -: appropriate asserts to be generated to validate that this is the case. |
643 | | -: |
644 | | -: Flags should be sorted asciibetically. |
| 657 | +: regen/embed.pl will rewrite this file with the entries within each condition |
| 658 | +: sorted in a (somewhat-modified) dictionary order, and each entry's flags |
| 659 | +: sorted asciibetically. |
645 | 660 | : |
646 | 661 | : Please keep the next line *BLANK* |
647 | 662 |
|
|
0 commit comments