Wasn't sure how to word the problem for the title of the post correctly. Here is the issue I am experiencing. We have an interface that will be implemented by our LuaStateManager
class to register functions to a LuaPlus::LuaState
. The issue is that these functions could potentially have any signature.
LuaPlus allows you to register any function with its LuaObject::RegisterDirect
method. It can do this because it uses templates. However, we have to encapsulate the LuaState
in an interface which has pure virtual functions.
So our idea was to have a function that LuaStateManager
will implement:
IScriptState::RegisterFunction( /* What should go here? */ )
As you can probably see, though, there is no way to specify what type of argument should be passed to this function as it could potentially be any function signature. We cant use templates like LuaPlus does because virtual functions cannot be templated. We can't template the entire LuaStateManager
class or IScriptState
interface either because for each type of function passed it would generate a wholly new script state and none of the functions would reside together.
How have problems like this been solved in the past? Currently we are going with a brute force method that just throws all our exports in a struct that users can derive from and fill out. That way they will know which scripting language they are using and be able to directly use LuaStateManager
instead of the IScriptState
interface, but that is totally a sloppy 'hack' solution.