diff --git a/Basic/.gitignore b/Basic/.gitignore index 484c8f696..002407891 100644 --- a/Basic/.gitignore +++ b/Basic/.gitignore @@ -1,4 +1,3 @@ lib/PDL/Core.c lib/PDL/Core/pdl.h -lib/PDL/Core/pdlperl.h script/pdl diff --git a/Basic/Makefile.PL b/Basic/Makefile.PL index c58fd3cd9..6e0845be6 100644 --- a/Basic/Makefile.PL +++ b/Basic/Makefile.PL @@ -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"; } @@ -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, ); @@ -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) { diff --git a/Basic/lib/PDL/Core/pdlperl.h.PL b/Basic/lib/PDL/Core/pdlperl.h similarity index 88% rename from Basic/lib/PDL/Core/pdlperl.h.PL rename to Basic/lib/PDL/Core/pdlperl.h index b63639b5f..837b775e5 100644 --- a/Basic/lib/PDL/Core/pdlperl.h.PL +++ b/Basic/lib/PDL/Core/pdlperl.h @@ -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 @@ -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) { @@ -225,4 +205,3 @@ static inline int _pdl_whichdatatype_double(NV nv) { /* __PDLPERL_H */ #endif -EOF diff --git a/MANIFEST b/MANIFEST index 34c5d5767..f871bcd4c 100644 --- a/MANIFEST +++ b/MANIFEST @@ -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 diff --git a/MANIFEST.SKIP b/MANIFEST.SKIP index b688fd912..9947f6baf 100644 --- a/MANIFEST.SKIP +++ b/MANIFEST.SKIP @@ -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\..*