On Oct 19, 1:06 pm, [EMAIL PROTECTED] wrote:
> Hi,
>
> Trying to create a scope from withing JavaScript with Rhino 1.6RC7
> (not possible to use newer version unfortunatly). Got the following
> code:
>
> function createScope()
> {
>         var cx = Packages.org.mozilla.javascript.Context.enter();
>         try {
>                 var scope = cx.initStandardObjects();
>
>                 /*
>                  * Add providers
>                  */
>                 for (i in allproviders) {
>                         scope.__defineGetter__(allproviders[i], 
> function(){return
> set["xxx"];});
>                         scope.__defineSetter__(allproviders[i], 
> function(){set["xxx"] =
> arguments[0];});
>                 }
>         }
>         catch (e) {
>         }
>         finally {
>                 cx.exit();
>         }
>
> }
>
> I tried calling defineProperty directly on the scope variable, but
> inside JavaScript the Scope object doesn't seem to support it's Java
> functions like .defineProperty etc.
>
> So, then I did things through defining getters and setters on the
> scope. The only issue is that when executing scripts within that
> scope, they can alter/override the getters and setters, which I want
> to disallow.
>
> So, the questions are:
> - Why can't I use all the Java functions of ScriptableObject on the
> scope variable?
> - Is it possible to make the getters/setters "final" somehow?
>
> Tnx,
>
> K.

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

Reply via email to