2004-12-27 Mike Kestner <mkestner@novell.com>

* generator/AliasGen.cs : derive from SimpleBase.
	* generator/ConstStringGen.cs : derive from SimpleBase.
	* generator/GObjectGen.cs : kill. now uses ManualGen.
	* generator/GStringGen.cs : kill. now uses MarshalGen.
	* generator/GUnicharGen.cs : kill. now uses MarshalGen.
	* generator/LPGen.cs : derive from SimpleGen.
	* generator/Makefile.am : update source files.
	* generator/ManualGen : make this general for handle types.
	* generator/MarshalGen : new CallByName/FromNative formatter class.
	* generator/SymbolTable.cs : needed some reorganizing and some
	restructuring of types to use MarshalGen.
	* generator/TimeTGen.cs : kill. now uses MarshalGen.

svn path=/trunk/gtk-sharp/; revision=38109
This commit is contained in:
Mike Kestner 2004-12-27 17:38:52 +00:00
parent f38222d9e0
commit 8d53021079
11 changed files with 128 additions and 237 deletions

View File

@ -1,3 +1,18 @@
2004-12-27 Mike Kestner <mkestner@novell.com>
* generator/AliasGen.cs : derive from SimpleBase.
* generator/ConstStringGen.cs : derive from SimpleBase.
* generator/GObjectGen.cs : kill. now uses ManualGen.
* generator/GStringGen.cs : kill. now uses MarshalGen.
* generator/GUnicharGen.cs : kill. now uses MarshalGen.
* generator/LPGen.cs : derive from SimpleGen.
* generator/Makefile.am : update source files.
* generator/ManualGen : make this general for handle types.
* generator/MarshalGen : new CallByName/FromNative formatter class.
* generator/SymbolTable.cs : needed some reorganizing and some
restructuring of types to use MarshalGen.
* generator/TimeTGen.cs : kill. now uses MarshalGen.
2004-12-26 Mike Kestner <mkestner@novell.com>
* generator/Makefile.am : add new file.

View File

