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

Quick hack to support partial dictionaries #100

Merged
merged 1 commit into from Nov 14, 2012
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
2 changes: 1 addition & 1 deletion js/core/templates/webidl/dictionary.html
@@ -1,3 +1,3 @@
<span class='idlDictionary' id='idl-def-{{obj.refId}}'>{{extAttr obj indent true
}}{{idn indent}}dictionary <span class='idlDictionaryID'>{{obj.id}}</span>{{superclasses obj}} {
}}{{idn indent}}{{partial}}dictionary <span class='idlDictionaryID'>{{obj.id}}</span>{{superclasses obj}} {
{{{children}}}};</span>
21 changes: 15 additions & 6 deletions js/core/webidl-oldschool.js
Expand Up @@ -174,8 +174,13 @@ define(
, str = $idl.attr("title")
, id = $idl.attr("id");
str = this.parseExtendedAttributes(str, def);
if (str.indexOf("interface") === 0 ||
str.indexOf("partial") === 0 ||
if (str.indexOf("partial") === 0) { // Could be interface or dictionary
var defType = str.slice(8);
if (defType.indexOf("interface") === 0) this.processInterface(def, str, $idl, { partial : true });
else if (defType.indexOf("dictionary") === 0) this.dictionary(def, defType, $idl, { partial : true });
else this.msg.pub("error", "Expected definition, got: " + str);
}
else if (str.indexOf("interface") === 0 ||
/^callback\s+interface\b/.test(str)) this.processInterface(def, str, $idl);
else if (str.indexOf("exception") === 0) this.exception(def, str, $idl);
else if (str.indexOf("dictionary") === 0) this.dictionary(def, str, $idl);
Expand All @@ -190,11 +195,13 @@ define(
return def;
},

processInterface: function (obj, str, $idl) {
processInterface: function (obj, str, $idl, opt) {
opt = opt || {};
obj.type = "interface";
obj.partial = opt.partial || false;

var match = /^\s*(?:(partial|callback)\s+)?interface\s+([A-Za-z][A-Za-z0-9]*)(?:\s+:\s*([^{]+)\s*)?/.exec(str);
if (match) {
obj.partial = !!match[1] && match[1] === "partial";
obj.callback = !!match[1] && match[1] === "callback";
this.setID(obj, match[2]);
if ($idl.attr('data-merge')) obj.merge = $idl.attr('data-merge').split(' ');
Expand All @@ -204,7 +211,9 @@ define(
return obj;
},

dictionary: function (obj, str, $idl) {
dictionary: function (obj, str, $idl, opt) {
opt = opt || {};
obj.partial = opt.partial || false;
return this.excDic("dictionary", obj, str, $idl);
},

Expand Down Expand Up @@ -1020,7 +1029,7 @@ define(
})
.join("")
;
return idlDictionaryTmpl({ obj: obj, indent: indent, children: children });
return idlDictionaryTmpl({ obj: obj, indent: indent, children: children, partial: obj.partial ? "partial " : "" });
}

else if (obj.type === "callback") {
Expand Down