1998-06-19 01:26:24 +00:00
|
|
|
#!/usr/bin/perl -w
|
1998-06-08 01:37:27 +00:00
|
|
|
#
|
|
|
|
# by Elliot Lee <sopwith@redhat.com>
|
|
|
|
|
|
|
|
%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",
|
1998-07-21 18:49:53 +00:00
|
|
|
"POINTER"=>"gpointer",
|
1998-07-21 16:06:00 +00:00
|
|
|
"OBJECT"=>"gpointer",
|
1998-07-21 18:49:53 +00:00
|
|
|
|
|
|
|
# complex types. These need special handling.
|
|
|
|
"FOREIGN"=>"FOREIGN",
|
|
|
|
"C_CALLBACK"=>"C_CALLBACK",
|
|
|
|
"SIGNAL"=>"SIGNAL",
|
|
|
|
"ARGS"=>"ARGS",
|
|
|
|
"CALLBACK"=>"CALLBACK"
|
|
|
|
);
|
1998-06-08 01:37:27 +00:00
|
|
|
|
1998-07-21 04:13:42 +00:00
|
|
|
$srcdir = $ENV{'srcdir'} || '.';
|
1998-09-20 14:58:08 +00:00
|
|
|
$indent = $ENV{'INDENT'};
|
|
|
|
|
|
|
|
sub indent {
|
|
|
|
my $filename = shift;
|
|
|
|
if (defined($indent) && $indent ne "") {
|
|
|
|
system($indent, $filename);
|
|
|
|
# we try the most likely names for backup files
|
|
|
|
system("rm", "-f", "$filename.bak", "$filename~");
|
|
|
|
}
|
|
|
|
}
|
1998-07-21 04:13:42 +00:00
|
|
|
|
|
|
|
open(IL, "<$srcdir/gtkmarshal.list") || die("Open failed: $!");
|
1998-09-20 14:58:08 +00:00
|
|
|
open(OH, ">$srcdir/gtkmarshal.h") || die("Open failed: $!");
|
|
|
|
open(OS, ">$srcdir/gtkmarshal.c") || die("Open failed: $!");
|
1998-06-08 01:37:27 +00:00
|
|
|
|
1998-06-19 01:26:24 +00:00
|
|
|
print OH <<EOT;
|
|
|
|
#ifndef __GTKMARSHAL_H__
|
|
|
|
#define __GTKMARSHAL_H__ 1
|
1998-06-08 01:37:27 +00:00
|
|
|
|
1998-07-21 04:13:42 +00:00
|
|
|
#include <gtk/gtktypeutils.h>
|
|
|
|
#include <gtk/gtkobject.h>
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif /* __cplusplus */
|
|
|
|
|
|
|
|
#define gtk_signal_default_marshaller gtk_marshal_NONE__NONE
|
1998-06-19 01:26:24 +00:00
|
|
|
|
|
|
|
EOT
|
|
|
|
|
|
|
|
print OS qq(#include "gtkmarshal.h"\n\n);
|
1998-06-08 01:37:27 +00:00
|
|
|
|
1998-09-20 14:58:08 +00:00
|
|
|
while (defined($aline = <IL>)) {
|
|
|
|
chomp $aline;
|
1998-06-08 01:37:27 +00:00
|
|
|
($retval, $paramlist) = split(/:/, $aline, 2);
|
|
|
|
@params = split(/\s*,\s*/, $paramlist);
|
|
|
|
|
1998-06-19 01:26:24 +00:00
|
|
|
my $funcname = $retval."__".join("_",@params);
|
1998-07-21 04:13:42 +00:00
|
|
|
my $defname;
|
1998-06-19 01:26:24 +00:00
|
|
|
|
|
|
|
next if (exists $defs{$funcname});
|
1998-06-08 01:37:27 +00:00
|
|
|
|
|
|
|
$doequiv = 0;
|
1998-06-19 01:26:24 +00:00
|
|
|
for (@params, $retval) {
|
1998-07-21 04:13:42 +00:00
|
|
|
if ($trans{$_} eq "gpointer" && $_ ne "POINTER") {
|
1998-06-19 01:26:24 +00:00
|
|
|
$doequiv = 1;
|
|
|
|
last;
|
1998-07-21 04:13:42 +00:00
|
|
|
}
|
|
|
|
if($_ eq "ENUM" || $_ eq "UINT" || $_ eq "ULONG") {
|
|
|
|
$doequiv = 1;
|
|
|
|
last;
|
|
|
|
}
|
1998-06-19 01:26:24 +00:00
|
|
|
}
|
1998-06-08 01:37:27 +00:00
|
|
|
|
1998-06-19 01:26:24 +00:00
|
|
|
# Translate all function pointers to gpointer
|
1998-07-21 04:13:42 +00:00
|
|
|
$defname = $funcname;
|
1998-06-08 01:37:27 +00:00
|
|
|
if($doequiv) {
|
1998-06-19 01:26:24 +00:00
|
|
|
print OH "#define gtk_marshal_$funcname ";
|
|
|
|
$defs{$defname} = 1;
|
|
|
|
|
|
|
|
for (@params, $retval) {
|
1998-07-21 04:13:42 +00:00
|
|
|
if ($trans{$_} eq "gpointer") {
|
|
|
|
$_ = "POINTER";
|
|
|
|
}
|
|
|
|
if($_ eq "ENUM") {
|
|
|
|
$_ = "UINT";
|
|
|
|
}
|
|
|
|
if($_ eq "UINT") {
|
|
|
|
$_ = "INT"; # Unvalidated assumption - please check
|
|
|
|
}
|
|
|
|
if($_ eq "ULONG") {
|
|
|
|
$_ = "LONG";
|
|
|
|
}
|
1998-06-19 01:26:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$funcname = $retval."__".join("_",@params);
|
|
|
|
|
1998-07-21 04:13:42 +00:00
|
|
|
print OH "gtk_marshal_$funcname\n\n";
|
1998-06-19 01:26:24 +00:00
|
|
|
next if (exists $defs{$funcname});
|
1998-06-08 01:37:27 +00:00
|
|
|
}
|
1998-06-19 01:26:24 +00:00
|
|
|
$defs{$funcname} = 1;
|
1998-06-08 01:37:27 +00:00
|
|
|
|
1998-06-19 01:26:24 +00:00
|
|
|
print OH <<EOT;
|
|
|
|
void gtk_marshal_$funcname (GtkObject *object,
|
|
|
|
GtkSignalFunc func,
|
|
|
|
gpointer func_data,
|
|
|
|
GtkArg *args);
|
1998-06-08 01:37:27 +00:00
|
|
|
|
1998-06-19 01:26:24 +00:00
|
|
|
EOT
|
|
|
|
|
|
|
|
print OS "typedef $trans{$retval} (*GtkSignal_$funcname) (GtkObject *object, \n";
|
1998-06-08 01:37:27 +00:00
|
|
|
$argn = 1;
|
1998-06-19 01:26:24 +00:00
|
|
|
for (@params) {
|
1998-07-21 16:06:00 +00:00
|
|
|
if($_ eq "C_CALLBACK") {
|
|
|
|
print OS "gpointer arg".$argn."a,\n";
|
1998-07-21 18:49:53 +00:00
|
|
|
print OS "gpointer arg".$argn."b,\n";
|
|
|
|
$argn++;
|
|
|
|
} elsif($_ eq "SIGNAL") {
|
|
|
|
print OS "gpointer arg".$argn."a,\n";
|
|
|
|
print OS "gpointer arg".$argn."b,\n";
|
|
|
|
$argn++;
|
|
|
|
} elsif($_ eq "ARGS") {
|
|
|
|
print OS "gpointer arg".$argn."a,\n";
|
|
|
|
print OS "gpointer arg".$argn."b,\n";
|
|
|
|
$argn++;
|
|
|
|
} elsif($_ eq "CALLBACK") {
|
|
|
|
print OS "gpointer arg".$argn."a,\n";
|
|
|
|
print OS "gpointer arg".$argn."b,\n";
|
|
|
|
print OS "gpointer arg".$argn."c,\n";
|
|
|
|
$argn++;
|
|
|
|
} elsif($_ eq "FOREIGN") {
|
|
|
|
print OS "gpointer arg".$argn."a,\n";
|
|
|
|
print OS "gpointer arg".$argn."b,\n";
|
|
|
|
$argn++;
|
1998-07-21 16:06:00 +00:00
|
|
|
} else {
|
|
|
|
print OS "$trans{$_} arg".$argn++.",\n" unless $_ eq "NONE";
|
|
|
|
}
|
1998-06-19 01:26:24 +00:00
|
|
|
}
|
1998-06-08 01:37:27 +00:00
|
|
|
print OS "gpointer user_data);\n";
|
|
|
|
|
1998-06-19 01:26:24 +00:00
|
|
|
print OS <<EOT;
|
|
|
|
void gtk_marshal_$funcname (GtkObject *object,
|
|
|
|
GtkSignalFunc func,
|
|
|
|
gpointer func_data,
|
|
|
|
GtkArg *args)
|
|
|
|
{
|
|
|
|
GtkSignal_$funcname rfunc;
|
|
|
|
EOT
|
1998-06-08 01:37:27 +00:00
|
|
|
|
|
|
|
if($retval ne "NONE") {
|
1998-06-19 01:26:24 +00:00
|
|
|
print OS " $trans{$retval} *return_val;\n";
|
1998-07-21 18:49:53 +00:00
|
|
|
$retn = 0;
|
|
|
|
$retn = scalar @params unless $params[0] eq "NONE";
|
|
|
|
print OS " return_val = GTK_RETLOC_$retval (args[$retn]);\n";
|
1998-06-08 01:37:27 +00:00
|
|
|
}
|
1998-06-19 01:26:24 +00:00
|
|
|
print OS " rfunc = (GtkSignal_$funcname) func;\n";
|
|
|
|
print OS " *return_val = " unless $retval eq "NONE";
|
|
|
|
print OS " (* rfunc) (object,\n";
|
1998-06-08 01:37:27 +00:00
|
|
|
|
|
|
|
for($i = 0; $i < (scalar @params); $i++) {
|
1998-07-21 16:06:00 +00:00
|
|
|
if($params[$i] eq "C_CALLBACK") {
|
|
|
|
print OS <<EOT;
|
|
|
|
GTK_VALUE_C_CALLBACK(args[$i]).func,
|
|
|
|
GTK_VALUE_C_CALLBACK(args[$i]).func_data,
|
1998-07-21 18:49:53 +00:00
|
|
|
EOT
|
|
|
|
} elsif ($params[$i] eq "SIGNAL") {
|
|
|
|
print OS <<EOT;
|
|
|
|
GTK_VALUE_SIGNAL(args[$i]).f,
|
|
|
|
GTK_VALUE_SIGNAL(args[$i]).d,
|
|
|
|
EOT
|
|
|
|
} elsif ($params[$i] eq "CALLBACK") {
|
|
|
|
print OS <<EOT;
|
|
|
|
GTK_VALUE_CALLBACK(args[$i]).marshal,
|
|
|
|
GTK_VALUE_CALLBACK(args[$i]).data,
|
|
|
|
GTK_VALUE_CALLBACK(args[$i]).notify,
|
|
|
|
EOT
|
|
|
|
} elsif ($params[$i] eq "FOREIGN") {
|
|
|
|
print OS <<EOT;
|
|
|
|
GTK_VALUE_FOREIGN(args[$i]).data,
|
|
|
|
GTK_VALUE_FOREIGN(args[$i]).notify,
|
1998-07-21 16:06:00 +00:00
|
|
|
EOT
|
|
|
|
} elsif ($params[$i] eq "NONE") {
|
|
|
|
} else {
|
|
|
|
print OS " GTK_VALUE_$params[$i](args[$i]),\n";
|
1998-06-19 01:26:24 +00:00
|
|
|
}
|
1998-06-08 01:37:27 +00:00
|
|
|
}
|
|
|
|
|
1998-06-19 01:26:24 +00:00
|
|
|
print OS " func_data);\n}\n\n";
|
1998-06-08 01:37:27 +00:00
|
|
|
}
|
1998-07-21 04:13:42 +00:00
|
|
|
print OH <<EOT;
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif /* __cplusplus */
|
|
|
|
|
|
|
|
#endif /* __GTKMARSHAL_H__ */
|
|
|
|
EOT
|
1998-06-19 01:26:24 +00:00
|
|
|
|
1998-06-08 01:37:27 +00:00
|
|
|
close(IL); close(OH); close(OS);
|
1998-09-20 14:58:08 +00:00
|
|
|
|
|
|
|
indent("$srcdir/gtkmarshal.h");
|
|
|
|
indent("$srcdir/gtkmarshal.c");
|