Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo


#531 Interface plugins

Stage (103)

This patch adds the ability for libstageplugin to load interfaces from plugins, similarly to the model plugin patch I submitted earlier. This patch depends on changes made in the previous patch, specifically the more generic plugin loading code. The changes have been omitted under the assumption that this patch will be applied second.

Interface plugins cannot be specified in the world file, as the player config which uses the interfaces is parsed before the world file is. So, they are specified in the config file, like this:

name "stage"
ifplugins [
provides [
model "mymodel"

Each interface plugin will have RegisterInterface called on it and must register itself as an interface at that point, like this:

extern "C"
void RegisterInterface(void)
RegisterInterface( PLAYER_DIO_CODE, InterfaceCreator<InterfaceDio> );

I did run into a problem where an interface plugin depends on a model plugin but cannot resolve the symbols because the interface plugin was loaded first. My solution was simply to put both plugins in the same shared library and let it be loaded twice (libtool ensures it is not actually loaded twice). It's not elegant but I'm not sure what else to do.



    Patch to add support for plugin interfaces

  • another great idea, thanks.

    I'll think a bit about the name resolution problem. Can probably get around it by making the registration a two-step process.

    - rtv


    Thanks. I did forget to mention one thing. To make it easy to compile interface plugins, I changed the CMakeLists to install p_driver.h. However, p_driver depends on stage.hh, and expects it to be in subdirectory libstage. I did not want to change the directory stage.hh is installed into, as that would break other peoples code. So, I simply installed stage.hh in both places. Perhaps you can come up with a better solution?