develooper Front page | perl.perl5.porters | Postings from November 2003

Re: question about load_module

Thread Previous
From:
Nick Ing-Simmons
Date:
November 10, 2003 14:13
Subject:
Re: question about load_module
Message ID:
20031110221230.18485.2@llama.ing-simmons.net
Jamie Le Tual <jletual@kmtechnologies.com> writes:
>I created a module using "h2xs -n LoaderTest", then tacked the following 
>XSUB at the end:
>
>void
>doLoad(SV *package_name)
>PPCODE:
>    load_module(0, package_name, Nullsv);

Where did you get that scheme from ?
If you do NOT specify PERL_LOADMOD_NOIMPORT in the flags slot,
you need to have a Nullsv to terminate the varargs list of args to 
pass to import.

e.g.

  load_module(0, package_name, Nullsv, Barsv, Nullsv); // use Foo 'Bar';

  load_module(0, package_name, Nullsv, Nullsv); // use Foo;

  load_module(PERL_LOADMOD_NOIMPORT, package_name, Nullsv); // use Foo ();

Note that all the SVs you pass will be SvREFCNT_dec()ed by time call returns.

>I then had the idea of seeing if any clever people had already used 
>load_module, so I looked through the source of mod_perl. 

Why not the source of perl ?

>Seems they 
>build a "require %s" type of thing and eval_sv() that instead....
>
>is load_module broken? 

No ;-)

>Badly documented? 

Documented? what is that ;-)

>Am I such a clod that I've 
>missed something obvious?

The source ? Perl_vload_module() in op.c is not that opaque.

>
>Will work for clue,
>Jamie


Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About