diff --git a/ChangeLog b/ChangeLog index 1214456dc..01a18531c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2001-11-08 Mike Kestner + + * codegen/defs-parse.pl : Build a structs hash and gen the structs + after the first pass of the defs. For structs and functions, mangle + the 100s of params/fields named object to objekt. Insert using stmnts + for structs too. + * codegen/hardcoded.defs : Add GtkAccelEntry struct. + 2001-11-07 Mike Kestner * codegen/defs-parse.pl (gen_object): Insert using statements. Insert diff --git a/codegen/defs-parse.pl b/codegen/defs-parse.pl index 696960a9b..1bd0089ad 100755 --- a/codegen/defs-parse.pl +++ b/codegen/defs-parse.pl @@ -30,8 +30,12 @@ while ($def = get_def()) { gen_enum (split (/\n/, $def)); } elsif ($def =~ /^\(define-struct (\w+)/) { $name = $1; + $def =~ /c-name "(\w+)"/; + $cname=$1; $def =~ s/\n\s*//g; - gen_struct ($name, $def); + $structs{$name} = $def; + $maptypes{$cname} = $name; + $marshaltypes{$cname} = $name; } elsif ($def =~ /^\(define-object (\w+)/) { $name = $1; $def =~ /c-name "(\w+)"/; @@ -61,8 +65,12 @@ while ($def = get_def()) { } -foreach $key (sort (keys (%objects))) { - next if ($key ne "GtkWindow"); +foreach $key (keys (%structs)) { + gen_struct ($key, $structs{$key}); +} + +foreach $key (keys (%objects)) { + next if ($key !~ /GtkWindow\b|GtkAccelGroup|GtkBin\b/); gen_object (split (/\n/, $objects{$key})); } @@ -178,7 +186,10 @@ sub gen_struct print OUTFILE "// Generated file: Do not modify\n\n"; print OUTFILE "namespace $namespace {\n\n"; - print OUTFILE "\t/// $name Structure \n"; + foreach $ns (split (/,/, $usings{$namespace})) { + print OUTFILE "\tusing $ns;\n"; + } + print OUTFILE "\n\t/// $name Structure \n"; print OUTFILE "\t/// \n\t///\tFIXME: Add docs.\n"; print OUTFILE "\t/// \n\n"; @@ -188,7 +199,10 @@ sub gen_struct foreach $parm (split(/\)'\(/, $1)) { $parm =~ s/\*//g; $parm =~ /"(\S*)" "(\S*)"/; - print OUTFILE "\t\tpublic $maptypes{$1} $2;\n"; + $ptype = $1; + $pname = $2; + $pname =~ s/object/objekt/; + print OUTFILE "\t\tpublic $maptypes{$ptype} $pname;\n"; } } @@ -412,30 +426,33 @@ sub gen_method sub gen_param_strings { my ($def) = @_; - my ($call, $parm, $pinv, $sig); + my ($call, $parm, $pinv, $pname, $ptype, $sig); $call = $pinv = $sig = ""; if ($def =~ /parameters'\((.*)\)\)\)/) { foreach $parm (split(/\)'\(/, $1)) { $parm =~ s/\*//g; $parm =~ /"(\S*)" "(\S*)"/; + $ptype = $1; + $pname = $2; + $pname =~ s/object/objekt/; if ($sig) { $sig .= ', '; $call .= ', '; $pinv .= ', '; } - $pinv .= "$marshaltypes{$1} $2"; - $sig .= "$maptypes{$1} $2"; - if ($maptypes{$1} eq $marshaltypes{$1}) { - $call .= "$2"; - } elsif (exists ($objects{$1})) { - $call .= "$2.Handle"; - } elsif ($1 =~ /gchar/) { - $call .= "Marshal.StringToHGlobalAnsi($2)"; - } elsif ($marshaltypes{$1} = "int") { - $call .= "(int) $2"; + $pinv .= "$marshaltypes{$ptype} $pname"; + $sig .= "$maptypes{$ptype} $pname"; + if ($maptypes{$ptype} eq $marshaltypes{$ptype}) { + $call .= "$pname"; + } elsif (exists ($objects{$ptype})) { + $call .= "$pname.Handle"; + } elsif ($ptype =~ /gchar/) { + $call .= "Marshal.StringToHGlobalAnsi($pname)"; + } elsif ($marshaltypes{$ptype} = "int") { + $call .= "(int) $pname"; } else { - die "Unexpected type encountered $1\n"; + die "Unexpected type encountered $ptype\n"; } } } diff --git a/codegen/hardcoded.defs b/codegen/hardcoded.defs index 9c31b0c7d..1d80e7ad2 100644 --- a/codegen/hardcoded.defs +++ b/codegen/hardcoded.defs @@ -16,3 +16,15 @@ ) ) +(define-struct AccelEntry + (in-module "Gtk") + (c-name "GtkAccelEntry") + (fields + '("GtkAccelGroup*" "accel_group") + '("guint" "accelerator_key") + '("GdkModifierType" "accelerator_mods") + '("GtkAccelFlags" "accel_flags") + '("GObject*" "object") + '("guint" "signal_id") + ) +)