Rafael Garcia-Suarez <[EMAIL PROTECTED]> writes:
>In an XS module Bar I want to get a pointer on a C function defined in
>an XS module Foo, and preferably at BOOT-time.
>
>I can't make it work; the problem I have is that at run time DynaLoader
>always answers with a "undefined symbol" error, although the Foo module
>has been loaded beforehand. Is there some known trick for this
>situation?

Several, mostly platfrom specific e.g.
   dl_open() original with RTLD_GLOBAL
   link your loadable with .so of other moduke (or its import library 
   for Win32's DLLs.

There is a DynaLoader hook "find symbol anywhere" which itterates through 
the things it has loaded.

The de-facto way to do it is to dodge the OS ways and use a table of functions.
This scheme was originally devised for DBI and Tk copied it.
Tk automates the process somewhat.

You have a .h file which defines

struct Bar_funcs
 Whateever (*barFuncP)(Thing *wibble,int cata);
};

Bar.xs initializes table and stores its address in 
something like $Bar::_functionTablePointer;

Foo.xs declares pointer to table and its BOOT: section 
initializes it from $Bar::_functionTablePointer;

This can be automated and macros defined to  do 

      (*bar_func_ptr->barFuncP)(wibble,cata)

When source shows 

       barFunc(wibble,cata) 


Reply via email to