I have a constructor Foo:
function Foo() { this.first = 1; }
Foo.prototype = { second: 2 };
and I want to intercept all property accesses of instances of Foo. I'm
trying to do this by creating an ObjectTemplate with a
NamedPropertyHandler and simulating the effect of "new Foo()" on an
object created from this ObjectTemplate. This almost works, except I
can't figure out how to apply Foo.prototype to the newly constructed
object.
Here's an example that demonstrates the problem:
function Foo() { this.first = 1; }
Foo.prototype = { second: 2 };
Foo = TracedObject(Foo);
var t = new Foo();
log(t.first + "\n");
log(t.second + "\n");
The output is:
1
undefined
TracedObject is implemented as: http://gist.github.com/10136
How do I correctly simulate the effect of new Foo() on the object
created from my ObjectTemplate?
Thanks,
-Jey Kottalam
--~--~---------~--~----~------------~-------~--~----~
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users
-~----------~----~----~----~------~----~------~--~---