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",
|
|
|
|
"CALLBACK"=>"gpointer", "POINTER"=>"gpointer",
|
|
|
|
"ARGS"=>"gpointer", "SIGNAL"=>"gpointer",
|
1998-06-29 02:12:46 +00:00
|
|
|
"C_CALLBACK"=>"gpointer", "OBJECT"=>"gpointer");
|
1998-06-08 01:37:27 +00:00
|
|
|
|
1998-06-10 01:04:46 +00:00
|
|
|
open(IL, "<".$ENV{'srcdir'}."/gtkmarshal.list") || die("Open failed: $!");
|
1998-06-21 22:03:58 +00:00
|
|
|
open(OH, "|indent >".$ENV{'srcdir'}."/gtkmarshal.h") || die("Open failed: $!");
|
|
|
|
open(OS, "|indent >".$ENV{'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-06-19 01:26:24 +00:00
|
|
|
#include "gtktypeutils.h"
|
|
|
|
#include "gtkobject.h"
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
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) {
|
|
|
|
if ($trans{$_} eq "gpointer") {
|
|
|
|
$doequiv = 1;
|
|
|
|
last;
|
|
|
|
}
|
|
|
|
}
|
1998-06-08 01:37:27 +00:00
|
|
|
|
1998-06-19 01:26:24 +00:00
|
|
|
# Translate all function pointers to gpointer
|
1998-06-08 01:37:27 +00:00
|
|
|
$defname = "";
|
|
|
|
if($doequiv) {
|
1998-06-19 01:26:24 +00:00
|
|
|
print OH "#define gtk_marshal_$funcname ";
|
|
|
|
$defs{$defname} = 1;
|
|
|
|
|
|
|
|
for (@params, $retval) {
|
|
|
|
if ($trans{$_} eq "gpointer") {
|
|
|
|
$_ = "POINTER";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$funcname = $retval."__".join("_",@params);
|
|
|
|
|
|
|
|
print OH "gtk_marshal_$funcname\n";
|
|
|
|
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) {
|
|
|
|
print OS "$trans{$_} arg".$argn++.",\n" unless $_ eq "NONE";
|
|
|
|
}
|
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-06-19 01:26:24 +00:00
|
|
|
if ($params[$i] ne "NONE") {
|
|
|
|
print OS " GTK_VALUE_$params[$i](args[$i]),\n";
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
print OH "#endif\n";
|
1998-06-19 01:26:24 +00:00
|
|
|
|
1998-06-08 01:37:27 +00:00
|
|
|
close(IL); close(OH); close(OS);
|