Removes g_ScriptingHost and implements global to compartment 1 to 1 relation.
Each GUI Page gets its own compartment and all ScriptInterfaces in the same thread should now use the same JS Runtime.
This is required for the SpiderMonkey upgrade.
Check the ticket for details.
I can confirm is a pain to implement the callback function properly, because the JS function has to be stored as a JS::Value in a C++ struct, but the function doesn't have to be passed between compartment boundaries, the callback function is still performed in the same context.
all of this ugly/hack example ^
ugly/hack example ^
ugliness example ^
Passing a function name instead of a function is a really uncomfortable solution that leaves much uglier JS code than the alternative that passes a function.
It for example means that the AI config dialog in gamesetup.js requires a global function that is 1000+ lines away from it's PushGuiPageCB call and prevents that from confining the AI behavior logic to one hunk.
Secondly it's easier for the JS dev if there is only one Push and one Pop function where the callback function and the return value are optional.
This previously called the GUI page function ("hack"), wheras now it uses the data already received.