forked from mozilla/gecko-dev
-
Notifications
You must be signed in to change notification settings - Fork 2
/
frame-verify.js
95 lines (75 loc) · 2.5 KB
/
frame-verify.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/* 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/. */
/**
* 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;
for each (let base in t.bases)
if (inheritsFrom(base.type, baseName))
return true;
return false;
}
let output = [];
function process_type(t)
{
if ((t.kind == "class" || t.kind == "struct")) {
if (!t.isIncomplete && inheritsFrom(t, 'nsIFrame')) {
if (inheritsFrom(t, 'nsISupports'))
warning("nsIFrame derivative %s inherits from nsISupports but is not refcounted.".format(t.name), t.loc);
let nonFrameBases = [];
output.push('CLASS-DEF: %s'.format(t.name));
for each (let base in t.bases) {
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,
["\\n(%s)".format(b) for each (b in nonFrameBases)].join('')));
}
}
}
let frameIIDRE = /::kFrameIID$/;
let queryFrameRE = /^do_QueryFrame::operator/;
/* A list of class names T that have do_QueryFrame<T> used */
let needIDs = [];
/* A map of class names that have a kFrameIID declared */
let haveIDs = {};
// We match up needIDs with haveIDs at the end because static variables are
// not present in the .members array of a type
function process_tree_decl(d)
{
d = dehydra_convert(d);
if (d.name && frameIIDRE.exec(d.name)) {
haveIDs[d.memberOf.name] = 1;
}
}
function process_cp_pre_genericize(d)
{
d = dehydra_convert(d);
if (queryFrameRE.exec(d.name) && d.template === undefined) {
let templtype = d.type.type.type;
while (templtype.typedef !== undefined)
templtype = templtype.typedef;
needIDs.push([templtype.name, d.loc]);
}
}
function input_end()
{
for each (let [name, loc] in needIDs) {
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'));
}
}