W3C home > Mailing lists > Public > public-script-coord@w3.org > April to June 2013

Re: [webidl] Add a [Maplike] tag?

From: Tab Atkins Jr. <jackalmage@gmail.com>
Date: Mon, 10 Jun 2013 18:36:23 -0700
Message-ID: <CAAWBYDCXqTB-PE37Zm5xXfKhENdJ=kVdHfCBuMNZOgYLM_DBFQ@mail.gmail.com>
To: "public-script-coord@w3.org" <public-script-coord@w3.org>
I've gone ahead and started using some pretend syntax for this in

[MapClass(DOMString, DOMString)]
interface CSSVariablesMap {
  DOMString get(DOMString varName);
  boolean has(DOMString varName);
  void set(DOMString varName, DOMString varValue);
  DOMString delete(DOMString varName);

The [MapClass(keyType, valType, iteratorType?)] extended attribute
takes two or three arguments.  The first two specify the types
required of its keys and values.  The interface MUST define the "map
tuples" for the interface, which consist of a unique key paired with a
value.  Unless manually defined in the interface, the entries(),
keys(), and values() methods, and the .size attribute, are
automatically defined in terms of the "map tuples".  The third
argument to the extended attribute defines which of the three is used
for the @@iterator() method, and must be either "entries", "keys",
"values", or omitted (which is the same as "entries").

The interface MAY manually define the get() and has() methods;
otherwise, they're automatically defined in terms of the "map tuples".
 The interface MAY manually define set() and delete() methods;
otherwise, they automatically throw TypeErrors with a message
indicating that the interface is readonly.  (Can we make the methods
auto-throw if the interface is used on a readonly attribute?)

The remaining Map methods (currently just clear() and forEach()) MAY
be manually defined; otherwise, they're automatically defined as in

The [MapClass] object has Map.prototype on its prototype chain, just
like [ArrayClass] and Array.prototype.

The [SetClass(valType)] extended attribute is defined similarly.

Received on Tuesday, 11 June 2013 01:37:13 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 17:14:13 UTC