On Jul 20, 10:08 am, Mark Porter <[email protected]> wrote:
> On Jul 20, 7:35 am, Martin Blom <[email protected]> wrote:
>
>
>
> > And of course, DONTENUM can be used from JS too:
>
> > var __dontenum__ = function (o, p) {
> > java.lang.Class.forName("org.mozilla.javascript.ScriptableObject")
> > .getMethod("setAttributes", java.lang.String, java.lang.Integer.TYPE)
> > .invoke(o, p, new java.lang.Integer(
> > org.mozilla.javascript.ScriptableObject.DONTENUM));
>
> > }
>
> > On 07/20/2009 03:19 PM, Rapha wrote:
>
> > > I'm working on implementing ES5 in Rhino. The Object.defineProperty is
> > > currently implemented in the CVS version,
> > > seehttp://www.mozilla.org/rhino/download.html
>
> > > In the meantime you can add non-enumerable properties from Java, using
> > > the ScriptableObject.DONTENUM attribute.
>
> > > On Jul 20, 1:15 am, Mark Porter<[email protected]> wrote:
> > >> Is there currently a way to define non-enumerable properties from
> > >> Javascript? Something like ES5's defineProperty? If not, are there
> > >> future plans to support this?
>
> Wow, that is exactly what I needed. Thanks Rapha and Martin.
>
> Rapha, I'll try to follow your blog to keep up with your progress.
>
> Thanks,
> Mark
>
> ------------
> Myna Server-Side Javascript:http://www.mynajs.org
OK, any idea on how to hide properties on instantiated objects? I
tried hiding the properties on the prototype, but that has no effect.
Hiding the property inside the constructor seems to make it null:
var hide = function (o, p) {
java.lang.Class.forName("org.mozilla.javascript.ScriptableObject")
.getMethod("setAttributes", java.lang.String,
java.lang.Integer.TYPE)
.invoke(o, p, new java.lang.Integer(
org.mozilla.javascript.ScriptableObject.DONTENUM));
}
function Test (){
hide(this,"doStuff")
}
Test.prototype.doStuff=function(){ return "stuff"}
new Test().doStuff();
//TypeError: Cannot call property doStuff in object [object Object].
It is not a function, it is "object".
Is it possible to make instance functions non-enumerable?
Thanks,
Mark
------------
Myna Server-Side Javascript: http://www.mynajs.org
_______________________________________________
dev-tech-js-engine-rhino mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino