1
0
forked from 0ad/0ad
0ad/source/ps/scripting
wraitii ee0d204bf6 Wrap JSAutoRequest and replace usage of JSContext* with the wrapper.
JSAutoRequest is required before calling into most JSAPI methods, for GC
reasons.
Calling it is required and fragile as one must not forget.
Further, SM52 and later make manipulating JSContext* dangerous as that
can cross Compartment(Realm in SM68) barriers (and ScriptInterface now
matches a Compartment).

The solution to both problems is to avoid using JSContext* in 0 A.D.
itself. To achieve this, a Request class is introduced, and must be used
to access a JSContext* from a scriptInterface. Further, Request is
passed to other ScriptInterface functions isntead of JSContext*, making
it obvious that the caller has already called it, reducing errors and
redundant JSAutoRequest calls.
Only JSNative functions now get a naked JSContext* without protection,
but the likelihood of forgetting a request is lower since many
ScriptInterface functions now expect it.

JSContext* is directly passed to JSAPI functions only.

Part of the SM52 migration, stage: SM45 compatible

Based on a patch by: Itms
Tested By: Freagarach
Refs #4893

Differential Revision: https://code.wildfiregames.com/D3088
This was SVN commit r24176.
2020-11-13 13:18:22 +00:00
..
JSInterface_ConfigDB.cpp Refactor HWDetect and rendering options setup. 2020-06-07 13:16:57 +00:00
JSInterface_ConfigDB.h redo 2d57478781, Create a ConfigDB_CreateAndWriteValueToFile function to absorb some duplication in the gui 2019-08-05 14:12:55 +00:00
JSInterface_Console.cpp Remove some unused Profiler.h and CLogger.h includes. 2019-09-07 13:35:45 +00:00
JSInterface_Console.h Add missing ScriptInterface includes to 2018-04-27 16:48:44 +00:00
JSInterface_Debug.cpp Refactor build information getters and remove the useless code. 2019-01-06 14:32:54 +00:00
JSInterface_Debug.h Refactor build information getters and remove the useless code. 2019-01-06 14:32:54 +00:00
JSInterface_Game.cpp Wrap JSAutoRequest and replace usage of JSContext* with the wrapper. 2020-11-13 13:18:22 +00:00
JSInterface_Game.h Allow JS GUI pages to find out if the game is running. 2019-09-14 15:33:46 +00:00
JSInterface_Main.cpp Wrap JSAutoRequest and replace usage of JSContext* with the wrapper. 2020-11-13 13:18:22 +00:00
JSInterface_Main.h Persist the lobby Terms Of Use and Terms Of Service checkbox if the logged in user and the accepted versions of the pages didn't change since last login, refs #5218. 2018-06-21 16:38:08 +00:00
JSInterface_Mod.cpp Main.cpp cleanup. 2018-05-08 09:45:54 +00:00
JSInterface_Mod.h Clean some forward declarations. 2018-04-27 16:06:42 +00:00
JSInterface_ModIo.cpp Wrap JSAutoRequest and replace usage of JSContext* with the wrapper. 2020-11-13 13:18:22 +00:00
JSInterface_ModIo.h Clean some forward declarations. 2018-04-27 16:06:42 +00:00
JSInterface_SavedGame.cpp Wrap JSAutoRequest and replace usage of JSContext* with the wrapper. 2020-11-13 13:18:22 +00:00
JSInterface_SavedGame.h Happy savegame hack removal following e0ea53a8ee, refs #2030. 2019-09-18 00:17:56 +00:00
JSInterface_UserReport.cpp New UserReporter Terms and Conditions, hopefully GDPR compliant, refs #5257. 2018-10-05 22:19:28 +00:00
JSInterface_UserReport.h New UserReporter Terms and Conditions, hopefully GDPR compliant, refs #5257. 2018-10-05 22:19:28 +00:00
JSInterface_VFS.cpp Wrap JSAutoRequest and replace usage of JSContext* with the wrapper. 2020-11-13 13:18:22 +00:00
JSInterface_VFS.h Add missing ScriptInterface includes to 2018-04-27 16:48:44 +00:00
JSInterface_VisualReplay.cpp Remove some unused Profiler.h and CLogger.h includes. 2019-09-07 13:35:45 +00:00
JSInterface_VisualReplay.h Add missing ScriptInterface includes to 2018-04-27 16:48:44 +00:00