Skip to content

Commit 3055df5

Browse files
committed
Gadgets/Stdrev: Add debugging support
1 parent 45100fd commit 3055df5

1 file changed

Lines changed: 49 additions & 1 deletion

File tree

gadgets/standard_revisions.js

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919

2020
$(function() {
2121

22+
var debug = false;
23+
2224
function array_equal(a, b) {
2325
var i = a.length;
2426
if (i != b.length) {
@@ -213,6 +215,20 @@ $(function() {
213215
return [val, val, val, val];
214216
}
215217

218+
/// Prints values returned by is_shown_on_rev
219+
function debug_print_is_shown_on_rev(revs) {
220+
var out = '{ ';
221+
for (var i = 0; i < revs.length; i++) {
222+
if (revs[i]) {
223+
out += 't';
224+
} else {
225+
out += 'f';
226+
}
227+
}
228+
out += ' }';
229+
return out;
230+
}
231+
216232
var get_mark, is_shown_on_rev, is_shown_fill;
217233

218234
if (is_cxx) { // select either C or C++ version
@@ -628,7 +644,23 @@ $(function() {
628644
}
629645
});
630646

631-
// Get the mapping between revisions and function version numbers
647+
// Prints defs to a string
648+
function debug_print_defs(defs) {
649+
var out = '';
650+
for (var i = 0; i < defs.length; i++) {
651+
out += ' { ' + i + ': ' + defs[i].type + ' ' + defs[i].num;
652+
out += ' ' + debug_print_is_shown_on_rev(defs[i].revs);
653+
if (defs[i].type == 'r') {
654+
out += ' { ';
655+
for (var j = 0 ; j < defs[i].children.length; ++j) {
656+
out += defs[i].children[j] + ' ';
657+
}
658+
out += '}';
659+
}
660+
out += ' }\n';
661+
}
662+
return out;
663+
}
632664

633665
/* Get the mapping between revisions and function version numbers.
634666
The function returns an array:
@@ -678,7 +710,23 @@ $(function() {
678710
return num_map;
679711
};
680712

713+
// Prints num_map to a string
714+
function debug_print_num_map(num_map) {
715+
var out = '';
716+
for (var rev = Rev.FIRST; rev != Rev.LAST; ++rev) {
717+
out += '[' + desc[rev].title + ']: { ';
718+
out += num_map[rev] + ' }\n';
719+
}
720+
return out;
721+
}
722+
681723
var num_map = get_num_map();
724+
725+
if (debug) {
726+
alert(debug_print_defs(defs) + '\n\n' +
727+
debug_print_num_map(num_map));
728+
}
729+
682730
// Analyze the abstract description again and modify the DOM
683731
function clear_rev_marks(tr) {
684732
marks = tr.children('td').eq(2).find('.t-mark-rev');

0 commit comments

Comments
 (0)