Start of marshalling centralization.
Start of marshalling centralization. Please check this over for sanity. I think the perl script and Makefile might need fixing up to allow builddir != srcdir I will start converting all the widgets to use this scheme if no problems arise.
This commit is contained in:
@@ -51,6 +51,7 @@ libgtk_1_1_la_SOURCES = \
|
||||
gtklist.c \
|
||||
gtklistitem.c \
|
||||
gtkmain.c \
|
||||
gtkmarshal.c \
|
||||
gtkmenu.c \
|
||||
gtkmenubar.c \
|
||||
gtkmenufactory.c \
|
||||
@@ -151,6 +152,7 @@ gtkinclude_HEADERS = \
|
||||
gtklist.h \
|
||||
gtklistitem.h \
|
||||
gtkmain.h \
|
||||
gtkmarshal.h \
|
||||
gtkmenu.h \
|
||||
gtkmenubar.h \
|
||||
gtkmenufactory.h \
|
||||
@@ -286,3 +288,6 @@ test-debug: testgtk
|
||||
builddir=`pwd`; cd $(top_builddir); top_builddir=`pwd`; \
|
||||
cd $$builddir; cd $(srcdir); \
|
||||
$(SHELL) $$top_builddir/libtool --mode=execute gdb $$builddir/testgtk
|
||||
|
||||
gtkmarshal.c gtkmarshal.h: gtkmarshal.list
|
||||
perl $(srcdir)/genmarshal.pl
|
||||
|
||||
80
gtk/genmarshal.pl
Executable file
80
gtk/genmarshal.pl
Executable file
@@ -0,0 +1,80 @@
|
||||
#!/usr/bin/perl
|
||||
#
|
||||
# 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",
|
||||
"C_CALLBACK"=>"gpointer");
|
||||
|
||||
open(IL, "<gtkmarshal.list") || die("Open failed: $!");
|
||||
open(OH, ">gtkmarshal.h") || die("Open failed: $!");
|
||||
open(OS, ">gtkmarshal.c") || die("Open failed: $!");
|
||||
|
||||
print OH "#ifndef __GTKMARSHAL_H__\n#define __GTKMARSHAL_H__ 1\n\n";
|
||||
print OH "#include \"gtktypeutils.h\"\n#include \"gtkobject.h\"\n";
|
||||
|
||||
print OS "#include \"gtkmarshal.h\"\n";
|
||||
|
||||
while(chomp($aline = <IL>)) {
|
||||
($retval, $paramlist) = split(/:/, $aline, 2);
|
||||
@params = split(/\s*,\s*/, $paramlist);
|
||||
|
||||
if($defs{$retval."__".join("_",@params)} == 1) { next; }
|
||||
|
||||
$doequiv = 0;
|
||||
foreach(@params) { if($trans{$_} eq "gpointer") { $doequiv = 1; } }
|
||||
|
||||
$defname = "";
|
||||
if($doequiv) {
|
||||
$defname = $retval."__".join("_",@params);
|
||||
print OH "#define gtk_marshal_".$retval."__".join("_",@params)." ";
|
||||
|
||||
for($i = 0; $i < scalar @params; $i++)
|
||||
{ if($trans{$params[$i]} eq "gpointer") { $params[$i] = "POINTER"; } }
|
||||
if($trans{$retval} eq "gpointer") { $retval = "POINTER"; }
|
||||
print OH "gtk_marshal_".$retval."__".join("_",@params)."\n";
|
||||
|
||||
$regname = $retval."__".join("_",@params);
|
||||
if($defs{$regname} == 1) { next; }
|
||||
$defs{$defname} = 1;
|
||||
}
|
||||
|
||||
$defs{$retval."__".join("_",@params)} = 1;
|
||||
|
||||
print OH "void gtk_marshal_".$retval."__".join("_",@params)."(GtkObject *object, GtkSignalFunc func, gpointer func_data, GtkArg *args);\n";
|
||||
|
||||
print OS "typedef ".$trans{$retval}. " (*GtkSignal_"
|
||||
.$retval."__".join("_",@params).")(GtkObject *object, ";
|
||||
|
||||
$argn = 1;
|
||||
foreach $it(@params) { print OS $trans{$it}." arg".$argn++.",\n"; }
|
||||
print OS "gpointer user_data);\n";
|
||||
|
||||
print OS "void gtk_marshal_".$retval."__".join("_",@params)."(GtkObject *object, GtkSignalFunc func, gpointer func_data, GtkArg *args)\n";
|
||||
|
||||
print OS "{\nGtkSignal_".$retval."__".join("_",@params)." rfunc;\n";
|
||||
if($retval ne "NONE") {
|
||||
print OS $trans{$retval}." *return_val;\n";
|
||||
|
||||
print OS "return_val = GTK_RETLOC_".$retval."(args[".(scalar @params)."]);\n";
|
||||
}
|
||||
print OS "rfunc = (GtkSignal_".$retval."__".join("_",@params).") func;\n";
|
||||
|
||||
if($retval ne "NONE") { print OS "*return_val = "; }
|
||||
|
||||
print OS "(* rfunc)(object, ";
|
||||
for($i = 0; $i < (scalar @params); $i++) {
|
||||
print OS "GTK_VALUE_".$params[$i]."(args[$i]), ";
|
||||
}
|
||||
|
||||
print OS "func_data);\n}\n\n";
|
||||
}
|
||||
print OH "#endif\n";
|
||||
close(IL); close(OH); close(OS);
|
||||
7
gtk/gtkmarshal.list
Normal file
7
gtk/gtkmarshal.list
Normal file
@@ -0,0 +1,7 @@
|
||||
NONE:POINTER,POINTER
|
||||
INT:POINTER,CHAR,CHAR
|
||||
NONE:POINTER
|
||||
INT:POINTER
|
||||
NONE:UINT
|
||||
NONE:BOXED
|
||||
BOOL:POINTER
|
||||
7
gtk/gtkmarshalers.list
Normal file
7
gtk/gtkmarshalers.list
Normal file
@@ -0,0 +1,7 @@
|
||||
NONE:POINTER,POINTER
|
||||
INT:POINTER,CHAR,CHAR
|
||||
NONE:POINTER
|
||||
INT:POINTER
|
||||
NONE:UINT
|
||||
NONE:BOXED
|
||||
BOOL:POINTER
|
||||
Reference in New Issue
Block a user