On Mon, 28 Apr 2008, [EMAIL PROTECTED] wrote:
> On Apr 28, 12:49 pm, [EMAIL PROTECTED] (Jan Dubois) wrote:
> > If you are using the mechanism from win32/Makefile, then you must make sure
> > you add your extension to the list in STATIC_EXT to make sure it gets
> > initialized properly.  Otherwise you need to add some code to your
> > xs_init() function to define the bootstrap function in your module via
> >
> >     newXS("MyExt::boot_MyExt", boot_MyExt, __FILE__);
> >
> > and then make sure you call MyExt::boot_MyExt() manually before calling
> > any function from MyExt().  The BOOT section in the XS code is responsible
> > for registering all the XS functions at the Perl level.
>
> Thank you for the quick reply. I'll try to outline my scenario :-
> 
> 1) Visual C++ App is called - DataDownloader.exe (with perl 5.8
> persistent interpreter inside)
> 
> 2) getdata.pl is a perl script that is called by the perl interpreter
> residing in DataDownloader.exe.
> 
> 3) DataLoader is the name of the Perl extension that I'm statically
> linking (i.e. DataLoader.lib) with my DataDownloader.exe app. This has
> a sub named 'DataLoader::Cache' which the getdata.pl calls.
> 
> Now in my DataDownloader.exe I have an xs_init() function that does a
>     newXS("DataLoader::boot_DataLoader", boot_DataLoader, __FILE__);
> 
> But my extension still does not get registered 'properly' as my
> getdata.pl script cannot see the DataLoader extension routines (i.e.
> Cache()) and complains of an 'undefined subroutine'.
> 
> Are you saying I should explicitly call boot_DataLoader() in my C++
> code ?
> If so, then what does the newXS() in xs_init() do ?  If I do call
> boot_DataLoader() manually, what arguments should I provide it with ?
> I looked at the perl headers and dont know what pTHX_ is ?

You need to pass your own xs_init() as an argument to perl_parse().
That way when the Perl interpreter is initialized you'll already
have the DataLoader::boot_DataLoader() function defined in Perl
space.

Normally this function would be called by DynaLoader::bootstrap(),
but you can't rely on that because DynaLoader will look for your
DataLoader.dll in @INC.  Therefore you need to call boot_DataLoader()
explicitly (from Perl code, or via eval_pv()).  boot_DataLoader()
will in turn define all the other functions in your XS module
for Perl, so after it returns you should be able to call
DataLoader::Cache().

Cheers,
-Jan

Reply via email to