mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-06-21 22:24:19 +00:00
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:
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user