2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
2009-01-12 22:21:11 +03:00
|
|
|
/**
|
|
|
|
* graph-frameclasses.js: a dehydra script to collect information about
|
|
|
|
* the class hierarchy of frame types.
|
|
|
|
*/
|
|
|
|
|
|
|
|
function inheritsFrom(t, baseName)
|
|
|
|
{
|
|
|
|
let name = t.name;
|
|
|
|
if (name == baseName)
|
|
|
|
return true;
|
|
|
|
|
2015-06-20 10:16:51 +03:00
|
|
|
for (let base of t.bases)
|
2009-01-12 22:21:11 +03:00
|
|
|
if (inheritsFrom(base.type, baseName))
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-09-15 21:19:45 +03:00
|
|
|
var output = [];
|
2009-01-12 22:21:11 +03:00
|
|
|
|
|
|
|
function process_type(t)
|
|
|
|
{
|
|
|
|
if ((t.kind == "class" || t.kind == "struct")) {
|
|
|
|
if (!t.isIncomplete && inheritsFrom(t, 'nsIFrame')) {
|
|
|
|
if (inheritsFrom(t, 'nsISupports'))
|
2009-01-13 19:32:25 +03:00
|
|
|
warning("nsIFrame derivative %s inherits from nsISupports but is not refcounted.".format(t.name), t.loc);
|
2009-01-12 22:21:11 +03:00
|
|
|
|
|
|
|
let nonFrameBases = [];
|
|
|
|
|
|
|
|
output.push('CLASS-DEF: %s'.format(t.name));
|
|
|
|
|
2015-06-20 10:16:51 +03:00
|
|
|
for (let base of t.bases) {
|
2009-01-12 22:21:11 +03:00
|
|
|
if (inheritsFrom(base.type, 'nsIFrame')) {
|
|
|
|
output.push('%s -> %s;'.format(base.type.name, t.name));
|
|
|
|
}
|
|
|
|
else if (base.type.name != 'nsQueryFrame') {
|
|
|
|
nonFrameBases.push(base.type.name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
output.push('%s [label="%s%s"];'.format(t.name, t.name,
|
2015-06-20 10:16:51 +03:00
|
|
|
nonFrameBases.map(b => "\\n(%s)".format(b)).join('')));
|
2009-01-12 22:21:11 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-15 21:19:45 +03:00
|
|
|
var frameIIDRE = /::kFrameIID$/;
|
|
|
|
var queryFrameRE = /^do_QueryFrame::operator/;
|
2009-01-12 22:21:11 +03:00
|
|
|
|
|
|
|
/* A list of class names T that have do_QueryFrame<T> used */
|
2015-09-15 21:19:45 +03:00
|
|
|
var needIDs = [];
|
2009-01-12 22:21:11 +03:00
|
|
|
|
|
|
|
/* A map of class names that have a kFrameIID declared */
|
2015-09-15 21:19:45 +03:00
|
|
|
var haveIDs = {};
|
2009-01-12 22:21:11 +03:00
|
|
|
|
|
|
|
// We match up needIDs with haveIDs at the end because static variables are
|
|
|
|
// not present in the .members array of a type
|
|
|
|
|
2009-08-07 19:16:26 +04:00
|
|
|
function process_tree_decl(d)
|
2009-01-12 22:21:11 +03:00
|
|
|
{
|
2009-08-07 19:16:26 +04:00
|
|
|
d = dehydra_convert(d);
|
|
|
|
|
2011-08-30 04:02:22 +04:00
|
|
|
if (d.name && frameIIDRE.exec(d.name)) {
|
2009-08-07 19:16:26 +04:00
|
|
|
haveIDs[d.memberOf.name] = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function process_cp_pre_genericize(d)
|
|
|
|
{
|
|
|
|
d = dehydra_convert(d);
|
2011-08-30 04:02:22 +04:00
|
|
|
if (queryFrameRE.exec(d.name) && d.template === undefined) {
|
2009-08-07 19:16:26 +04:00
|
|
|
let templtype = d.type.type.type;
|
|
|
|
while (templtype.typedef !== undefined)
|
|
|
|
templtype = templtype.typedef;
|
2009-01-12 22:21:11 +03:00
|
|
|
|
2009-08-07 19:16:26 +04:00
|
|
|
needIDs.push([templtype.name, d.loc]);
|
2009-01-12 22:21:11 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function input_end()
|
|
|
|
{
|
2015-06-20 10:16:51 +03:00
|
|
|
for (let [name, loc] of needIDs) {
|
2009-01-12 22:21:11 +03:00
|
|
|
if (!haveIDs.hasOwnProperty(name)) {
|
|
|
|
error("nsQueryFrame<%s> found, but %s::kFrameIID is not declared".format(name, name), loc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (output.length > 0) {
|
|
|
|
write_file(sys.aux_base_name + '.framedata', output.join('\n'));
|
|
|
|
}
|
|
|
|
}
|