I suspect you put the interceptor either on the prototype template or instance template of the prototype. It should be on the instance template of the function template.
On Mon, Oct 31, 2016 at 11:16 AM Zac Hansen <[email protected]> wrote: > Thank you for your help. I mostly understand what you're saying, but I'm > not quite clear on what I'm doing that's making holder != this. Are there > any common/semi-common things you can do while wrapping a c++ object in a > JS Object's internalfield that causes this to happen? > > When I say new MyType(), that calls into a FunctionTemplate that takes > info.This() and puts a C++ object in its internal field. The "new > MyType()" FunctionTemplate can have a bunch of stuff on it's > Instance/Prototype templates including accessors, data members, etc, though > I thought I filtered most of that out in my test cases. Is anything I > said or maybe something I'm probably doing and didn't say going to cause > the holder != this? > > Thank you so much. > > --Zac > > On Monday, October 31, 2016 at 1:39:29 AM UTC-7, Toon Verwaest wrote: > > It just follows JS property access semantics. And that's complicated. > > If you're trying to set a property, but it doesn't exist on the receiver, > we need check whether the property exists on the prototype chain. If it > does and has a setter, we need to call the setter. If it does and is > read-only, we need to throw. If it exists and isn't either of those, that > would mask a property up the prototype chain. Hence if we see an > interceptor that's not on the receiver, we need to check whether it has the > property. If it does, that would mask a non-writable/settable property > further up the prototype chain. > > So we basically get the attributes to see whether it exists and whether > it's writable. That can either be returned through the query callback, or > through the getter. > > Now for your specific problem; it seems like your simple example must > mismatch the actual code you're having. If you don't see your setter being > called at all, that just means that you put the setter on Point.prototype, > not on instances of Point. Setters for "native data properties"; which > includes interceptors; are only invoked on the receiver directly. Only real > JS accessors are called through the prototype chain. This again follows the > spec. > > On Mon, Oct 31, 2016 at 2:10 AM Zac Hansen <[email protected]> wrote: > > Stack traces for the working and non-working versions: > > https://gist.github.com/xaxxon/5eabcc079a3103abd0f7b3239b2cf3b2 > > > my v8 source is at commit: > > a05f85a3db33860f7f9651d904fd4193ee757848 > > On Saturday, October 29, 2016 at 3:33:14 AM UTC-7, Zac Hansen wrote: > > I run the following javascript: > > var p = new Point(); p.foo = 5; > > where Point creates an object from an ObjectTemplate that has > had SetHandler called on it. However, this calls my getter callback. > Everything I've tried from javascript calls my getter callback. > > object_template->SetHandler(v8::NamedPropertyHandlerConfiguration( > // Getter > [](v8::Local<v8::Name> property_name, > v8::PropertyCallbackInfo<v8::Value> const & info){ > printf("IN GETTER CALLBACK111 %s\n", > *v8::String::Utf8Value(property_name)); > }, > // setter > [](v8::Local<v8::Name> property_name, > v8::Local<v8::Value> new_property_value, > v8::PropertyCallbackInfo<v8::Value> const & info){ > printf("IN SETTER CALLBACK222 %s\n", > *v8::String::Utf8Value(property_name)); > }, > nullptr, // query > nullptr, // deleter > nullptr, // enumerator > v8::External::New(this->isolate, (void *)data), > v8::PropertyHandlerFlags::kNonMasking)); // <== Tried > with and without this > }; > > > and prints out: IN GETTER CALLBACK111 foo > > I originally tried with the older API for string-only property names and > had the same results. > > #define V8_MAJOR_VERSION 5 > #define V8_MINOR_VERSION 6 > #define V8_BUILD_NUMBER 0 > #define V8_PATCH_LEVEL 0 > > on os x 10.11 clang 3.9 > > -- > -- > v8-users mailing list > > [email protected] > > > http://groups.google.com/group/v8-users > --- > You received this message because you are subscribed to the Google Groups > "v8-users" group. > > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > > > For more options, visit https://groups.google.com/d/optout. > > -- > -- > v8-users mailing list > [email protected] > http://groups.google.com/group/v8-users > --- > You received this message because you are subscribed to the Google Groups > "v8-users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- -- v8-users mailing list [email protected] http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups "v8-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
