|
14 | 14 | : real (full) name, with any appropriate thread context paramaters, thus hiding
|
15 | 15 | : that detail from the typical code.
|
16 | 16 | :
|
17 |
| -: Most macros (as opposed to functions) listed here are the complete full name. |
| 17 | +: Many macros (as opposed to functions) listed here are the complete full name, |
| 18 | +: though we may want to start converting those to have full names. |
18 | 19 | :
|
19 | 20 | : All non-static functions defined by perl need to be listed in this file.
|
20 | 21 | : embed.pl uses the entries here to construct:
|
|
157 | 158 | : and you know at a glance that the macro actually has documentation. It
|
158 | 159 | : doesn't by itself create any documentation; instead the other apidoc lines
|
159 | 160 | : pull in information specified by these lines. Many of the lines in this
|
160 |
| -: file for macros could be pulled out of here and replaced by these lines |
161 |
| -: throughout the source. It is a goal to do that as convenience dictates. |
| 161 | +: file for macros that don't also have the 'p' flag (described below) could be |
| 162 | +: pulled out of here and replaced by these lines throughout the source. It is |
| 163 | +: a goal to do that as convenience dictates. |
162 | 164 | :
|
163 | 165 | : The other apidoc lines either have the usage data as part of the line, or
|
164 | 166 | : pull in the data from this file or apidoc_defn lines.
|
|
210 | 212 | : line that begins with an '='. In particular, an '=cut' line ends that
|
211 | 213 | : documentation without introducing something new.
|
212 | 214 | :
|
213 |
| -: Various macros and other elements aren't listed here in embed.fnc. They are |
214 |
| -: documented in the same manner, but since they don't have this file to get |
215 |
| -: information from, the defining lines have the syntax and meaning they do in |
216 |
| -: this file, so it can be specified: |
| 215 | +: Various macros and other elements aren't listed here in embed.fnc (though |
| 216 | +: they could be). They are documented in the same manner, but since they don't |
| 217 | +: have this file to get information from, the defining lines have the syntax |
| 218 | +: and meaning they do in this file, so it can be specified: |
217 | 219 | :
|
218 | 220 | : =for apidoc flags|return_type|name|arg1|arg2|...|argN
|
219 | 221 | : =for apidoc_item flags|return_type|name|arg1|arg2|...|argN
|
|
301 | 303 | : functions flagged with this, the installation can run Configure with
|
302 | 304 | : the -Accflags='-DNO_MATHOMS' parameter to not even compile them.
|
303 | 305 | :
|
304 |
| -: Sometimes the function has been subsumed by a more general one (say, |
305 |
| -: by adding a flags parameter), and a macro exists with the original |
306 |
| -: short name API, and it calls the new function, bypassing this one, and |
307 |
| -: the original 'Perl_' form is being deprecated. In this case also |
308 |
| -: specify the 'M' flag. |
| 306 | +: If the function can be implemented as a macro (that evaluates its |
| 307 | +: arguments exactly once), use the 'm' and 'p' flags together to implement |
| 308 | +: this. (See the discussion under 'm'.) Another option for this is to |
| 309 | +: use the 'M' flag. |
309 | 310 | :
|
310 |
| -: Without the M flag, these functions should be deprecated, and it is an |
311 |
| -: error to not also specify the 'D' flag. |
| 311 | +: Without the m or M flags, these functions should be deprecated, and it |
| 312 | +: is an error to not also specify the 'D' flag. |
312 | 313 | :
|
313 | 314 | : The 'b' functions are normally moved to mathoms.c, but if
|
314 | 315 | : circumstances dictate otherwise, they can be anywhere, provided the
|
|
439 | 440 | : __attribute__always_inline__ is added
|
440 | 441 | :
|
441 | 442 | : 'm' Implemented as a macro; there is no function associated with this
|
442 |
| -: name, and hence no long Perl_ or S_ name. However, if the macro name |
443 |
| -: itself begins with 'Perl_', autodoc.pl will show a thread context |
444 |
| -: parameter unless the 'T' flag is specified. |
| 443 | +: name. There is no long S_ name. |
| 444 | +: |
| 445 | +: However, you may #define the macro with a long name like 'Perl_foo', |
| 446 | +: and specify the 'p' flag. This will cause an embed.h entry to be |
| 447 | +: created that #defines 'foo' as 'Perl_foo'. This can be used to make |
| 448 | +: any macro have a long name, perhaps to avoid name collisions. If |
| 449 | +: instead you define the macro as 'PERL_FOO' (all uppercase), the |
| 450 | +: embed.h entry will use all uppercase. |
| 451 | +: |
| 452 | +: It is particularly useful tp preserve backward compatibility when a |
| 453 | +: function is converted to be a macro (remembering to not create a macro |
| 454 | +: which evaluates its parameters more than once). Most of mathoms.c |
| 455 | +: could be converted to use this facility. When there is no thread |
| 456 | +: context involved, you just do something like |
| 457 | +: |
| 458 | +: #define Perl_foo(a, b, c) Perl_bar(a, b, 0, c) |
| 459 | +: |
| 460 | +: Otherwise consider this general case where there is a series of macros |
| 461 | +: that build on the previous ones by calling something with a different |
| 462 | +: name or with an extra parameter beyond what the previous one did: |
| 463 | +: |
| 464 | +: #define Perl_foo(mTHX, a) Perl_bar1(aTHX, a) |
| 465 | +: #define Perl_bar1(mTHX, a) Perl_bar2(aTHX, a, 0) |
| 466 | +: #define Perl_bar2(mTHX, a, b) Perl_bar3(aTHX, a, b, 0) |
| 467 | +: #define Perl_bar3(mTHX, a, b, c) Perl_func(aTHX_ a, b, c, 0) |
| 468 | +: |
| 469 | +: Use the formal parameter name 'mTHX,' (which stands for "macro thread |
| 470 | +: context") as the first in each macro definition, and call the next |
| 471 | +: macro in the sequence with 'aTHX,' (Note the commas). Eventually, the |
| 472 | +: sequence will end with a function call (or else there would be no need |
| 473 | +: for thread context). For that instead call it with 'aTHX_' (with an |
| 474 | +: underscore instead of a comma). |
445 | 475 | :
|
446 | 476 | : suppress proto.h entry (actually, not suppressed, but commented out)
|
447 | 477 | : suppress entry in the list of exported symbols available on all
|
448 | 478 | : platforms
|
449 |
| -: suppress embed.h entry, as the implementation should furnish the macro |
| 479 | +: suppress embed.h entry (when no 'p' flag), as the implementation |
| 480 | +: should furnish the macro |
450 | 481 | :
|
451 | 482 | : 'M' The implementation is furnishing its own macro instead of relying on
|
452 | 483 | : the automatically generated short name macro (which simply expands to
|
453 | 484 | : call the real name function). One reason to do this is if the
|
454 |
| -: parameters need to be cast from what the caller has, or if there is a |
455 |
| -: macro that bypasses this function (whose long name is being retained |
456 |
| -: for backward compatibility for those who call it with that name). An |
457 |
| -: example is when a new function is created with an extra parameter and |
458 |
| -: a wrapper macro is added that has the old API, but calls the new one |
459 |
| -: with the exta parameter set to a default. |
| 485 | +: parameters need to be cast from what the caller has. There is less |
| 486 | +: need to do this now that 'm' and 'p' together is supported. |
460 | 487 | :
|
461 | 488 | : This flag requires the 'p' flag to be specified, as there would be no
|
462 | 489 | : need to do this if the function weren't publicly accessible before.
|
|
492 | 519 | :
|
493 | 520 | : This is used for whatever reason to force the function to be called
|
494 | 521 | : with the long name. Perhaps there is a varargs issue. Use the 'M'
|
495 |
| -: flag instead for wrapper macros, and legacy-only functions should |
496 |
| -: also use 'b'. |
| 522 | +: or 'm' flags instead for wrapper macros, and legacy-only functions |
| 523 | +: should also use 'b'. |
497 | 524 | :
|
498 | 525 | : embed.h: suppress "#define foo Perl_foo"
|
499 | 526 | :
|
|
518 | 545 | :
|
519 | 546 | : proto.h: add __attribute__pure__
|
520 | 547 | :
|
521 |
| -: 'p' Function in source code has a Perl_ prefix: |
| 548 | +: 'p' Function or macro in source code has a Perl_ prefix: |
522 | 549 | :
|
523 |
| -: proto.h: function is declared as Perl_foo rather than foo |
| 550 | +: proto.h: function or macro is declared as Perl_foo rather than foo |
| 551 | +: (though the entries for macros will be commented out) |
524 | 552 | : embed.h: "#define foo Perl_foo" entries added
|
525 | 553 | :
|
526 | 554 | : 'R' Return value must not be ignored (also implied by 'a' and 'P' flags):
|
|
0 commit comments