Skip to content

Commit

Permalink
zap "PDL_COMMENT" - for multiline nestable comment, just use #if 0
Browse files Browse the repository at this point in the history
  • Loading branch information
mohawk2 committed Nov 13, 2024
1 parent 359d72d commit c311500
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 34 deletions.
10 changes: 5 additions & 5 deletions Basic/lib/PDL/Core/pdl.h.PL
Original file line number Diff line number Diff line change
Expand Up @@ -640,13 +640,13 @@ typedef struct pdl_slice_args {
register PDL_Indx __tdims1 = __tdims[1]; \
register PDL_Indx *__offsp = PDL->get_threadoffsp(&(brc)); \
if (!__offsp ) return PDL->make_error_simple(PDL_EFATAL, "Error in get_threadoffsp"); \
PDL_COMMENT("incs are each pdl's stride, declared at func start") \
PDL_COMMENT("offs are each pthread's starting offset into each pdl") \
/* incs are each pdl's stride, declared at func start */ \
/* offs are each pthread's starting offset into each pdl */ \
ptrStep1 \
for( __tind1 = 0 ; \
__tind1 < __tdims1 ; \
__tind1++ \
PDL_COMMENT("step by tinc1, undoing inner-loop of tinc0*tdims0") \
/* step by tinc1, undoing inner-loop of tinc0*tdims0 */ \
PDL_EXPAND ptrStep2 \
) \
{ \
Expand All @@ -655,11 +655,11 @@ typedef struct pdl_slice_args {
__tind0++ \
PDL_EXPAND ptrStep3 \
) { \
PDL_COMMENT("This is the tightest loop. Make sure inside is optimal.")
/* This is the tightest loop. Make sure inside is optimal. */
#define PDL_BROADCASTLOOP_END(brc, ptrStep1) \
} \
} \
PDL_COMMENT("undo outer-loop of tinc1*tdims1, and original per-pthread offset") \
/* undo outer-loop of tinc1*tdims1, and original per-pthread offset */ \
ptrStep1 \
__brcloopval = PDL->iterbroadcastloop(&(brc),2); \
if ( __brcloopval < 0 ) return PDL->make_error_simple(PDL_EFATAL, "Error in iterbroadcastloop"); \
Expand Down
23 changes: 4 additions & 19 deletions Basic/lib/PDL/PP.pm
Original file line number Diff line number Diff line change
Expand Up @@ -454,21 +454,6 @@ our $header_c = pp_line_numbers(__LINE__, <<'EOF');
* THIS FILE WAS GENERATED BY PDL::PP from %s! Do not modify!
*/
#define PDL_COMMENT(comment)
PDL_COMMENT("This preprocessor symbol is used to add commentary in the PDL ")
PDL_COMMENT("autogenerated code. Normally, one would use typical C-style ")
PDL_COMMENT("multiline comments (i.e. /* comment */). However, because such ")
PDL_COMMENT("comments do not nest, it's not possible for PDL::PP users to ")
PDL_COMMENT("comment-out sections of code using multiline comments, as is ")
PDL_COMMENT("often the practice when debugging, for example. So, when you ")
PDL_COMMENT("see something like this: ")
PDL_COMMENT(" ")
PDL_COMMENT("Memory access")
PDL_COMMENT(" ")
PDL_COMMENT("just think of it as a C multiline comment like: ")
PDL_COMMENT(" ")
PDL_COMMENT(" /* Memory access */ ")
#define PDL_FREE_CODE(trans, destroy, comp_free_code, ntpriv_free_code) \
if (destroy) { \
comp_free_code \
Expand All @@ -483,11 +468,11 @@ PDL_COMMENT(" /* Memory access */ ")
#include "pdl.h"
#include "pdlcore.h"
#define PDL %s
extern Core* PDL; PDL_COMMENT("Structure hold core C functions")
extern Core* PDL; /* Structure hold core C functions */
EOF
our $header_xs = <<'EOF';
Core* PDL = NULL; PDL_COMMENT("Structure hold core C functions")
Core* PDL = NULL; /* Structure hold core C functions */
MODULE = %1$s PACKAGE = %2$s PREFIX=pdl_run_
Expand All @@ -496,8 +481,8 @@ PROTOTYPES: DISABLE
EOF
our $header_xsboot = pp_line_numbers(__LINE__, <<'EOF');
BOOT:
PDL_COMMENT("Get pointer to structure of core shared C routines")
PDL_COMMENT("make sure PDL::Core is loaded")
/* Get pointer to structure of core shared C routines */
/* make sure PDL::Core is loaded */
EOF

use Config;
Expand Down
16 changes: 8 additions & 8 deletions Basic/lib/PDL/PP/PDLCode.pm
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,11 @@ sub new {
$this->{Code} = (join '',sort values %$sizeprivs).
($dont_add_brcloop?'':join '', map "$_\n",
'if (!$PRIV(broadcast).incs) $CROAK("broadcast.incs NULL");',
'PDL_COMMENT("broadcastloop declarations")',
'/* broadcastloop declarations */',
'int __brcloopval;',
'register PDL_Indx __tind0,__tind1; PDL_COMMENT("counters along dim")',
'register PDL_Indx __tind0,__tind1; /* counters along dim */',
'register PDL_Indx __tnpdls = $PRIV(broadcast).npdls;',
'PDL_COMMENT("dims here are how many steps along those dims")',
'/* dims here are how many steps along those dims */',
(map "register PDL_Indx __tinc0_$parnames->[$_] = PDL_BRC_INC(\$PRIV(broadcast).incs,__tnpdls,$_,0);", 0..$#$parnames),
(map "register PDL_Indx __tinc1_$parnames->[$_] = PDL_BRC_INC(\$PRIV(broadcast).incs,__tnpdls,$_,1);", 0..$#$parnames),
eol_protect(
Expand Down Expand Up @@ -416,13 +416,13 @@ sub get_str {
EOF
return $good_str if !defined(my $bad = $this->[1]);
my $str = <<EOF;
if ( \$PRIV(bvalflag) ) { PDL_COMMENT("** do 'bad' Code **")
if ( \$PRIV(bvalflag) ) { /* ** do 'bad' Code ** */
#define PDL_BAD_CODE
#define PDL_IF_BAD(t,f) t
@{[ PDL::PP::indent 2, $bad->get_str($parent,$context)
]} #undef PDL_BAD_CODE
#undef PDL_IF_BAD
} else { PDL_COMMENT("** else do 'good' Code **")
} else { /* ** else do 'good' Code ** */
@{[ PDL::PP::indent 2, $good_str
]}}
EOF
Expand Down Expand Up @@ -469,14 +469,14 @@ sub myprelude { my($this,$parent,$context) = @_;
$loopend =~ /^-/ ? "(__${loopdim}_size$loopend)" :
"PDLMIN($loopend, (__${loopdim}_size))";
}
$text .= "{PDL_COMMENT(\"Open $_\") PDL_EXPAND2(register PDL_Indx $loopvar=$loopstart, $loopstopvar=$loopend); for(; $loopvar$cmp$loopstopvar; $loopvar+=$loopinc) {";
$text .= "{/* Open $_ */ PDL_EXPAND2(register PDL_Indx $loopvar=$loopstart, $loopstopvar=$loopend); for(; $loopvar$cmp$loopstopvar; $loopvar+=$loopinc) {";
$i;
} @{$this->[0]};
$text;
}
sub mypostlude { my($this,$parent,$context) = @_;
splice @$context, - ($#{$this->[0]}+1);
return join '', map "}} PDL_COMMENT(\"Close $_\")", @{$this->[0]};
return join '', map "}} /* Close $_ */", @{$this->[0]};
}

package PDL::PP::GenericSwitch;
Expand Down Expand Up @@ -509,7 +509,7 @@ sub myprelude {
push @{$parent->{Gencurtype}}, undef; # so that $GENERIC can get at it
die "ERROR: need to rethink NaN support in GenericSwitch\n"
if defined $this->[1] and $parent->{ftypes_type};
qq[switch ($this->[3]) { PDL_COMMENT("Start generic switch")\n];
qq[switch ($this->[3]) { /* Start generic switch */\n];
}

my @GENTYPE_ATTRS = qw(integer real unsigned);
Expand Down
3 changes: 1 addition & 2 deletions Libtmp/LegacyComplex/complex.pd
Original file line number Diff line number Diff line change
Expand Up @@ -765,10 +765,9 @@ pp_def 'Cpow',
$GENERIC() ar = $a(m=>0), ai = $a(m=>1);
$GENERIC() br = $b(m=>0), bi = $b(m=>1);
PDL_COMMENT(real ndarray (scalar or 1-ndarray))
/* real ndarray (scalar or 1-ndarray) */
if($PDL(b)->dims[0]==0)
bi = 0;
PDL_COMMENT(printf("ar: %f ai: %f\nbr: %f bi: %f\nDimsB: %ld\n",ar,ai,br,bi,$PDL(b)->dims[0]);)
double logr, logi, x, y;
double s, c;
Expand Down

0 comments on commit c311500

Please sign in to comment.