On 11/14/12 6:32 PM, Jeff Walden wrote:
> Some sort of method that you call that you provide a list of { jsclass, functionspecs, propertyspecs } (or a list of roughly morally equivalent things), then the engine does magic to give you a global object whose prototype chain matches that list, then has a standardly-constructed Object.prototype, then ends in null. Basically from the point of view of the embedder the whole process of creating a global object and its prototype chain would be atomic.
OK. We could do something like that; for my purposes we wouldn't even
need functionspecs/propertyspecs, since I can just set those later, but
_would_ need a proxyhandler for the proxy that's on the proto chain of
the window. But yeah, something like that would be just fine for my
purposes.
> Of course even this might not be enough, if those objects needed custom privates, or wanted to have reserved slots set in special ways from the start.
Apart from the global itself (which needs a reserved slot pointing to
the actual DOM window) and the proxy handler and proxy private for the
gsp, I don't think we need anything like that for the window proto
chain. I guess that's a pretty big "apart"... ;)
We'd have to go through later and define some .constructor properties on
those prototypes, and some of those might need custom bits, but that can
be done post-facto without too much trouble I'd think.
> I did mean JSContext, because I was speaking in a semi-futurish world where we've unified JSRuntime and JSContext, after we've eliminated that 1-to-many relationship.
Um. At that point we'd have one JSContext for all windows, period. So
I certainly hope we would not be limited to creating globals to right
after we created the JSContext... I feel like I'm just misunderstanding
something.
>> Why is XPConnect relevant here? I'm happy to try to fix things in XPConnect if I know what needs fixing!
>
> I tried making standard class init non-lazy a year or so ago. I ran into the issue that XPCWrappedNative::WrapNewGlobal offers the explicit option of choosing whether standard classes are lazy or eager. Just making it all non-lazy caused the browser to not start up, throwing up some sort of alert about something going wrong. I wish I remembered exactly what it was.
I see. This is definitely worth revisiting, but yes, trying to resolve
stuff on the global (or more precisely, invoke its resolve hook) before
it has its private slot set would not have worked well....
This API is starting to sound very much like a "do all the DOM Window
magic" kind of API. :(
-Boris