@ -22,7 +22,7 @@ namespace GtkSharp.Generation {
using System;
public class AliasGen : SimpleGen {
public class AliasGen : SimpleBase {
public AliasGen (string ctype, string type) : base (ctype, type) {}
}

View File

@ -23,7 +23,7 @@ namespace GtkSharp.Generation {
using System;
public class ConstStringGen : SimpleGen {
public class ConstStringGen : SimpleBase {
public ConstStringGen (string ctype) : base (ctype, "string")
{

View File

@ -1,37 +0,0 @@
// GtkSharp.Generation.GObjectGen.cs - The GObject generatable
//
// Note: This generatable only handles GObject* values. GObject subclasses
// are handled by ObjectGen.
//
// Author: Rachel Hestilow <rachel@nullenvoid.com>
//
// Copyright (c) 2004 Rachel Hestilow
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of version 2 of the GNU General Public
// License as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public
// License along with this program; if not, write to the
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
namespace GtkSharp.Generation {
public class GObjectGen : ManualGen {
public GObjectGen () : base ("GObject", "GLib.Object") {}
public override string FromNative(string var)
{
return "GLib.Object.GetObject (" + var + ")";
}
}
}

View File

@ -1,47 +0,0 @@
// GtkSharp.Generation.GUnicharGen.cs - The gunichar Generatable.
//
// Author: Mike Kestner <mkestner@novell.com>
//
// Copyright (c) 2004 Novell, Inc.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of version 2 of the GNU General Public
// License as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public
// License along with this program; if not, write to the
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
namespace GtkSharp.Generation {
using System;
public class GUnicharGen : SimpleBase {
public GUnicharGen () : base ("gunichar", "char") {}
public override string MarshalType {
get {
return "uint";
}
}
public override string CallByName (string var_name)
{
return "GLib.Marshaller.CharToGUnichar (" + var_name + ")";
}
public override string FromNative(string var)
{
return "GLib.Marshaller.GUnicharToChar (" + var + ")";
}
}
}

View File

@ -23,7 +23,7 @@ namespace GtkSharp.Generation {
using System;
public class LPGen : SimpleBase {
public class LPGen : SimpleGen {
public LPGen (string ctype) : base (ctype, "long") {}

View File

@ -21,9 +21,6 @@ sources = \
Field.cs \
GenBase.cs \
GenerationInfo.cs \
GObjectGen.cs \
GStringGen.cs \
GUnicharGen.cs \
IGeneratable.cs \
ImportSignature.cs \
InterfaceGen.cs \
@ -31,6 +28,7 @@ sources = \
LPUGen.cs \
ManagedCallString.cs \
ManualGen.cs \
MarshalGen.cs \
MethodBody.cs \
Method.cs \
ObjectGen.cs \
@ -49,7 +47,6 @@ sources = \
StructBase.cs \
StructGen.cs \
SymbolTable.cs \
TimeTGen.cs \
VirtualMethod.cs \
VMSignature.cs

View File

@ -1,8 +1,9 @@
// GtkSharp.Generation.ManualGen.cs - The Manually wrapped type Generatable.
// GtkSharp.Generation.ManualGen.cs - Ungenerated handle type Generatable.
//
// Author: Mike Kestner <mkestner@speakeasy.net>
// Author: Mike Kestner <mkestner@novell.com>
//
// Copyright (c) 2003 Mike Kestner
// Copyright (c) 2004 Novell, Inc.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of version 2 of the GNU General Public
@ -25,30 +26,32 @@ namespace GtkSharp.Generation {
public class ManualGen : SimpleBase {
string handle;
string from_fmt;
public ManualGen (string ctype, string type) : this (ctype, type, "Handle") {}
public ManualGen (string ctype, string type, string handle) : base (ctype, type)
public ManualGen (string ctype, string type) : base (ctype, type)
{
this.handle = handle;
from_fmt = "new " + QualifiedName + "({0})";
}
public ManualGen (string ctype, string type, string from_fmt) : base (ctype, type)
{
this.from_fmt = from_fmt;
}
public override string MarshalType {
get
{
get {
return "IntPtr";
}
}
public override string CallByName (string var_name)
{
return var_name + "." + handle;
return var_name + ".Handle";
}
public override string FromNative(string var)
{
return "new " + QualifiedName + "(" + var + ")";
return String.Format (from_fmt, var);
}
}
}

View File

@ -1,48 +1,56 @@
// GtkSharp.Generation.GStringGen.cs - The GString type Generatable.
//
// Author: Mike Kestner <mkestner@novell.com>
//
// Copyright (c) 2004 Novell, Inc.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of version 2 of the GNU General Public
// License as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public
// License along with this program; if not, write to the
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
namespace GtkSharp.Generation {
using System;
public class GStringGen : SimpleBase {
public GStringGen () : base ("GString", "string") {}
public override string MarshalType {
get {
return "IntPtr";
}
}
public override string CallByName (string var_name)
{
return "(new GLib.GString (" + var_name + ")).Handle";
}
public override string FromNative (string var)
{
return "GLib.GString.PtrToString (" + var + ")";
}
}
}
// GtkSharp.Generation.MarshalGen.cs - Simple marshaling Generatable.
//
// Author: Mike Kestner <mkestner@novell.com>
//
// Copyright (c) 2004 Novell, Inc.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of version 2 of the GNU General Public
// License as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public
// License along with this program; if not, write to the
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
namespace GtkSharp.Generation {
using System;
public class MarshalGen : SimpleBase {
string mtype;
string call_fmt;
string from_fmt;
public MarshalGen (string ctype, string type, string mtype, string call_fmt, string from_fmt) : base (ctype, type)
{
this.mtype = mtype;
this.call_fmt = call_fmt;
this.from_fmt = from_fmt;
}
public override string MarshalType {
get {
return mtype;
}
}
public override string CallByName (string var)
{
return String.Format (call_fmt, var);
}
public override string FromNative (string var)
{
return String.Format (from_fmt, var);
}
}
}

View File

@ -42,52 +42,38 @@ namespace GtkSharp.Generation {
public SymbolTable ()
{
// Simple easily mapped types
AddType (new SimpleGen ("void", "void"));
AddType (new SimpleGen ("gpointer", "IntPtr"));
AddType (new SimpleGen ("gboolean", "bool"));
AddType (new SimpleGen ("gint", "int"));
AddType (new SimpleGen ("guint", "uint"));
AddType (new SimpleGen ("int", "int"));
AddType (new SimpleGen ("unsigned int", "uint"));
AddType (new SimpleGen ("gshort", "short"));
AddType (new SimpleGen ("gushort", "ushort"));
AddType (new SimpleGen ("guint32", "uint"));
AddType (new SimpleGen ("guint64", "ulong"));
// Const returned strings must be generated
// differently from memory-managed strings
AddType (new ConstStringGen ("const-gchar"));
AddType (new ConstStringGen ("const-xmlChar"));
AddType (new ConstStringGen ("const-char"));
AddType (new StringGen ("gchar"));
AddType (new SimpleGen ("gfloat", "float"));
AddType (new SimpleGen ("gdouble", "double"));
AddType (new SimpleGen ("short", "short"));
AddType (new SimpleGen ("guchar", "byte"));
AddType (new SimpleGen ("unsigned char", "byte"));
AddType (new SimpleGen ("guint1", "bool"));
AddType (new SimpleGen ("uint1", "bool"));
AddType (new SimpleGen ("gint8", "sbyte"));
AddType (new SimpleGen ("guint8", "byte"));
AddType (new SimpleGen ("gint16", "short"));
AddType (new SimpleGen ("gint32", "int"));
AddType (new SimpleGen ("gint64", "long"));
AddType (new SimpleGen ("guint16", "ushort"));
AddType (new SimpleGen ("guint1", "bool"));
AddType (new SimpleGen ("gpointer", "IntPtr"));
AddType (new SimpleGen ("guchar", "byte"));
AddType (new SimpleGen ("unsigned char", "byte"));
AddType (new SimpleGen ("short", "short"));
AddType (new SimpleGen ("GQuark", "int"));
AddType (new SimpleGen ("int", "int"));
AddType (new StringGen ("char"));
AddType (new SimpleGen ("double", "double"));
AddType (new SimpleGen ("gint32", "int"));
AddType (new SimpleGen ("guint32", "uint"));
AddType (new SimpleGen ("gint64", "long"));
AddType (new SimpleGen ("guint64", "ulong"));
AddType (new SimpleGen ("gfloat", "float"));
AddType (new SimpleGen ("float", "float"));
AddType (new SimpleGen ("uint1", "bool"));
AddType (new SimpleGen ("GC", "IntPtr"));
AddType (new SimpleGen ("GPtrArray", "IntPtr[]"));
AddType (new ManualGen ("GType", "GLib.GType", "Val"));
AddType (new SimpleGen ("GError", "IntPtr"));
// gsize is a system-specific typedef in glibconfig.h,
// but this should work for now
AddType (new SimpleGen ("gdouble", "double"));
AddType (new SimpleGen ("double", "double"));
AddType (new SimpleGen ("gsize", "uint"));
AddType (new SimpleGen ("gssize", "int"));
AddType (new AliasGen ("off_t", "size_t"));
AddType (new SimpleGen ("GQuark", "int"));
// system specific integer types. these will break on any
// platform specific integer types. these will break on any
// platform where sizeof (long) != sizeof (pointer)
AddType (new LPGen ("ssize_t"));
AddType (new LPGen ("long"));
@ -95,10 +81,30 @@ namespace GtkSharp.Generation {
AddType (new LPUGen ("size_t"));
AddType (new LPUGen ("ulong"));
AddType (new LPUGen ("gulong"));
AddType (new GUnicharGen ());
AddType (new AliasGen ("off_t", "size_t"));
// string types
AddType (new ConstStringGen ("const-gchar"));
AddType (new ConstStringGen ("const-xmlChar"));
AddType (new ConstStringGen ("const-char"));
AddType (new StringGen ("gchar"));
AddType (new StringGen ("char"));
// manually wrapped types requiring more complex marshaling
AddType (new ManualGen ("GObject", "GLib.Object", "GLib.Object.GetObject ({0})"));
AddType (new ManualGen ("GList", "GLib.List"));
AddType (new ManualGen ("GSList", "GLib.SList"));
AddType (new MarshalGen ("gunichar", "char", "uint", "GLib.Marshaller.CharToGUnichar ({0})", "GLib.Marshaller.GUnicharToChar ({0})"));
AddType (new MarshalGen ("time_t", "System.DateTime", "IntPtr", "GLib.Marshaller.DateTimeTotime_t ({0})", "GLib.Marshaller.time_tToDateTime ({0})"));
AddType (new MarshalGen ("GString", "string", "IntPtr", "new GLib.GString ({0}).Handle", "GLib.GString.PtrToString ({0})"));
AddType (new MarshalGen ("GType", "GLib.GType", "IntPtr", "{0}.Val", "new GLib.GType({0})"));
AddType (new ByRefGen ("GValue", "GLib.Value"));
// FIXME: These ought to be handled properly.
AddType (new SimpleGen ("GC", "IntPtr"));
AddType (new SimpleGen ("GError", "IntPtr"));
AddType (new SimpleGen ("GMemChunk", "IntPtr"));
AddType (new SimpleGen ("GPtrArray", "IntPtr[]"));
AddType (new SimpleGen ("GTimeVal", "IntPtr"));
AddType (new SimpleGen ("GClosure", "IntPtr"));
AddType (new SimpleGen ("GArray", "IntPtr"));
@ -112,12 +118,6 @@ namespace GtkSharp.Generation {
AddType (new SimpleGen ("GParamSpec", "IntPtr"));
AddType (new SimpleGen ("gconstpointer", "IntPtr"));
AddType (new SimpleGen ("GDestroyNotify", "IntPtr"));
AddType (new TimeTGen ());
AddType (new ManualGen ("GSList", "GLib.SList"));
AddType (new ManualGen ("GList", "GLib.List"));
AddType (new ByRefGen ("GValue", "GLib.Value"));
AddType (new GStringGen ());
AddType (new GObjectGen ());
}
public void AddType (IGeneratable gen)

View File

@ -1,48 +0,0 @@
// GtkSharp.Generation.TimeTGen.cs - The time_t Generatable.
//
// Author: Mike Kestner <mkestner@novell.com>
//
// Copyright (c) 2003 Mike Kestner
// Copyright (c) 2004 Novell, Inc.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of version 2 of the GNU General Public
// License as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public
// License along with this program; if not, write to the
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
namespace GtkSharp.Generation {
using System;
public class TimeTGen : SimpleBase {
public TimeTGen () : base ("time_t", "System.DateTime") {}
public override string MarshalType {
get {
return "IntPtr";
}
}
public override string CallByName (string var_name)
{
return "GLib.Marshaller.DateTimeTotime_t (" + var_name + ")";
}
public override string FromNative(string var)
{
return "GLib.Marshaller.time_tToDateTime (" + var + ")";
}
}
}