Gavin Camp (gcamp) a écrit :
>> Christophe Grand a écrit :
>> ScriptRuntime.toNumber(ScriptRuntime.getObjectProp(yourFunction, 
>> length,
>> cx))
> 
> Thanks, I've tried this and the "arity" property and the both seem to return 
> "confusing" results.
> Length always returns 1, and arity 0.

Wow. Which version are you using? Can you give an example of the code 
produced by myFunctionCode.toString()? How do you create your scope object?

FYI, the test below prints 4 on stderr.

public class TestLength {
        public static void main(String[] args) {
                Context.call(new ContextAction() {

                        public Object run(Context cx) {
                                cx.setOptimizationLevel(9);
                                ScriptableObject scope = 
cx.initStandardObjects();
                                Function function = cx.compileFunction(scope, 
"function(a, b, c, 
d){}", "-", 1, null);
                                
System.err.println(ScriptRuntime.getObjectProp(function, "length", cx));
                                return null;
                        }
                        
                });
        }
}


Could you run it?
_______________________________________________
dev-tech-js-engine-rhino mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino

Reply via email to