summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKalev Lember <kalev@smartlink.ee>2011-05-02 15:24:24 +0300
committerMurray Cumming <murrayc@murrayc.com>2011-05-03 09:36:02 +0200
commit6b514655c29c760786ab0eefbcc8c9e1412f56aa (patch)
tree6f33fd910836b17759d8d2daef3c5fdaad73a7a0
parent4679488b0d0c47b89e04aa048d62cdb49783bfed (diff)
downloadglibmm-6b514655c29c760786ab0eefbcc8c9e1412f56aa.tar.gz
gmmproc: Factored some copy-pasted code out to a common function
* tools/generate_wrap_init.pl.in: Added print_with_guards() subroutine and replaced all _DISABLE_DEPRECATED and G_OS_WIN32 guard printing with calls to print_with_guards().
-rw-r--r--ChangeLog8
-rw-r--r--tools/generate_wrap_init.pl.in125
2 files changed, 41 insertions, 92 deletions
diff --git a/ChangeLog b/ChangeLog
index d15216f9..dba8c15b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2011-05-03 Kalev Lember <kalev@smartlink.ee>
+
+ gmmproc: Factored some copy-pasted code out to a common function
+
+ * tools/generate_wrap_init.pl.in: Added print_with_guards() subroutine
+ and replaced all _DISABLE_DEPRECATED and G_OS_WIN32 guard printing with
+ calls to print_with_guards().
+
2011-05-03 Volker Grabsch <bugzilla.gnome.org@v.notjusthosting.com>
Examples build: Use the GLIB_COMPILE_SCHEMAS variable.
diff --git a/tools/generate_wrap_init.pl.in b/tools/generate_wrap_init.pl.in
index 5d62bf2d..cf5339d6 100644
--- a/tools/generate_wrap_init.pl.in
+++ b/tools/generate_wrap_init.pl.in
@@ -18,6 +18,35 @@ my %basenames = ();
my %win32_nowrap = ();
my %deprecated = ();
+sub print_with_guards
+{
+ my $object = $_[0];
+ my $message = $_[1];
+ if( $deprecated{$object} eq 1 )
+ {
+ # The uc(parent_dir) is a bit of a hack. One day it will get it wrong.
+ print "#ifndef " . uc($parent_dir) ."_DISABLE_DEPRECATED\n"
+ }
+
+ #On Win32, these classes are not compiled:
+ if( $win32_nowrap{$object} eq 1 )
+ {
+ print "#ifndef G_OS_WIN32\n"
+ }
+
+ print "$message";
+
+ if( $win32_nowrap{$object} eq 1 )
+ {
+ print "#endif //G_OS_WIN32\n"
+ }
+
+ if( $deprecated{$object} eq 1 )
+ {
+ print "#endif // *_DISABLE_DEPRECATED\n"
+ }
+}
+
# Loop through command line arguments, setting variables:
while ($ARGV[0] =~ /^-/)
{
@@ -202,29 +231,7 @@ print "\n//Declarations of the *_get_type() functions:\n\n";
my $i = 0;
foreach $i (sort keys %objects)
{
- if( $deprecated{$i} eq 1 )
- {
- # The uc(parent_dir) is a bit of a hack. One day it will get it wrong.
- print "#ifndef " . uc($parent_dir) ."_DISABLE_DEPRECATED\n"
- }
-
- #On Win32, these classes are not compiled:
- if( $win32_nowrap{$i} eq 1 )
- {
- print "#ifndef G_OS_WIN32\n"
- }
-
- print "GType $basenames{$i}_get_type(void);\n";
-
- if( $win32_nowrap{$i} eq 1 )
- {
- print "#endif //G_OS_WIN32\n"
- }
-
- if( $deprecated{$i} eq 1 )
- {
- print "#endif // *_DISABLE_DEPRECATED\n"
- }
+ print_with_guards( $i, "GType $basenames{$i}_get_type(void);\n" );
}
print "\n//Declarations of the *_error_quark() functions:\n\n";
@@ -243,18 +250,6 @@ print "\n//Declarations of the *_Class::wrap_new() methods, instead of including
my $i = 0;
foreach $i (sort keys %objects)
{
- if( $deprecated{$i} eq 1 )
- {
- # The uc(parent_dir) is a bit of a hack. One day it will get it wrong.
- print "#ifndef " . uc($parent_dir) ."_DISABLE_DEPRECATED\n"
- }
-
- #On Win32, these classes are not compiled:
- if( $win32_nowrap{$i} eq 1 )
- {
- print "#ifndef G_OS_WIN32\n"
- }
-
my $namespace_declarations = "";
my $namespace_close = "";
foreach ( @{$namespaces{$i}} )
@@ -263,17 +258,7 @@ foreach $i (sort keys %objects)
$namespace_close .= " }";
}
- print "${namespace_declarations} class ${i}_Class { public: static Glib::ObjectBase* wrap_new(GObject*); }; ${namespace_close}\n";
-
- if( $win32_nowrap{$i} eq 1 )
- {
- print "#endif //G_OS_WIN32\n"
- }
-
- if( $deprecated{$i} eq 1 )
- {
- print "#endif // *_DISABLE_DEPRECATED\n"
- }
+ print_with_guards( $i, "${namespace_declarations} class ${i}_Class { public: static Glib::ObjectBase* wrap_new(GObject*); }; ${namespace_close}\n" );
}
# print "\n//Declarations of the *Error::throw_func() methods:\n\n";
@@ -327,35 +312,13 @@ print "// Map gtypes to gtkmm wrapper-creation functions:\n";
foreach $i (sort keys %objects)
{
- if( $deprecated{$i} eq 1 )
- {
- # The uc(parent_dir) is a bit of a hack. One day it will get it wrong.
- print "#ifndef " . uc($parent_dir) ."_DISABLE_DEPRECATED\n"
- }
-
- #On Win32, these classes are not compiled:
- if( $win32_nowrap{$i} eq 1 )
- {
- print "#ifndef G_OS_WIN32\n"
- }
-
my $namespace_prefix = "";
foreach( @{$namespaces{$i}} )
{
$namespace_prefix .= $_ ."::";
}
- print " Glib::wrap_register($basenames{$i}_get_type(), &", "${namespace_prefix}${i}_Class::wrap_new);\n";
-
- if( $win32_nowrap{$i} eq 1 )
- {
- print "#endif //G_OS_WIN32\n"
- }
-
- if( $deprecated{$i} eq 1 )
- {
- print "#endif // *_DISABLE_DEPRECATED\n"
- }
+ print_with_guards( $i, " Glib::wrap_register($basenames{$i}_get_type(), &" . "${namespace_prefix}${i}_Class::wrap_new);\n" );
}
print "\n";
@@ -363,35 +326,13 @@ print " // Register the gtkmm gtypes:\n";
foreach $i (sort keys %objects)
{
- if( $deprecated{$i} eq 1 )
- {
- # The uc(parent_dir) is a bit of a hack. One day it will get it wrong.
- print "#ifndef " . uc($parent_dir) ."_DISABLE_DEPRECATED\n"
- }
-
- #On Win32, these classes are not compiled:
- if( $win32_nowrap{$i} eq 1 )
- {
- print "#ifndef G_OS_WIN32\n"
- }
-
my $namespace_prefix = "";
foreach( @{$namespaces{$i}} )
{
$namespace_prefix .= $_ ."::";
}
- print " ${namespace_prefix}${i}::get_type();\n";
-
- if( $win32_nowrap{$i} eq 1 )
- {
- print "#endif //G_OS_WIN32\n"
- }
-
- if( $deprecated{$i} eq 1 )
- {
- print "#endif // *_DISABLE_DEPRECATED\n"
- }
+ print_with_guards( $i, " ${namespace_prefix}${i}::get_type();\n" );
}
print << "EOF";