Replace ScriptInterface::Call* with new ScriptFunction functions

Finishes work started in f3aedf88a6.
This removes the boost-CPP function wrappers entirely, in favour of pure
templated code in FunctionWrapper.h
The Call* functions were already heavily templated, so there is nothing
really new here. I just use tag dispatch to reduce the number of
overloads slightly.

The new functions do not need the script interface, only the script
request.

Differential Revision: https://code.wildfiregames.com/D3912
This was SVN commit r25354.
This commit is contained in:
wraitii
2021-05-01 14:04:53 +00:00
parent d9748173c7
commit d46a417748
20 changed files with 164 additions and 446 deletions
+5 -4
View File
@@ -19,6 +19,7 @@
#include "Simulation2.h"
#include "scriptinterface/FunctionWrapper.h"
#include "scriptinterface/ScriptContext.h"
#include "scriptinterface/ScriptInterface.h"
@@ -726,7 +727,7 @@ void CSimulation2::PreInitGame()
{
ScriptRequest rq(GetScriptInterface());
JS::RootedValue global(rq.cx, rq.globalValue());
GetScriptInterface().CallFunctionVoid(global, "PreInitGame");
ScriptFunction::CallVoid(rq, global, "PreInitGame");
}
void CSimulation2::InitGame()
@@ -738,7 +739,7 @@ void CSimulation2::InitGame()
JS::RootedValue tmpInitAttributes(rq.cx, GetInitAttributes());
GetScriptInterface().GetProperty(tmpInitAttributes, "settings", &settings);
GetScriptInterface().CallFunctionVoid(global, "InitGame", settings);
ScriptFunction::CallVoid(rq, global, "InitGame", settings);
}
void CSimulation2::Update(int turnLength)
@@ -832,7 +833,7 @@ void CSimulation2::LoadPlayerSettings(bool newPlayers)
{
ScriptRequest rq(GetScriptInterface());
JS::RootedValue global(rq.cx, rq.globalValue());
GetScriptInterface().CallFunctionVoid(global, "LoadPlayerSettings", m->m_MapSettings, newPlayers);
ScriptFunction::CallVoid(rq, global, "LoadPlayerSettings", m->m_MapSettings, newPlayers);
}
void CSimulation2::LoadMapSettings()
@@ -842,7 +843,7 @@ void CSimulation2::LoadMapSettings()
JS::RootedValue global(rq.cx, rq.globalValue());
// Initialize here instead of in Update()
GetScriptInterface().CallFunctionVoid(global, "LoadMapSettings", m->m_MapSettings);
ScriptFunction::CallVoid(rq, global, "LoadMapSettings", m->m_MapSettings);
GetScriptInterface().FreezeObject(m->m_InitAttributes, true);
GetScriptInterface().SetGlobal("InitAttributes", m->m_InitAttributes, true, true, true);