2002-01-05 12:45:55 +00:00
|
|
|
// GtkSharp.Generation.SymbolTable.cs - The Symbol Table Class.
|
|
|
|
//
|
|
|
|
// Author: Mike Kestner <mkestner@speakeasy.net>
|
|
|
|
//
|
2002-05-23 23:43:25 +00:00
|
|
|
// (c) 2001-2002 Mike Kestner
|
2002-01-05 12:45:55 +00:00
|
|
|
|
|
|
|
namespace GtkSharp.Generation {
|
|
|
|
|
|
|
|
using System;
|
|
|
|
using System.Collections;
|
|
|
|
|
|
|
|
public class SymbolTable {
|
|
|
|
|
2002-05-26 16:23:40 +00:00
|
|
|
private static Hashtable alias = new Hashtable ();
|
2002-05-23 23:43:25 +00:00
|
|
|
private static Hashtable complex_types = new Hashtable ();
|
|
|
|
private static Hashtable simple_types;
|
2002-06-26 Rachel Hestilow <hestilow@ximian.com>
* configure.in, makefile, makefile.win32: add gnome.
* doc/index.html, netdoc.xsl: Add gnome.
* gdk/Event.cs: New manual wrap for GdkEvent.
* generator/ClassBase.cs: Add methods GetProperty,
GetPropertyRecursively, GetMethodRecursively.
Move Parent property here from ObjectGen.cs. Pass this pointer
into Property.
* generator/Ctor.cs: Generate docs.
* generator/Method.cs, Property.cs: Tag method as "new" if a
Method/Property with the same name is found in the class hierarchy.
* generator/SignalHandler.cs: Correctly wrap complex signal argument
types. Add gnome directory.
* generator/SymbolTable.cs: Add manually wrapped types hash
(contains GLib.GSList and Gdk.Event). Add method IsManuallyWrapped.
* glib/SList.cs: Add constructor from IntPtr.
* glue/slist.c, glue/event.c: Added (field accessor glue).
* glue/Makefile.am: Update.
* parser/Gtk.metadata: Add new signal renames for new signals
exposed by GdkEvent changes.
* parser/README, parser/build.pl: Add libgnome, libgnomecanvas,
libgnomeui.
* parser/gapi2xml.pl: Handle literal-length array parameters,
and NULL property doc strings.
* sample/: Add new test GnomeHelloWorld.cs.
* gnome/: Added.
* parser/Gnome.metadata: Added.
svn path=/trunk/gtk-sharp/; revision=5461
2002-06-26 08:36:05 +00:00
|
|
|
private static Hashtable manually_wrapped_types;
|
2002-01-05 12:45:55 +00:00
|
|
|
|
2002-05-23 23:43:25 +00:00
|
|
|
static SymbolTable ()
|
2002-01-05 13:24:13 +00:00
|
|
|
{
|
|
|
|
simple_types = new Hashtable ();
|
2002-02-08 23:56:27 +00:00
|
|
|
simple_types.Add ("void", "void");
|
2002-01-05 13:24:13 +00:00
|
|
|
simple_types.Add ("gboolean", "bool");
|
|
|
|
simple_types.Add ("gint", "int");
|
|
|
|
simple_types.Add ("guint", "uint");
|
|
|
|
simple_types.Add ("glong", "long");
|
2002-01-06 13:33:25 +00:00
|
|
|
simple_types.Add ("gshort", "short");
|
2002-07-30 23:02:12 +00:00
|
|
|
simple_types.Add ("gushort", "ushort");
|
2002-01-05 13:24:13 +00:00
|
|
|
simple_types.Add ("guint32", "uint");
|
2002-11-01 05:01:22 +00:00
|
|
|
simple_types.Add ("guint64", "ulong");
|
2002-04-04 16:20:53 +00:00
|
|
|
simple_types.Add ("const-gchar", "string");
|
2002-06-26 Rachel Hestilow <hestilow@ximian.com>
* configure.in, makefile, makefile.win32: add gnome.
* doc/index.html, netdoc.xsl: Add gnome.
* gdk/Event.cs: New manual wrap for GdkEvent.
* generator/ClassBase.cs: Add methods GetProperty,
GetPropertyRecursively, GetMethodRecursively.
Move Parent property here from ObjectGen.cs. Pass this pointer
into Property.
* generator/Ctor.cs: Generate docs.
* generator/Method.cs, Property.cs: Tag method as "new" if a
Method/Property with the same name is found in the class hierarchy.
* generator/SignalHandler.cs: Correctly wrap complex signal argument
types. Add gnome directory.
* generator/SymbolTable.cs: Add manually wrapped types hash
(contains GLib.GSList and Gdk.Event). Add method IsManuallyWrapped.
* glib/SList.cs: Add constructor from IntPtr.
* glue/slist.c, glue/event.c: Added (field accessor glue).
* glue/Makefile.am: Update.
* parser/Gtk.metadata: Add new signal renames for new signals
exposed by GdkEvent changes.
* parser/README, parser/build.pl: Add libgnome, libgnomecanvas,
libgnomeui.
* parser/gapi2xml.pl: Handle literal-length array parameters,
and NULL property doc strings.
* sample/: Add new test GnomeHelloWorld.cs.
* gnome/: Added.
* parser/Gnome.metadata: Added.
svn path=/trunk/gtk-sharp/; revision=5461
2002-06-26 08:36:05 +00:00
|
|
|
simple_types.Add ("const-char", "string");
|
2002-04-04 16:20:53 +00:00
|
|
|
simple_types.Add ("gchar", "string");
|
2002-01-05 13:24:13 +00:00
|
|
|
simple_types.Add ("GObject", "GLib.Object");
|
|
|
|
simple_types.Add ("gfloat", "float");
|
|
|
|
simple_types.Add ("gdouble", "double");
|
|
|
|
simple_types.Add ("gint8", "byte");
|
|
|
|
simple_types.Add ("guint8", "byte");
|
|
|
|
simple_types.Add ("gint16", "short");
|
2002-01-06 13:33:25 +00:00
|
|
|
simple_types.Add ("gint32", "int");
|
2002-11-01 05:01:22 +00:00
|
|
|
simple_types.Add ("gint64", "long");
|
2002-01-06 13:33:25 +00:00
|
|
|
simple_types.Add ("guint16", "ushort");
|
2002-01-05 13:24:13 +00:00
|
|
|
simple_types.Add ("guint1", "bool");
|
2002-04-04 16:20:53 +00:00
|
|
|
simple_types.Add ("gpointer", "System.IntPtr");
|
2002-01-05 13:24:13 +00:00
|
|
|
simple_types.Add ("guchar", "byte");
|
|
|
|
simple_types.Add ("long", "long");
|
|
|
|
simple_types.Add ("gulong", "ulong");
|
|
|
|
simple_types.Add ("GQuark", "int");
|
|
|
|
simple_types.Add ("int", "int");
|
2002-05-08 00:33:53 +00:00
|
|
|
simple_types.Add ("char", "string");
|
2002-01-05 13:24:13 +00:00
|
|
|
simple_types.Add ("double", "double");
|
2002-01-12 02:08:16 +00:00
|
|
|
simple_types.Add ("float", "float");
|
2002-04-04 16:20:53 +00:00
|
|
|
simple_types.Add ("gunichar", "string");
|
2002-01-05 13:24:13 +00:00
|
|
|
simple_types.Add ("uint1", "bool");
|
2002-04-04 16:20:53 +00:00
|
|
|
simple_types.Add ("GPtrArray", "System.IntPtr[]");
|
2002-12-25 00:36:00 +00:00
|
|
|
simple_types.Add ("GType", "uint");
|
2002-06-20 01:45:13 +00:00
|
|
|
simple_types.Add ("GError", "IntPtr");
|
2002-07-02 03:35:07 +00:00
|
|
|
// gsize is a system-specific typedef in glibconfig.h,
|
|
|
|
// but this should work for now
|
|
|
|
simple_types.Add ("gsize", "uint");
|
|
|
|
simple_types.Add ("gssize", "int");
|
2002-08-28 20:58:01 +00:00
|
|
|
simple_types.Add ("size_t", "int");
|
2002-01-05 13:24:13 +00:00
|
|
|
|
|
|
|
// FIXME: These ought to be handled properly.
|
2002-04-04 16:20:53 +00:00
|
|
|
simple_types.Add ("GMemChunk", "System.IntPtr");
|
|
|
|
simple_types.Add ("GTimeVal", "System.IntPtr");
|
|
|
|
simple_types.Add ("GClosure", "System.IntPtr");
|
|
|
|
simple_types.Add ("GArray", "System.IntPtr");
|
|
|
|
simple_types.Add ("GData", "System.IntPtr");
|
2002-01-10 15:01:31 +00:00
|
|
|
simple_types.Add ("GTypeModule", "GLib.Object");
|
2002-04-04 16:20:53 +00:00
|
|
|
simple_types.Add ("GHashTable", "System.IntPtr");
|
|
|
|
simple_types.Add ("va_list", "System.IntPtr");
|
|
|
|
simple_types.Add ("GParamSpec", "System.IntPtr");
|
2002-07-30 23:02:12 +00:00
|
|
|
simple_types.Add ("gconstpointer", "System.IntPtr");
|
2002-06-26 Rachel Hestilow <hestilow@ximian.com>
* configure.in, makefile, makefile.win32: add gnome.
* doc/index.html, netdoc.xsl: Add gnome.
* gdk/Event.cs: New manual wrap for GdkEvent.
* generator/ClassBase.cs: Add methods GetProperty,
GetPropertyRecursively, GetMethodRecursively.
Move Parent property here from ObjectGen.cs. Pass this pointer
into Property.
* generator/Ctor.cs: Generate docs.
* generator/Method.cs, Property.cs: Tag method as "new" if a
Method/Property with the same name is found in the class hierarchy.
* generator/SignalHandler.cs: Correctly wrap complex signal argument
types. Add gnome directory.
* generator/SymbolTable.cs: Add manually wrapped types hash
(contains GLib.GSList and Gdk.Event). Add method IsManuallyWrapped.
* glib/SList.cs: Add constructor from IntPtr.
* glue/slist.c, glue/event.c: Added (field accessor glue).
* glue/Makefile.am: Update.
* parser/Gtk.metadata: Add new signal renames for new signals
exposed by GdkEvent changes.
* parser/README, parser/build.pl: Add libgnome, libgnomecanvas,
libgnomeui.
* parser/gapi2xml.pl: Handle literal-length array parameters,
and NULL property doc strings.
* sample/: Add new test GnomeHelloWorld.cs.
* gnome/: Added.
* parser/Gnome.metadata: Added.
svn path=/trunk/gtk-sharp/; revision=5461
2002-06-26 08:36:05 +00:00
|
|
|
|
|
|
|
manually_wrapped_types = new Hashtable ();
|
|
|
|
manually_wrapped_types.Add ("GSList", "GLib.SList");
|
2002-09-01 04:46:38 +00:00
|
|
|
manually_wrapped_types.Add ("GList", "GLib.List");
|
2002-08-09 04:54:39 +00:00
|
|
|
manually_wrapped_types.Add ("GValue", "GLib.Value");
|
2002-01-05 13:24:13 +00:00
|
|
|
}
|
|
|
|
|
2002-05-26 16:23:40 +00:00
|
|
|
public static void AddAlias (string name, string type)
|
|
|
|
{
|
|
|
|
type = type.TrimEnd(' ', '\t');
|
|
|
|
alias [name] = type;
|
|
|
|
}
|
|
|
|
|
2002-05-23 23:43:25 +00:00
|
|
|
public static void AddType (IGeneratable gen)
|
2002-01-05 12:45:55 +00:00
|
|
|
{
|
|
|
|
complex_types [gen.CName] = gen;
|
|
|
|
}
|
|
|
|
|
2002-08-19 Rachel Hestilow <hestilow@ximian.com>
* art/Makefile.in (clean): Change to avoid bugging out on generated/CVS.
* glib/ObjectManager.cs: Added. Used to be auto-generated, but
now it can infer names, and relies on per-namespace ObjectManager
classes to inform it of oddly-named classes.
* generator/IGeneratable.cs, GenBase.cs: New "DoGenerate" property.
* generator/*Gen.cs: Honor DoGenerate.
* generator/CodeGenerator.cs: Support including dependency files
which will not be generated.
* generator/ObjectGen.cs: Generate mapping file per-namespace, as one
that calls back to the one in glib. Only generate if the name does
not follow the normal conventions, otherwise, GtkSharp.ObjectManager
can infer the name.
* generator/Parser.cs: Accept 'generate' flag to pass on to the
IGeneratables. Parse a new toplevel element, "symbol", which adds
a type to the SymbolTable (instead of hard-coding it).
* generator/SignalHandler.cs: Do not optimize signal handler creation,
instead creating them in their own namespaces. Do not generate
if the calling Signal told us not to.
* generator/Signal.cs: Do not generate handlers if container's DoGenerate
is false. Adjust to the marshaller name being in a sub-namespace.
* generator/SymbolTable.cs (AddSimpleType, AddManualType): Used
to add simple and manually wrapped types at runtime instead of
compile-time.
(FromNative): Remove hard-coded cases for manually wrapped types, use
a generic case instead.
* api: Added. Move api files and generation targets here.
* source: Added. Move source parsing here.
* generator/makefile: Move actual generation to api/.
* glib/Makefile.in: Remove generated/* target.
* glue/Makefile.am: Fix to include canvas-marshal. Move canvas stuff
to GNOME target.
* gnome/CanvasProxy.cs: Update to work with SignalHandlers being
namespace-specific.
* parser/Metadata.pm: Moved to GAPI/Metadata.pm, renamed, etc.
* parser/gapi2xml.pl: Use GAPI::Metadata.
* parser/makefile: Install scripts, remove source parse build target.
Rename formatXML to gapi_format_xml.
svn path=/trunk/gtk-sharp/; revision=6818
2002-08-20 19:56:18 +00:00
|
|
|
public static void AddSimpleType (string cname, string name)
|
|
|
|
{
|
|
|
|
simple_types.Add (cname, name);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void AddManualType (string cname, string name)
|
|
|
|
{
|
|
|
|
manually_wrapped_types.Add (cname, name);
|
|
|
|
}
|
|
|
|
|
2002-05-23 23:43:25 +00:00
|
|
|
public static int Count {
|
2002-01-05 12:45:55 +00:00
|
|
|
get
|
|
|
|
{
|
|
|
|
return complex_types.Count;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-05-23 23:43:25 +00:00
|
|
|
public static IEnumerable Generatables {
|
2002-03-08 22:40:00 +00:00
|
|
|
get {
|
|
|
|
return complex_types.Values;
|
|
|
|
}
|
2002-01-05 12:45:55 +00:00
|
|
|
}
|
|
|
|
|
2002-05-23 23:43:25 +00:00
|
|
|
private static string Trim(string type)
|
2002-02-03 03:44:10 +00:00
|
|
|
{
|
2002-08-21 00:57:52 +00:00
|
|
|
// HACK: If we don't detect this here, there is no
|
|
|
|
// way of indicating it in the symbol table
|
|
|
|
if (type == "void*" || type == "const-void*") return "gpointer";
|
|
|
|
|
2002-04-04 16:20:53 +00:00
|
|
|
string trim_type = type.TrimEnd('*');
|
2002-02-18 19:26:33 +00:00
|
|
|
if (trim_type.StartsWith("const-")) return trim_type.Substring(6);
|
2002-02-03 03:44:10 +00:00
|
|
|
return trim_type;
|
|
|
|
}
|
|
|
|
|
2002-05-26 16:23:40 +00:00
|
|
|
private static string DeAlias (string type)
|
|
|
|
{
|
|
|
|
while (alias.ContainsKey(type))
|
|
|
|
type = (string) alias[type];
|
|
|
|
|
|
|
|
return type;
|
|
|
|
}
|
|
|
|
|
2002-07-26 06:08:52 +00:00
|
|
|
public static string FromNativeReturn(string c_type, string val)
|
|
|
|
{
|
|
|
|
return FromNative (c_type, val, true);
|
|
|
|
}
|
|
|
|
|
2002-05-23 23:43:25 +00:00
|
|
|
public static string FromNative(string c_type, string val)
|
2002-07-26 06:08:52 +00:00
|
|
|
{
|
|
|
|
return FromNative (c_type, val, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static string FromNative(string c_type, string val, bool ret)
|
2002-02-08 23:56:27 +00:00
|
|
|
{
|
|
|
|
c_type = Trim(c_type);
|
2002-05-26 16:23:40 +00:00
|
|
|
c_type = DeAlias(c_type);
|
2002-02-08 23:56:27 +00:00
|
|
|
if (simple_types.ContainsKey(c_type)) {
|
|
|
|
return val;
|
|
|
|
} else if (complex_types.ContainsKey(c_type)) {
|
|
|
|
IGeneratable gen = (IGeneratable) complex_types[c_type];
|
2002-07-26 06:08:52 +00:00
|
|
|
if (ret)
|
|
|
|
return gen.FromNativeReturn(val);
|
|
|
|
else
|
|
|
|
return gen.FromNative(val);
|
2002-06-26 Rachel Hestilow <hestilow@ximian.com>
* configure.in, makefile, makefile.win32: add gnome.
* doc/index.html, netdoc.xsl: Add gnome.
* gdk/Event.cs: New manual wrap for GdkEvent.
* generator/ClassBase.cs: Add methods GetProperty,
GetPropertyRecursively, GetMethodRecursively.
Move Parent property here from ObjectGen.cs. Pass this pointer
into Property.
* generator/Ctor.cs: Generate docs.
* generator/Method.cs, Property.cs: Tag method as "new" if a
Method/Property with the same name is found in the class hierarchy.
* generator/SignalHandler.cs: Correctly wrap complex signal argument
types. Add gnome directory.
* generator/SymbolTable.cs: Add manually wrapped types hash
(contains GLib.GSList and Gdk.Event). Add method IsManuallyWrapped.
* glib/SList.cs: Add constructor from IntPtr.
* glue/slist.c, glue/event.c: Added (field accessor glue).
* glue/Makefile.am: Update.
* parser/Gtk.metadata: Add new signal renames for new signals
exposed by GdkEvent changes.
* parser/README, parser/build.pl: Add libgnome, libgnomecanvas,
libgnomeui.
* parser/gapi2xml.pl: Handle literal-length array parameters,
and NULL property doc strings.
* sample/: Add new test GnomeHelloWorld.cs.
* gnome/: Added.
* parser/Gnome.metadata: Added.
svn path=/trunk/gtk-sharp/; revision=5461
2002-06-26 08:36:05 +00:00
|
|
|
} else if (manually_wrapped_types.ContainsKey(c_type)) {
|
2002-08-19 Rachel Hestilow <hestilow@ximian.com>
* art/Makefile.in (clean): Change to avoid bugging out on generated/CVS.
* glib/ObjectManager.cs: Added. Used to be auto-generated, but
now it can infer names, and relies on per-namespace ObjectManager
classes to inform it of oddly-named classes.
* generator/IGeneratable.cs, GenBase.cs: New "DoGenerate" property.
* generator/*Gen.cs: Honor DoGenerate.
* generator/CodeGenerator.cs: Support including dependency files
which will not be generated.
* generator/ObjectGen.cs: Generate mapping file per-namespace, as one
that calls back to the one in glib. Only generate if the name does
not follow the normal conventions, otherwise, GtkSharp.ObjectManager
can infer the name.
* generator/Parser.cs: Accept 'generate' flag to pass on to the
IGeneratables. Parse a new toplevel element, "symbol", which adds
a type to the SymbolTable (instead of hard-coding it).
* generator/SignalHandler.cs: Do not optimize signal handler creation,
instead creating them in their own namespaces. Do not generate
if the calling Signal told us not to.
* generator/Signal.cs: Do not generate handlers if container's DoGenerate
is false. Adjust to the marshaller name being in a sub-namespace.
* generator/SymbolTable.cs (AddSimpleType, AddManualType): Used
to add simple and manually wrapped types at runtime instead of
compile-time.
(FromNative): Remove hard-coded cases for manually wrapped types, use
a generic case instead.
* api: Added. Move api files and generation targets here.
* source: Added. Move source parsing here.
* generator/makefile: Move actual generation to api/.
* glib/Makefile.in: Remove generated/* target.
* glue/Makefile.am: Fix to include canvas-marshal. Move canvas stuff
to GNOME target.
* gnome/CanvasProxy.cs: Update to work with SignalHandlers being
namespace-specific.
* parser/Metadata.pm: Moved to GAPI/Metadata.pm, renamed, etc.
* parser/gapi2xml.pl: Use GAPI::Metadata.
* parser/makefile: Install scripts, remove source parse build target.
Rename formatXML to gapi_format_xml.
svn path=/trunk/gtk-sharp/; revision=6818
2002-08-20 19:56:18 +00:00
|
|
|
string cs_type = (string) manually_wrapped_types[c_type];
|
|
|
|
return String.Format ("new {0} ({1})", cs_type, val);
|
2002-02-08 23:56:27 +00:00
|
|
|
} else {
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-05-23 23:43:25 +00:00
|
|
|
public static string GetCSType(string c_type)
|
2002-01-05 12:45:55 +00:00
|
|
|
{
|
2002-02-03 03:44:10 +00:00
|
|
|
c_type = Trim(c_type);
|
2002-05-26 16:23:40 +00:00
|
|
|
c_type = DeAlias(c_type);
|
2002-01-05 13:24:13 +00:00
|
|
|
if (simple_types.ContainsKey(c_type)) {
|
2002-04-04 16:20:53 +00:00
|
|
|
return (string) simple_types[c_type];
|
2002-01-05 13:24:13 +00:00
|
|
|
} else if (complex_types.ContainsKey(c_type)) {
|
|
|
|
IGeneratable gen = (IGeneratable) complex_types[c_type];
|
|
|
|
return gen.QualifiedName;
|
2002-06-26 Rachel Hestilow <hestilow@ximian.com>
* configure.in, makefile, makefile.win32: add gnome.
* doc/index.html, netdoc.xsl: Add gnome.
* gdk/Event.cs: New manual wrap for GdkEvent.
* generator/ClassBase.cs: Add methods GetProperty,
GetPropertyRecursively, GetMethodRecursively.
Move Parent property here from ObjectGen.cs. Pass this pointer
into Property.
* generator/Ctor.cs: Generate docs.
* generator/Method.cs, Property.cs: Tag method as "new" if a
Method/Property with the same name is found in the class hierarchy.
* generator/SignalHandler.cs: Correctly wrap complex signal argument
types. Add gnome directory.
* generator/SymbolTable.cs: Add manually wrapped types hash
(contains GLib.GSList and Gdk.Event). Add method IsManuallyWrapped.
* glib/SList.cs: Add constructor from IntPtr.
* glue/slist.c, glue/event.c: Added (field accessor glue).
* glue/Makefile.am: Update.
* parser/Gtk.metadata: Add new signal renames for new signals
exposed by GdkEvent changes.
* parser/README, parser/build.pl: Add libgnome, libgnomecanvas,
libgnomeui.
* parser/gapi2xml.pl: Handle literal-length array parameters,
and NULL property doc strings.
* sample/: Add new test GnomeHelloWorld.cs.
* gnome/: Added.
* parser/Gnome.metadata: Added.
svn path=/trunk/gtk-sharp/; revision=5461
2002-06-26 08:36:05 +00:00
|
|
|
} else if (manually_wrapped_types.ContainsKey(c_type)) {
|
|
|
|
return (string) manually_wrapped_types[c_type];
|
2002-01-05 13:24:13 +00:00
|
|
|
} else {
|
|
|
|
return "";
|
|
|
|
}
|
2002-01-05 12:45:55 +00:00
|
|
|
}
|
|
|
|
|
2002-05-23 23:43:25 +00:00
|
|
|
public static string GetName(string c_type)
|
2002-02-15 01:08:57 +00:00
|
|
|
{
|
|
|
|
c_type = Trim(c_type);
|
2002-05-26 16:23:40 +00:00
|
|
|
c_type = DeAlias(c_type);
|
2002-06-26 Rachel Hestilow <hestilow@ximian.com>
* configure.in, makefile, makefile.win32: add gnome.
* doc/index.html, netdoc.xsl: Add gnome.
* gdk/Event.cs: New manual wrap for GdkEvent.
* generator/ClassBase.cs: Add methods GetProperty,
GetPropertyRecursively, GetMethodRecursively.
Move Parent property here from ObjectGen.cs. Pass this pointer
into Property.
* generator/Ctor.cs: Generate docs.
* generator/Method.cs, Property.cs: Tag method as "new" if a
Method/Property with the same name is found in the class hierarchy.
* generator/SignalHandler.cs: Correctly wrap complex signal argument
types. Add gnome directory.
* generator/SymbolTable.cs: Add manually wrapped types hash
(contains GLib.GSList and Gdk.Event). Add method IsManuallyWrapped.
* glib/SList.cs: Add constructor from IntPtr.
* glue/slist.c, glue/event.c: Added (field accessor glue).
* glue/Makefile.am: Update.
* parser/Gtk.metadata: Add new signal renames for new signals
exposed by GdkEvent changes.
* parser/README, parser/build.pl: Add libgnome, libgnomecanvas,
libgnomeui.
* parser/gapi2xml.pl: Handle literal-length array parameters,
and NULL property doc strings.
* sample/: Add new test GnomeHelloWorld.cs.
* gnome/: Added.
* parser/Gnome.metadata: Added.
svn path=/trunk/gtk-sharp/; revision=5461
2002-06-26 08:36:05 +00:00
|
|
|
if (simple_types.ContainsKey(c_type) || manually_wrapped_types.ContainsKey(c_type)) {
|
|
|
|
string stype;
|
|
|
|
if (simple_types.ContainsKey(c_type))
|
|
|
|
stype = (string) simple_types[c_type];
|
|
|
|
else
|
|
|
|
stype = (string) manually_wrapped_types[c_type];
|
2002-02-15 01:08:57 +00:00
|
|
|
int dotidx = stype.IndexOf(".");
|
|
|
|
if (dotidx == -1) {
|
|
|
|
return stype;
|
|
|
|
} else {
|
|
|
|
return stype.Substring(dotidx+1);
|
|
|
|
}
|
|
|
|
} else if (complex_types.ContainsKey(c_type)) {
|
|
|
|
IGeneratable gen = (IGeneratable) complex_types[c_type];
|
|
|
|
return gen.Name;
|
|
|
|
} else {
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-07-26 06:08:52 +00:00
|
|
|
public static string GetMarshalReturnType(string c_type)
|
|
|
|
{
|
|
|
|
return GetMarshalType (c_type, true);
|
|
|
|
}
|
|
|
|
|
2002-05-23 23:43:25 +00:00
|
|
|
public static string GetMarshalType(string c_type)
|
2002-07-26 06:08:52 +00:00
|
|
|
{
|
|
|
|
return GetMarshalType (c_type, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static string GetMarshalType(string c_type, bool ret)
|
2002-01-12 02:08:16 +00:00
|
|
|
{
|
2002-02-06 20:09:14 +00:00
|
|
|
c_type = Trim(c_type);
|
2002-05-26 16:23:40 +00:00
|
|
|
c_type = DeAlias(c_type);
|
2002-01-12 02:08:16 +00:00
|
|
|
if (simple_types.ContainsKey(c_type)) {
|
2002-04-04 16:20:53 +00:00
|
|
|
return (string) simple_types[c_type];
|
2002-06-26 Rachel Hestilow <hestilow@ximian.com>
* configure.in, makefile, makefile.win32: add gnome.
* doc/index.html, netdoc.xsl: Add gnome.
* gdk/Event.cs: New manual wrap for GdkEvent.
* generator/ClassBase.cs: Add methods GetProperty,
GetPropertyRecursively, GetMethodRecursively.
Move Parent property here from ObjectGen.cs. Pass this pointer
into Property.
* generator/Ctor.cs: Generate docs.
* generator/Method.cs, Property.cs: Tag method as "new" if a
Method/Property with the same name is found in the class hierarchy.
* generator/SignalHandler.cs: Correctly wrap complex signal argument
types. Add gnome directory.
* generator/SymbolTable.cs: Add manually wrapped types hash
(contains GLib.GSList and Gdk.Event). Add method IsManuallyWrapped.
* glib/SList.cs: Add constructor from IntPtr.
* glue/slist.c, glue/event.c: Added (field accessor glue).
* glue/Makefile.am: Update.
* parser/Gtk.metadata: Add new signal renames for new signals
exposed by GdkEvent changes.
* parser/README, parser/build.pl: Add libgnome, libgnomecanvas,
libgnomeui.
* parser/gapi2xml.pl: Handle literal-length array parameters,
and NULL property doc strings.
* sample/: Add new test GnomeHelloWorld.cs.
* gnome/: Added.
* parser/Gnome.metadata: Added.
svn path=/trunk/gtk-sharp/; revision=5461
2002-06-26 08:36:05 +00:00
|
|
|
} else if (manually_wrapped_types.ContainsKey(c_type)) {
|
|
|
|
return "IntPtr";
|
2002-01-12 02:08:16 +00:00
|
|
|
} else if (complex_types.ContainsKey(c_type)) {
|
|
|
|
IGeneratable gen = (IGeneratable) complex_types[c_type];
|
2002-07-26 06:08:52 +00:00
|
|
|
if (ret)
|
|
|
|
return gen.MarshalReturnType;
|
|
|
|
else
|
|
|
|
return gen.MarshalType;
|
2002-01-12 02:08:16 +00:00
|
|
|
} else {
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-05-23 23:43:25 +00:00
|
|
|
public static string CallByName(string c_type, string var_name)
|
2002-02-06 20:09:14 +00:00
|
|
|
{
|
|
|
|
c_type = Trim(c_type);
|
2002-05-26 16:23:40 +00:00
|
|
|
c_type = DeAlias(c_type);
|
2002-02-06 20:09:14 +00:00
|
|
|
if (simple_types.ContainsKey(c_type)) {
|
|
|
|
return var_name;
|
2002-06-26 Rachel Hestilow <hestilow@ximian.com>
* configure.in, makefile, makefile.win32: add gnome.
* doc/index.html, netdoc.xsl: Add gnome.
* gdk/Event.cs: New manual wrap for GdkEvent.
* generator/ClassBase.cs: Add methods GetProperty,
GetPropertyRecursively, GetMethodRecursively.
Move Parent property here from ObjectGen.cs. Pass this pointer
into Property.
* generator/Ctor.cs: Generate docs.
* generator/Method.cs, Property.cs: Tag method as "new" if a
Method/Property with the same name is found in the class hierarchy.
* generator/SignalHandler.cs: Correctly wrap complex signal argument
types. Add gnome directory.
* generator/SymbolTable.cs: Add manually wrapped types hash
(contains GLib.GSList and Gdk.Event). Add method IsManuallyWrapped.
* glib/SList.cs: Add constructor from IntPtr.
* glue/slist.c, glue/event.c: Added (field accessor glue).
* glue/Makefile.am: Update.
* parser/Gtk.metadata: Add new signal renames for new signals
exposed by GdkEvent changes.
* parser/README, parser/build.pl: Add libgnome, libgnomecanvas,
libgnomeui.
* parser/gapi2xml.pl: Handle literal-length array parameters,
and NULL property doc strings.
* sample/: Add new test GnomeHelloWorld.cs.
* gnome/: Added.
* parser/Gnome.metadata: Added.
svn path=/trunk/gtk-sharp/; revision=5461
2002-06-26 08:36:05 +00:00
|
|
|
} else if (manually_wrapped_types.ContainsKey(c_type)) {
|
|
|
|
return var_name + ".Handle";
|
2002-02-06 20:09:14 +00:00
|
|
|
} else if (complex_types.ContainsKey(c_type)) {
|
|
|
|
IGeneratable gen = (IGeneratable) complex_types[c_type];
|
|
|
|
return gen.CallByName(var_name);
|
|
|
|
} else {
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
}
|
2002-07-26 06:08:52 +00:00
|
|
|
|
|
|
|
public static bool IsOpaque(string c_type)
|
|
|
|
{
|
|
|
|
c_type = Trim(c_type);
|
|
|
|
c_type = DeAlias(c_type);
|
|
|
|
if (complex_types.ContainsKey(c_type)) {
|
|
|
|
IGeneratable gen = (IGeneratable) complex_types[c_type];
|
|
|
|
if (gen is OpaqueGen) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2002-05-23 23:43:25 +00:00
|
|
|
public static bool IsBoxed(string c_type)
|
2002-01-17 00:26:46 +00:00
|
|
|
{
|
2002-02-15 01:08:57 +00:00
|
|
|
c_type = Trim(c_type);
|
2002-05-26 16:23:40 +00:00
|
|
|
c_type = DeAlias(c_type);
|
2002-01-17 00:26:46 +00:00
|
|
|
if (complex_types.ContainsKey(c_type)) {
|
|
|
|
IGeneratable gen = (IGeneratable) complex_types[c_type];
|
|
|
|
if (gen is BoxedGen) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2002-07-14 01:32:18 +00:00
|
|
|
public static bool IsStruct(string c_type)
|
|
|
|
{
|
|
|
|
c_type = Trim(c_type);
|
|
|
|
c_type = DeAlias(c_type);
|
|
|
|
if (complex_types.ContainsKey(c_type)) {
|
|
|
|
IGeneratable gen = (IGeneratable) complex_types[c_type];
|
|
|
|
if (gen is StructGen) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2002-05-23 23:43:25 +00:00
|
|
|
public static bool IsEnum(string c_type)
|
2002-05-02 21:57:41 +00:00
|
|
|
{
|
|
|
|
c_type = Trim(c_type);
|
2002-05-26 16:23:40 +00:00
|
|
|
c_type = DeAlias(c_type);
|
2002-05-02 21:57:41 +00:00
|
|
|
if (complex_types.ContainsKey(c_type)) {
|
|
|
|
IGeneratable gen = (IGeneratable) complex_types[c_type];
|
|
|
|
if (gen is EnumGen) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2002-08-03 22:24:37 +00:00
|
|
|
|
|
|
|
public static bool IsEnumFlags(string c_type)
|
|
|
|
{
|
|
|
|
c_type = Trim(c_type);
|
|
|
|
c_type = DeAlias(c_type);
|
|
|
|
if (complex_types.ContainsKey(c_type)) {
|
|
|
|
EnumGen gen = complex_types[c_type] as EnumGen;
|
|
|
|
return (gen != null && gen.Elem.GetAttribute ("type") == "flags");
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2002-05-23 23:43:25 +00:00
|
|
|
public static bool IsInterface(string c_type)
|
2002-01-17 00:26:46 +00:00
|
|
|
{
|
2002-02-15 01:08:57 +00:00
|
|
|
c_type = Trim(c_type);
|
2002-05-26 16:23:40 +00:00
|
|
|
c_type = DeAlias(c_type);
|
2002-01-17 00:26:46 +00:00
|
|
|
if (complex_types.ContainsKey(c_type)) {
|
|
|
|
IGeneratable gen = (IGeneratable) complex_types[c_type];
|
|
|
|
if (gen is InterfaceGen) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2002-06-21 Rachel Hestilow <hestilow@ximian.com>
* generator/ClassBase.cs: New base class for classes and interfaces.
* generator/InterfaceGen.cs: Inherit from ClassBase, generate declarations.
* generator/ObjectGen.cs: Move half of this into ClassBase.
* generator/Method.cs: Turn all applicable Get/Set functions into .NET
accessors. Remove redundant == overload and move into Equals, as
it was confusing "!= null".
* generator/Parameters.cs: Alter signature creation to accept "is_set"
option, add support for variable arguments. Add properties "Count",
"IsVarArgs", "VAType".
* generator/Ctor.cs: Fixup for changes in Parameters (indenting,
signature creation).
* generator/Signal.cs: Support generating declarations.
* generator/SymbolTable: Change GetObjectGen to GetClassGen.
* glib/IWrapper.cs: Move "Handle" declaration to here, so
both classes and interfaces can benefit from it.
* glib/Object.cs: Inherit from IWrapper.cs
* parser/Metadata.pm: Support attribute changes on constructors,
methods, signals, and paramater lists.
* parser/gapi2xml.pl: Parse init funcs for interfaces. Ignore "_"
functions here.
* parser/gapi_pp.pl: Remove boxed_type_register check, as it will
be caught in the init funcs.
* parser/Atk.metadata: Added.
* parser/Gtk.metadata: Add all needed signal/method collision
renames. Rename GtkEditable.Editable accessors to IsEditable,
as .NET does not like accessors with the same name as their
declaring type. Tag TreeStore constructor as varargs.
* samples/ButtonApp.cs: s/EmitAdd/Add.
* samples/Menu.cs: s/EmitAdd/Add, s/Activate/Activated.
svn path=/trunk/gtk-sharp/; revision=5394
2002-06-21 17:15:19 +00:00
|
|
|
public static ClassBase GetClassGen(string c_type)
|
2002-05-23 23:43:25 +00:00
|
|
|
{
|
|
|
|
c_type = Trim(c_type);
|
2002-05-26 16:23:40 +00:00
|
|
|
c_type = DeAlias(c_type);
|
2002-07-26 06:08:52 +00:00
|
|
|
return (complex_types[c_type] as ClassBase);
|
2002-05-23 23:43:25 +00:00
|
|
|
}
|
2002-06-21 Rachel Hestilow <hestilow@ximian.com>
* generator/ClassBase.cs: New base class for classes and interfaces.
* generator/InterfaceGen.cs: Inherit from ClassBase, generate declarations.
* generator/ObjectGen.cs: Move half of this into ClassBase.
* generator/Method.cs: Turn all applicable Get/Set functions into .NET
accessors. Remove redundant == overload and move into Equals, as
it was confusing "!= null".
* generator/Parameters.cs: Alter signature creation to accept "is_set"
option, add support for variable arguments. Add properties "Count",
"IsVarArgs", "VAType".
* generator/Ctor.cs: Fixup for changes in Parameters (indenting,
signature creation).
* generator/Signal.cs: Support generating declarations.
* generator/SymbolTable: Change GetObjectGen to GetClassGen.
* glib/IWrapper.cs: Move "Handle" declaration to here, so
both classes and interfaces can benefit from it.
* glib/Object.cs: Inherit from IWrapper.cs
* parser/Metadata.pm: Support attribute changes on constructors,
methods, signals, and paramater lists.
* parser/gapi2xml.pl: Parse init funcs for interfaces. Ignore "_"
functions here.
* parser/gapi_pp.pl: Remove boxed_type_register check, as it will
be caught in the init funcs.
* parser/Atk.metadata: Added.
* parser/Gtk.metadata: Add all needed signal/method collision
renames. Rename GtkEditable.Editable accessors to IsEditable,
as .NET does not like accessors with the same name as their
declaring type. Tag TreeStore constructor as varargs.
* samples/ButtonApp.cs: s/EmitAdd/Add.
* samples/Menu.cs: s/EmitAdd/Add, s/Activate/Activated.
svn path=/trunk/gtk-sharp/; revision=5394
2002-06-21 17:15:19 +00:00
|
|
|
|
2002-05-23 23:43:25 +00:00
|
|
|
public static bool IsObject(string c_type)
|
2002-01-12 02:08:16 +00:00
|
|
|
{
|
2002-02-15 01:08:57 +00:00
|
|
|
c_type = Trim(c_type);
|
2002-05-26 16:23:40 +00:00
|
|
|
c_type = DeAlias(c_type);
|
2002-01-12 02:08:16 +00:00
|
|
|
if (complex_types.ContainsKey(c_type)) {
|
|
|
|
IGeneratable gen = (IGeneratable) complex_types[c_type];
|
|
|
|
if (gen is ObjectGen) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2002-06-26 Rachel Hestilow <hestilow@ximian.com>
* configure.in, makefile, makefile.win32: add gnome.
* doc/index.html, netdoc.xsl: Add gnome.
* gdk/Event.cs: New manual wrap for GdkEvent.
* generator/ClassBase.cs: Add methods GetProperty,
GetPropertyRecursively, GetMethodRecursively.
Move Parent property here from ObjectGen.cs. Pass this pointer
into Property.
* generator/Ctor.cs: Generate docs.
* generator/Method.cs, Property.cs: Tag method as "new" if a
Method/Property with the same name is found in the class hierarchy.
* generator/SignalHandler.cs: Correctly wrap complex signal argument
types. Add gnome directory.
* generator/SymbolTable.cs: Add manually wrapped types hash
(contains GLib.GSList and Gdk.Event). Add method IsManuallyWrapped.
* glib/SList.cs: Add constructor from IntPtr.
* glue/slist.c, glue/event.c: Added (field accessor glue).
* glue/Makefile.am: Update.
* parser/Gtk.metadata: Add new signal renames for new signals
exposed by GdkEvent changes.
* parser/README, parser/build.pl: Add libgnome, libgnomecanvas,
libgnomeui.
* parser/gapi2xml.pl: Handle literal-length array parameters,
and NULL property doc strings.
* sample/: Add new test GnomeHelloWorld.cs.
* gnome/: Added.
* parser/Gnome.metadata: Added.
svn path=/trunk/gtk-sharp/; revision=5461
2002-06-26 08:36:05 +00:00
|
|
|
|
2002-07-31 19:18:37 +00:00
|
|
|
public static bool IsCallback(string c_type)
|
|
|
|
{
|
|
|
|
c_type = Trim(c_type);
|
|
|
|
c_type = DeAlias(c_type);
|
|
|
|
if (complex_types.ContainsKey(c_type)) {
|
|
|
|
IGeneratable gen = (IGeneratable) complex_types[c_type];
|
|
|
|
if (gen is CallbackGen) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2002-06-26 Rachel Hestilow <hestilow@ximian.com>
* configure.in, makefile, makefile.win32: add gnome.
* doc/index.html, netdoc.xsl: Add gnome.
* gdk/Event.cs: New manual wrap for GdkEvent.
* generator/ClassBase.cs: Add methods GetProperty,
GetPropertyRecursively, GetMethodRecursively.
Move Parent property here from ObjectGen.cs. Pass this pointer
into Property.
* generator/Ctor.cs: Generate docs.
* generator/Method.cs, Property.cs: Tag method as "new" if a
Method/Property with the same name is found in the class hierarchy.
* generator/SignalHandler.cs: Correctly wrap complex signal argument
types. Add gnome directory.
* generator/SymbolTable.cs: Add manually wrapped types hash
(contains GLib.GSList and Gdk.Event). Add method IsManuallyWrapped.
* glib/SList.cs: Add constructor from IntPtr.
* glue/slist.c, glue/event.c: Added (field accessor glue).
* glue/Makefile.am: Update.
* parser/Gtk.metadata: Add new signal renames for new signals
exposed by GdkEvent changes.
* parser/README, parser/build.pl: Add libgnome, libgnomecanvas,
libgnomeui.
* parser/gapi2xml.pl: Handle literal-length array parameters,
and NULL property doc strings.
* sample/: Add new test GnomeHelloWorld.cs.
* gnome/: Added.
* parser/Gnome.metadata: Added.
svn path=/trunk/gtk-sharp/; revision=5461
2002-06-26 08:36:05 +00:00
|
|
|
public static bool IsManuallyWrapped(string c_type)
|
|
|
|
{
|
|
|
|
c_type = Trim(c_type);
|
|
|
|
c_type = DeAlias(c_type);
|
|
|
|
return manually_wrapped_types.ContainsKey(c_type);
|
|
|
|
}
|
|
|
|
|
2002-01-05 12:45:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|