Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
------ I've tried to install C::DynaLib but get failed on tests in "make test". At now I'm looks over code of C::DynaLib and many others. Showed ecample works good with method which is like thatpackage SO; use DynaLoader; sub new { my $class = shift; my $libname = shift; my $so = DynaLoader::dl_findfile( $libname ); die 'Failed to find .so for '.$libname unless defined( $so ); my $lib = DynaLoader::dl_load_file( $so, @_ ); die 'Failed to load '.$so unless $lib; return bless [ $lib, $so ], $class; }; sub AUTOLOAD { my $self = shift; my $sub = $AUTOLOAD; $sub =~ s/.*\:\://; warn 'called DL'; return $self->call( $sub, @_ ); }; sub DESTROY { my $self = shift; DynaLoader::dl_unload_file( $self->[0] ); }; sub call { my $self = shift; my $sym = shift; my $symref = DynaLoader::dl_find_symbol( $self->[0], $sym ); die 'failed to find '.$sym.' in '.$self->[1] unless $symref; DynaLoader::dl_install_xsub( $sym, $symref ); return &$sym( @_ ); }; 1;
My question is how I should to repack $x or it's components to make them clear for original .so library. .so library is third party library which sources I have but will not like to change ( it comes from yum official repositories ).use SO; my $so = SO->new('some.so'); my $string = $so->get_some_string();#correct result my $x = { a => 'b', c => 123 }; my $r = $so->change_this_argument( $x );#get error from .so about wron +g arguments, but the arguments definetly correct. my $r2 = $so->accept_this_argument( $x );#get same error.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: DynaLoader and data types (perlxstut)
by Anonymous Monk on Jan 06, 2017 at 08:37 UTC |