]> Pileus Git - ~andy/gtk/commitdiff
Start of marshalling centralization.
authorElliot Lee <sopwith@src.gnome.org>
Mon, 8 Jun 1998 01:37:27 +0000 (01:37 +0000)
committerElliot Lee <sopwith@src.gnome.org>
Mon, 8 Jun 1998 01:37:27 +0000 (01:37 +0000)
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.

gtk/Makefile.am
gtk/genmarshal.pl [new file with mode: 0755]
gtk/gtkmarshal.list [new file with mode: 0644]
gtk/gtkmarshalers.list [new file with mode: 0644]

index 31a1a5d89f50adcb1c45e002f2279f3c7c04849b..c7e4f3c8eac89e74aaad8d1b00019ca8fd7eba14 100644 (file)
@@ -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 (executable)
index 0000000..f1c76a9
--- /dev/null
@@ -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 (file)
index 0000000..bfe854a
--- /dev/null
@@ -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 (file)
index 0000000..bfe854a
--- /dev/null
@@ -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