Re: __defineGetter__

"Hannes Wallnoefer" <[email protected]>
Newsgroups gmane.comp.java.helma.general
Message-ID <[email protected]>
2007/4/2, Hannes Wallnoefer <[email protected]>:
> Hi Felix,
>
> 2007/4/1, jfwittmann <[email protected]>:
> >
> > In the Mustang includes Rhino JavaScript engine it's already possible.
> > this was a little test by me with the known  prototype lib on server side.
> > ....
> > function MapAdapter(map) {
> >     this.__has__ = function(name) {
> >        return map.containsKey(name);
> >     }
> >     this.__get__ = function(name) {
> >         return map.get(name);
> >     }
> >     this.__put__ = function(name, value) {
> >         map.put(name, value);
> >     }
> >     this.__delete__ = function(name) {
> >         map.remove(name);
> >     }
> >     this.__getIds__ = function() {
> >         var result = [];
> >         for (var keyIterator = map.keySet().iterator();
> > keyIterator.hasNext();) {
> >             var key = keyIterator.next();
> >             result.push(key);
> >         }
> >         return result;
> >     }
> > };
> >
> > var Hash = function(obj) {
> >     if (obj instanceof java.util.HashMap) {
> >         Object.extend(this, new JSAdapter(new MapAdapter(obj)))
> >     } else {
> >         Object.extend(this, new JSAdapter(new MapAdapter(new
> > java.util.HashMap())))
> >         Object.extend(this, obj || {});
> >     }
> > };
> > ....
> >
> > And here is another blog thread to this interesting topic too.
> >
> > http://blogs.sun.com/sundararajan/entry/self_javascript_and_jsadapter
>
> Thanks for the info and link. This is really very interesting. The
> implementation looks actually really nice, definitely nicer than
> __defineGetter__ and friends.
>
> But I wonder if Sun (or whoever implemented this) has made any effort
> to get this into mainline Rhino. Is this even documented anywhere
> except on A. Sundararajan's weblog? And where is the source code to
> it?

First question solved: source code seems to live here:

https://scripting.dev.java.net/source/browse/scripting/engines/javascript/src/com/sun/phobos/script/javascript/

hannes

> A lot of questions marks here, but definitely interesting.
>
> hannes
>
> > Felix
> >
> >
> > _______________________________________________
> > Helma-user mailing list
> > [email protected]
> > http://helma.org/mailman/listinfo/helma-user
> >
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.