Closed
Bug 515419
Opened 15 years ago
Closed 13 years ago
Array constructor can no longer be overriden to provide a custom Array class
Categories
(Rhino Graveyard :: Core, defect)
Tracking
(Not tracked)
RESOLVED
FIXED
People
(Reporter: kriszyp, Unassigned)
Details
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/532.0 (KHTML, like Gecko) Chrome/3.0.195.10 Safari/532.0 Build Identifier: R3Pre ScriptRuntime no longer checks the global scope for an Array constructor, but rather is hard-coded to use new NativeArray to create arrays. Reproducible: Always Steps to Reproduce: 1. Create a custom array class that should be used for all array creation in the JS environment. 2. Actual Results: You can't use it! Expected Results: Should be able to override array construction. The Persevere project relies on this functionality. I don't need "Array" to be looked up in the scope, but at the very least, there should be a way to override array construction. This can be fixed with this simple patch: at line 3495 in ScriptRuntime.java NativeArray array = new NativeArray(sparse); setObjectProtoAndParent(array, scope); return array; } NativeArray array = new NativeArray(length); setObjectProtoAndParent(array, scope); -> return cx.newArray(scope, sparse); } Scriptable array = cx.newArray(scope, length); at line 1546 in Context.java public final Scriptable newArray(Scriptable scope, int length) -> public Scriptable newArray(Scriptable scope, int length) at line 1563 in Context.java public final Scriptable newArray(Scriptable scope, Object[] elements) -> public Scriptable newArray(Scriptable scope, Object[] elements)
Comment 1•13 years ago
|
||
I included the changes you proposed into my patch for bug #637587. Please let me know if this works for you.
Status: UNCONFIRMED → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•