| 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 | 71 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 71 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 71 | ▶ | use Exporter; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 3345 | ▶ | sub import { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
import: called CC=6 SCAR=24.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | ▶ | my $pkg = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
import: not called CC=6 SCAR=24.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | ▶ | return if $pkg eq 'PDL::Exporter'; # Module don't export thyself :) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | my $callpkg = caller($Exporter::ExportLevel); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | ▶ | print "DBG: pkg=$pkg callpkg = $callpkg :@_\n" if($PDL::Exporter::Verbose); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | ▶ | push @_, ':Func' unless @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | ▶ | @_=() if scalar(@_)==1 and $_[0] eq ''; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition50%3/6
scalar @_ == 1 and $_[0] eq ""
scalar @_ == 1 and $_[0] eq ""
MC/DC100%2/2
scalar @_ == 1 and $_[0] eq ""
scalar @_ == 1
$_[0] eq ""
MC/DC0%0/2
scalar @_ == 1 and $_[0] eq ""
scalar @_ == 1
$_[0] eq ""
Truth table100%3/3
A and B
A= scalar @_ == 1B= $_[0] eq ""
Truth table0%0/3
A and B
A= scalar @_ == 1B= $_[0] eq ""
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | Exporter::export($pkg, $callpkg, @_); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 71 | 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 | ||||||||||||||||||||||||||||||||||||||||||||||||||