Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for static attributes in WebIDL oldschool #527

Merged
merged 2 commits into from Nov 24, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 5 additions & 4 deletions js/core/webidl-oldschool.js
Expand Up @@ -431,14 +431,15 @@ define(
var match;

// ATTRIBUTE
match = /^\s*(?:(readonly|inherit|stringifier)\s+)?attribute\s+(.*?)\s+(\S+)\s*$/.exec(str);
match = /^\s*(?:(static)\s+)?(?:(readonly|inherit|stringifier)\s+)?attribute\s+(.*?)\s+(\S+)\s*$/.exec(str);
if (match) {
obj.type = "attribute";
obj.declaration = match[1] ? match[1] : "";
obj.declaration += (new Array(12-obj.declaration.length)).join(" "); // fill string with spaces
var type = match[2];
obj.declaration += (obj.declaration ? " " : "") + (match[2] !== undefined ? match[2] : "");
obj.declaration += (new Array(16-obj.declaration.length)).join(" "); // fill string with spaces
var type = match[3];
this.parseDatatype(obj, type);
this.setID(obj, match[3]);
this.setID(obj, match[4]);
obj.raises = [];
$sgrs.each(function () {
var $el = $(this)
Expand Down
43 changes: 23 additions & 20 deletions tests/spec/core/webidl-oldschool-spec.js
Expand Up @@ -134,19 +134,20 @@ describe("Core - WebIDL", function () {
it("should handle attributes", function () {
$target = $("#attr-basic", doc);
text = "interface SuperStar {\n" +
" attribute DOMString regular;\n" +
" readonly attribute DOMString ro;\n" +
" readonly attribute DOMString _readonly;\n" +
" inherit attribute DOMString in;\n" +
" stringifier attribute DOMString st;\n" +
" attribute DOMString regular;\n" +
" readonly attribute DOMString ro;\n" +
" readonly attribute DOMString _readonly;\n" +
" inherit attribute DOMString in;\n" +
" stringifier attribute DOMString st;\n" +
" [Something]\n" +
" readonly attribute DOMString ext;\n" +
" attribute sequence<Date> dates;\n" +
" attribute Promise<DOMString> operation;\n" +
" attribute sequence<Promise<Superstar>> wouldBeStars;\n" +
" readonly attribute DOMString ext;\n" +
" attribute sequence<Date> dates;\n" +
" attribute Promise<DOMString> operation;\n" +
" attribute sequence<Promise<Superstar>> wouldBeStars;\n" +
" static readonly attribute FrozenArray<RTCIceServer> xdefaultIceServers;\n" +
"};";
expect($target.text()).toEqual(text);
expect($target.find(".idlAttribute").length).toEqual(9);
expect($target.find(".idlAttribute").length).toEqual(10);
var $at = $target.find(".idlAttribute").first();
expect($at.find(".idlAttrType").text()).toEqual("DOMString");
expect($at.find(".idlAttrName").text()).toEqual("regular");
Expand All @@ -160,9 +161,9 @@ describe("Core - WebIDL", function () {
expect($seqpromise.find(".idlAttrType").text()).toEqual("sequence<Promise<Superstar>>");

var $sec = $("#attributes-1 dl.attributes", doc);
expect($sec.find("dt").length).toEqual(9);
expect($sec.find("dt").length).toEqual(10);
expect($sec.find("dt").eq(4).find("code").text()).toEqual("readonly");
expect($sec.find("dd").length).toEqual(9);
expect($sec.find("dd").length).toEqual(10);
expect($sec.find("dt").first().find("code").first().text()).toEqual("dates");
expect($sec.find("dt").first().find(".idlAttrType").text()).toEqual("sequence<Date>");
expect($sec.find("dd").first().text()).toEqual("3.5");
Expand All @@ -171,6 +172,8 @@ describe("Core - WebIDL", function () {
expect($sec.find("dd").eq(3).text()).toEqual("4.0");
expect($sec.find("dt").eq(8).find(".idlAttrType").text()).toEqual("sequence<Promise<Superstar>>");
expect($sec.find("dd").eq(8).text()).toEqual("4.5");
expect($sec.find("dt").eq(9).find(".idlAttrType").text()).toEqual("FrozenArray<RTCIceServer>");
expect($sec.find("dd").eq(9).text()).toEqual("4.6");
});

it("should handle operations", function () {
Expand Down Expand Up @@ -199,8 +202,8 @@ describe("Core - WebIDL", function () {
it("should handle serializer", function () {
$target = $("#serializer-map", doc);
text = "interface SuperStar {\n" +
" attribute DOMString foo;\n" +
" attribute DOMString bar;\n" +
" attribute DOMString foo;\n" +
" attribute DOMString bar;\n" +
" serializer = {foo, bar};\n" +
"};";
expect($target.text()).toEqual(text);
Expand All @@ -214,7 +217,7 @@ describe("Core - WebIDL", function () {
text = "interface SuperStar {\n" +
" void foo ();\n" +
" maplike<DOMString, SuperStar>;\n" +
" attribute DOMString bar;\n" +
" attribute DOMString bar;\n" +
"};";
expect($target.text()).toEqual(text);
expect($target.find(".idlMaplike").length).toEqual(1);
Expand All @@ -228,7 +231,7 @@ describe("Core - WebIDL", function () {
text = "interface SuperStar {\n" +
" void foo ();\n" +
" readonly maplike<DOMString, SuperStar>;\n" +
" attribute DOMString bar;\n" +
" attribute DOMString bar;\n" +
"};";
expect($target.text()).toEqual(text);
expect($target.find(".idlMaplike").length).toEqual(1);
Expand All @@ -241,8 +244,8 @@ describe("Core - WebIDL", function () {
$target = $("#if-iterable", doc);
text = "interface AnIterableInterface {\n" +
" iterable<DOMString>;\n" +
" attribute DOMString foo;\n" +
" attribute DOMString bar;\n" +
" attribute DOMString foo;\n" +
" attribute DOMString bar;\n" +
"};";
expect($target.text()).toEqual(text);
expect($target.find(".idlIterable").length).toEqual(1);
Expand All @@ -254,8 +257,8 @@ describe("Core - WebIDL", function () {
$target = $("#if-iterable-pairs", doc);
text = "interface AnIterablePairInterface {\n" +
" iterable<DOMString,SuperStar>;\n" +
" attribute DOMString foo;\n" +
" attribute DOMString bar;\n" +
" attribute DOMString foo;\n" +
" attribute DOMString bar;\n" +
"};";
expect($target.text()).toEqual(text);
expect($target.find(".idlIterable").length).toEqual(1);
Expand Down
3 changes: 2 additions & 1 deletion tests/spec/core/webidl.html
Expand Up @@ -194,7 +194,8 @@ <h2>Attributes</h2>
<dd>4.0</dd>
<dt>attribute sequence&lt;Promise&lt;Superstar&gt;&gt; wouldBeStars</dt>
<dd>4.5</dd>

<dt>static readonly attribute FrozenArray&lt;RTCIceServer> xdefaultIceServers</dt>
<dd>4.6</dd>
<!-- <dt>static attribute DOMString unmovable</dt>
<dd>3</dd>
<dt>stringifier attribute DOMString asString</dt>
Expand Down