Hello,
Is it possible/recommendable to have more than one pdlpp file per
module?  I noticed that the PDL itself never does this (it puts each
*.pd in its own directory and with its own Makefile.PL, referenced by
parent Makefile.PL's).

I tried to see if I could accomplish this... below are four files
(Makefile.PL, Sample1.pd, Sample2.pd, and t/test.t).  Sample1.pd (to be
Foo::Sample1) and Sample2.pd (to be Foo::Sample2) have dummy pp_def's. 
In Makefile.PL, I tried to generalize the example in PDL::PP... I added
entries for PM, OBJECT, MAN3PODS, and clean, and concatenated the
pdlpp_postamble calls in MY::postamble(). NAME was set to Foo.

After make-ing, I run 'prove -vlbc t/test.t', and get:

 t/test.t .. Can't locate loadable object for module Foo::Sample1 in
 @INC (@INC contains: [... snip ...]) at t/test.t line 6.

because apparently Foo::Sample1 tries to load
auto/Foo/Sample1/Sample1.so, but PDL builds auto/Foo/Foo.so instead
instead, based on the EUMM's NAME argument.  

Is there an easy, recommended way around this?
 
 ### Sample1.pd
 pp_def(
     'mysumover1',
     Pars => 'a(n); [o]b();',
     Code => q{ $GENERIC() tmp=0; loop(n) %{ tmp += $a(); %} $b() = tmp;
     },
 );
 pp_done();

 ### Sample2.pd
 pp_def(
     'mysumover2',
     Pars => 'a(n); [o]b();',
     Code => q{ $GENERIC() tmp=0; loop(n) %{ tmp += $a(); %} $b() = tmp;
     },
 );
 pp_done();

 ### Makefile.PL
 
 use PDL::Core::Dev;            # Pick up development utilities
 use ExtUtils::MakeMaker;
 
 my $package1 = ["Sample1.pd","Sample1","Foo::Sample1"];
 my $package2 = ["Sample2.pd","Sample2","Foo::Sample2"];
 
 my %hash = (
     'MAN3PODS' => {
         'Sample1.pm' => '$(INST_MAN3DIR)/Foo::Sample1.$(MAN3EXT)',
         'Sample2.pm' => '$(INST_MAN3DIR)/Foo::Sample2.$(MAN3EXT)',
     },
     'TYPEMAPS' => [
     '/opt/perl/lib/site_perl/5.16.0/x86_64-linux/PDL/Core/typemap.pdl'
     ],
     'NAME' => 'Foo',
     'LIBS' => [],
     'INC' => '-I/opt/perl/lib/site_perl/5.16.0/x86_64-linux/PDL/Core ',
     'OBJECT' => 'Sample1$(OBJ_EXT) Sample2$(OBJ_EXT)',
     'clean' => {
         'FILES' => 'Sample1.xs Sample1.pm Sample1$(OBJ_EXT) Sample1.c
         Sample2.xs Sample2.pm Sample2$(OBJ_EXT) Sample2.c',
     },
     'PM' => {
         'Sample1.pm' => '$(INST_LIBDIR)/Foo/Sample1.pm',
         'Sample2.pm' => '$(INST_LIBDIR)/Foo/Sample2.pm',
     }
 );
 
 $hash{'VERSION'} = '0.0.1';
 WriteMakefile(%hash);
 
 sub MY::postamble { 
     join "\n", pdlpp_postamble($package1), pdlpp_postamble($package2);
 }

 ### t/test.t

 use strict;
 use warnings;
 use Test::More qw(no_plan);
 use PDL;
 use Foo::Sample1;
 use Foo::Sample2;
 use List::Util qw//;
 
 my %v = (
     first  => long (1 .. 10),
     second => long (-5 .. 19),
     third  => long (72 .. 100),
 );
 
 while (my ($name,$pdl) = each %v) {
     is($pdl->mysumover1(), List::Util::sum(list($pdl)), $name);
     is($pdl->mysumover2(), List::Util::sum(list($pdl)), $name);
 }

 
thanks,
Tom

_______________________________________________
Perldl mailing list
[email protected]
http://mailman.jach.hawaii.edu/mailman/listinfo/perldl

Reply via email to