public static object[] GetArrayElements(Scriptable @object)
{
Context cx = Context.GetContext();
long longLen = NativeArray.GetLengthProperty(cx, @object);
if (longLen > int.MaxValue)
{
// arrays beyond MAX_INT is not in Java in any case
throw new ArgumentException();
}
int len = (int)longLen;
if (len == 0)
{
return ScriptRuntime.emptyArgs;
}
else
{
object[] result = new object[len];
for (int i = 0; i < len; i++)
{
object elem = ScriptableObject.GetProperty(@object, i);
result[i] = (elem == ScriptableConstants.NOT_FOUND) ? Undefined.instance : elem;
}
return result;
}
}