idl-helper.js (639B)
1 "use strict"; 2 3 var typedefFrom = interfaceFrom; 4 var dictionaryFrom = interfaceFrom; 5 function interfaceFrom(i) { 6 var idl = new IdlArray(); 7 idl.add_idls(i); 8 for (var prop in idl.members) { 9 return idl.members[prop]; 10 } 11 } 12 13 function memberFrom(m) { 14 var idl = new IdlArray(); 15 idl.add_idls('interface A { ' + m + '; };'); 16 return idl.members["A"].members[0]; 17 } 18 19 function typeFrom(type) { 20 var ast = WebIDL2.parse('interface Foo { ' + type + ' a(); };'); 21 ast = ast[0]; // get the first fragment 22 ast = ast.members[0]; // get the first member 23 return ast.idlType; // get the type of the first field 24 }