Hi, I'm trying to create a completely synthetic Iterator object (not really an array or some other collection type). I have a Java class that extends ScriptableObject, has a jsConstructor and several jsFunctions, and works fine when used from JS. Now, by reading the documentation, my guess was simply to make it implement Iterator and the interface's hasNext() and next() methods, and that should be enough. However, it isn't. With this definition, the following variations in JS don't work:
for (x in obj) ... for (x in Iterator(obj))... for (x in new Iterator(obj))... They don't result in any errors, but by adding log messages to the hasNext() and next() functions I see they are never invoked. The "for each" variants behave the same (actually, I don't know how would "for" and "for each" be different in my case as I'm creating simple objects to be iterated over, not key-value pairs). Abandoning implementation of Iterator and converting (for debugging purposes...) next() into jsFunction_next() shows that the function itself works fine when simply called from JS. How do I create an iterator from scratch? _______________________________________________ dev-tech-js-engine-rhino mailing list [email protected] https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino
