1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/layout/generic/frame-verify.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,95 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 + 1.8 +/** 1.9 + * graph-frameclasses.js: a dehydra script to collect information about 1.10 + * the class hierarchy of frame types. 1.11 + */ 1.12 + 1.13 +function inheritsFrom(t, baseName) 1.14 +{ 1.15 + let name = t.name; 1.16 + if (name == baseName) 1.17 + return true; 1.18 + 1.19 + for each (let base in t.bases) 1.20 + if (inheritsFrom(base.type, baseName)) 1.21 + return true; 1.22 + 1.23 + return false; 1.24 +} 1.25 + 1.26 +let output = []; 1.27 + 1.28 +function process_type(t) 1.29 +{ 1.30 + if ((t.kind == "class" || t.kind == "struct")) { 1.31 + if (!t.isIncomplete && inheritsFrom(t, 'nsIFrame')) { 1.32 + if (inheritsFrom(t, 'nsISupports')) 1.33 + warning("nsIFrame derivative %s inherits from nsISupports but is not refcounted.".format(t.name), t.loc); 1.34 + 1.35 + let nonFrameBases = []; 1.36 + 1.37 + output.push('CLASS-DEF: %s'.format(t.name)); 1.38 + 1.39 + for each (let base in t.bases) { 1.40 + if (inheritsFrom(base.type, 'nsIFrame')) { 1.41 + output.push('%s -> %s;'.format(base.type.name, t.name)); 1.42 + } 1.43 + else if (base.type.name != 'nsQueryFrame') { 1.44 + nonFrameBases.push(base.type.name); 1.45 + } 1.46 + } 1.47 + 1.48 + output.push('%s [label="%s%s"];'.format(t.name, t.name, 1.49 + ["\\n(%s)".format(b) for each (b in nonFrameBases)].join(''))); 1.50 + } 1.51 + } 1.52 +} 1.53 + 1.54 +let frameIIDRE = /::kFrameIID$/; 1.55 +let queryFrameRE = /^do_QueryFrame::operator/; 1.56 + 1.57 +/* A list of class names T that have do_QueryFrame<T> used */ 1.58 +let needIDs = []; 1.59 + 1.60 +/* A map of class names that have a kFrameIID declared */ 1.61 +let haveIDs = {}; 1.62 + 1.63 +// We match up needIDs with haveIDs at the end because static variables are 1.64 +// not present in the .members array of a type 1.65 + 1.66 +function process_tree_decl(d) 1.67 +{ 1.68 + d = dehydra_convert(d); 1.69 + 1.70 + if (d.name && frameIIDRE.exec(d.name)) { 1.71 + haveIDs[d.memberOf.name] = 1; 1.72 + } 1.73 +} 1.74 + 1.75 +function process_cp_pre_genericize(d) 1.76 +{ 1.77 + d = dehydra_convert(d); 1.78 + if (queryFrameRE.exec(d.name) && d.template === undefined) { 1.79 + let templtype = d.type.type.type; 1.80 + while (templtype.typedef !== undefined) 1.81 + templtype = templtype.typedef; 1.82 + 1.83 + needIDs.push([templtype.name, d.loc]); 1.84 + } 1.85 +} 1.86 + 1.87 +function input_end() 1.88 +{ 1.89 + for each (let [name, loc] in needIDs) { 1.90 + if (!haveIDs.hasOwnProperty(name)) { 1.91 + error("nsQueryFrame<%s> found, but %s::kFrameIID is not declared".format(name, name), loc); 1.92 + } 1.93 + } 1.94 + 1.95 + if (output.length > 0) { 1.96 + write_file(sys.aux_base_name + '.framedata', output.join('\n')); 1.97 + } 1.98 +}