W3C home > Mailing lists > Public > public-script-coord@w3.org > October to December 2011

Dictionaries in WebIDL

From: Ross Burton <ross@burtonini.com>
Date: Fri, 7 Oct 2011 13:45:51 +0100
Message-ID: <CAAnfSTtdhsgY-GqG+tWWGoyCTE3hbKOeNh-uL0c8cgCqH9QxWA@mail.gmail.com>
To: public-script-coord@w3.org
Hi,

I'm trying to express in WebIDL an interface with a string attribute
"uri", and a string-string dictionary "options" that has no
restrictions on the keys.

In JS this would be something like this as a literal:

{
 uri: "",
 options: {}
}

Now I came up with the following WebIDL:

 /* arbitrary key-value hints */
 dictionary Options {};

 [Constructor]
 interface Item {
   attribute DOMString uri;
   attribute Options options;
 };

Which seems reasonable to me but the specification says "Dictionaries
must not be used as the type of an attribute, constant or exception
field".  Maybe I'm misreading the spec but doesn't this make my IDL
invalid?  Is there a better way of expressing what I want?

Related: is there a good tutorial/annotated reference/set of examples
for WebIDL?  The spec is quite... concise and isn't that great for
learning from. :)

Thanks,
Ross
Received on Friday, 7 October 2011 12:46:40 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 8 May 2013 19:30:04 UTC