| 1 | =head1 NAME | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | PDL::Exporter - PDL export control | ||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | Implements the standard conventions for | ||||||||||||||||||||||||||||
| 8 | import of PDL modules in to the namespace | ||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | Hopefully will be extended to allow fine | ||||||||||||||||||||||||||||
| 11 | control of which namespace is used. | ||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | use PDL::Exporter; | ||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | use PDL::MyModule; # Import default function list ':Func' | ||||||||||||||||||||||||||||
| 18 | use PDL::MyModule ''; # Import nothing (OO) | ||||||||||||||||||||||||||||
| 19 | use PDL::MyModule '...'; # Same behaviour as Exporter | ||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | =head1 SUMMARY | ||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | C<PDL::Exporter> is a drop-in replacement for the L<Exporter> | ||||||||||||||||||||||||||||
| 24 | module. It confers the standard PDL export conventions to your module. | ||||||||||||||||||||||||||||
| 25 | Usage is fairly straightforward and best illustrated by an example. The | ||||||||||||||||||||||||||||
| 26 | following shows typical usage near the top of a simple PDL module: | ||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | package PDL::MyMod; | ||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | use strict; | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | # For Perl 5.6: | ||||||||||||||||||||||||||||
| 34 | use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); | ||||||||||||||||||||||||||||
| 35 | # For more modern Perls: | ||||||||||||||||||||||||||||
| 36 | our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS); | ||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | require PDL::Exporter; | ||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | @ISA = qw(PDL::Exporter); | ||||||||||||||||||||||||||||
| 41 | @EXPORT_OK = qw(inc myfunc); # these will be exported by default | ||||||||||||||||||||||||||||
| 42 | %EXPORT_TAGS = (Func=>[@EXPORT_OK], | ||||||||||||||||||||||||||||
| 43 | Internal => [qw/internfunc1 internfunc2/], | ||||||||||||||||||||||||||||
| 44 | ); | ||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | # ... body of your module | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 1; # end of simple module | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | =cut | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | package PDL::Exporter; | ||||||||||||||||||||||||||||
| 54 | 70 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 55 | 70 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | 70 | ▶ | use Exporter; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | sub import { | ||||||||||||||||||||||||||||
| 60 | 3303 | ▶ | my $pkg = shift; | ||||||||||||||||||||||||||
|
Subroutine
import: called CC=6 SCAR=17.9
| |||||||||||||||||||||||||||||
| 61 | 3303 | ▶ | return if $pkg eq 'PDL::Exporter'; # Module don't export thyself :) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 62 | 2559 | my $callpkg = caller($Exporter::ExportLevel); | |||||||||||||||||||||||||||
| 63 | 2559 | ▶ | print "DBG: pkg=$pkg callpkg = $callpkg :@_\n" if($PDL::Exporter::Verbose); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 64 | 2559 | ▶ | push @_, ':Func' unless @_; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 65 | 2559 | ▶ | @_=() if scalar(@_)==1 and $_[0] eq ''; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
scalar @_ == 1 and $_[0] eq ""
MC/DC100%2/2
scalar @_ == 1 and $_[0] eq ""
scalar @_ == 1
$_[0] eq ""
Truth table100%3/3
A and B
A= scalar @_ == 1B= $_[0] eq ""
| |||||||||||||||||||||||||||||
| 66 | 2559 | Exporter::export($pkg, $callpkg, @_); | |||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | 70 | 1; | |||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | =head1 SEE ALSO | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | L<Exporter> | ||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | Copyright (C) Karl Glazebrook (kgb@aaoepp.aao.gov.au). | ||||||||||||||||||||||||||||
| 78 | Some docs by Christian Soeller. | ||||||||||||||||||||||||||||
| 79 | All rights reserved. There is no warranty. You are allowed | ||||||||||||||||||||||||||||
| 80 | to redistribute this software / documentation under certain | ||||||||||||||||||||||||||||
| 81 | conditions. For details, see the file COPYING in the PDL | ||||||||||||||||||||||||||||
| 82 | distribution. If this file is separated from the PDL distribution, | ||||||||||||||||||||||||||||
| 83 | the copyright notice should be included in the file. | ||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | =cut | ||||||||||||||||||||||||||||