Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add some documentation, and make tests and such slightly more forgiving.
  • Loading branch information
Craig DeForest authored and Craig DeForest committed Feb 23, 2015
1 parent dfdef89 commit 1e3c95f
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 2 deletions.
43 changes: 43 additions & 0 deletions Basic/Core/IFiles.pm
@@ -1,3 +1,40 @@
=head1 NAME
PDL::Install::Files
=head1 DESCRIPTION
This module is a stub that contains some auxiliary routines useful for
inlining PDL-aware C code into PDL programs.
It defines some auxiliary package variables and two routines that are not
normally called by users.
=head1 METHODS
=head2 deps
=for ref
Returns nothing -- stub for "Inline with => 'PDL'".
=head2 Inline
=for ref
Accepts a class and a lanaguage string.
If the language string is "C", Inline returns a hash containing TYPEMAPS, INC,
AUTO_INCLUDE, and BOOT information that are useful for autogenerated PDL-aware C
code using "Inline with => 'PDL'". The actual data are pulled from methods in
C<PDL::Core::Dev>.
If the language string is anything else, then it returns nothing.
=cut



package PDL::Install::Files;
# support ExtUtils::Depends
require PDL::Core::Dev;
Expand All @@ -19,10 +56,16 @@ foreach (@INC) {

sub deps { }
# support: use Inline with => 'PDL';

require Inline;

sub Inline {
my ($class, $lang) = @_;
return {} if $lang eq 'Pdlpp';
return unless $lang eq 'C';
unless($ENV{"PDL_Early_Inline"} // ($Inline::VERSION >= 0.68) ) {
die "PDL::Inline: requires Inline version 0.68 or higher to make sense\n (yours is $Inline::VERSION). You should upgrade Inline, \n or else set \$ENV{PDL_Early_Inline} to a true value to ignore this message.\n";
}
+{
TYPEMAPS => [ &PDL::Core::Dev::PDL_TYPEMAP ],
INC => &PDL::Core::Dev::PDL_INCLUDE,
Expand Down
6 changes: 6 additions & 0 deletions Basic/PDL.pm
Expand Up @@ -192,6 +192,12 @@ die $@ if $@;
package PDL;

# support: use Inline with => 'PDL';
# Returns a hash containing parameters accepted by recent versions of
# Inline, to tweak compilation. Not normally called by anyone but
# the Inline API.
#
# If you're trying to debug the actual code, you're looking for "IFiles.pm"
# which is currently in the Core directory. --CED 23-Feb-2015
sub Inline {
require PDL::Install::Files;
goto &PDL::Install::Files::Inline;
Expand Down
8 changes: 6 additions & 2 deletions t/inline-with.t
Expand Up @@ -23,6 +23,10 @@ BEGIN {
} or do {
plan skip_all => "Skipped: Inline not installed";
};

if( $Inline::VERSION < 0.68 ) {
plan skip_all => "Skipped: Inline too early a version for Inline with=>'foo' form";
}
}
use File::Path;
END {
Expand All @@ -33,10 +37,10 @@ END {
}
}
}
rmtree $inline_test_dir if -d $inline_test_dir;
# rmtree $inline_test_dir if -d $inline_test_dir;
}

# use Inline 'INFO'; # use to generate lots of info
use Inline 'INFO'; # use to generate lots of info
use Inline with => 'PDL';
use Inline 'C';

Expand Down

0 comments on commit 1e3c95f

Please sign in to comment.