Re: [WebIDL] enum

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