Use ScriptInterface::CreateObject for ToJSVal<CColor>, and for ToJSVal<Grid<u8> >, ToJSVal<Grid<u16> > used by the AIManager obtaining the pathfinder grid.

Make that function static, so that it can be used for these functions
without slowly having to obtain the ScriptInterface instance using
GetScriptInterfaceAndCBData just to get the JSContext again.
Remove few redundant conversions for CreateObject arguments.

Differential Revision: https://code.wildfiregames.com/D2128
Tested on: gcc 9.1.0, clang 8.0.1, Jenkins
Tedious performance testing in: D2128, D2127

This was SVN commit r22894.
This commit is contained in:
elexis
2019-09-13 00:56:51 +00:00
parent 7f943b07b7
commit a84e2e57df
31 changed files with 161 additions and 161 deletions
+3 -4
View File
@@ -567,11 +567,11 @@ bool ScriptInterface::CallFunction_(JS::HandleValue val, const char* name, JS::H
return ok;
}
bool ScriptInterface::CreateObject_(JS::MutableHandleObject object) const
bool ScriptInterface::CreateObject_(JSContext* cx, JS::MutableHandleObject object)
{
// JSAutoRequest is the responsibility of the caller
object.set(JS_NewPlainObject(GetContext()));
object.set(JS_NewPlainObject(cx));
if (!object)
throw PSERROR_Scripting_CreateObjectFailed();
@@ -579,9 +579,8 @@ bool ScriptInterface::CreateObject_(JS::MutableHandleObject object) const
return true;
}
void ScriptInterface::CreateArray(JS::MutableHandleValue objectValue, size_t length) const
void ScriptInterface::CreateArray(JSContext* cx, JS::MutableHandleValue objectValue, size_t length)
{
JSContext* cx = GetContext();
JSAutoRequest rq(cx);
objectValue.setObjectOrNull(JS_NewArrayObject(cx, length));