Remove Script::CreateArray

It's better to construct a js-array from a `JS::RootedValueVector`.
Because it is more strongly typed and the index doesn't has to be
specified when appending an element.
Some usages are replaced with `JS::RootedValueArray`.

Fixes: #8702
This commit is contained in:
phosit
2026-02-02 18:24:57 +01:00
parent fe9c0f6c2f
commit df18e22277
14 changed files with 146 additions and 136 deletions
+1 -10
View File
@@ -1,4 +1,4 @@
/* Copyright (C) 2025 Wildfire Games.
/* Copyright (C) 2026 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@@ -271,15 +271,6 @@ inline bool CreateObject(const ScriptRequest& rq, JS::MutableHandleValue objectV
return CreateObject(rq, objectValue, args...) && SetProperty(rq, objectValue, propertyName, val, false, true);
}
/**
* Sets the given value to a new JS object or Null Value in case of out-of-memory.
*/
inline bool CreateArray(const ScriptRequest& rq, JS::MutableHandleValue objectValue, size_t length = 0)
{
objectValue.setObjectOrNull(JS::NewArrayObject(rq.cx, length));
return !objectValue.isNullOrUndefined();
}
} // namespace Script
#endif // INCLUDED_SCRIPTINTERFACE_Object