#!/usr/bin/perl -w # # by Elliot Lee %trans = ( "NONE"=>"void", "CHAR"=>"char", "BOOL"=>"gboolean", "INT"=>"gint", "UINT"=>"guint", "LONG"=>"glong", "ULONG"=>"gulong", "FLOAT"=>"gfloat", "DOUBLE"=>"gdouble", "STRING"=>"gpointer", "ENUM"=>"gint", "FLAGS"=>"gint", "BOXED"=>"gpointer", "FOREIGN"=>"gpointer", "POINTER"=>"gpointer", "OBJECT"=>"gpointer", # complex types. These need special handling. "FOREIGN"=>"FOREIGN", "C_CALLBACK"=>"C_CALLBACK", "SIGNAL"=>"SIGNAL", "ARGS"=>"ARGS", "CALLBACK"=>"CALLBACK" ); $srcdir = $ENV{'srcdir'} || '.'; open(IL, "<$srcdir/gtkmarshal.list") || die("Open failed: $!"); open(OH, "|indent > $srcdir/gtkmarshal.h") || die("Open failed: $!"); open(OS, "|indent > $srcdir/gtkmarshal.c") || die("Open failed: $!"); print OH < #include #ifdef __cplusplus extern "C" { #pragma } #endif /* __cplusplus */ #define gtk_signal_default_marshaller gtk_marshal_NONE__NONE EOT print OS qq(#include "gtkmarshal.h"\n\n); while(chomp($aline = )) { ($retval, $paramlist) = split(/:/, $aline, 2); @params = split(/\s*,\s*/, $paramlist); my $funcname = $retval."__".join("_",@params); my $defname; next if (exists $defs{$funcname}); $doequiv = 0; for (@params, $retval) { if ($trans{$_} eq "gpointer" && $_ ne "POINTER") { $doequiv = 1; last; } if($_ eq "ENUM" || $_ eq "UINT" || $_ eq "ULONG") { $doequiv = 1; last; } } # Translate all function pointers to gpointer $defname = $funcname; if($doequiv) { print OH "#define gtk_marshal_$funcname "; $defs{$defname} = 1; for (@params, $retval) { if ($trans{$_} eq "gpointer") { $_ = "POINTER"; } if($_ eq "ENUM") { $_ = "UINT"; } if($_ eq "UINT") { $_ = "INT"; # Unvalidated assumption - please check } if($_ eq "ULONG") { $_ = "LONG"; } } $funcname = $retval."__".join("_",@params); print OH "gtk_marshal_$funcname\n\n"; next if (exists $defs{$funcname}); } $defs{$funcname} = 1; print OH <