Yeah, I just realized that there is Object.defineProperty which I already knew, but havent used it before.
Thanks for the hints, this is exactly what I wanted :-) On Sep 28, 2012 10:35 AM, "Jakob Kummerow" <[email protected]> wrote: > Defining getters (and setters) is possible in plain JavaScript, it is not > V8 specific at all and does not need custom extensions. See for example > https://developer.mozilla.org/en-US/docs/JavaScript/Guide/Working_with_Objects?redirectlocale=en-US&redirectslug=Core_JavaScript_1.5_Guide%2FWorking_with_Objects#Defining_getters_and_setters > . > > > On Fri, Sep 28, 2012 at 3:50 AM, Michael Schwartz <[email protected]>wrote: > >> https://github.com/mschwartz/SilkJS-Harmony >> >> Note that SilkJS turns on harmony extensions to make this all possible. >> If you are using some other JS implementation, you'll have to see if you >> need to start up with some extra command line switches or whatever. >> >> >> >> On Sep 27, 2012, at 6:37 PM, Christoph Martens <[email protected]> >> wrote: >> >> Hey everyone, >> >> I wanted to ask if anyone of you knows a possibility to have the >> capability of defining accessors of Objects inside the javascript side. >> >> Why am I asking? >> >> For my V8GL environment, I have the glut bindings in place. That means >> they are available inside the javascript context via: >> >> glut.get(glut.WINDOW_WIDTH); >> >> Now I want to emulate the WebGL API on top of the usual GL/GLES/GLUT >> stuff. But, for example, I want to offer the glut functionality wrapped >> with JavaScript polyfills. I think that this is the best way to get there >> to not having obsolete or duplicated code on the C++ side. >> >> For example, I wanted to do something like this: >> >> var Window = function(width, height) { >> }; >> >> Window.__SETACCESSOR('x', function() { >> glut.get(glut.WINDOW_X); >> }); >> >> I know that on the native side, you can use setAccessor() on templates, >> but I don't know if there's a possibility to offer the same functionality >> here on the javascript side somehow via extending the native Object in JS >> or something. >> >> Does anyone of you have a clue where to start or if that is possible? >> >> Thanks! >> Christoph >> >> > -- > v8-users mailing list > [email protected] > http://groups.google.com/group/v8-users -- v8-users mailing list [email protected] http://groups.google.com/group/v8-users
