I guess I solved my problems:
I made a small script to copy pdl's typemap to the directory
containing the .pd file:

         our $VERSION = '0.008';

         # Copy pdl's typemap to this directory

         use strict;
         use warnings;
         use File::Copy;
         use PDL::Core::Dev;
         my $file=PDL::Core::Dev::PDL_TYPEMAP;
         my $detination="lib/Photonic/typemap"; #where .pd file lives
         copy($file, "lib/Photonic/typemap") 
             or die "Copy of $file to typemap failed: $!";

Then I modified the PMCode adding explicitly the PDL:: namespace as follows.

       pp_def('test', 
             Pars=>'a(); [o] b();',
             PMCode => q{ 
                        sub PDL::test { # 
                            my ($a)=@_;
                            $b=PDL->null;
                            PDL::_test_int($a, $b);
                        }
              },
             Code=> q{
                $b()=2*$a();
             },
          );
As I understand, when .pd files are compiled by PP the populate the
PDL:: namespace, but the routine defined in the PMCode was actually
defined in the package's own namespace, not in the PDL
namespace. Maybe a note in the documentation of PDL::PP might help.

Best regards,
Luis



On Sun, Feb 05, 2017 at 09:39:57PM -0600, Luis Mochan wrote:
> I got rid of the typemap mistake below by copying by hand the file
> named in
> 
>    perl -MPDL::Core::Dev -E 'say PDL::Core::Dev::PDL_TYPEMAP'
> 
> to the same directory where the .pd file lives. Is this (an automated
> version of this) a reasonable solution? Is there a cleaner one?
> 
> Anyway, the code below still doesn't work for me, because when I use
> PMCode in the package (below), use the package in a small program and
> call the test function, I get the error
> 
>    Undefined subroutine &PDL::test
> 
> If I don't use PMCode the program works fine.
> 
> Best regrards,
> Luis
> 
> 
> On Sun, Feb 05, 2017 at 08:27:23PM -0600, Luis Mochan wrote:
> > I guess that my problem originates in my not knowing how to specify
> > the appropriate typemap during the build process. I currently
> >    use Module::Build::Pluggable ('PDL', 'Fortran');
> > in my Build.PL, but I have found no information in the Module::Build
> > and related packages on how to setup the typemap. I'll appreciate any
> > advice.
> > 
> > Regards,
> > Luis
> > 
> > 
> > On Sun, Feb 05, 2017 at 11:22:00AM -0600, Luis Mochan wrote:
> > > I tried to do a simple function to try out the PMCode solution, but I'm 
> > > missing something. 
> > > The following code defines a simple function that multiplies a pdl by 2.
> > >       ...
> > >       pp_def('test', 
> > >        Pars=>'a(); [o] b();',
> > >        PMCode => q{ 
> > >                   sub test { # 
> > >                       my ($a)=@_;
> > >                       $b=PDL->null;
> > >                       _test_int($a, $b);
> > >                   }
> > >         },
> > >        Code=> q{
> > >           $b()=2*$a();
> > >        },
> > >     );
> > >       ...
> > > 
> > > The PMCode doesn't do anything useful yet. I was just trying to
> > > understand how to use it.
> > > 
> > > If I remove all of the PMCode section, I can compile and install the
> > > code and it works as expected. However, with the PMCode it produces an 
> > > error message:
> > > 
> > >      Could not find a typemap for C type 'pdl *'.  The following C types
> > >      are mapped by the current typemap: 'AV *', 'Boolean', 'CV *', 'FILE
> > >      *', 'FileHandle', 'HV *', 'I16', 'I32', 'I8', 'IV', 'InOutStream',
> > >      'InputStream', 'NV', 'OutputStream', 'PerlIO *', 'Result', 'STRLEN',
> > >      'SV *', 'SVREF', 'SysRet', 'SysRetLong', 'Time_t *', 'U16', 'U32',
> > >      'U8', 'UV', 'bool', 'bool_t', 'caddr_t', 'char', 'char *', 'char **',
> > >      'const char *', 'double', 'float', 'int', 'long', 'short', 'size_t',
> > >      'ssize_t', 'time_t', 'unsigned', 'unsigned char', 'unsigned char *',
> > >      'unsigned int', 'unsigned long', 'unsigned long *', 'unsigned short',
> > >      'void *', 'wchar_t', 'wchar_t *'
> > > 
> > > The line that produces the error in the generated xs code is:
> > > 
> > >        void
> > >        _test_int(a,b)
> > >          pdl  *a         # <=This generates the error
> > >          pdl  *b
> > >   CODE:
> > >   { pdl_test_struct  *__privtrans;
> > >    int badflag_cache = 0;
> > >    ...
> > > 
> > > 
> > > What am I doing wrong, or missing?
> > > 
> > > Regards,
> > > 
> > > Luis
> > > 
> > > 
> > > On Sat, Feb 04, 2017 at 09:33:41PM -0600, Luis Mochan wrote:
> > > > 
> > > > 
> > > > On Sat, Feb 04, 2017 at 02:56:45PM -0700, Craig DeForest wrote:
> > > > > I seem to be late to the discussion, but this is exactly what I do.  
> > > > > I make heavy use of PMCode to condition and take care of any Stupid 
> > > > > Index Tricks that are needed, then hand that in to a PP routine that 
> > > > > does the work.
> > > > > 
> > > > Thanks for the suggestion. I'll follow it.
> > > > Best regards,
> > > > Luis
> > > > 
> > > > 
> > > > -- 
> > > > 
> > > >                                                                   o
> > > > W. Luis Mochán,                      | tel:(52)(777)329-1734     /<(*)
> > > > Instituto de Ciencias Físicas, UNAM  | fax:(52)(777)317-5388     `>/   
> > > > /\
> > > > Apdo. Postal 48-3, 62251             |                           (*)/\/ 
> > > >  \
> > > > Cuernavaca, Morelos, México          | [email protected]   /\_/\__/
> > > > GPG: 791EB9EB, C949 3F81 6D9B 1191 9A16  C2DF 5F0A C52B 791E B9EB
> > > > 
> > > > 
> > > > 
> > > > ------------------------------------------------------------------------------
> > > > Check out the vibrant tech community on one of the world's most
> > > > engaging tech sites, SlashDot.org! http://sdm.link/slashdot
> > > > _______________________________________________
> > > > pdl-general mailing list
> > > > [email protected]
> > > > https://lists.sourceforge.net/lists/listinfo/pdl-general
> > > > 
> > > 
> > > -- 
> > > 
> > >                                                                   o
> > > W. Luis Mochán,                      | tel:(52)(777)329-1734     /<(*)
> > > Instituto de Ciencias Físicas, UNAM  | fax:(52)(777)317-5388     `>/   /\
> > > Apdo. Postal 48-3, 62251             |                           (*)/\/  \
> > > Cuernavaca, Morelos, México          | [email protected]   /\_/\__/
> > > GPG: 791EB9EB, C949 3F81 6D9B 1191 9A16  C2DF 5F0A C52B 791E B9EB
> > > 
> > > 
> > > 
> > > ------------------------------------------------------------------------------
> > > Check out the vibrant tech community on one of the world's most
> > > engaging tech sites, SlashDot.org! http://sdm.link/slashdot
> > > _______________________________________________
> > > pdl-general mailing list
> > > [email protected]
> > > https://lists.sourceforge.net/lists/listinfo/pdl-general
> > > 
> > 
> > -- 
> > 
> >                                                                   o
> > W. Luis Mochán,                      | tel:(52)(777)329-1734     /<(*)
> > Instituto de Ciencias Físicas, UNAM  | fax:(52)(777)317-5388     `>/   /\
> > Apdo. Postal 48-3, 62251             |                           (*)/\/  \
> > Cuernavaca, Morelos, México          | [email protected]   /\_/\__/
> > GPG: 791EB9EB, C949 3F81 6D9B 1191 9A16  C2DF 5F0A C52B 791E B9EB
> > 
> > 
> > 
> > ------------------------------------------------------------------------------
> > Check out the vibrant tech community on one of the world's most
> > engaging tech sites, SlashDot.org! http://sdm.link/slashdot
> > _______________________________________________
> > pdl-general mailing list
> > [email protected]
> > https://lists.sourceforge.net/lists/listinfo/pdl-general
> > 
> 
> -- 
> 
>                                                                   o
> W. Luis Mochán,                      | tel:(52)(777)329-1734     /<(*)
> Instituto de Ciencias Físicas, UNAM  | fax:(52)(777)317-5388     `>/   /\
> Apdo. Postal 48-3, 62251             |                           (*)/\/  \
> Cuernavaca, Morelos, México          | [email protected]   /\_/\__/
> GPG: 791EB9EB, C949 3F81 6D9B 1191 9A16  C2DF 5F0A C52B 791E B9EB
> 
> 
> 
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, SlashDot.org! http://sdm.link/slashdot
> _______________________________________________
> pdl-general mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/pdl-general
> 

-- 

                                                                  o
W. Luis Mochán,                      | tel:(52)(777)329-1734     /<(*)
Instituto de Ciencias Físicas, UNAM  | fax:(52)(777)317-5388     `>/   /\
Apdo. Postal 48-3, 62251             |                           (*)/\/  \
Cuernavaca, Morelos, México          | [email protected]   /\_/\__/
GPG: 791EB9EB, C949 3F81 6D9B 1191 9A16  C2DF 5F0A C52B 791E B9EB



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
pdl-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pdl-general

Reply via email to