Skip to content

Commit

Permalink
pdlperl.h no need be .PL
Browse files Browse the repository at this point in the history
  • Loading branch information
mohawk2 committed Nov 13, 2024
1 parent 0c36b28 commit ecddab6
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 40 deletions.
1 change: 0 additions & 1 deletion Basic/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
lib/PDL/Core.c
lib/PDL/Core/pdl.h
lib/PDL/Core/pdlperl.h
script/pdl
6 changes: 3 additions & 3 deletions Basic/Makefile.PL
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ ${pdlroot}$::Config{exe_ext} : ${pdlroot}.c
\t\$(CC) \$(CFLAGS) \$(LDFLAGS) \$(CCCDLFLAGS) ${pdlroot}.c -o \$\@
EOT
my $typespm = catfile(qw(lib PDL Types.pm));
for (qw(pdl.h pdlperl.h)) {
for (qw(pdl.h)) {
my $base = "lib/PDL/Core/$_"; # no catfile as init_PM uses File::Find which normalises to /
$text .= "$base :: $base.PL $typespm\n\t\$(PERLRUN) $base.PL $base\n";
}
Expand Down Expand Up @@ -98,7 +98,7 @@ WriteMakefile(
},
clean => { FILES => join ' ',
qw(MANIFEST.bak _Inline/ .inlinepdlpp/ .inlinewith/ .pptest/), @cleanup,
(map catfile(qw(lib PDL Core), $_), qw(pdl.h pdlperl.h)),
catfile(qw(lib PDL Core pdl.h)),
},
NO_MYMETA => 1,
);
Expand All @@ -110,7 +110,7 @@ sub init_PM {
my ($self) = @_;
$self->SUPER::init_PM;
my ($pm, $plf) = @$self{qw(PM PL_FILES)};
for my $f (grep /pdl(?:perl)?\.h\.PL$/, keys %$pm) {
for my $f (grep /pdl\.h\.PL$/, keys %$pm) {
$pm->{ _nopl($f) } = _nopl(delete $pm->{$f}); # dealing in postamble but still install
}
for my $f (grep /\.PL$/, keys %$pm) {
Expand Down
47 changes: 13 additions & 34 deletions Basic/lib/PDL/Core/pdlperl.h.PL → Basic/lib/PDL/Core/pdlperl.h
Original file line number Diff line number Diff line change
@@ -1,19 +1,3 @@
use strict;
use warnings;

require './lib/PDL/Types.pm';

my $file = shift @ARGV;
print "Extracting $file\n";
open OUT,">$file" or die "Can't create $file: $!";
chmod 0644, $file;

print OUT sprintf qq{#line %d "%s"\n}, __LINE__ + 2, __FILE__;
print OUT <<'EOF';
/*
* THIS FILE IS GENERATED FROM pdlperl.h.PL! Do NOT edit!
*/
#ifndef __PDLPERL_H
#define __PDLPERL_H

Expand Down Expand Up @@ -180,27 +164,23 @@ static inline pdl *PDL_XS_pdlinit(pTHX_ char *objname, HV *bless_stash, SV *to_p
outany.value.C = (PDL_CDouble)(vals[0] + I * vals[1]); \
} while (0)

#define ANYVAL_UNSIGNED_X(outsv, inany, sym, ctype, ppsym, ...) \
sv_setuv(outsv, (UV)(inany.value.ppsym));
#define ANYVAL_SIGNED_X(outsv, inany, sym, ctype, ppsym, ...) \
sv_setiv(outsv, (IV)(inany.value.ppsym));
#define ANYVAL_FLOATREAL_X(outsv, inany, sym, ctype, ppsym, ...) \
sv_setnv(outsv, (NV)(inany.value.ppsym));
#define ANYVAL_COMPLEX_X(outsv, inany, sym, ctype, ppsym, shortctype, defbval, realctype, floatsuffix, ...) \
PDL_MAKE_PERL_COMPLEX(outsv, creal ## floatsuffix(inany.value.ppsym), cimag ## floatsuffix(inany.value.ppsym));
#define ANYVAL_TO_SV(outsv,inany) do { switch (inany.type) { \
EOF
for (PDL::Types::types()) {
print OUT "case @{[$_->sym]}: ";
if ($_->real) {
my $upper = uc(my $letter = $_->unsigned ? 'u' : $_->integer ? 'i' : 'n');
print OUT "sv_set${letter}v(outsv, (${upper}V)(inany.value.".$_->ppsym."))";
} else {
my ($fs, $ppsym) = ($_->floatsuffix, $_->ppsym);
print OUT "PDL_MAKE_PERL_COMPLEX(outsv, creal$fs(inany.value.$ppsym), cimag$fs(inany.value.$ppsym))"
}
print OUT "; break; \\\n";
}
print OUT <<'EOF';
default: outsv = &PL_sv_undef; \
PDL_TYPELIST_UNSIGNED(PDL_GENERICSWITCH_CASE, ANYVAL_UNSIGNED_X, (outsv,inany,),) \
PDL_TYPELIST_SIGNED(PDL_GENERICSWITCH_CASE, ANYVAL_SIGNED_X, (outsv,inany,),) \
PDL_TYPELIST_FLOATREAL(PDL_GENERICSWITCH_CASE, ANYVAL_FLOATREAL_X, (outsv,inany,),) \
PDL_TYPELIST_COMPLEX(PDL_GENERICSWITCH_CASE, ANYVAL_COMPLEX_X, (outsv,inany,),) \
default: outsv = &PL_sv_undef; \
} \
} while (0)
EOF

print OUT sprintf qq{#line %d "%s"\n}, __LINE__ + 2, __FILE__;
print OUT <<'EOF';
/* Check minimum datatype required to represent number */
#define PDL_TESTTYPE(sym, ctype, v) {ctype foo = v; if (v == foo) return sym;}
static inline int _pdl_whichdatatype_uint(UV uv) {
Expand All @@ -225,4 +205,3 @@ static inline int _pdl_whichdatatype_double(NV nv) {

/* __PDLPERL_H */
#endif
EOF
2 changes: 1 addition & 1 deletion MANIFEST
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ Basic/lib/PDL/Core/pdlcore.c
Basic/lib/PDL/Core/pdlcore.h
Basic/lib/PDL/Core/pdlmagic.c
Basic/lib/PDL/Core/pdlmagic.h
Basic/lib/PDL/Core/pdlperl.h.PL
Basic/lib/PDL/Core/pdlperl.h
Basic/lib/PDL/Core/pdlutil.c
Basic/lib/PDL/Core/ppport.h
Basic/lib/PDL/Core/typemap
Expand Down
1 change: 0 additions & 1 deletion MANIFEST.SKIP
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ RCS
^Basic/Bad/Bad\..*
^Basic/lib/PDL/Core\.c$
^Basic/lib/PDL/Core/pdl\.h$
^Basic/lib/PDL/Core/pdlperl\.h$
^Basic/IO-Misc/Misc\..*
^Basic/IO-Pnm/Pnm\..*
^Basic/IO-Storable/Storable\..*
Expand Down

0 comments on commit ecddab6

Please sign in to comment.