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 16:06:00 +00:00
|
|
|
"C_CALLBACK"=>"C_CALLBACK", "POINTER"=>"gpointer",
|
1998-06-08 01:37:27 +00:00
|
|
|
"ARGS"=>"gpointer", "SIGNAL"=>"gpointer",
|
1998-07-21 16:06:00 +00:00
|
|
|
"OBJECT"=>"gpointer",
|
1998-07-21 04:13:42 +00:00
|
|
|
"STYLE"=>"gpointer", "GDK_EVENT"=>"gpointer");
|
1998-06-08 01:37:27 +00:00
|
|
|
|
1998-07-21 04:13:42 +00:00
|
|
|
$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: $!");
|
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" {
|
|
|
|
#pragma }
|
|
|
|
#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
|
|
|
|
|
|
|
while(chomp($aline = <IL>)) {
|
|
|
|
($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";
|
|
|
|
print OS "gpointer arg".$argn++."b,\n";
|
|
|
|
} 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";
|
|
|
|
print OS " return_val = GTK_RETLOC_$retval (args[".(scalar @params)."]);\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,
|
|
|
|
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);
|