Skip to content
This repository has been archived by the owner on Jun 7, 2024. It is now read-only.

Commit

Permalink
Merge branch 'release/v3.0.6' into gh-pages
Browse files Browse the repository at this point in the history
  • Loading branch information
darobin committed May 31, 2012
2 parents 85d2998 + 5848d7f commit 6461758
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 70 deletions.
7 changes: 7 additions & 0 deletions builds/respec-w3c-common-3.0.6.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion builds/respec-w3c-common.js

Large diffs are not rendered by default.

13 changes: 6 additions & 7 deletions examples/basic.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,12 @@
</p>
</section>
<section>
<h2>WebIDL Callback</h2>
<dl title='callback IceCandidateCallback = void' class='idl'>
<!-- test with extattr, spaced type, array, nullable, optional -->
<dt>[FooBar] optional IceCandidate[] candidate</dt>
<dd>The new ICE candidate.</dd>
<dt>BestCandidate[]? winner</dt>
<dd>The Pirate Party for the win!</dd>
<h2>WebIDL Enum</h2>
<dl title='enum BunchOfThings' class='idl'>
<dt>something</dt>
<dd>The first option</dd>
<dt>something else whatever</dt>
<dd>The second option</dd>
</dl>
</section>
</body>
Expand Down
2 changes: 1 addition & 1 deletion js/core/css/respec2.css
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ pre.idl::before {
/*.idlModule*/
/*.idlModuleID*/
/*.idlInterface*/
.idlInterfaceID, .idlCallbackID {
.idlInterfaceID, .idlCallbackID, .idlEnumID {
font-weight: bold;
color: #005a9c;
}
Expand Down
129 changes: 69 additions & 60 deletions js/w3c/legacy.js
Original file line number Diff line number Diff line change
Expand Up @@ -968,7 +968,8 @@ berjon.respec.prototype = {
var df = w.makeMarkup();
idl.parentNode.replaceChild(df, idl);
if (inf.type == "interface" || inf.type == "exception" ||
inf.type == "dictionary" || inf.type == "typedef" || inf.type == "callback") infNames.push(inf.id);
inf.type == "dictionary" || inf.type == "typedef" ||
inf.type == "callback" || inf.type == "enum") infNames.push(inf.id);
}
document.normalize();
var ants = document.querySelectorAll("a:not([href])");
Expand Down Expand Up @@ -1041,6 +1042,7 @@ berjon.WebIDLProcessor.prototype = {
else if (str.indexOf("exception") == 0) this.exception(def, str, idl);
else if (str.indexOf("dictionary") == 0) this.dictionary(def, str, idl);
else if (str.indexOf("callback") == 0) this.callback(def, str, idl);
else if (str.indexOf("enum") == 0) this.enum(def, str, idl);
else if (str.indexOf("typedef") == 0) this.typedef(def, str, idl);
else if (/\bimplements\b/.test(str)) this.implements(def, str, idl);
else error("Expected definition, got: " + str);
Expand Down Expand Up @@ -1108,6 +1110,19 @@ berjon.WebIDLProcessor.prototype = {
return inf;
},

enum: function (inf, str, idl) {
inf.type = "enum";
var match = /^\s*enum\s+([A-Za-z][A-Za-z0-9]*)\s*$/.exec(str);
if (match) {
inf.id = match[1];
inf.refId = this._id(inf.id);
}
else {
error("Expected enum, got: " + str);
}
return inf;
},

exception: function (exc, str, idl) {
exc.type = "exception";
var match = /^\s*exception\s+([A-Za-z][A-Za-z0-9]*)\s*/.exec(str);
Expand Down Expand Up @@ -1181,6 +1196,9 @@ berjon.WebIDLProcessor.prototype = {
else if (obj.type == "callback") {
mem = this.callbackMember(dt, dd);
}
else if (obj.type == "enum") {
mem = this.enumMember(dt, dd);
}
else {
mem = this.interfaceMember(dt, dd);
}
Expand Down Expand Up @@ -1273,7 +1291,7 @@ berjon.WebIDLProcessor.prototype = {
}

// NOTHING MATCHED
error("Expected callback member, got: " + str);
error("Expected dictionary member, got: " + str);
},

callbackMember: function (dt, dd) {
Expand Down Expand Up @@ -1315,7 +1333,21 @@ berjon.WebIDLProcessor.prototype = {
}

// NOTHING MATCHED
error("Expected dictionary member, got: " + str);
error("Expected callback member, got: " + str);
},

enumMember: function (dt, dd) {
var mem = { children: [] };
var str = this._norm(dt.textContent);
mem.description = sn.documentFragment();
sn.copyChildren(dd, mem.description);
str = this.parseExtendedAttributes(str, mem);

// MEMBER
mem.type = "member";
mem.id = str;
mem.refId = this._id(mem.id);
return mem;
},

interfaceMember: function (dt, dd) {
Expand Down Expand Up @@ -1725,6 +1757,25 @@ berjon.WebIDLProcessor.prototype = {
return df;
}

else if (obj.type == "enum") {
var df = sn.documentFragment();
var curLnk = "widl-" + obj.refId + "-";
var things = obj.children;
if (things.length == 0) return df;

var sec = sn.element("table", { "class": "simple" }, df);
sn.element("tr", {}, sec, [sn.element("th", { colspan: 2 }, null, [sn.text("Enumeration description")])]);
for (var j = 0; j < things.length; j++) {
var it = things[j];
var tr = sn.element("tr", {}, sec)
, td1 = sn.element("td", {}, tr)
;
sn.element("code", {}, td1, it.id);
sn.element("td", {}, tr, [it.description]);
}
return df;
}

else if (obj.type == "interface") {
var df = sn.documentFragment();
var curLnk = "widl-" + obj.refId + "-";
Expand Down Expand Up @@ -1784,32 +1835,6 @@ berjon.WebIDLProcessor.prototype = {
else {
sn.element("div", {}, desc, [sn.element("em", {}, null, "No parameters.")]);
}
// if (it.raises.length) {
// var table = sn.element("table", { "class": "exceptions" }, desc);
// var tr = sn.element("tr", {}, table);
// ["Exception", "Description"].forEach(function (tit) { sn.element("th", {}, tr, tit); });
// for (var k = 0; k < it.raises.length; k++) {
// var exc = it.raises[k];
// var tr = sn.element("tr", {}, table);
// sn.element("td", { "class": "excName" }, tr, [sn.element("a", {}, null, exc.id)]);
// var dtd = sn.element("td", { "class": "excDesc" }, tr);
// if (exc.type == "simple") {
// dtd.appendChild(exc.description);
// }
// else {
// var ctab = sn.element("table", { "class": "exceptionCodes" }, dtd );
// for (var m = 0; m < exc.description.length; m++) {
// var cd = exc.description[m];
// var tr = sn.element("tr", {}, ctab);
// sn.element("td", { "class": "excCodeName" }, tr, [sn.element("code", {}, null, cd.id)]);
// sn.element("td", { "class": "excCodeDesc" }, tr, [cd.description]);
// }
// }
// }
// }
// else {
// sn.element("div", {}, desc, [sn.element("em", {}, null, "No exceptions.")]);
// }
var reDiv = sn.element("div", {}, desc);
sn.element("em", {}, reDiv, "Return type: ");
var matched = /^sequence<(.+)>$/.exec(it.datatype);
Expand Down Expand Up @@ -1840,37 +1865,6 @@ berjon.WebIDLProcessor.prototype = {
}
if (it.readonly) sn.text(", readonly", dt);
if (it.nullable) sn.text(", nullable", dt);

// if (it.raises.length) {
// var table = sn.element("table", { "class": "exceptions" }, desc);
// var tr = sn.element("tr", {}, table);
// ["Exception", "On Get", "On Set", "Description"].forEach(function (tit) { sn.element("th", {}, tr, tit); });
// for (var k = 0; k < it.raises.length; k++) {
// var exc = it.raises[k];
// var tr = sn.element("tr", {}, table);
// sn.element("td", { "class": "excName" }, tr, [sn.element("a", {}, null, exc.id)]);
// ["onGet", "onSet"].forEach(function (gs) {
// if (exc[gs]) sn.element("td", { "class": "excGetSetTrue" }, tr, "\u2714");
// else sn.element("td", { "class": "excGetSetFalse" }, tr, "\u2718");
// });
// var dtd = sn.element("td", { "class": "excDesc" }, tr);
// if (exc.type == "simple") {
// dtd.appendChild(exc.description);
// }
// else {
// var ctab = sn.element("table", { "class": "exceptionCodes" }, dtd );
// for (var m = 0; m < exc.description.length; m++) {
// var cd = exc.description[m];
// var tr = sn.element("tr", {}, ctab);
// sn.element("td", { "class": "excCodeName" }, tr, [sn.element("code", {}, null, cd.id)]);
// sn.element("td", { "class": "excCodeDesc" }, tr, [cd.description]);
// }
// }
// }
// }
// else {
// sn.element("div", {}, desc, [sn.element("em", {}, null, "No exceptions.")]);
// }
}
else if (type == "constant") {
sn.text(" of type ", dt);
Expand Down Expand Up @@ -2038,6 +2032,21 @@ berjon.WebIDLProcessor.prototype = {
str += ");</span>\n";
return str;
}
else if (obj.type == "enum") {
var str = "<span class='idlEnum' id='idl-def-" + obj.refId + "'>";
if (obj.extendedAttributes) str += this._idn(indent) + "[<span class='extAttr'>" + obj.extendedAttributes + "</span>]\n";
str += this._idn(indent) + "enum <span class='idlEnumID'>" + obj.id + "</span> {\n";

var curLnk = "widl-" + obj.refId + "-";
for (var i = 0; i < obj.children.length; i++) {
var ch = obj.children[i];
str += this._idn(indent + 1) + '"<span class="idlEnumItem">' + ch.id + '</span>"'
if (i < obj.children.length - 1) str += ","
str += "\n";
}
str += this._idn(indent) + "};</span>\n";
return str;
}
},

writeField: function (attr, max, indent, curLnk) {
Expand Down
2 changes: 1 addition & 1 deletion tools/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.0.5
3.0.6

0 comments on commit 6461758

Please sign in to comment.