2001-10-11 Mike Kestner <mkestner@speakeasy.net>

* makefile : Add the codegen directory
	* codegen/defs-parse.pl : Moved here from topdir and updated to parse
	the new defs format for enums and flags.
	* codegen/gtk-types.defs : Borrowed from pygtk.
	* codegen/makefile : new
	* gtk/makefile : remove generation step.
	* gtk/gtk.defs : removed, now in codegen dir.

svn path=/trunk/gtk-sharp/; revision=1139
This commit is contained in:
Mike Kestner 2001-10-11 10:14:14 +00:00
parent 8f475577c5
commit bd567cdd45
11 changed files with 2073 additions and 2217 deletions

View file

@ -1,3 +1,13 @@
2001-10-11 Mike Kestner <mkestner@speakeasy.net>
* makefile : Add the codegen directory
* codegen/defs-parse.pl : Moved here from topdir and updated to parse
the new defs format for enums and flags.
* codegen/gtk-types.defs : Borrowed from pygtk.
* codegen/makefile : new
* gtk/makefile : remove generation step.
* gtk/gtk.defs : removed, now in codegen dir.
2001-10-07 Mike Kestner <mkestner@speakeasy.net>
* gtk/Button.cs : Some nomenclature changes. s/EmitClicked/Click, etc.

77
codegen/defs-parse.pl Executable file
View file

@ -0,0 +1,77 @@
#!/usr/bin/perl
while ($line = <STDIN>) {
if ($line =~ /^\(define-(enum|flags)/) {
parse_enum_flags ();
}
}
sub parse_enum_flags ()
{
$line =~ /^\(define-(enum|flags) (\w+)/;
$type = $1;
$typename = $2;
$line = <STDIN>;
$line =~ /\(in-module "(\w+)"/;
$namespace = $1;
do { $line = <STDIN>; } until ($line =~ /\(values/);
@enums = ();
while ($line = <STDIN>) {
last if ($line =~ /^\s*\)/);
if ($line =~ /\((.+)\)/) {
($name, $dontcare, $val) = split (/ /, $1);
$name =~ s/\"//g;
$name =~ s/^([a-z])/\u\1/;
$name =~ s/\-([a-z])/\u\1/g;
$name =~ s/\-(\d)/\1/g;
@enums = (@enums, "$name:$val");
} else {
die $line;
}
}
$dir = lc ($namespace);
if (! -e "../$dir") {
`mkdir ../$dir`;
}
open (OUTFILE, ">../$dir/$typename.cs") || die "can't open file";
print OUTFILE "// Generated file: Do not modify\n\n";
print OUTFILE "namespace $namespace {\n\n";
print OUTFILE "\t/// <summary> $typename Enumeration </summary>\n";
print OUTFILE "\t/// <remarks>\n\t///\t Valid values:\n";
foreach $enum (@enums) {
($name) = split (/:/, $enum);
print OUTFILE "\t///\t\t$name\n"
}
print OUTFILE "\t/// </remarks>\n\n";
if ($type eq "flags") {
print OUTFILE "\tusing System;\n\n\t[Flags]\n";
}
print OUTFILE "\tpublic enum $typename {\n";
$flag = 1;
foreach $enum (@enums) {
($name, $val) = split (/:/, $enum);
if ($val) {
print OUTFILE "\t\t$name = $val,\n";
} elsif ($type eq "enum") {
print OUTFILE "\t\t$name,\n";
} else {
print OUTFILE "\t\t$name = $flag,\n";
$flag *= 2;
}
}
print OUTFILE "\t}\n\n}\n";
close (OUTFILE);
}

1968
codegen/gtk-types.defs Normal file

File diff suppressed because it is too large Load diff

10
codegen/makefile Executable file
View file

@ -0,0 +1,10 @@
all:
@echo "You must use 'make windows' or 'make unix'."
@echo "'make unix' is broken for now."
windows:
./defs-parse.pl < gtk-types.defs
unix:
@echo "'make unix' is broken for now."

View file

@ -1,54 +0,0 @@
#!/usr/bin/perl
while ($line = <STDIN>) {
if ($line =~ /^\(define-(enum|flags) (Gtk|G|Gdk)(\w+)/) {
if (!defined ($namespace)) {
print "// Generated file: Do not modify\n\n";
print "namespace $2 {\n\n\tusing System;\n\n";
} elsif ($2 ne $namespace) {
print "}\n\nnamespace $2 {\n\n";
}
$type = $1;
$namespace = $2;
$typename = $3;
foreach $paren ($line =~ /[\(\)]/g) {
($paren eq "(") ? $nest++ : $nest--;
}
if ($type eq "flags") {
print "\t[Flags]\n";
}
print "\tpublic enum $typename {\n";
$val = 1;
while ($nest > 0) {
$line = <STDIN>;
if ($line =~ /\((.*) .*\)/) {
$name = $1;
$name =~ s/^([a-z])/\u\1/;
$name =~ s/\-([a-z])/\u\1/g;
$name =~ s/\-(\d)/\1/g;
if ($type eq "enum") {
print "\t\t$name,\n";
} else {
print "\t\t$name = $val,\n";
$val *= 2;
}
}
foreach $paren ($line =~ /[\(\)]/g) {
($paren eq "(") ? $nest++ : $nest--;
}
}
print "\t}\n\n";
}
}
if (defined ($namespace)) {
print "}\n";
}

View file

@ -16,8 +16,6 @@ namespace Gtk {
public class Widget : Object {
private static readonly string DelEvName = "delete-event";
private Hashtable Signals = new Hashtable ();
// Properties
@ -271,7 +269,7 @@ namespace Gtk {
}
/// <summary>
/// DeleteEvent Event
/// Deleted Event
/// </summary>
///
/// <remarks>
@ -279,7 +277,9 @@ namespace Gtk {
/// windowing environment.
/// </remarks>
public event EventHandler DeleteEvent {
private static readonly string DelEvName = "delete-event";
public event EventHandler Deleted {
add {
if (Events [DelEvName] == null)
Signals [DelEvName] = new SimpleEvent (

File diff suppressed because it is too large Load diff

View file

@ -2,11 +2,9 @@ all:
@echo "You must use 'make windows' or 'make unix'."
@echo "'make unix' is broken for now."
windows: defs
windows:
$(CSC) /unsafe /target:library /r:../glib/glib-sharp.dll /r:../gdk/gdk-sharp.dll /out:gtk-sharp.dll /recurse:*.cs
unix:
@echo "'make unix' is broken for now."
defs:
../defs-parse.pl < gtk.defs > generated.cs

View file

@ -1,4 +1,4 @@
DIRS=glib gdk gtk sample
DIRS=codegen glib gdk gtk sample
ROOT=//$(subst \,/,$(subst :\,/,$(SYSTEMROOT)))
CSC=$(ROOT)/microsoft.net/framework/v1.0.2914/csc.exe

View file

@ -16,7 +16,7 @@ namespace GtkSamples {
{
Application.Init (ref args);
Window win = new Window ("Button Tester");
win.DeleteEvent += new EventHandler (Window_Delete);
win.Deleted += new EventHandler (Window_Delete);
Button btn = new Button ();
btn.Clicked += new EventHandler (btn_click);
btn.SizeRequest = new Size (32, 24);

View file

@ -20,7 +20,7 @@ namespace GtkSamples {
System.Console.WriteLine (win.Title);
System.Console.WriteLine (win.DefaultSize);
System.Console.WriteLine (win.AllowShrink);
win.DeleteEvent += new EventHandler (Window_Delete);
win.Deleted += new EventHandler (Window_Delete);
win.Show ();
Application.Run ();
return 0;