getIds() on NativeArray does return Integer instances, however if you want to recursively iterate over all objects in a top level scope you would 1) use getIds(), 2) use get(String, Scriptable), 3) recurse into anything that is instanceof Scriptable and repeat the process. However for this to work you also need to check if you are holding an instance of NativeArray, if so you need to use both getIds(String, Scriptable) and getIds(int, Scriptable) (one gives you attributes like "length" the other gives you array elements). To further the complexity of this little recursive sweep you need to use get(int, Scriptable) to access the elements, and get(String, Scriptable) for the non element attributes of the NativeArray object. I might also note that get(int, Scriptable) requires the hash code of the same string you would pass to getIds(String, Scriptable), except in the case of NativeArray, essentially making the method get(int, Scriptable) redundant for all objects other than NativeArray.
Is this really required as part of the spec? It may be so, I'm the first to admit that I'm brand new to this and don't know as much as I should, but it seemed pretty clumsy when I went to implement this seemingly simple recursive scan. Also noted, getAllIds() returns less information on a NativeArray than does getIds() because NativeArray didn't override this method, so you need to also check if you are holding a NativeArray specifically if you want to use getAllIds() recursively. Dave -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] a.org] On Behalf Of Attila Szegedi Sent: Friday, November 14, 2008 11:06 AM To: Hannes Wallnoefer Cc: [email protected] Subject: Re: Feedback wanted on new features On 2008.11.14., at 10:58, Hannes Wallnoefer wrote: > It is true > that some of it is quirky, e.g getIds() returning strings for array > indices, but that's actually based on the ES spec IIRC. Where does it do that? getIds() on NativeArray returns java.lang.Integer instances, not java.lang.String. Attila. _______________________________________________ dev-tech-js-engine-rhino mailing list [email protected] https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino _______________________________________________ dev-tech-js-engine-rhino mailing list [email protected] https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino
