Fundation for WebIDL.js

Hi,  
I've made a pull request with an initial prototype of how I think we could implement the WebIDL implementation (specifically focusing the types):
https://github.com/extensibleweb/webidl.js/pull/27

Every type in Web IDL is essentially defined as "what it is" (Sections 3.x of the spec) and how to perform the conversion from one type to another (Sections 4.x). Implementation-wise, this is easy to grasp if you look at:
https://github.com/marcoscaceres/webidl.js/commit/ed1606ebef8c5dd7b40044da8fe0fd654f3afaa0

As all types are composed of essentially the same patter (a value, [restrictions], a converter), I created a base class IDLType that takes a converter and handles the conversion on set. For example:

var x = new webIDL.Boolean("hello"); 
x.value === true; 
x.value = "";
x.value === false; 


I also integrated a modified interface object exposing code that we worked on last week in the interfaces/WebIDL.js. So, the following is also exposed:

window.WebIDL;

I we should make parse(), implement(), etc. static. Right now, they rely on an instance that is exposed on the window object:

var parsedIDL = window.webIDL.parse("interface Foo{ };")

If you want to test this out before we pull it in, you can grab a copy to play with here:
https://github.com/marcoscaceres/webidl.js

Remember to fire this up on a local Web server, otherwise it probably won't work. 

Would like to hear thoughts.  

-- 
Marcos Caceres

Received on Monday, 7 January 2013 18:52:15 UTC