I've run your code and it does print 4, also I've refactored my code now and 
putting a similar call into this also gives the expected/correct results.  
Sorry, it looks like the previous results must have been due to an error in my 
original code.

On a different note, I have finished the code that gets the function name and 
argument names by parsing the result of the "toSource" call.

Regards,
Gavin

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Christophe Grand
Sent: 06 February 2008 12:47
To: [email protected]
Subject: Re: Obtaining function signature from compiled JS functions

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
_______________________________________________
dev-tech-js-engine-rhino mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino

Reply via email to