- Notifications
You must be signed in to change notification settings - Fork2
marcoscaceres/webidl.js
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
An implementation ofWebIDL inECMAScript.
The initial goal of this project is to implement a "prollyfill" code generator based on theWebIDL specification inECMAScript (i.e., implement theWebIDL ECMAScript bindings).
For the first version, webidl.js will take as input well-formed Web IDL and generate JavaScript code that:
- Implements the given WebIDL in conformance to WebIDL'sWebIDL ECMAScript bindings.
- can be eval'ed immediately to implement a noop object.
- can be used indepedently of webidl.js.
The generated code will not depend on any external libraries.
#Proposed Architecture (in WebIDL)WebIDLCompiler will be based on Robin Berjon'sWebIDL Parser,
interface WebIDLCompiler : WebIDL{ static DOMString compile(DOMString dataFragment); static DOMString compile(object dataTree);}interface WebIDL{ static object parse(); }WhereWebIDL is and instance ofhttps://github.com/darobin/webidl2.js
##Examples of what we want to do(The following examples are hypothetical, as we don't actually have any running code yet! :) )
Given some WebIDL, like:
interfaceVehicle{attributeDOMStringmake;attributeDOMStringmodel;voidmove();}[Constructor,Constructor(DOMStringmake,optionalDOMStringmodel)]interfaceCar :Vehicle{constoctetmaxspeed=200;voiddrive([Clamp]octetspeed);};
webidl.js will implement the following in the browser:
varwebIDL=newWebIDLCompiler();//convert to javascriptvarscript=webIDL.compile(carIDLString);eval(script);// noop methods by default// interfaces are added to the global scopeconsole.log(window.Car);console.log(window.Vehicle);console.log(window.Car.prototype.drive);console.log(Car.maxspeed===200);// instances are valid and inheritance works properlyvarcar=newCar();console.log(carinstanceofwindow.Car===true);console.log(carinstanceofwindow.Vehicle===true);console.log("make"incar===true);console.log("move"incar===true);// methods can be called on instancescar.drive();window.Car.prototype.drive.call(car)// methods can't be called on other objects (throws a type error)try{window.Car.prototype.drive.call({});}catch(e){console.log(e);}// type checking is built-in (throws a type error)try{car.drive({});}catch(e){console.log(e);}// type conversion is also buit-incar.drive("100");
We welcome code contributions in the form ofpull requests.All pull requests are reviewed prior to being integrated.
To retain a high level of quality, we require that all contributed code include:
- appropriate unit tests,
- documentation,
- and the code has beenlinted.
Linting, beautificaiton, and generation of documentation is handled bygrunt..
We attempt to adhere to theGoogle JavaScript Style Guide.
We are also moving to usJSDoc to document out code.
Before submitting code, please be sure to rungrunt.
Copyright © 2013Extensible Web Community Group
Permission is hereby granted, free of charge, to any person obtaining a copy ofthis software and associated documentation files (the "Software"), to deal inthe Software without restriction, including without limitation the rights touse, copy, modify, merge, publish, distribute, sublicense, and/or sell copies ofthe Software, and to permit persons to whom the Software is furnished to do so,subject to the following conditions:
The above copyright notice and this permission notice shall be included in allcopies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ORIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESSFOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS ORCOPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHERIN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR INCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
About
An implementation of WebIDL in JS.
Resources
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
Packages0
Uh oh!
There was an error while loading.Please reload this page.