W3C home > Mailing lists > Public > public-webapi@w3.org > October 2007

Re: [Bindings] extended attribute for callback function interfaces?

From: Cameron McCormack <cam@mcc.id.au>
Date: Thu, 18 Oct 2007 12:05:43 +1000
To: public-webapi@w3.org
Message-ID: <20071018020543.GA7057@arc.mcc.id.au>

Hi David.

L. David Baron:
> There are a number of interfaces, used as callbacks, like
> EventListener [1], NodeFilter [2], and UserDataHandler [3], and
> XPathNSEventResolver [4] where an interface has a single method and
> is intended to be implemented by the DOM user as a callback.  In
> ECMAScript bindings, the implementation typically accepts a raw
> function for such cases, in addition to (or rather than, in some
> implementations, perhaps?) an object with a named property for the
> function.
> 
> Should there be an extended attribute to indicate such interfaces?
> (I'd note that Mozilla's IDL has such an extended attribute,
> [function].)
> 
> (I believe Mozilla will also accept { handleEvent: my_handler } as
> an EventListener in addition to my_handler, where my_handler is a
> function, but I'm not sure whether that's true of other
> implementations.  It would probably be good if the relevant
> specifications said one way or the other.)

I believe this is already handled for all such interfaces, in the last
paragraph of section 4.4:

  As a special case, a Function object F is considered to implement an
  interface if that interface is declared with exactly one operation.
  The function itself is the implementation of the operation. If the
  Function object also has a property P whose name is the name of the
  operation and whose value is a Function object, then that P is used as
  the implementation of the operation rather than F.

-- 
Cameron McCormack, http://mcc.id.au/
	xmpp:heycam@jabber.org  ▪  ICQ 26955922  ▪  MSN cam@mcc.id.au
Received on Thursday, 18 October 2007 02:06:05 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 8 January 2008 14:18:58 GMT