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

RE: [WebIDL] enum

From: Marcin Hanclik <Marcin.Hanclik@access-company.com>
Date: Tue, 17 Nov 2009 10:37:42 +0100
To: Jonas Sicking <jonas@sicking.cc>
CC: "public-script-coord@w3.org" <public-script-coord@w3.org>
Message-ID: <FAA1D89C5BAF1142A74AF116630A9F2C28942D7484@OBEEX01.obe.access-company.com>
Hi Jonas,

Human comprehension is one thing.
Having the enum in the syntax of WebIDL could allow formal verification of the specification, easier test case preparation etc.

>>  // 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;
Here at best the line with comment could appear before each constant (this almost equals to extended attribute specification), since otherwise it is not clear whether the comment applies to all constants.

OMG IDL has enum, JAVA has enum. Therefore WebIDL could have it as well.

Thanks,
Marcin

Marcin Hanclik
ACCESS Systems Germany GmbH
Tel: +49-208-8290-6452  |  Fax: +49-208-8290-6465
Mobile: +49-163-8290-646
E-Mail: marcin.hanclik@access-company.com

-----Original Message-----
From: Jonas Sicking [mailto:jonas@sicking.cc]
Sent: Monday, November 16, 2009 7:38 PM
To: Marcin Hanclik
Cc: public-script-coord@w3.org
Subject: 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

________________________________________

Access Systems Germany GmbH
Essener Strasse 5  |  D-46047 Oberhausen
HRB 13548 Amtsgericht Duisburg
Geschaeftsfuehrer: Michel Piquemal, Tomonori Watanabe, Yusuke Kanda

www.access-company.com

CONFIDENTIALITY NOTICE
This e-mail and any attachments hereto may contain information that is privileged or confidential, and is intended for use only by the
individual or entity to which it is addressed. Any disclosure, copying or distribution of the information by anyone else is strictly prohibited.
If you have received this document in error, please notify us promptly by responding to this e-mail. Thank you.
Received on Tuesday, 17 November 2009 10:12:35 UTC

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