WebIDL Dictionaries

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

WebIDL Dictionaries

Eliot Graff-2
Does anyone know how to create WebIDL for dictionary types[1] using ReSpec? I'm trying to get something like this to generate a table of parameters:

dictionary IDBDatabaseOptionalParameters {
  DOMString keyPath = null;
  boolean autoIncrement = false;
};

Thanks in advance.

Eliot

[1] http://dev.w3.org/2006/webapi/WebIDL/#idl-dictionary



Reply | Threaded
Open this post in threaded view
|

Re: WebIDL Dictionaries

Robin Berjon-2
Hi Eliot,

On Jul 8, 2011, at 22:45 , Eliot Graff wrote:
> Does anyone know how to create WebIDL for dictionary types[1] using ReSpec? I'm trying to get something like this to generate a table of parameters:
>
> dictionary IDBDatabaseOptionalParameters {
>  DOMString keyPath = null;
>  boolean autoIncrement = false;
> };

Dictionary types aren't supported. That's a bug! So essentially you'd want the same sort of rendering as for interfaces?

--
Robin Berjon - http://berjon.com/ - @robinberjon


Reply | Threaded
Open this post in threaded view
|

RE: WebIDL Dictionaries

Eliot Graff-2
Thanks, Robin.

Yes, the same sort of rendering would be perfect.

> -----Original Message-----
> From: Robin Berjon [mailto:[hidden email]]
> Sent: Monday, July 11, 2011 10:26 AM
> To: Eliot Graff
> Cc: [hidden email]
> Subject: Re: WebIDL Dictionaries
>
> Hi Eliot,
>
> On Jul 8, 2011, at 22:45 , Eliot Graff wrote:
>> Does anyone know how to create WebIDL for dictionary types[1] using
> ReSpec? I'm trying to get something like this to generate a table of
> parameters:
>>
>> dictionary IDBDatabaseOptionalParameters {  DOMString keyPath = null;
>> boolean autoIncrement = false; };
>
> Dictionary types aren't supported. That's a bug! So essentially you'd want the
> same sort of rendering as for interfaces?
>
> --
> Robin Berjon - http://berjon.com/ - @robinberjon
>




Reply | Threaded
Open this post in threaded view
|

Re: WebIDL Dictionaries

Robin Berjon-2
Hi Eliot,

On Jul 11, 2011, at 19:44 , Eliot Graff wrote:
> Yes, the same sort of rendering would be perfect.

Sorry it took a while. I've just committed an update to ReSpec that supports dictionaries. The syntax is hopefully pretty much the one you'd expect.

--
Robin Berjon - http://berjon.com/ - @robinberjon


Reply | Threaded
Open this post in threaded view
|

Re: WebIDL Dictionaries

Anssi Kostiainen
Hi Robin,

On 7.9.2011, at 18.33, ext Robin Berjon wrote:

> On Jul 11, 2011, at 19:44 , Eliot Graff wrote:
>> Yes, the same sort of rendering would be perfect.
>
> Sorry it took a while. I've just committed an update to ReSpec that supports dictionaries. The syntax is hopefully pretty much the one you'd expect.

Thanks, this is excellent!

Would it possible for the dictionary to show up within the same WebIDL block with other definitions? Currently it is wrapped within its own WebIDL block (or am I doing it wrong?), see:

  http://dev.w3.org/2009/dap/system-info/battery-status.html#batterystatusevent-interface

Some specs which do not use ReSpec.js but do use dictionaries seem to include dictionary within the same WebIDL block with other definitions which depend on it, e.g.:

  http://dev.w3.org/2006/webapi/progress/#interface-progressevent

I may try to get my hands dirty and hack with ReSpec.js myself, but I'm asking here first in case you have a preference because you're Mr. ReSpec.js :)

-Anssi
Reply | Threaded
Open this post in threaded view
|

Re: WebIDL Dictionaries

Robin Berjon-2
Hi Anssi,

On Sep 7, 2011, at 19:09 , Anssi Kostiainen wrote:
> Would it possible for the dictionary to show up within the same WebIDL block with other definitions? Currently it is wrapped within its own WebIDL block (or am I doing it wrong?), see:
>
>  http://dev.w3.org/2009/dap/system-info/battery-status.html#batterystatusevent-interface
>
> Some specs which do not use ReSpec.js but do use dictionaries seem to include dictionary within the same WebIDL block with other definitions which depend on it, e.g.:
>
>  http://dev.w3.org/2006/webapi/progress/#interface-progressevent
>
> I may try to get my hands dirty and hack with ReSpec.js myself, but I'm asking here first in case you have a preference because you're Mr. ReSpec.js :)

I can see how this is indeed nice, but given the way in which WebIDL support is implemented in ReSpec v1 it's a change I'd rather not make myself (the code is a mindless pile of horror). Supporting it in v2, which uses a proper WebIDL parser and templates in order to render it (or at least is getting there) would be easier, but I wouldn't advise switching to that for a mature spec such as Battery.

