On Jul 25, 3:02 am, "Bret Lester" <[EMAIL PROTECTED]> wrote:
> I am very excited to see E4X support in the official Rhino release. That
> said, I was disappointed to find the following example didn't work:
>
> ...
>
> XML.prototype.testfunc = function() {
> java.lang.System.out.println("hihihihih");
>
> }
>
> var foo = <some-tag><b>xxx</b></some-tag>;
> foo.testfunc();
>
> ...
>
> I got the following exception. Can someone explain? Thanks in advance!
>
> Exception in thread "main" org.mozilla.javascript.EcmaError: TypeError:
> Cannot find function testfunc in object <some-tag>
> <b>xxx</b>
> </some-tag>. (srcname#7)
> at
> org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3557)
> at
> org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3535)
> at
> org.mozilla.javascript.ScriptRuntime.typeError(ScriptRuntime.java:3563)
> at
> org.mozilla.javascript.ScriptRuntime.typeError2(ScriptRuntime.java:3582)
> at
> org.mozilla.javascript.ScriptRuntime.notFunctionError(ScriptRuntime.java:3646)
> at
> org.mozilla.javascript.ScriptRuntime.getPropFunctionAndThis(ScriptRuntime.java:2186)
> at
> org.mozilla.javascript.optimizer.OptRuntime.callProp0(OptRuntime.java:117)
> at org.mozilla.javascript.gen.c1._c0(srcname:7)
> at org.mozilla.javascript.gen.c1.call(srcname)
> at
> org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:401)
> at
> org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3003)
> at org.mozilla.javascript.gen.c1.call(srcname)
> at org.mozilla.javascript.gen.c1.exec(srcname)
> at org.mozilla.javascript.Context.evaluateReader(Context.java:1119)
> at Test.main(Test.java:22)
>
> Regards
> Bret Lester
FWIW, SpiderMonkey also reports an error for calling testfunc. I don't
have time to dive into the spec to see the official word on this; can
anyone on this line opine?
Thanks,
Norris
_______________________________________________
dev-tech-js-engine-rhino mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino