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

Add support for union types to callbacks #190

Merged
merged 1 commit into from Apr 9, 2013
Merged
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
30 changes: 15 additions & 15 deletions js/core/webidl-oldschool.js
Expand Up @@ -189,8 +189,8 @@ define(
return isOptional;
}
}


, definition: function ($idl) {
var def = { children: [] }
, str = $idl.attr("title")
Expand Down Expand Up @@ -342,7 +342,7 @@ define(
, str = norm($dt.text());
obj.description = $dd.contents();
str = this.parseExtendedAttributes(str, obj);

// CONST
if (this.parseConst(obj, str)) return obj;

Expand Down Expand Up @@ -388,7 +388,7 @@ define(
str = this.parseExtendedAttributes(str, obj);

// MEMBER
var match = /^\s*\b(.*?)\s+([A-Za-z][A-Za-z0-9]*)\s*$/.exec(str);
var match = /^\s*(.*?)\s+([A-Za-z][A-Za-z0-9]*)\s*$/.exec(str);
if (match) {
obj.type = "member";
var type = match[1];
Expand Down Expand Up @@ -625,7 +625,7 @@ define(
}
return obj;
},

parseDatatype: function (obj, type) {
type = this.nullable(obj, type);
type = this.array(obj, type);
Expand All @@ -643,7 +643,7 @@ define(
obj.datatype = type;
}
},

parseStatic: function (obj, type) {
if (/^static\s+/.test(type)) {
type = type.replace(/^static\s+/, "");
Expand All @@ -654,7 +654,7 @@ define(
}
return type;
},

parseExtendedAttributes: function (str, obj) {
if (!str) return;
return str.replace(/^\s*\[([^\]]+)\]\s*/, function (x, m1) { obj.extendedAttributes = m1; return ""; });
Expand Down Expand Up @@ -848,7 +848,7 @@ define(
sn.text(">", span);
}
else {
sn.element("a", {}, span, it.datatype);
sn.element("a", {}, span, it.isUnionType ? "(" + it.datatype.join(" or ") + ")" : it.datatype);
}
if (it.nullable) sn.text(", nullable", dt);
if (it.defaultValue) {
Expand Down Expand Up @@ -1122,17 +1122,17 @@ define(
}
else return $(idlModuleTmpl(opt));
}

else if (obj.type === "typedef") {
opt.nullable = obj.nullable ? "?" : "";
opt.arr = arrsq(obj);
return $(idlTypedefTmpl(opt));
}

else if (obj.type === "implements") {
return $(idlImplementsTmpl(opt));
}

else if (obj.type === "interface") {
// stop gap fix for duplicate IDs while we're transitioning the code
var div = this.doc.createElement("div")
Expand Down Expand Up @@ -1174,7 +1174,7 @@ define(
, children: children
});
}

else if (obj.type === "exception") {
var maxAttr = 0, maxConst = 0;
obj.children.forEach(function (it) {
Expand All @@ -1195,7 +1195,7 @@ define(
;
return idlExceptionTmpl({ obj: obj, indent: indent, children: children });
}

else if (obj.type === "dictionary") {
var max = 0;
obj.children.forEach(function (it) {
Expand All @@ -1214,7 +1214,7 @@ define(
;
return idlDictionaryTmpl({ obj: obj, indent: indent, children: children, partial: obj.partial ? "partial " : "" });
}

else if (obj.type === "callback") {
var params = obj.children
.map(function (it) {
Expand All @@ -1235,7 +1235,7 @@ define(
, children: params
});
}

else if (obj.type === "enum") {
var children = obj.children
.map(function (it) { return idlEnumItemTmpl({ obj: it, parentID: obj.refId, indent: indent + 1 }); })
Expand Down