From 04d02e08b6f464a6d6aeed57e2626e5a2784ca99 Mon Sep 17 00:00:00 2001 From: David Schleef Date: Sat, 22 Nov 2003 04:08:11 +0000 Subject: [PATCH] check g_signal_new() calls Original commit message from CVS: check g_signal_new() calls --- tests/old/testsuite/gst-lint | 22 ++++++++++++++++++++++ testsuite/gst-lint | 22 ++++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/tests/old/testsuite/gst-lint b/tests/old/testsuite/gst-lint index 3a5d468176..97575fef1f 100755 --- a/tests/old/testsuite/gst-lint +++ b/tests/old/testsuite/gst-lint @@ -38,6 +38,7 @@ sub check_debugging(); sub check_old_typefind(); sub check_bad_casts(); sub check_old_plugin(); +sub check_signal_new(); sub m_check_plugindir(); @@ -69,6 +70,7 @@ foreach $filename () { check_old_typefind(); check_bad_casts(); check_old_plugin(); + check_signal_new(); } open FIND, "find . -name \"Makefile.am\" -print|"; @@ -377,3 +379,23 @@ sub check_old_plugin() } } +# +# Check for calls to g_signal_new() with a callback type of G_TYPE_POINTER +# +sub check_signal_new() +{ + my $n = 0; + my $lineno = 1; + + foreach $line (@lines){ + if($line =~ /g_signal_new/){ + $n=5; + } + if($n>0 && $line =~ /G_TYPE_POINTER/){ + print "W: ($lineno) g_signal_new() with callback type of G_TYPE_POINTER. Register and use a boxed type instead.\n"; + return; + } + $n--; + $lineno++; + } +} diff --git a/testsuite/gst-lint b/testsuite/gst-lint index 3a5d468176..97575fef1f 100755 --- a/testsuite/gst-lint +++ b/testsuite/gst-lint @@ -38,6 +38,7 @@ sub check_debugging(); sub check_old_typefind(); sub check_bad_casts(); sub check_old_plugin(); +sub check_signal_new(); sub m_check_plugindir(); @@ -69,6 +70,7 @@ foreach $filename () { check_old_typefind(); check_bad_casts(); check_old_plugin(); + check_signal_new(); } open FIND, "find . -name \"Makefile.am\" -print|"; @@ -377,3 +379,23 @@ sub check_old_plugin() } } +# +# Check for calls to g_signal_new() with a callback type of G_TYPE_POINTER +# +sub check_signal_new() +{ + my $n = 0; + my $lineno = 1; + + foreach $line (@lines){ + if($line =~ /g_signal_new/){ + $n=5; + } + if($n>0 && $line =~ /G_TYPE_POINTER/){ + print "W: ($lineno) g_signal_new() with callback type of G_TYPE_POINTER. Register and use a boxed type instead.\n"; + return; + } + $n--; + $lineno++; + } +}