Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 4 | |
michael@0 | 5 | /** |
michael@0 | 6 | * graph-frameclasses.js: a dehydra script to collect information about |
michael@0 | 7 | * the class hierarchy of frame types. |
michael@0 | 8 | */ |
michael@0 | 9 | |
michael@0 | 10 | function inheritsFrom(t, baseName) |
michael@0 | 11 | { |
michael@0 | 12 | let name = t.name; |
michael@0 | 13 | if (name == baseName) |
michael@0 | 14 | return true; |
michael@0 | 15 | |
michael@0 | 16 | for each (let base in t.bases) |
michael@0 | 17 | if (inheritsFrom(base.type, baseName)) |
michael@0 | 18 | return true; |
michael@0 | 19 | |
michael@0 | 20 | return false; |
michael@0 | 21 | } |
michael@0 | 22 | |
michael@0 | 23 | let output = []; |
michael@0 | 24 | |
michael@0 | 25 | function process_type(t) |
michael@0 | 26 | { |
michael@0 | 27 | if ((t.kind == "class" || t.kind == "struct")) { |
michael@0 | 28 | if (!t.isIncomplete && inheritsFrom(t, 'nsIFrame')) { |
michael@0 | 29 | if (inheritsFrom(t, 'nsISupports')) |
michael@0 | 30 | warning("nsIFrame derivative %s inherits from nsISupports but is not refcounted.".format(t.name), t.loc); |
michael@0 | 31 | |
michael@0 | 32 | let nonFrameBases = []; |
michael@0 | 33 | |
michael@0 | 34 | output.push('CLASS-DEF: %s'.format(t.name)); |
michael@0 | 35 | |
michael@0 | 36 | for each (let base in t.bases) { |
michael@0 | 37 | if (inheritsFrom(base.type, 'nsIFrame')) { |
michael@0 | 38 | output.push('%s -> %s;'.format(base.type.name, t.name)); |
michael@0 | 39 | } |
michael@0 | 40 | else if (base.type.name != 'nsQueryFrame') { |
michael@0 | 41 | nonFrameBases.push(base.type.name); |
michael@0 | 42 | } |
michael@0 | 43 | } |
michael@0 | 44 | |
michael@0 | 45 | output.push('%s [label="%s%s"];'.format(t.name, t.name, |
michael@0 | 46 | ["\\n(%s)".format(b) for each (b in nonFrameBases)].join(''))); |
michael@0 | 47 | } |
michael@0 | 48 | } |
michael@0 | 49 | } |
michael@0 | 50 | |
michael@0 | 51 | let frameIIDRE = /::kFrameIID$/; |
michael@0 | 52 | let queryFrameRE = /^do_QueryFrame::operator/; |
michael@0 | 53 | |
michael@0 | 54 | /* A list of class names T that have do_QueryFrame<T> used */ |
michael@0 | 55 | let needIDs = []; |
michael@0 | 56 | |
michael@0 | 57 | /* A map of class names that have a kFrameIID declared */ |
michael@0 | 58 | let haveIDs = {}; |
michael@0 | 59 | |
michael@0 | 60 | // We match up needIDs with haveIDs at the end because static variables are |
michael@0 | 61 | // not present in the .members array of a type |
michael@0 | 62 | |
michael@0 | 63 | function process_tree_decl(d) |
michael@0 | 64 | { |
michael@0 | 65 | d = dehydra_convert(d); |
michael@0 | 66 | |
michael@0 | 67 | if (d.name && frameIIDRE.exec(d.name)) { |
michael@0 | 68 | haveIDs[d.memberOf.name] = 1; |
michael@0 | 69 | } |
michael@0 | 70 | } |
michael@0 | 71 | |
michael@0 | 72 | function process_cp_pre_genericize(d) |
michael@0 | 73 | { |
michael@0 | 74 | d = dehydra_convert(d); |
michael@0 | 75 | if (queryFrameRE.exec(d.name) && d.template === undefined) { |
michael@0 | 76 | let templtype = d.type.type.type; |
michael@0 | 77 | while (templtype.typedef !== undefined) |
michael@0 | 78 | templtype = templtype.typedef; |
michael@0 | 79 | |
michael@0 | 80 | needIDs.push([templtype.name, d.loc]); |
michael@0 | 81 | } |
michael@0 | 82 | } |
michael@0 | 83 | |
michael@0 | 84 | function input_end() |
michael@0 | 85 | { |
michael@0 | 86 | for each (let [name, loc] in needIDs) { |
michael@0 | 87 | if (!haveIDs.hasOwnProperty(name)) { |
michael@0 | 88 | error("nsQueryFrame<%s> found, but %s::kFrameIID is not declared".format(name, name), loc); |
michael@0 | 89 | } |
michael@0 | 90 | } |
michael@0 | 91 | |
michael@0 | 92 | if (output.length > 0) { |
michael@0 | 93 | write_file(sys.aux_base_name + '.framedata', output.join('\n')); |
michael@0 | 94 | } |
michael@0 | 95 | } |