summaryrefslogtreecommitdiff
path: root/regen/embed.pl
diff options
context:
space:
mode:
authorYves Orton <demerphq@gmail.com>2016-10-19 22:44:45 +0200
committerYves Orton <demerphq@gmail.com>2016-10-19 22:44:45 +0200
commit2155384086267a57ee889c698fad3a1380105303 (patch)
treebce77c9b06c2c056829e99d5074425965c8b3fd5 /regen/embed.pl
parent04a83e5bd7a0783edd6a771c965154e14a103644 (diff)
downloadperl-2155384086267a57ee889c698fad3a1380105303.tar.gz
Add a way to have functions with a trailing depth argument under debugging
In the regex engine it can be useful in debugging mode to maintain a depth counter, but in normal mode this argument would be unused. This allows us to define functions in embed.fnc with a "W" flag which use _pDEPTH and _aDEPTH defines which effectively define/pass through a U32 depth parameter to the macro wrappers. These defines are similar to the existing aTHX and pTHX parameters.
Diffstat (limited to 'regen/embed.pl')
-rwxr-xr-xregen/embed.pl14
1 files changed, 12 insertions, 2 deletions
diff --git a/regen/embed.pl b/regen/embed.pl
index 0b1ed0d943..50ca2eb712 100755
--- a/regen/embed.pl
+++ b/regen/embed.pl
@@ -75,10 +75,11 @@ my ($embed, $core, $ext, $api) = setup_embed();
}
my ($flags,$retval,$plain_func,@args) = @$_;
- if ($flags =~ / ( [^AabDdEfiMmnOoPpRrsUXx] ) /x) {
+ if ($flags =~ / ( [^AabDdEfiMmnOoPpRrsUWXx] ) /x) {
warn "flag $1 is not legal (for function $plain_func)";
}
my @nonnull;
+ my $has_depth = ( $flags =~ /W/ );
my $has_context = ( $flags !~ /n/ );
my $never_returns = ( $flags =~ /r/ );
my $binarycompat = ( $flags =~ /b/ );
@@ -161,6 +162,7 @@ my ($embed, $core, $ext, $api) = setup_embed();
else {
$ret .= "void" if !$has_context;
}
+ $ret .= " _pDEPTH" if $has_depth;
$ret .= ")";
my @attrs;
if ( $flags =~ /r/ ) {
@@ -321,7 +323,15 @@ sub embed_h {
$ret .= "\t" x ($t < 4 ? 4 - $t : 1);
$ret .= full_name($func, $flags) . "(aTHX";
$ret .= "_ " if $alist;
- $ret .= $alist . ")\n";
+ $ret .= $alist;
+ if ($flags =~ /W/) {
+ if ($alist) {
+ $ret .= " _aDEPTH";
+ } else {
+ die "Can't use W without other args (currently)";
+ }
+ }
+ $ret .= ")\n";
}
$ret = "#ifndef NO_MATHOMS\n$ret#endif\n" if $flags =~ /b/;
}