diff options
author | Elliot Lee <sopwith@src.gnome.org> | 1998-06-08 01:37:27 +0000 |
---|---|---|
committer | Elliot Lee <sopwith@src.gnome.org> | 1998-06-08 01:37:27 +0000 |
commit | 1e32cc3d6370b72add69c4a3c0ee4ecb8ca5b712 (patch) | |
tree | 19591eadb4d6397c273dc7591f8f871db24ad7a0 | |
parent | db0c8b158ca4c3151b02b16f3a3bc87ea30fc031 (diff) | |
download | gtk+-1e32cc3d6370b72add69c4a3c0ee4ecb8ca5b712.tar.gz |
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.
-rw-r--r-- | gtk/Makefile.am | 5 | ||||
-rwxr-xr-x | gtk/genmarshal.pl | 80 | ||||
-rw-r--r-- | gtk/gtkmarshal.list | 7 | ||||
-rw-r--r-- | gtk/gtkmarshalers.list | 7 |
4 files changed, 99 insertions, 0 deletions
diff --git a/gtk/Makefile.am b/gtk/Makefile.am index 31a1a5d89f..c7e4f3c8ea 100644 --- a/gtk/Makefile.am +++ b/gtk/Makefile.am @@ -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 diff --git a/gtk/genmarshal.pl b/gtk/genmarshal.pl new file mode 100755 index 0000000000..f1c76a9867 --- /dev/null +++ b/gtk/genmarshal.pl @@ -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); diff --git a/gtk/gtkmarshal.list b/gtk/gtkmarshal.list new file mode 100644 index 0000000000..bfe854a7b1 --- /dev/null +++ b/gtk/gtkmarshal.list @@ -0,0 +1,7 @@ +NONE:POINTER,POINTER +INT:POINTER,CHAR,CHAR +NONE:POINTER +INT:POINTER +NONE:UINT +NONE:BOXED +BOOL:POINTER
\ No newline at end of file diff --git a/gtk/gtkmarshalers.list b/gtk/gtkmarshalers.list new file mode 100644 index 0000000000..bfe854a7b1 --- /dev/null +++ b/gtk/gtkmarshalers.list @@ -0,0 +1,7 @@ +NONE:POINTER,POINTER +INT:POINTER,CHAR,CHAR +NONE:POINTER +INT:POINTER +NONE:UINT +NONE:BOXED +BOOL:POINTER
\ No newline at end of file |