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

Re: [WebIDL] enum

From: Jonas Sicking <jonas@sicking.cc>
Date: Mon, 16 Nov 2009 10:38:27 -0800
Message-ID: <63df84f0911161038y65f43ff8v24f9e31afc3106e9@mail.gmail.com>
To: Marcin Hanclik <Marcin.Hanclik@access-company.com>
Cc: "public-script-coord@w3.org" <public-script-coord@w3.org>
On Mon, Nov 16, 2009 at 7:15 AM, Marcin Hanclik
<Marcin.Hanclik@access-company.com> wrote:
> Hi,
>
> To facilitate the comprehension of the interfaces specified in WebIDL, I think we need to have some way of specifying enumerated values.
> At present we define constants and associate them with the attributes in the prose.
> E.g. in HTML5 we have:
>
>  const unsigned short NETWORK_EMPTY = 0;
>  const unsigned short NETWORK_IDLE = 1;
>  const unsigned short NETWORK_LOADING = 2;
>  const unsigned short NETWORK_NO_SOURCE = 3;
>  readonly attribute unsigned short networkState;
>
> media . networkState
> Returns the current state of network activity for the element, from the codes in the list below.
>
> To ease the process of comprehension of the interfaces, we could have e.g.
>  [EnumFor=networkState]
>  const unsigned short NETWORK_EMPTY = 0;
>  [EnumFor=networkState]
>  const unsigned short NETWORK_IDLE = 1;
>  [EnumFor=networkState]
>  const unsigned short NETWORK_LOADING = 2;
>  [EnumFor=networkState]
>  const unsigned short NETWORK_NO_SOURCE = 3;
>
>  readonly attribute unsigned short networkState;

If it's just for human comprehension, then wouldn't simply doing

interface HTMLMediaElement {
  ...
  // Values for the networkState property
  const unsigned sort NETWORK_EMPTY = 0;
  const unsigned short NETWORK_IDLE = 1;
  const unsigned short NETWORK_LOADING = 2;
  const unsigned short NETWORK_NO_SOURCE = 3;

  readonly attribute unsigned short networkState;

  ...
}

work just as well?

/ Jonas
Received on Monday, 16 November 2009 18:39:27 UTC

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