- From: Robin Berjon via cvs-syncmail <cvsmail@w3.org>
- Date: Thu, 03 Dec 2009 11:43:19 +0000
- To: public-dap-commits@w3.org
Update of /sources/public/2009/dap/ReSpec.js/js In directory hutz:/tmp/cvs-serv13467/js Modified Files: respec.js Log Message: support optional Index: respec.js =================================================================== RCS file: /sources/public/2009/dap/ReSpec.js/js/respec.js,v retrieving revision 1.56 retrieving revision 1.57 diff -u -d -r1.56 -r1.57 --- respec.js 2 Dec 2009 17:42:13 -0000 1.56 +++ respec.js 3 Dec 2009 11:43:17 -0000 1.57 @@ -14,9 +14,8 @@ // - WebIDL // . make it so that extended attributes on members and attributes are only wrapped if needed // . make processor aware of some extended attributes (e.g. Constructor) -// . support nullable // . support variadic params -// . support optional params +// . support arrays // . support special operations: getter, setter, creator, deleter, caller, omittable // . support stringifiers // - add support for a test variant of the specification, based on the ideas in P+C @@ -1077,6 +1076,21 @@ } } } + + // apply optional + var isOptional = false; + for (var i = 0; i < mem.params.length; i++) { + var p = mem.params[i]; + var pkw = p.datatype.split(/\s+/); + var idx = pkw.indexOf("optional"); + if (idx > -1) { + isOptional = true; + pkw.splice(idx, 1); + p.datatype = pkw.join(" "); + } + p.optional = isOptional; + } + return mem; } @@ -1170,7 +1184,7 @@ if (it.params.length) { var table = sn.element("table", { "class": "parameters" }, desc); var tr = sn.element("tr", {}, table); - ["Parameter", "Type", "Nullable", "Description"].forEach(function (tit) { sn.element("th", {}, tr, tit); }); + ["Parameter", "Type", "Nullable", "Optional", "Description"].forEach(function (tit) { sn.element("th", {}, tr, tit); }); for (var k = 0; k < it.params.length; k++) { var prm = it.params[k]; var tr = sn.element("tr", {}, table); @@ -1187,6 +1201,8 @@ } if (prm.nullable) sn.element("td", { "class": "prmNullTrue" }, tr, "\u2714"); else sn.element("td", { "class": "prmNullFalse" }, tr, "\u2718"); + if (prm.optional) sn.element("td", { "class": "prmOptTrue" }, tr, "\u2714"); + else sn.element("td", { "class": "prmOptFalse" }, tr, "\u2718"); var cnt = prm.description ? [prm.description] : ""; sn.element("td", { "class": "prmDesc" }, tr, cnt); } @@ -1413,12 +1429,12 @@ var obj = this; str += meth.params.map(function (it) { var nullable = it.nullable ? "?" : ""; + var optional = it.optional ? " optional " : " "; var prm = "<span class='idlParam'>"; if (it.extendedAttributes) prm += "[<span class='extAttr'>" + it.extendedAttributes + "</span>] "; - prm += "in <span class='idlParamType'>" + obj.writeDatatype(it.datatype) + nullable + "</span> " + + prm += "in" + optional + "<span class='idlParamType'>" + obj.writeDatatype(it.datatype) + nullable + "</span> " + "<span class='idlParamName'>" + it.id + "</span>" + "</span>"; - return prm; }) .join(", ");
Received on Thursday, 3 December 2009 11:43:28 UTC