From 36b58bc44cdcc4e73eb700ece2005105ee7baf65 Mon Sep 17 00:00:00 2001 From: John Ralls Date: Mon, 2 Jul 2012 21:24:07 +0000 Subject: [PATCH] Fix make-testfile to count references in UI files Some functions may be called only by callback reference in a GtkBuilder XML file (*.glade, *.xml, or *.ui). Indicate that usage in the test-file function summary. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@22259 57a11ea4-9604-0410-9ed3-97b8803252fd --- test-templates/make-testfile | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/test-templates/make-testfile b/test-templates/make-testfile index 6565c1ff3e..60dbdb1250 100755 --- a/test-templates/make-testfile +++ b/test-templates/make-testfile @@ -117,6 +117,19 @@ sub search_scheme { return ($calls, $files); } +sub search_glade { + my ($name) = @_; + my $calls = `egrep -r $name --include="*.glade" --include=*.xml" --include=*.ui" src | wc -l`; + chomp $calls; + $calls =~ s/\s//g; + my $files = `egrep -rl $name --include="*.glade" --include=*.xml" --include=*.ui" src | wc -l`; + chomp $files; + $files =~ s/\s//g; + + return ($calls, $files); +} + + sub search_local { my ($name, $inpath) = @_; open INFILE, "<$inpath" or die "Failed to open $inpath: $!"; @@ -147,7 +160,7 @@ sub search_local { sub process_function { my ($c_name, $static, $func, $inpath) = @_; - my ($ext_calls, $ext_files, $scm_calls, $scm_files, $not_used); + my ($ext_calls, $ext_files, $scm_calls, $scm_files, $ui_calls, $ui_files, $not_used); my $gobject_re = qr/_(?:init|constructor|dispose|finalize|[sg]et_property)$/; if ($c_name =~ /$gobject_re/) { print OUTFH "/* $c_name\n"; @@ -158,9 +171,10 @@ sub process_function { unless ($static) { ($ext_calls, $ext_files) = search_external($c_name, $inpath); ($scm_calls, $scm_files) = search_scheme($c_name); + ($ui_calls, $ui_files) = search_glade($c_name); } my ($local_calls, $local_callbacks, $local_refs) = search_local($c_name, $inpath); - unless ($ext_calls || $scm_calls) { + unless ($ext_calls || $scm_calls || $ui_calls) { my $local_use = $local_calls + $local_callbacks + $local_refs; print OUTFH "// Make Static\n" if !$static && $local_use > 1; unless ($local_use) { @@ -175,11 +189,13 @@ sub process_function { print OUTFH "/* $c_name\n"; print OUTFH join("\n", @$func); print OUTFH "// "; - print OUTFH "External: 0\n" if $ext_calls + $scm_calls == 0; + print OUTFH "External: 0\n" if $ext_calls + $scm_calls + $ui_calls == 0; print OUTFH "C: $ext_calls " if $ext_calls > 0; print OUTFH "in $ext_files " if $ext_calls > 1; print OUTFH "SCM: $scm_calls " if $scm_calls > 0; print OUTFH "in $scm_files" if $scm_calls > 1; + print OUTFH "UI: $ui_calls " if $ui_calls > 0; + print OUTFH "in $ui_files" if $ui_calls > 1; print OUTFH " Local: $local_calls:$local_callbacks:$local_refs\n"; print OUTFH "*/\n"; }