Yes, same behaviour is observed here. In console, it is printed as ƒ [object customValue ]
Thank you for your help, ibon. :) regards, Anoop R. S. On Tuesday, 22 May 2018 14:49:55 UTC+5:30, ibon wrote: > > On my side, I don't do anything in the object template with > SetCallAsFunctionHandler. > I have tested setting my object template SetCallAsFunctionHandler and as > you say, instant tooltip in DevTools shows the object as anonymous, but > still prints as [object MyStuff] in the console. > so I am afraid I can't be of any more help :( > > best > - i > > El martes, 22 de mayo de 2018, 7:56:26 (UTC+2), Anoop R. S. escribió: >> >> Hi, >> I read around a bit and did some changes. >> Instead of using an *ObjectTemplate *directly, for wrapping the C++ >> object, I created a *FunctionTemplate *first, used *SetClassName()* and >> then called *InstanceTemplate()* to create an *ObjectTemplate *from it. >> All handlers were set on this *ObjectTemplate*. Now the name is getting >> displayed for the returned object. :) >> However, there is a catch. When I set the callback >> *SetCallAsFunctionHandler()* on the *ObjectTemplate*, it stops working >> and starts showing up as *f anonymous()*. I need this because I want to >> further call the object as a function. >> ibon, can you please check if *SetCallAsFunctionHandler()* is set for >> your *ObjectTemplate*? >> >> regards, >> Anoop R. S. >> >> On Tuesday, 22 May 2018 10:03:11 UTC+5:30, Anoop R. S. wrote: >>> >>> Thank you for your reply, ibon. >>> I am using *FunctionTemplate *to expose the keyword '*Point*'. So, it >>> will call the function registered with the *FunctionTemplate*. In that >>> function, I am using *ObjectTemplate* to wrap the C++ object and >>> return. For the *ObjectTemplate*, I am setting the handlers. ( >>> *v8::NamedPropertyHandlerConfiguration* and >>> *v8::IndexedPropertyHandlerConfiguration*) >>> I tried using *SetClassName()* on the *FunctionTemplate*. That worked >>> in a different way. Now, when I do mouse over on '*Point*', it is >>> displaying the string I am populating. >>> >>> >>> <https://lh3.googleusercontent.com/-PSLiQPCRb1I/WwOX4xdV49I/AAAAAAAAFsE/G3j_Hd1AhdQ6RlW0L0urVEDFpMW4L_MzQCLcBGAs/s1600/Capture.PNG> >>> >>> Where as, if *SetClassName()* is not called, it is displayed as >>> anonymous. >>> >>> >>> <https://lh3.googleusercontent.com/-R8rnC7ug-a0/WwOX-DvaSKI/AAAAAAAAFsI/Y8eMsL2C5_IYW7RKOStkOUMnThbqdf6PgCLcBGAs/s1600/Capture2.PNG> >>> >>> My aim is to change the value being displayed for the variable p, to >>> which I am returning an *ObjectTemplate*. >>> Or, is it that I can use a *FunctionTemplate* to return? In that case, >>> how can I set the handlers? >>> I used the source >>> *https://github.com/v8/v8/blob/master/samples/process.cc* >>> <https://github.com/v8/v8/blob/master/samples/process.cc> as a guide. >>> >>> Maybe I am not doing it properly here. The Embedder's guide says: >>> >>>> Each function template has an associated object template. This is used >>>> to configure objects created with this function as their constructor. >>> >>> But it seems I am using an unrelated *ObjectTemplate* to wrap C++ >>> object. Please correct me if I am wrong. I am inferring that you are using >>> the associated *ObjectTemplate *of the of the *FunctionTemplate *to >>> wrap the C++ object. >>> Also, from *v8.h:* >>> >>> /** >>> * Set the class name of the FunctionTemplate. This is used for >>> * printing objects created with the function created from the >>> * FunctionTemplate as its constructor. >>> */ >>> void SetClassName(Local<String> name); >>> This also leads me to believe that I am not using the *ObjectTemplate *as >>> intended. >>> >>> regards, >>> Anoop R. S. >>> >>> On Monday, 21 May 2018 14:03:25 UTC+5:30, ibon wrote: >>>> >>>> Have you tried setting the class name in the FunctionTemplate ? >>>> >>>> interface_template->SetClassName( v8::String ) >>>> >>>> This names my objects as expected. I also get [object MyObject] instead >>>> of [object Object] when calling Object's prototype toString. >>>> You also might want to name the prototype by setting the GetToStringTag >>>> symbol in the prototype object template. >>>> >>>> >>>> El lunes, 21 de mayo de 2018, 6:40:45 (UTC+2), Anoop R. S. escribió: >>>>> >>>>> Hi All, >>>>> I noticed another behaviour. If the callback *SetCallAsFunctionHandler() >>>>> *is implemented for the ObjectTemplate, the value of the object is >>>>> displayed as *f anonymous() *as shown below. >>>>> >>>>> >>>>> <https://lh3.googleusercontent.com/-CS_h9_oMPmM/WwJMTnHwc-I/AAAAAAAAFrg/aDVzcqVeqmEsmdi53rFQ1b0YV23r1ainQCLcBGAs/s1600/Capture.PNG> >>>>> >>>>> it seems to be overriding the callbacks >>>>> *NamedPropertyHandlerConfiguration* and >>>>> *IndexedPropertyHandlerConfiguration >>>>> *(with respect to how it is displayed only). >>>>> >>>>> Is there any way to override this behaviour? >>>>> >>>>> I tried tracking where it is getting populated as *function, *but >>>>> ended up in *CALL_GENERATED_CODE* called in *Invoke()* in >>>>> *execution.cc* >>>>> >>>>> >>>>> regards, >>>>> Anoop R. S. >>>>> >>>>> On Tuesday, 8 May 2018 10:05:12 UTC+5:30, Anoop R. S. wrote: >>>>>> >>>>>> Hi All, >>>>>> I am trying out a debugger prototype using the remote debugger >>>>>> protocol. >>>>>> Going by the standard example in Embedder's Guide: >>>>>> C++ class: >>>>>> ------------- >>>>>> class Point { >>>>>> public: >>>>>> Point(int x, int y) : x_(x), y_(y) { } >>>>>> int x_, y_; >>>>>> } >>>>>> >>>>>> Usage in JavaScript: >>>>>> --------------------------- >>>>>> var p = Point(1,2); >>>>>> >>>>>> Has anyone tried debugging a wrapped C++ object that is being >>>>>> returned to Javascript? Is it possible? >>>>>> >>>>>> regards, >>>>>> Anoop R. S. >>>>>> >>>>> -- -- v8-users mailing list v8-users@googlegroups.com 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 v8-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.