W3C home > Mailing lists > Public > public-webapps@w3.org > April to June 2009

Re: [WebIDL] Callback, PropertyOnly, NoInterfaceObject

From: Cameron McCormack <cam@mcc.id.au>
Date: Fri, 26 Jun 2009 10:50:33 +1000
To: Marcin Hanclik <Marcin.Hanclik@access-company.com>
Cc: WebApps WG <public-webapps@w3.org>
Message-ID: <20090626005033.GB8712@arc.mcc.id.au>
Marcin Hanclik:
> Following our conversation on the geolocation ML
> http://lists.w3.org/Archives/Public/public-geolocation/2009Jun/0173.html
> I have the following clarification request related to the Web IDL spec.
> 
> In the geolocation spec we have now:
>   [NoInterfaceObject]
>   interface PositionOptions {
>     attribute boolean enableHighAccuracy;
>     attribute long timeout;
>     attribute long maximumAge;
>   };
> 
> Proposed and agreed in our mail discussion:
>   [Callback]
>   interface PositionOptions {
>     attribute boolean enableHighAccuracy;
>     attribute long timeout;
>     attribute long maximumAge;
>   };
> 
> Our intentions are:
> 1) Not to instantiate the interface object with new PositionOptions();
> This is handled by not specifying [Constructor] extended attribute.
>
> 2) Not to have PositionOptions on the ES global object.
> This shall be handled by specifying [NoInterfaceObject]. But it
> seems to have to be removed.
>
> 3) Use PositionOptions interface to specify properties of the object
> passed to e.g. getCurrentPosition() method.
> This is handled by specifying [Callback].
>
> 4) Resulting from the above, use the PositionOptions as follows:
> navigator.geolocation.getCurrentPosition(successCallback,
>                                              errorCallback,
>                                              {maximumAge:600000});

Right.

> Questions:
> a) What is the PropertyOnly argument/identifier for?
> It seems unclear from the Web IDL spec.
> Does it specify that the interface has one attribute only and ES
> binding just one property?
> Or does it specify that the interface includes only attributes?
> Or does it signify only the opposite to FunctionOnly?

I’ll try to clear up the wording in
http://dev.w3.org/2006/webapi/WebIDL/#native-objects.

The intended meaning of [Callback=PropertyOnly] is that if the interface
has one or more operations with the same name (but no others) and no
attributes, then an ECMAScript Function object’s [[Call]] will not be
considered to be the implementation of those operations.  Instead, the
[[Call]] of the object returned from invoking [[Get]] with the operation
identifier as the property name will be.

So for example with these interfaces:

  interface Target {
    void registerListener(in Listener x);
  };

  [Callback]
  interface Listener {
    void f();
  };

this would work:

  getTarget().registerListener(function() { … })
  
as would:

  getTarget().registerListener({ f: function() { … } });

If [Callback=FunctionOnly] was specified, then only the former would
work (passing a Function object), while if [Callback=PropertyOnly] was
specified, then only the latter would work.

Web IDL really should make IDL fragments non-conforming to use
FunctionOnly or PropertyOnly when the interface has operations of
different names or when it has attributes.

> b)
> Shouldn't we have the PositionOptions specified as follows?
>   [NoInterfaceObject]
>   [Callback=PropertyOnly]
>   interface PositionOptions {
>     attribute boolean enableHighAccuracy;
>     attribute long timeout;
>     attribute long maximumAge;
>   };

It should be:

  [NoInterfaceObject, Callback]
  interface PositionOptions {
    …
  };

as far as I can tell.  (I’ll probably loosen the IDL grammar to allow
sequences of square-bracketed extended attributes instead of requiring
them to be all in one, but for now you do need to have them all in one,
comma separated.)

Cameron

-- 
Cameron McCormack ≝ http://mcc.id.au/
Received on Friday, 26 June 2009 00:51:12 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 18:49:31 GMT