If you feel like hacking this in, here's what I'd do:

    0) Don't try to support this in the WebIDL code. Instead, make it as a step that runs *after* WebIDL and moves the right parts of the DOM around.
    1) Figure out a way to specify that a given IDL construct will merge one or more others into itself, e.g. data-merge="BatteryStatusEventInit OtherDictionary YetAnother" on the <dl> defining the interface.
    2) Grab the generated IDL for each dictionary to be merged, append it to the interface IDL.
    3) Grab the "Members" section for the dictionary, and append it after the Attributes, Methods, etc. sections (maybe rename it to "Dictionary Foo Members" for clarity).
    4) Kill the original dictionary section (this may lose some content, you could add what's left to the Member section.
    5) You should be good, everything else (e.g. definitions linking, section numbering) should just work. Don't blame me if you spend the night on it ;)

--
Robin Berjon - http://berjon.com/ - @robinberjon


Reply | Threaded
Open this post in threaded view
|

Re: WebIDL Dictionaries

Anssi Kostiainen
Hi,

On 7.9.2011, at 22.21, ext Robin Berjon wrote:

> On Sep 7, 2011, at 19:09 , Anssi Kostiainen wrote:
>> Would it possible for the dictionary to show up within the same WebIDL block with other definitions? Currently it is wrapped within its own WebIDL block (or am I doing it wrong?), see:
>>
>> http://dev.w3.org/2009/dap/system-info/battery-status.html#batterystatusevent-interface
>>
>> Some specs which do not use ReSpec.js but do use dictionaries seem to include dictionary within the same WebIDL block with other definitions which depend on it, e.g.:
>>
>> http://dev.w3.org/2006/webapi/progress/#interface-progressevent
>>
>> I may try to get my hands dirty and hack with ReSpec.js myself, but I'm asking here first in case you have a preference because you're Mr. ReSpec.js :)
>
> I can see how this is indeed nice, but given the way in which WebIDL support is implemented in ReSpec v1 it's a change I'd rather not make myself (the code is a mindless pile of horror). Supporting it in v2, which uses a proper WebIDL parser and templates in order to render it (or at least is getting there) would be easier, but I wouldn't advise switching to that for a mature spec such as Battery.

I forgot v2 was in the works. Given that, I believe it does not make sense to add any new features to v1, or to do significant refactoring. I revised my monkey patch that fixes the issue in the spec I edit, so I'm happy with what we have in ReSpec.js v1 currently.

-Anssi
Reply | Threaded
Open this post in threaded view
|

Re: WebIDL Dictionaries

Anssi Kostiainen
In reply to this post by Robin Berjon-2
Hi Robin,

On 7.9.2011, at 22.21, ext Robin Berjon wrote:

> If you feel like hacking this in, here's what I'd do:
>
>    0) Don't try to support this in the WebIDL code. Instead, make it as a step that runs *after* WebIDL and moves the right parts of the DOM around.
>    1) Figure out a way to specify that a given IDL construct will merge one or more others into itself, e.g. data-merge="BatteryStatusEventInit OtherDictionary YetAnother" on the <dl> defining the interface.
>    2) Grab the generated IDL for each dictionary to be merged, append it to the interface IDL.
>    3) Grab the "Members" section for the dictionary, and append it after the Attributes, Methods, etc. sections (maybe rename it to "Dictionary Foo Members" for clarity).
>    4) Kill the original dictionary section (this may lose some content, you could add what's left to the Member section.
>    5) You should be good, everything else (e.g. definitions linking, section numbering) should just work. Don't blame me if you spend the night on it ;)


I ended up hacking on this after all :)

I tried to implement it as you describe above. The patch works for me with all the relevant browsers, so I committed it. Feel free to review and refactor where necessary. Here's an example of a spec using it:

  http://dev.w3.org/2009/dap/system-info/battery-status.html

-Anssi

Btw. Should I update the ReSpec documentation as well?

Reply | Threaded
Open this post in threaded view
|

Re: WebIDL Dictionaries

Robin Berjon-2
On Sep 13, 2011, at 12:41 , Anssi Kostiainen wrote:
> On 7.9.2011, at 22.21, ext Robin Berjon wrote:
>> If you feel like hacking this in, here's what I'd do:
>
> I ended up hacking on this after all :)

Thanks, it looks great!

> Btw. Should I update the ReSpec documentation as well?

It would be great if you at least included a note in the docs that this feature needs documenting, even if you don't have the time to flesh out some text. If nothing else it'll be a reminder for me to port it over to v2 :)

--
Robin Berjon - http://berjon.com/ - @robinberjon


Reply | Threaded
Open this post in threaded view
|

Re: WebIDL Dictionaries

Anssi Kostiainen
Hi,

On 13.9.2011, at 14.07, ext Robin Berjon wrote:

> It would be great if you at least included a note in the docs that this feature needs documenting, even if you don't have the time to flesh out some text. If nothing else it'll be a reminder for me to port it over to v2 :)

I added a note about this feature to the bottom of the "WebIDL Support" section.

-Anssi