Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

DynaLoader and data types

by Anonymous Monk
on Jan 06, 2017 at 05:40 UTC ( [id://1179060]=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi, All. Is there any way to process data-types defined in .so library ? I've used code like this :
package 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;
------ 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 that
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.
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 ).

Replies are listed 'Best First'.
Re: DynaLoader and data types (perlxstut)
by Anonymous Monk on Jan 06, 2017 at 08:37 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1179060]
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (8)
As of 2024-04-23 17:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found