>>
>> 1) is clear. But what do you mean with 2) ? Which function pointers?
>
> I just meant that there is likely some interface in the plugin that you
> use to
> tell it where to find your functions, which usually involves some way of
> passing the pointers to your functions (or passing the functions by
> reference,
> if you prefer).
>
> But you know that better than I do.
If I understand correctly, the issue here is that plugins are written like
this:
#include <pluginutils.h>
... implement plugin somehow, call functions in pluginutils.h
And then, these plugins are taken out of their original environment and
loaded through Cython. And so the loader must resolve the symbols declared
in pluginutils.h, meaning Cython must implement the actual utils within
pluginutils and export them statically without name mangling? Am I right?
Stefan: I don't know if Cython can declare external cdef functions that
are not name mangled?
First off, you should see whether you could use the existing
implementation of the pluginutils, and if so link with it. This depend on
the nature of the plugin functions. If not, and if Stefan's answer to the
above is negative, this is what you do: Write a new pluginutils.c
containing code like this:
// Assuming pluginutils.h looks like this:
int somefunc(int, char*);
...one would implement pluginutils.cpp like this:
static int (g_somefunc_ptr*)(int, char*)
void set_somefunc(int (func*)(int, char*)) {
g_somefunc_ptr = func;
}
int somefunc(int i, char* c) {
return (*g_somefunc_ptr)(i, c);
}
and also create pluginutils_cythonapi.h like this:
void set_somefunc(int (func*)(int, char*));
and finally, import/declare that latter header-file in Cython as well, and
call it with the Cython implementation of somefunc as the parameter. Hope
that helps.
Dag Sverre
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev