I am newbie in rhino.
Currently, I am using Rhino 1.7R framework thru .NET 4 and IKVM.NET. I exposed several wrapped classes implementing NativeJavaObject using setWrapFractory() API.
public class InterceptNativeObject : NativeJavaObject
{
public InterceptNativeObject()
{
}
public override Object get(String name, Scriptable start)
{
Object res = base.get(name, start);
if (res is NativeJavaMethod)
{
NativeJavaMethod method = (NativeJavaMethod)res;
return new RhinoMethodWrapFunction(method);
}
if (res == org.mozilla.javascript.UniqueTag.NOT_FOUND &&
base.javaObject is IPropertBox && base.javaObject != null)
{
object ret = ((IPropertBox)base.javaObject)._x__GetPropertyValue(name);
return Utils.ConvertCLRValueToJavaValue(ret);
}
return res;
}
.....
}
Now, I can access all .NET methods and properties as I wanted.
My current problem is to support 'for...in' my NativeJavaObject classes. When I evaluate
'for(var prop in myClass){printf(prop);};' ,
it returns 'no 'in' call for non-object' error.
It seems the 'get' attempting to searching an object of ' _iterator_', but it resulted in 'not found' at get() function. So, it ends up with exception. So far, I tried
- added java.util.iterator
- return this.getIds().GetEnumrator();
None of works.
How can i allow property enumrate access for my Wrapped NativeJavaObject? What is Rhino's expected return value of ' _iterator_' to enable 'for...in'?
Thanks in advance!