[chromium-dev] Re: Question about V8 bindings

2009-07-22 Thread Mads Sig Ager
Ah, yes of course. The generated code for the base class itself needs it. I had also forgotten that we use the ID to get the superclass template to inherit from. Don't listen to me. :-) -- Mads On Wed, Jul 22, 2009 at 10:15 PM, Drew Wilson wrote: > Digging further through the errors, it seems

[chromium-dev] Re: Question about V8 bindings

2009-07-22 Thread Drew Wilson
Digging further through the errors, it seems that the generated code for the base class itself is littered with references to the V8ClassIndex:: value. For example: static v8::Handle locationAttrGetter(v8::Local name, const v8::AccessorInfo& info) { INC_STATS("DOM.WorkerContext.location._get"

[chromium-dev] Re: Question about V8 bindings

2009-07-22 Thread Drew Wilson
I think this may not be true, as I got a compilation error in the generated bindings when I removed the type enum for the base class. Note that the code generated for my derived class contains an explicit reference to the base class: static v8::Persistent ConfigureV8DedicatedWorkerContextTemplate(v

[chromium-dev] Re: Question about V8 bindings

2009-07-21 Thread Mads Sig Ager
If you don't need the base 'type' in the binding layer code, you don't have to specify it in the V8Index file. Prototype chains and instanceof operations are all handled by V8 based on the code generated from the IDL files and it is independent of the 'type' declarations in the V8Index file. Che

[chromium-dev] Re: Question about V8 bindings

2009-07-21 Thread Drew Wilson
The other unanswered question is whether it's useful to define the base "type" in V8Index.h. If a wrapper of the base type (WRAPPERCONTEXT) is never instantiated, do I still need to define it for the purposes of things like "instanceof" and prototype chains? Or is it *only* used to specify the type

[chromium-dev] Re: Question about V8 bindings

2009-07-21 Thread Adam Barth
I think the way this works in general is that you create the wrapper for the derived class. You can see all the switch statements in V8DOMWrapper.cpp that try to do this for Nodes, etc. Adam On Tue, Jul 21, 2009 at 10:32 AM, Jeremy Orlow wrote: > On Tue, Jul 21, 2009 at 10:19 AM, Drew Wilson

[chromium-dev] Re: Question about V8 bindings

2009-07-21 Thread Drew Wilson
Thanks for the gmail tip, Jeremy - I think my life will be much happier now. I managed to catch Mads in chat, and he suggested that the pattern to follow is the one in V8DOMWrapper::converNodeToV8Object(). That code looks at the type of the impl object passed in, and generates the appropriate wrapp

[chromium-dev] Re: Question about V8 bindings

2009-07-21 Thread Drew Wilson
Yes, there's polymorphism in the IDL files. For example, the IDL for DedicatedWorkerContext is: interface [ ] DedicatedWorkerContext : WorkerContext { void postMessage(in DOMString message, in [Optional] MessagePort messagePort) raises(DOMException);

[chromium-dev] Re: Question about V8 bindings

2009-07-21 Thread Jeremy Orlow
On Tue, Jul 21, 2009 at 10:27 AM, Drew Wilson wrote: > Sigh. I keep sending this with the wrong email address. I wish Gmail would > just use the address from the last time I replied to the thread. Settings -> Accounts -> When receiving a message:Reply from the same address the message was sent

[chromium-dev] Re: Question about V8 bindings

2009-07-21 Thread Jeremy Orlow
On Tue, Jul 21, 2009 at 10:19 AM, Drew Wilson wrote: > It seems like that would have some undesirable side-effects, aside from the > fact that WebKit frowns on using virtual functions unnecessarily. > So, let's imagine that I have two derived classes, SharedWorkerContext and > DedicatedWorkerCont

[chromium-dev] Re: Question about V8 bindings

2009-07-21 Thread Drew Wilson
Sigh. I keep sending this with the wrong email address. I wish Gmail would just use the address from the last time I replied to the thread. -=-=- It seems like that would have some undesirable side-effects, aside from the fact that WebKit frowns on using virtual functions unnecessarily. So, let's

[chromium-dev] Re: Question about V8 bindings

2009-07-20 Thread Jeremy Orlow
In other words, make all workers appear the same to V8 (i.e. as a WORKERCONTEXT) and then implement polymorphism in the implementations being wrapped by V8. On Mon, Jul 20, 2009 at 8:19 PM, Jeremy Orlow wrote: > Sorry if this is a dumb question, but why woudn't you simply have a > WORKERCONTEXT a

[chromium-dev] Re: Question about V8 bindings

2009-07-20 Thread Jeremy Orlow
Sorry if this is a dumb question, but why woudn't you simply have a WORKERCONTEXT and let virtual dispatch do its job for the rest? Shared methods can be implemented on the base class and the rest can be purely virtual with implementations in the sub classes. J On Mon, Jul 20, 2009 at 3:21 PM, Dr

[chromium-dev] Re: Question about V8 bindings

2009-07-20 Thread Drew Wilson
Following up on this. Let's imagine that I don't define a V8ClassIndex enum for the common base class (so, in my case, I get rid of WORKERCONTEXT, and have only DEDICATEDWORKERCONTEXT and SHAREDWORKERCONTEXT (the derived classes). Now, let's say I'm defining an ACCESSOR_GETTER on the base class - t