2 * graph-frameclasses.js: a dehydra script to collect information about
3 * the class hierarchy of frame types.
6 function inheritsFrom(t, baseName)
12 for each (let base in t.bases)
13 if (inheritsFrom(base.type, baseName))
21 function process_type(t)
23 if ((t.kind == "class" || t.kind == "struct")) {
24 if (!t.isIncomplete && inheritsFrom(t, 'nsIFrame')) {
25 if (inheritsFrom(t, 'nsISupports'))
26 warning("nsIFrame derivative %s inherits from nsISupports but is not refcounted.".format(t.name), t.loc);
28 let nonFrameBases = [];
30 output.push('CLASS-DEF: %s'.format(t.name));
32 for each (let base in t.bases) {
33 if (inheritsFrom(base.type, 'nsIFrame')) {
34 output.push('%s -> %s;'.format(base.type.name, t.name));
36 else if (base.type.name != 'nsQueryFrame') {
37 nonFrameBases.push(base.type.name);
41 output.push('%s [label="%s%s"];'.format(t.name, t.name,
42 ["\\n(%s)".format(b) for each (b in nonFrameBases)].join('')));
47 let frameIIDRE = /::kFrameIID$/;
48 let queryFrameRE = /^do_QueryFrame::operator/;
50 /* A list of class names T that have do_QueryFrame<T> used */
53 /* A map of class names that have a kFrameIID declared */
56 // We match up needIDs with haveIDs at the end because static variables are
57 // not present in the .members array of a type
59 function process_tree_decl(d)
61 d = dehydra_convert(d);
63 if (d.name && frameIIDRE(d.name)) {
64 haveIDs[d.memberOf.name] = 1;
68 function process_cp_pre_genericize(d)
70 d = dehydra_convert(d);
71 if (queryFrameRE(d.name) && d.template === undefined) {
72 let templtype = d.type.type.type;
73 while (templtype.typedef !== undefined)
74 templtype = templtype.typedef;
76 needIDs.push([templtype.name, d.loc]);
82 for each (let [name, loc] in needIDs) {
83 if (!haveIDs.hasOwnProperty(name)) {
84 error("nsQueryFrame<%s> found, but %s::kFrameIID is not declared".format(name, name), loc);
88 if (output.length > 0) {
89 write_file(sys.aux_base_name + '.framedata', output.join('\n'));