AS function "pointers"
Hi
Would it be hard/possible to extend AS to be able to send AS functions as arguments? I.e. something like:
void someEventHandler()
{
does something;
}
void someOtherFunction(object @someobject)
{
someObject->setSomeEventHandler(@someEventHandler);
}
And then "setSomeEventHandler" would take an int as argument and receive the ID for someEventHandler.
Even cooler would be if a call-function was JIT-compiled and returned as a real C function pointer. Oh well, a boy can dream... :)
This is planned for a future version. Maybe I'll be able to include it with version 2.3.0, after I've implemented the script structures.
Returning the function as a real C function pointer would indeed be really cool, and should be possible, though it is not very portable, as it requires generating machine code at run-time.
Returning the function as a real C function pointer would indeed be really cool, and should be possible, though it is not very portable, as it requires generating machine code at run-time.
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game
An alternative to this is to return the function name as a string, which the host app can use to look up the function id from the engine.
Quote: Original post by Deyja
An alternative to this is to return the function name as a string, which the host app can use to look up the function id from the engine.
Indeed. This is how I plan to do it for now, but it'd be sweet to have it in the engine eventually to get rid of an extra lookup. (Not that this is something my code will do very often, but either way. It looks better in code too. :)
Absolutely no high priority thing in my end though. :)
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement