Closed
Bug 854490
Opened 11 years ago
Closed 5 years ago
Support constructors for WebIDL dictionaries
Categories
(Core :: DOM: Core & HTML, defect)
Core
DOM: Core & HTML
Tracking
()
RESOLVED
INVALID
People
(Reporter: bugs, Unassigned)
References
Details
Attachments
(3 files, 3 obsolete files)
WebIDL dictionaries don't have constructors. This bug add support for that: [Constructor] dictionary DOMPoint { float x = 0; float y = 0; };
Reporter | ||
Comment 1•11 years ago
|
||
This comment belongs here... (Cameron McCormack (:heycam) wrote on bug 850805) > I've added this now: > > http://dev.w3.org/2006/webapi/WebIDL/#Constructor > http://dev.w3.org/2006/webapi/WebIDL/#es-dictionary-constructors > > http://dev.w3.org/cvsweb/2006/webapi/WebIDL/Overview.xml.diff?r1=1.617;r2=1. > 618;f=h
Reporter | ||
Comment 2•11 years ago
|
||
Add WebIDL binding support for dictionaries with [Constructor] and [NamedConstructor] attributes.
Comment 3•11 years ago
|
||
Note that in the spec I've allowed [Constructor] on dictionaries but not [NamedConstructor], but only because it didn't seem like it was necessary. Let me know if this is in fact needed.
Comment 4•11 years ago
|
||
Note that the patch just adds support to the parser and data model. Actually doing the codegen for these things and exposing them on the window are separate things... I don't think we really need NamedConstructor for dictionaries so far.
Reporter | ||
Comment 5•11 years ago
|
||
(In reply to Boris Zbarsky (:bz) from comment #4) > Note that the patch just adds support to the parser and data model. > Actually doing the codegen for these things and exposing them on the window > are separate things... Right. Still working on that bit. > I don't think we really need NamedConstructor for dictionaries so far. NamedConstructor is how I'm aliasing WebKitPoint() to DOMPoint() in bug 850805. Maybe there's a smarter way to do that?
Comment 6•11 years ago
|
||
I think you could just duplicate the dictionary in the IDL, just as easily. Not sure whether that's better than building out infrastructure for named constructors here or not....
Comment on attachment 733149 [details] [diff] [review] Adds WebIDL binding support Review of attachment 733149 [details] [diff] [review]: ----------------------------------------------------------------- I'd prefer that we put the Constructor/NamedConstructor handling logic in a single function that IDLInterface/IDLDictionary can share. ::: dom/bindings/parser/WebIDL.py @@ +1128,5 @@ > + > + args = attr.args() if attr.hasArgs() else [] > + > + retType = IDLWrapperType(self.location, self) > + extraneous whitespace!
Attachment #733149 -
Flags: review?(khuey) → review-
Reporter | ||
Comment 8•11 years ago
|
||
Reporter | ||
Comment 9•11 years ago
|
||
I think this is how the bindings should look like for dictionary constructors based on earlier feedback from bz & khuey. Before I hack up the codegen.py for this, I'd like some feedback on the following items in this file: line 190: contents of DOMIfaceAndProtoJSClass InterfaceObjectClass line 216: contents of DOMIfaceAndProtoJSClass PrototypeClass line 261: parameters to dom::CreateInterfaceObjects line 281: JSCLASS_HAS_RESERVED_SLOTS(?) Thanks!
Attachment #738380 -
Flags: feedback?(khuey)
Comment 10•11 years ago
|
||
We shouldn't have a PrototypeClass at all here, or a prototype object. Not sure whether DOMPoint.prototype should be undefined or Object.prototype. Perhaps the latter, since that's what we'd do in practice.
Reporter | ||
Comment 11•11 years ago
|
||
(In reply to Boris Zbarsky (:bz) from comment #10) > We shouldn't have a PrototypeClass at all here, or a prototype object. OK. > Not sure whether DOMPoint.prototype should be undefined or Object.prototype. > Perhaps the latter, since that's what we'd do in practice. It looks like we use 'undefined' in practice, or at least that's what "nullptr" seems to do: if needInterfacePrototypeObject: protoClass = "&PrototypeClass.mBase" protoCache = "&protoAndIfaceArray[prototypes::id::%s]" % self.descriptor.name else: protoClass = "nullptr" protoCache = "nullptr"
Comment 12•11 years ago
|
||
> It looks like we use 'undefined' in practice
For interfaces with no prototype, yes. And I'm not sure that's the right thing to do either, fwiw; it means we end up with Function.prototype as the .prototype!
Reporter | ||
Comment 13•11 years ago
|
||
This header file was auto-generated by the codegen changes in this bug fix.
Attachment #738376 -
Attachment is obsolete: true
Attachment #744449 -
Flags: review?(khuey)
Reporter | ||
Comment 14•11 years ago
|
||
This cpp file was auto-generated by the codegen changes in this bug fix.
Attachment #738380 -
Attachment is obsolete: true
Attachment #738380 -
Flags: feedback?(khuey)
Attachment #744450 -
Flags: review?(khuey)
Reporter | ||
Comment 15•11 years ago
|
||
Modifies the python code to generate constructor bindings for JS dictionary types.
Attachment #733149 -
Attachment is obsolete: true
Attachment #744453 -
Flags: review?(khuey)
Reporter | ||
Comment 16•11 years ago
|
||
/* This is the WebIDL source for attachment 744449 [details] and attachment 744450 [details] */ [Constructor(optional float x = 0, optional float y = 0),Pref="layout.css.dompoint.enabled"] dictionary DOMPoint { float x = 0; float y = 0; };
Updated•11 years ago
|
Attachment #744449 -
Attachment mime type: text/x-chdr → text/plain
Updated•11 years ago
|
Attachment #744450 -
Attachment mime type: text/x-c++src → text/plain
Comment 17•11 years ago
|
||
Would be good to at least add some codegen and webidl parser tests for this stuff.
Reporter | ||
Comment 18•11 years ago
|
||
(In reply to Boris Zbarsky (:bz) from comment #17) > Would be good to at least add some codegen and webidl parser tests for this > stuff. Yes! this needs proper tests. Working on it...
Comment on attachment 744453 [details] [diff] [review] Adds WebIDL binding support Review of attachment 744453 [details] [diff] [review]: ----------------------------------------------------------------- you have whitespace at the end of lines all over the place. This looks pretty good. I'd like Boris to do the final signoff though. ::: dom/bindings/parser/WebIDL.py @@ +484,5 @@ > > def _getDependentObjects(self): > return set() > > +class IDLConstructable(): class IDLConstructable(object): Add a doc comment explaining what this is and that it's intended to be used as a mixin for things inheriting from IDLObjectWithScope.
Attachment #744453 -
Flags: review?(khuey) → feedback+
Attachment #744453 -
Flags: review?(bzbarsky)
Attachment #744449 -
Flags: review?(khuey)
Attachment #744450 -
Flags: review?(khuey)
Comment 20•11 years ago
|
||
Comment on attachment 744453 [details] [diff] [review] Adds WebIDL binding support Jet, do you want to merge on top of bug 873417 before I review the details? For the overall approach, I think the changes to WebIDL.py look fine. I'm a bit concerned about the change to CGCallGenerator to assume that the descriptorProvider is in fact a descriptor. If that's the case, we should rename it and document which thing it's supposed to be a descriptor for. >+ builder.add(d.nativeType,d.interface.isDictionary) isDictionary(), most importantly. But also, isStruct=d.interface.isDictionary(), please. It bothers me conceptually to have descriptor.interface not be an interface, but I'm not going to make you rename it to something else... though maybe as a followup we should. It looks like for now we only support dictionary members that have a default value and can be assigned with '=', right? The biggest correctness problem here is that we need to root the dictionary. So ideally the codegen would look more like this: RootedDictionary<WhateverType> result(cx); result.Init(args); or something along those lines. Passing the args directly to the RootedDictionary constructor is hard, unfortunately, since we don't codegen that constructor....
Attachment #744453 -
Flags: review?(bzbarsky) → feedback+
Updated•6 years ago
|
Assignee: bugs → nobody
Status: ASSIGNED → NEW
Assignee | ||
Updated•5 years ago
|
Component: DOM → DOM: Core & HTML
Comment 21•5 years ago
|
||
I think we decided this wasn't going to happen, no?
Flags: needinfo?(bzbarsky)
Comment 22•5 years ago
|
||
Yes. It's gone from the spec.
Status: NEW → RESOLVED
Closed: 5 years ago
Flags: needinfo?(bzbarsky)
Resolution: --- → INVALID
You need to log in
before you can comment on or make changes to this bug.
Description
•