2001-11-14 Mike Kestner <mkestner@speakeasy.net>
* codegen/defs-parse.pl : Add System.Collections to usings. s/event/signal. Add gen_signal sub and call it from gen_object. Mangle method names that collide with signal names by prepending Emit to the method name. * codegen/makefile : add gtk-signals.defs to the build. svn path=/trunk/gtk-sharp/; revision=1359
This commit is contained in:
parent
b6338e2402
commit
2ce0c470c2
3 changed files with 68 additions and 9 deletions
|
@ -1,3 +1,11 @@
|
||||||
|
2001-11-14 Mike Kestner <mkestner@speakeasy.net>
|
||||||
|
|
||||||
|
* codegen/defs-parse.pl : Add System.Collections to usings.
|
||||||
|
s/event/signal. Add gen_signal sub and call it from gen_object.
|
||||||
|
Mangle method names that collide with signal names by prepending
|
||||||
|
Emit to the method name.
|
||||||
|
* codegen/makefile : add gtk-signals.defs to the build.
|
||||||
|
|
||||||
2001-11-13 Mike Kestner <mkestner@speakeasy.net>
|
2001-11-13 Mike Kestner <mkestner@speakeasy.net>
|
||||||
|
|
||||||
* codegen/get-signals-from-source.pl : My own little perl signal
|
* codegen/get-signals-from-source.pl : My own little perl signal
|
||||||
|
|
|
@ -18,8 +18,8 @@
|
||||||
|
|
||||||
|
|
||||||
%usings = (
|
%usings = (
|
||||||
'Gdk', "System,System.Runtime.InteropServices,GLib",
|
'Gdk', "System,System.Collections,System.Runtime.InteropServices,GLib",
|
||||||
'Gtk', "System,System.Runtime.InteropServices,GLib,Gdk");
|
'Gtk', "System,System.Collections,System.Runtime.InteropServices,GLib,Gdk");
|
||||||
|
|
||||||
`mkdir -p ../gdk/generated`;
|
`mkdir -p ../gdk/generated`;
|
||||||
`mkdir -p ../gtk/generated`;
|
`mkdir -p ../gtk/generated`;
|
||||||
|
@ -44,7 +44,7 @@ while ($def = get_def()) {
|
||||||
$objects{$cname} = $def;
|
$objects{$cname} = $def;
|
||||||
$maptypes{$cname} = $name;
|
$maptypes{$cname} = $name;
|
||||||
$marshaltypes{$cname} = "IntPtr";
|
$marshaltypes{$cname} = "IntPtr";
|
||||||
} elsif ($def =~ /^\(define-(prop|event|method)/) {
|
} elsif ($def =~ /^\(define-(prop|signal|method)/) {
|
||||||
$def =~ /of-object "(\w+)"/;
|
$def =~ /of-object "(\w+)"/;
|
||||||
$cname=$1;
|
$cname=$1;
|
||||||
$def =~ s/\n\s*//g;
|
$def =~ s/\n\s*//g;
|
||||||
|
@ -226,14 +226,14 @@ sub gen_object
|
||||||
$dir = "../" . lc ($namespace = $1) . "/generated";
|
$dir = "../" . lc ($namespace = $1) . "/generated";
|
||||||
|
|
||||||
%props = ();
|
%props = ();
|
||||||
%events = ();
|
%signals = ();
|
||||||
%methods = ();
|
%methods = ();
|
||||||
@ctors = ();
|
@ctors = ();
|
||||||
foreach $def (@defs) {
|
foreach $def (@defs) {
|
||||||
if ($def =~ /define-property (\w+)/) {
|
if ($def =~ /define-property (\w+)/) {
|
||||||
$props{StudCaps($1)} = $def;
|
$props{StudCaps($1)} = $def;
|
||||||
} elsif ($def =~ /define-event (\w+)/) {
|
} elsif ($def =~ /define-signal (\w+)/) {
|
||||||
$events{StudCaps($1)} = $def;
|
$signals{StudCaps($1)} = $def;
|
||||||
} elsif ($def =~ /define-method (\w+)/) {
|
} elsif ($def =~ /define-method (\w+)/) {
|
||||||
$methods{StudCaps($1)} = $def;
|
$methods{StudCaps($1)} = $def;
|
||||||
} elsif ($def =~ /is-constructor-of/) {
|
} elsif ($def =~ /is-constructor-of/) {
|
||||||
|
@ -278,9 +278,21 @@ sub gen_object
|
||||||
print OUTFILE gen_prop ($key, $props{$key}, "gtk-1.3.dll");
|
print OUTFILE gen_prop ($key, $props{$key}, "gtk-1.3.dll");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (%signals) {
|
||||||
|
print OUTFILE "\t\tprivate Hashtable Signals = new Hashtable ();\n\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach $key (sort (keys (%signals))) {
|
||||||
|
print OUTFILE gen_signal ($key, $signals{$key}, "gtk-1.3.dll");
|
||||||
|
}
|
||||||
|
|
||||||
foreach $key (sort (keys (%methods))) {
|
foreach $key (sort (keys (%methods))) {
|
||||||
next if (($key =~ /^(Get|Set)(\w+)/) && exists($props{$2}));
|
next if (($key =~ /^(Get|Set)(\w+)/) && exists($props{$2}));
|
||||||
print OUTFILE gen_method ($key, $methods{$key}, "gtk-1.3.dll");
|
my $mod = "";
|
||||||
|
if (exists($signals{$key})) {
|
||||||
|
$mod = "Emit";
|
||||||
|
}
|
||||||
|
print OUTFILE gen_method ("$mod$key", $methods{$key}, "gtk-1.3.dll");
|
||||||
}
|
}
|
||||||
|
|
||||||
$custom = "../" . lc ($namespace) . "/$typename.custom";
|
$custom = "../" . lc ($namespace) . "/$typename.custom";
|
||||||
|
@ -290,7 +302,46 @@ sub gen_object
|
||||||
print "done\n";
|
print "done\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
sub gen_prop ()
|
sub gen_signal
|
||||||
|
{
|
||||||
|
my ($name, $def, $dll) = @_;
|
||||||
|
my ($cname, @plist, $ret, $sret, $mret, $code);
|
||||||
|
|
||||||
|
$def =~ /define-signal (\w+)/;
|
||||||
|
$cname = "\"$1\"";
|
||||||
|
|
||||||
|
$def =~ /return-type \"(\w+)\"/;
|
||||||
|
$ret = $1;
|
||||||
|
|
||||||
|
$def =~ /parameters\s*'\((.*)\)\)\)/;
|
||||||
|
@plist = split(/\)'\(/, $1);
|
||||||
|
|
||||||
|
if (($ret eq "none") && (@plist == 1)) {
|
||||||
|
$marsh = "SimpleSignal";
|
||||||
|
} elsif (($ret eq "gboolean") && (@plist == 2) &&
|
||||||
|
($plist[1] =~ /^\"GdkEvent\*\"/)) {
|
||||||
|
$marsh = "SimpleEvent";
|
||||||
|
} else {
|
||||||
|
return "\t\t// FIXME: Need Marshaller for $name event\n\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
$code = "\t\t/// <summary> $name Event </summary>\n";
|
||||||
|
$code .= "\t\t/// <remarks>\n\t\t///\tFIXME: Get some docs.\n";
|
||||||
|
$code .= "\t\t/// </remarks>\n\n";
|
||||||
|
$code .= "\t\tpublic event EventHandler $name {\n";
|
||||||
|
$code .= "\t\t\tadd {\n";
|
||||||
|
$code .= "\t\t\t\tif (Events [$cname] == null)\n";
|
||||||
|
$code .= "\t\t\t\t\tSignals [$cname] = new $marsh (this, RawObject, ";
|
||||||
|
$code .= "$cname, value);\n";
|
||||||
|
$code .= "\t\t\t\tEvents.AddHandler ($cname, value);\n\t\t\t}\n";
|
||||||
|
$code .= "\t\t\tremove {\n";
|
||||||
|
$code .= "\t\t\t\tEvents.RemoveHandler ($cname, value);\n";
|
||||||
|
$code .= "\t\t\t\tif (Events [$cname] == null)\n";
|
||||||
|
$code .= "\t\t\t\t\tSignals.Remove ($cname);\n\t\t\t}\n\t\t}\n\n";
|
||||||
|
return $code;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub gen_prop
|
||||||
{
|
{
|
||||||
my ($name, $def, $dll) = @_;
|
my ($name, $def, $dll) = @_;
|
||||||
my ($cname, $mode, $sret, $mret, $docs, $code);
|
my ($cname, $mode, $sret, $mret, $docs, $code);
|
||||||
|
|
|
@ -3,7 +3,7 @@ all:
|
||||||
@echo "'make unix' is broken for now."
|
@echo "'make unix' is broken for now."
|
||||||
|
|
||||||
windows:
|
windows:
|
||||||
cat gdk-types.defs hardcoded.defs gtk-types.defs gtk-props.defs gtk.defs | ./defs-parse.pl
|
cat gdk-types.defs hardcoded.defs gtk-types.defs gtk-signals.defs gtk-props.defs gtk.defs | ./defs-parse.pl
|
||||||
|
|
||||||
unix:
|
unix:
|
||||||
@echo "'make unix' is broken for now."
|
@echo "'make unix' is broken for now."
|
||||||
|
|
Loading…
Reference in a new issue