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

Re: Web IDL Garden Hose

From: Yehuda Katz <wycats@gmail.com>
Date: Tue, 29 Sep 2009 22:11:50 -0700
Message-ID: <245fb4700909292211g30413e8an5b218ced0efa9859@mail.gmail.com>
To: public-script-coord@w3.org
On Tue, Sep 29, 2009 at 9:18 PM, Maciej Stachowiak <mjs@apple.com> wrote:

>
> +public-script-coord
> -public-webapps
>
> (Soon I will start dropping es-discuss too).
>
> On Sep 29, 2009, at 3:38 AM, Yehuda Katz wrote:
>
>  I meant "actually written". Being able to see actual code that implemented
>> pieces of the IDL in ES would make some of the more complex interactions
>> more obvious (I suspect).
>>
>
>
> I don't entirely understand this request. The IDL just defines an
> interface. ECMAScript doesn't have a way to declare an interface without
> implementing it. And the actual behavior of most objects described with Web
> IDL interfaces is not implementable in pure ECMAScript - not the interface
> behavior, the actual core behavior. But maybe you can help me understand
> what you want with an example. Here's a trivial Web IDL interface, what
> would count as an ES implementation to you:
>
> interface FooBar {
>    boolean isFoo(DOMString a, long b);
>    boolean isBar(DOMString a, long b);
> }
>

I'm spitballing a bit here. Maybe something like:

FooBar = function() {};
FooBar.prototype = new IDLValue;
FooBar.prototype.isFoo = function(a, b) {
  var idlA = WebIDL.CoerceStrict.toLong(a);
  var idlB = WebIDL.CoerceStrict.toDOMString(b);
}

FooBar.prototype.isBar(a, b) {
  var idlA = WebIDL.CoerceStrict.toLong(a);
  var idlB = WebIDL.CoerceStrict.toDOMString(b);
  return WebIDL.Type.Boolean;
}

It would be possible to implement the above using a library that would look
like:

FooBar = new IDLInterface(function(i) {
  i.function("isFoo", WebIDL.Boolean, ["a", WebIDL.Type.long, "b",
WebIDL.Type.DOMString]);
  i.function("isBar", WebIDL.Boolean, ["a", WebIDL.Type.long, "b",
WebIDL.Type.DOMString]);
});

This is extremely half-baked, but the basic idea is to show a valid
implementation of the Interface using WebIDL semantics. I believe that even
just defining Section 4.1 in ECMAScript itself (where possible) would do a
lot to clarify the semantics.

I'm sending this to public-script-coord alone so I'm not spamming three
lists.


> Regards,
> Maciej
>
>


-- 
Yehuda Katz
Developer | Engine Yard
(ph) 718.877.1325
Received on Wednesday, 30 September 2009 05:12:38 UTC

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