Remove all external usage of CmptPrivate. Header cleanup.

This removes usage of CmptPrivate outside of ScriptInterface.
ScriptRequest can now be used to safely recover the scriptInterface from
a JSContext instead of going through ScriptInterface, which allows more
code cleanup.

Follows 34b1920e7b

Differential Revision: https://code.wildfiregames.com/D3963
This was SVN commit r25442.
This commit is contained in:
wraitii
2021-05-15 13:54:58 +00:00
parent 3ebff376cc
commit 507f44f7f9
20 changed files with 173 additions and 118 deletions
@@ -49,21 +49,22 @@ public:
TSM_ASSERT(L"Running script "+pathname.string(), scriptInterface.LoadScript(pathname, content));
}
static void Script_LoadComponentScript(ScriptInterface::CmptPrivate* pCmptPrivate, const VfsPath& pathname)
static void Script_LoadComponentScript(const ScriptInterface& scriptInterface, const VfsPath& pathname)
{
CComponentManager* componentManager = static_cast<CComponentManager*> (pCmptPrivate->pCBData);
ScriptRequest rq(scriptInterface);
CComponentManager* componentManager = scriptInterface.ObjectFromCBData<CComponentManager>(rq);
TS_ASSERT(componentManager->LoadScript(VfsPath(L"simulation/components") / pathname));
}
static void Script_LoadHelperScript(ScriptInterface::CmptPrivate* pCmptPrivate, const VfsPath& pathname)
static void Script_LoadHelperScript(const ScriptInterface& scriptInterface, const VfsPath& pathname)
{
CComponentManager* componentManager = static_cast<CComponentManager*> (pCmptPrivate->pCBData);
ScriptRequest rq(scriptInterface);
CComponentManager* componentManager = scriptInterface.ObjectFromCBData<CComponentManager>(rq);
TS_ASSERT(componentManager->LoadScript(VfsPath(L"simulation/helpers") / pathname));
}
static JS::Value Script_SerializationRoundTrip(ScriptInterface::CmptPrivate* pCmptPrivate, JS::HandleValue value)
static JS::Value Script_SerializationRoundTrip(const ScriptInterface& scriptInterface, JS::HandleValue value)
{
ScriptInterface& scriptInterface = *(pCmptPrivate->pScriptInterface);
ScriptRequest rq(scriptInterface);
JS::RootedValue val(rq.cx);