HomeWildfire Games

Removes g_ScriptingHost and implements global to compartment 1 to 1 relation.


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.

Closes #2241
Refs #1886
Refs #1966


YvesJan 4 2014, 11:14 AM
rP14495: Roman tower remake

Event Timeline

elexis raised a concern with this commit.Sep 26 2018, 10:17 AM
elexis added a subscriber: elexis.
elexis added inline comments.

// Because passing functions accross compartment boundaries is a pain, we just store them here together with some optional arguments.

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 commit now has outstanding concerns.Sep 26 2018, 10:17 AM
historic_bruno raised a concern with this commit.Jul 24 2019, 8:45 PM
historic_bruno added a subscriber: historic_bruno.
historic_bruno added inline comments.

This commit likely broke Engine.DisplayErrorDialog for hwdetect.js, but almost nobody would ever encounter it, so we never noticed. See D2123

The hwdetect concern was addressed in rP22549 (and I guess the patch isn't scheduled to be audited completely).

elexis removed an auditor: elexis.Aug 16 2019, 8:47 PM

Passing callback functions as arguments instead of names fixed in rP22676.

This commit no longer requires audit.Aug 16 2019, 8:47 PM
elexis added inline comments.Sep 3 2019, 3:58 PM

missing AutoRequest


missing AutoRequest

elexis added inline comments.Sep 17 2019, 9:24 PM

This hack originates from rP13579.
Not 100% sure, but it looks like this commit (rP14496) made this function unused, rather than being called, since Engine.SaveGame -> SavedGames::Save now receives the data and doesnt call this anymore.


This previously called the GUI page function ("hack"), wheras now it uses the data already received.

elexis added inline comments.Oct 9 2019, 5:40 PM

The call change obsoleted PSERROR_Scripting catch (refs D2363)


(No PSERROR_Scripting exceptions thrown here)