From b6338e24021586202e580492b4aaee6379ab053b Mon Sep 17 00:00:00 2001 From: Mike Kestner Date: Wed, 14 Nov 2001 00:58:14 +0000 Subject: [PATCH] 2001-11-13 Mike Kestner * codegen/get-signals-from-source.pl : My own little perl signal parser. * codegen/gtk-signals.defs : Ripped the GtkWindow signals into here to goof with. svn path=/trunk/gtk-sharp/; revision=1345 --- ChangeLog | 9 ++- codegen/get-signals-from-source.pl | 96 ++++++++++++++++++++++++++++++ codegen/gtk-signals.defs | 48 +++++++++++++++ 3 files changed, 152 insertions(+), 1 deletion(-) create mode 100755 codegen/get-signals-from-source.pl create mode 100644 codegen/gtk-signals.defs diff --git a/ChangeLog b/ChangeLog index 49c894c5f..a3b437676 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,11 @@ -2001-11-09 Mike Kestner +2001-11-13 Mike Kestner + + * codegen/get-signals-from-source.pl : My own little perl signal + parser. + * codegen/gtk-signals.defs : Ripped the GtkWindow signals into here + to goof with. + +2001-11-10 Mike Kestner * codegen/defs-parse.pl : Fix String prop generation code. * gtk/Window.custom : Fix ctor param casting error. diff --git a/codegen/get-signals-from-source.pl b/codegen/get-signals-from-source.pl new file mode 100755 index 000000000..c41319d55 --- /dev/null +++ b/codegen/get-signals-from-source.pl @@ -0,0 +1,96 @@ +#!/usr/bin/perl + +$hdrfile = $srcfile = $ARGV[0]; +$hdrfile =~ s/c$/h/; + +open (SRCFILE, $srcfile) || die "Could open $srcfile"; +@lines = ; + +open (SRCFILE, $hdrfile) || die "Could open $hdrfile"; +@hdrlines = ; + +$linenum = 0; + +while ($linenum < @lines) { + + $line = $lines[$linenum]; + + if ($line =~ /^(\w+)_class_init/) { + $typename = StudCaps($1); + } elsif ($line =~ /g_signal_new/) { + $str = $line; + do { + $str .= $lines[++$linenum]; + } until ($lines[$linenum] =~ /;/); + + print_signal ($str, $typename); + } + + $linenum++; +} + +sub print_signal +{ + my ($spec, $class) = @_; + $spec =~ s/\n\s*//g; + + $spec =~ /\(\"(\w+)\",.*G_SIGNAL_RUN_(\w+).*_OFFSET\s*\((.*)\),/; + $signame = $1; + $run = lc($2); + $class_method = $3; + + ($ret, $params) = lookup_method($class_method); + + print "(define-signal $signame\n"; + print " (of-object \"$class\")\n"; + print " (return-type \"$ret\")\n"; + print " (when \"$run\")\n"; + print $params; + print ")\n\n"; +} + +sub lookup_method +{ + my ($pstr) = @_; + my $lineno = 0; + ($classname, $method) = split(/,\s*/, $pstr); + + while ($hdrlines[$lineno] !~ /^struct\s*_$classname/) {$lineno++;} + + do { + if ($hdrlines[$lineno] =~ /$method/) { + $sig = ""; + while ($hdrlines[$lineno] !~ /;/) { + $sig .= $hdrlines[$lineno++]; + } + $sig .= $hdrlines[$lineno]; + $sig =~ s/\n\s*//g; + $sig =~ /(\S+)\s*\(\* $method\)\s*\((.*)\);/; + $ret = $1; + $parms = $2; + $ret =~ s/void/none/; + @plist = split(/,/, $parms); + $parms = " (parameters\n"; + foreach $parm (@plist) { + $parm =~ s/\s+\*/\* /; + $parm =~ s/(\S+)/"$1"/g; + $parms .= " '($parm)\n"; + } + $parms .= " )\n"; + return ($ret, $parms); + } + } until ($hdrlines[$lineno++] =~ /^}/); + + return (); + +} + +sub StudCaps +{ + my ($str) = @_; + + $str =~ s/^(\w)/\u\1/; + $str =~ s/[_-]([a-z])/\u\1/g; + $str =~ s/[_-](\d)/\1/g; + return $str; +} diff --git a/codegen/gtk-signals.defs b/codegen/gtk-signals.defs new file mode 100644 index 000000000..37a73cfb0 --- /dev/null +++ b/codegen/gtk-signals.defs @@ -0,0 +1,48 @@ +(define-signal set_focus + (of-object "GtkWindow") + (return-type "none") + (when "last") + (parameters + '("GtkWindow*" "window") + '("GtkWidget*" "focus") + ) +) + +(define-signal frame_event + (of-object "GtkWindow") + (return-type "gboolean") + (when "last") + (parameters + '("GtkWidget*" "widget") + '("GdkEvent*" "event") + ) +) + +(define-signal activate_focus + (of-object "GtkWindow") + (return-type "none") + (when "last") + (parameters + '("GtkWindow*" "window") + ) +) + +(define-signal activate_default + (of-object "GtkWindow") + (return-type "none") + (when "last") + (parameters + '("GtkWindow*" "window") + ) +) + +(define-signal move_focus + (of-object "GtkWindow") + (return-type "none") + (when "last") + (parameters + '("GtkWindow*" "window") + '("GtkDirectionType" "direction") + ) +) +