X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=os2%2FOS2%2FREXX%2FDLL%2FDLL.pm;h=09e3e37a08e778686b83eaf73bcafae64c1af7e3;hb=5c728af092d5febae92774d9106a235643cb49e5;hp=7e54371973d8ed5513bf28d2d1d9c9c961e9fff2;hpb=6e7c9e4dbac15378c097f03304f6025aebc78a15;p=p5sagit%2Fp5-mst-13.2.git diff --git a/os2/OS2/REXX/DLL/DLL.pm b/os2/OS2/REXX/DLL/DLL.pm index 7e54371..09e3e37 100644 --- a/os2/OS2/REXX/DLL/DLL.pm +++ b/os2/OS2/REXX/DLL/DLL.pm @@ -1,9 +1,9 @@ package OS2::DLL; -use Carp; -use DynaLoader; +our $VERSION = '1.00'; -@ISA = qw(DynaLoader); +use Carp; +use XSLoader; sub AUTOLOAD { $AUTOLOAD =~ /^OS2::DLL::.+::(.+)$/ @@ -22,6 +22,17 @@ sub AUTOLOAD { # Cannot autoload, the autoloader is used for the REXX functions. +sub new { + confess 'Usage: OS2::DLL->new( [] )' unless @_ >= 2; + my ($class, $file) = (shift, shift); + my $handle; + $handle = $class->load($file, @_) and return $handle; + my $path = @_ ? " from '@_'" : ''; + my $err = DynaLoader::dl_error(); + $err =~ s/\s+at\s+\S+\s+line\s+\S+\s*\z//; + croak "Can't load '$file'$path: $err"; +} + sub load { confess 'Usage: load OS2::DLL []' unless $#_ >= 1; @@ -73,7 +84,7 @@ EOE return 1; } -bootstrap OS2::DLL; +XSLoader::load 'OS2::DLL'; 1; __END__ @@ -108,7 +119,15 @@ is performed in default DLL path (without adding paths and extensions). The DLL is not unloaded when the variable dies. -Returns DLL object reference, or undef on failure. +Returns DLL object reference, or undef on failure (in this case one can +get the reason via C). + +=head2 Create a REXX DLL handle + + $dll = OS2::DLL->new( NAME [, WHERE] ); + +Same as L|Load REXX DLL>, but croaks with a meaningful message on +failure. =head2 Check for functions (optional):