2001-11-04 Mike Kestner <mkestner@speakeasy.net>
* codegen/defs-parse.pl : struct generation. Added float and double type mapping entries. * codegen/hardcoded.defs : GdkGeometry definition. define-struct doesn't appear to be supported in the current defs files. This file will be used for manual definition of unsupported defs. * codegen/makefile : add hardcoded.defs. svn path=/trunk/gtk-sharp/; revision=1256
This commit is contained in:
parent
408db7677c
commit
aba851645c
4 changed files with 66 additions and 7 deletions
|
@ -1,3 +1,12 @@
|
|||
2001-11-04 Mike Kestner <mkestner@speakeasy.net>
|
||||
|
||||
* codegen/defs-parse.pl : struct generation. Added float and double
|
||||
type mapping entries.
|
||||
* codegen/hardcoded.defs : GdkGeometry definition. define-struct
|
||||
doesn't appear to be supported in the current defs files. This file
|
||||
will be used for manual definition of unsupported defs.
|
||||
* codegen/makefile : add hardcoded.defs.
|
||||
|
||||
2001-11-02 Mike Kestner <mkestner@speakeasy.net>
|
||||
|
||||
* codegen/defs-parse.pl : define-struct detection. Partial ctor
|
||||
|
|
|
@ -9,12 +9,12 @@
|
|||
%maptypes = (
|
||||
'none', "void", 'gboolean', "bool", 'gint', "int", 'guint', "uint",
|
||||
'guint32', "uint", 'const-gchar', "String", 'GObject', "GLib.Object",
|
||||
'gchar', "String");
|
||||
'gchar', "String", 'gfloat', "float", 'gdouble', "double");
|
||||
|
||||
%marshaltypes = (
|
||||
'none', "void", 'gboolean', "bool", 'gint', "int", 'guint', "uint",
|
||||
'guint32', "uint", 'const-gchar', "IntPtr", 'GObject', "IntPtr",
|
||||
'gchar', "IntPtr");
|
||||
'gchar', "IntPtr", 'gfloat', "float", 'gdouble', "double");
|
||||
|
||||
`mkdir -p ../gdk/generated`;
|
||||
`mkdir -p ../gtk/generated`;
|
||||
|
@ -25,11 +25,8 @@ 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;
|
||||
$maptypes{$cname} = $name;
|
||||
$marshaltypes{$cname} = "IntPtr";
|
||||
gen_struct ($name, $def);
|
||||
} elsif ($def =~ /^\(define-object (\w+)/) {
|
||||
$name = $1;
|
||||
$def =~ /c-name "(\w+)"/;
|
||||
|
@ -159,6 +156,41 @@ sub gen_enum
|
|||
close (OUTFILE);
|
||||
}
|
||||
|
||||
sub gen_struct
|
||||
{
|
||||
my ($name, $def) = @_;
|
||||
|
||||
$def =~ /c-name "(\w+)"/;
|
||||
$cname = $1;
|
||||
$def =~ /in-module "(\w+)"/;
|
||||
$namespace = $1;
|
||||
|
||||
$maptypes{$cname} = $name;
|
||||
$marshaltypes{$cname} = $name;
|
||||
|
||||
$dir = "../" . lc ($namespace) . "/generated";
|
||||
open (OUTFILE, ">$dir/$name.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> $name Structure </summary>\n";
|
||||
print OUTFILE "\t/// <remarks>\n\t///\tFIXME: Add docs.\n";
|
||||
print OUTFILE "\t/// </remarks>\n\n";
|
||||
|
||||
print OUTFILE "\tpublic struct $name {\n";
|
||||
|
||||
if ($def =~ /fields'\((.*)\)\)\)/) {
|
||||
foreach $parm (split(/\)'\(/, $1)) {
|
||||
$parm =~ s/\*//g;
|
||||
$parm =~ /"(\S*)" "(\S*)"/;
|
||||
print OUTFILE "\t\tpublic $maptypes{$1} $2;\n";
|
||||
}
|
||||
}
|
||||
|
||||
print OUTFILE "\t}\n\n}\n";
|
||||
close (OUTFILE);
|
||||
}
|
||||
|
||||
# Code generation for objects.
|
||||
sub gen_object
|
||||
{
|
||||
|
|
18
codegen/hardcoded.defs
Normal file
18
codegen/hardcoded.defs
Normal file
|
@ -0,0 +1,18 @@
|
|||
(define-struct Geometry
|
||||
(in-module "Gdk")
|
||||
(c-name "GdkGeometry")
|
||||
(fields
|
||||
'("gint" "min_width")
|
||||
'("gint" "max_width")
|
||||
'("gint" "min_height")
|
||||
'("gint" "max_height")
|
||||
'("gint" "base_width")
|
||||
'("gint" "base_height")
|
||||
'("gint" "width_inc")
|
||||
'("gint" "height_inc")
|
||||
'("gdouble" "min_aspect")
|
||||
'("gdouble" "max_aspect")
|
||||
'("GdkGravity" "win_gravity")
|
||||
)
|
||||
)
|
||||
|
|
@ -3,7 +3,7 @@ all:
|
|||
@echo "'make unix' is broken for now."
|
||||
|
||||
windows:
|
||||
cat gdk-types.defs gtk-types.defs gtk-props.defs gtk.defs | ./defs-parse.pl
|
||||
cat gdk-types.defs hardcoded.defs gtk-types.defs gtk-props.defs gtk.defs | ./defs-parse.pl
|
||||
|
||||
unix:
|
||||
@echo "'make unix' is broken for now."
|
||||
|
|
Loading…
Reference in a new issue