Closed GoogleCodeExporter closed 9 years ago
In fact, v8 doesn't allow to use non-function in __defineGetter__
// v8native.js
// Extensions for providing property getters and setters.
function ObjectDefineGetter(name, fun) {
var receiver = this;
if (receiver == null && !IS_UNDETECTABLE(receiver)) {
receiver = %GlobalReceiver(global);
}
if (!IS_SPEC_FUNCTION(fun)) {
throw new $TypeError(
'Object.prototype.__defineGetter__: Expecting function');
}
var desc = new PropertyDescriptor();
desc.setGet(fun);
desc.setEnumerable(true);
desc.setConfigurable(true);
DefineOwnProperty(ToObject(receiver), ToName(name), desc, false);
}
you could wrap your object with anonymous function
with ctxt:
print ctxt.eval("""
var obj = {};
obj.__defineGetter__('zomg', function() { return Foober(100)(); });
obj.zomg;
""")
Original comment by flier...@gmail.com
on 12 Aug 2013 at 8:30
Original issue reported on code.google.com by
csaft...@gmail.com
on 19 Jul 2013 at 5:29