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

Commit

Permalink
Add support for union types to callbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
lanthaler committed Apr 5, 2013
1 parent 230fe9b commit f65d78e
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions js/core/webidl-oldschool.js
Original file line number Diff line number Diff line change
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

0 comments on commit f65d78e

Please sign in to comment.