Our system has a function looks like this:
MyObject* getAnotherObject(std::function<int(int)> get_strategy);
This function need to be called from script side, but we prefer to allow get_strategy
being implemented from script side. I immediately got some problems:
1, Is it ever possible to call a script function on the half way of native callback? Does AngelScript allow to do that?
2, How to obtain the running AngelScript context from the function wrapper side? I only find GetEngine()
in asIScriptGeneric
that give you corresponding engine, but don't know how to get context.
3, The C++ function probably should be registered as MyObject@+ getAnotherObject( CallbackFunc@ )
, where the callback function probably looks like funcdef int CallbackFunc( int );
. However, at the time C++ function is registered, the funcdef to callback function does not exist, as source code is compiled after C++ type registration. How should I solve this?