2001-11-13 Mike Kestner <mkestner@speakeasy.net>
* 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
This commit is contained in:
parent
2af291dc52
commit
b6338e2402
3 changed files with 152 additions and 1 deletions
|
@ -1,4 +1,11 @@
|
|||
2001-11-09 Mike Kestner <mkestner@speakeasy.net>
|
||||
2001-11-13 Mike Kestner <mkestner@speakeasy.net>
|
||||
|
||||
* 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 <mkestner@speakeasy.net>
|
||||
|
||||
* codegen/defs-parse.pl : Fix String prop generation code.
|
||||
* gtk/Window.custom : Fix ctor param casting error.
|
||||
|
|
96
codegen/get-signals-from-source.pl
Executable file
96
codegen/get-signals-from-source.pl
Executable file
|
@ -0,0 +1,96 @@
|
|||
#!/usr/bin/perl
|
||||
|
||||
$hdrfile = $srcfile = $ARGV[0];
|
||||
$hdrfile =~ s/c$/h/;
|
||||
|
||||
open (SRCFILE, $srcfile) || die "Could open $srcfile";
|
||||
@lines = <SRCFILE>;
|
||||
|
||||
open (SRCFILE, $hdrfile) || die "Could open $hdrfile";
|
||||
@hdrlines = <SRCFILE>;
|
||||
|
||||
$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;
|
||||
}
|
48
codegen/gtk-signals.defs
Normal file
48
codegen/gtk-signals.defs
Normal file
|
@ -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")
|
||||
)
|
||||
)
|
||||
|
Loading…
Reference in a new issue