2002-01-17 00:26:46 +00:00
|
|
|
// GtkSharp.Generation.BoxedGen.cs - The Boxed Type Generatable.
|
|
|
|
//
|
|
|
|
// Author: Mike Kestner <mkestner@speakeasy.net>
|
|
|
|
//
|
|
|
|
// (c) 2001-2002 Mike Kestner
|
|
|
|
|
|
|
|
namespace GtkSharp.Generation {
|
|
|
|
|
|
|
|
using System;
|
2002-02-19 19:46:44 +00:00
|
|
|
using System.Collections;
|
2002-01-17 00:26:46 +00:00
|
|
|
using System.IO;
|
|
|
|
using System.Xml;
|
|
|
|
|
|
|
|
public class BoxedGen : StructBase, IGeneratable {
|
|
|
|
|
2002-06-21 20:25:43 +00:00
|
|
|
public BoxedGen (XmlElement ns, XmlElement elem) : base (ns, elem) {}
|
2002-01-17 00:26:46 +00:00
|
|
|
|
2002-07-13 Rachel Hestilow <hestilow@ximian.com>
* parser/Gnome.metadata, Gtk.metadata: More conflict
fixes.
* parser/build.pl: Fully qualify all lib names. (Gtk+ packages
are now LFS-compliant in Debian...)
* parser/gapi2xml.pl: Fix for whitespace in fields, defines,
and docs.
* generator/BoxedGen.cs: Remove extraneous CallByName definition,
add "override" keyword to FromNative.
(Generate): Generate methods after fields.
* generator/ClassBase.cs: Change CallByName, FromNative to virtual.
(.ctor): Ignore "hidden" nodes. Set container on signal.
(GenSignals, GenMethods): Add "implementor" argument for interface
use.
(Get(Method|Signal|Property)Recursively): Rework to correctly
recurse interfaces.
(Implements): Added.
* generator/Ctor.cs (Initialize): Move clash initialization completely
out of Generate, so we can check for collisions.
* generator/Method.cs (GenerateDeclCommon): Check for duplicates,
for "new" keyword.
(Generate): Add "implementor" argument.
* generator/ObjectGen.cs (Generate): Initialize ctor clashes on
this and all parents, before generating.
(Ctors, InitializeCtors): Added.
* generator/Signal.cs: Store the container_type, check for
collisions.
* generator/StructGen.cs: Add "override" keyword to overriden methods.
* gtk/FileSelection.custom (ActionArea): Add "new" keyword.
svn path=/trunk/gtk-sharp/; revision=5782
2002-07-13 20:31:23 +00:00
|
|
|
public override String FromNative(String var)
|
2002-02-08 23:56:27 +00:00
|
|
|
{
|
2002-05-02 21:57:41 +00:00
|
|
|
return "(" + QualifiedName + ") GLib.Boxed.FromNative(" + var + ")";
|
2002-02-08 23:56:27 +00:00
|
|
|
}
|
|
|
|
|
2002-05-23 23:43:25 +00:00
|
|
|
public void Generate ()
|
2002-01-17 00:26:46 +00:00
|
|
|
{
|
2002-06-21 20:25:43 +00:00
|
|
|
StreamWriter sw = CreateWriter ();
|
2002-01-17 00:26:46 +00:00
|
|
|
|
|
|
|
sw.WriteLine ("\tusing System;");
|
|
|
|
sw.WriteLine ("\tusing System.Collections;");
|
|
|
|
sw.WriteLine ("\tusing System.Runtime.InteropServices;");
|
|
|
|
sw.WriteLine ();
|
|
|
|
|
2002-06-24 22:04:10 +00:00
|
|
|
sw.WriteLine("\t\t/// <summary> " + Name + " Boxed Struct</summary>");
|
|
|
|
sw.WriteLine("\t\t/// <remarks>");
|
|
|
|
sw.WriteLine("\t\t/// </remarks>");
|
|
|
|
|
2002-01-17 00:26:46 +00:00
|
|
|
sw.WriteLine ("\t[StructLayout(LayoutKind.Sequential)]");
|
2002-05-02 21:57:41 +00:00
|
|
|
sw.WriteLine ("\tpublic class " + Name + " : GLib.Boxed {");
|
2002-01-17 00:26:46 +00:00
|
|
|
sw.WriteLine ();
|
|
|
|
|
2002-02-19 19:46:44 +00:00
|
|
|
sw.WriteLine("\t\tpublic " + Name + "(IntPtr raw) : base(raw) {}");
|
|
|
|
sw.WriteLine();
|
|
|
|
|
|
|
|
Hashtable clash_map = new Hashtable();
|
|
|
|
|
2002-06-21 20:25:43 +00:00
|
|
|
foreach (XmlNode node in Elem.ChildNodes) {
|
2002-06-26 13:10:48 +00:00
|
|
|
if (!(node is XmlElement)) continue;
|
2002-01-17 00:26:46 +00:00
|
|
|
XmlElement member = (XmlElement) node;
|
|
|
|
|
|
|
|
switch (node.Name) {
|
|
|
|
case "field":
|
2002-02-19 03:12:47 +00:00
|
|
|
Statistics.IgnoreCount++;
|
2002-05-23 23:43:25 +00:00
|
|
|
// GenField(member, sw);
|
2002-01-17 00:26:46 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case "callback":
|
2002-02-19 03:12:47 +00:00
|
|
|
Statistics.IgnoreCount++;
|
2002-01-17 00:26:46 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case "constructor":
|
2002-05-23 23:43:25 +00:00
|
|
|
if (!GenCtor(member, sw, clash_map)) {
|
2002-02-19 19:46:44 +00:00
|
|
|
Console.WriteLine(" in boxed " + CName);
|
|
|
|
}
|
2002-01-17 00:26:46 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case "method":
|
2002-07-13 Rachel Hestilow <hestilow@ximian.com>
* parser/Gnome.metadata, Gtk.metadata: More conflict
fixes.
* parser/build.pl: Fully qualify all lib names. (Gtk+ packages
are now LFS-compliant in Debian...)
* parser/gapi2xml.pl: Fix for whitespace in fields, defines,
and docs.
* generator/BoxedGen.cs: Remove extraneous CallByName definition,
add "override" keyword to FromNative.
(Generate): Generate methods after fields.
* generator/ClassBase.cs: Change CallByName, FromNative to virtual.
(.ctor): Ignore "hidden" nodes. Set container on signal.
(GenSignals, GenMethods): Add "implementor" argument for interface
use.
(Get(Method|Signal|Property)Recursively): Rework to correctly
recurse interfaces.
(Implements): Added.
* generator/Ctor.cs (Initialize): Move clash initialization completely
out of Generate, so we can check for collisions.
* generator/Method.cs (GenerateDeclCommon): Check for duplicates,
for "new" keyword.
(Generate): Add "implementor" argument.
* generator/ObjectGen.cs (Generate): Initialize ctor clashes on
this and all parents, before generating.
(Ctors, InitializeCtors): Added.
* generator/Signal.cs: Store the container_type, check for
collisions.
* generator/StructGen.cs: Add "override" keyword to overriden methods.
* gtk/FileSelection.custom (ActionArea): Add "new" keyword.
svn path=/trunk/gtk-sharp/; revision=5782
2002-07-13 20:31:23 +00:00
|
|
|
//Console.WriteLine ("HIYA {0}", ((Method) member).Name);
|
2002-01-17 00:26:46 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
Console.WriteLine ("Unexpected node");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2002-07-13 Rachel Hestilow <hestilow@ximian.com>
* parser/Gnome.metadata, Gtk.metadata: More conflict
fixes.
* parser/build.pl: Fully qualify all lib names. (Gtk+ packages
are now LFS-compliant in Debian...)
* parser/gapi2xml.pl: Fix for whitespace in fields, defines,
and docs.
* generator/BoxedGen.cs: Remove extraneous CallByName definition,
add "override" keyword to FromNative.
(Generate): Generate methods after fields.
* generator/ClassBase.cs: Change CallByName, FromNative to virtual.
(.ctor): Ignore "hidden" nodes. Set container on signal.
(GenSignals, GenMethods): Add "implementor" argument for interface
use.
(Get(Method|Signal|Property)Recursively): Rework to correctly
recurse interfaces.
(Implements): Added.
* generator/Ctor.cs (Initialize): Move clash initialization completely
out of Generate, so we can check for collisions.
* generator/Method.cs (GenerateDeclCommon): Check for duplicates,
for "new" keyword.
(Generate): Add "implementor" argument.
* generator/ObjectGen.cs (Generate): Initialize ctor clashes on
this and all parents, before generating.
(Ctors, InitializeCtors): Added.
* generator/Signal.cs: Store the container_type, check for
collisions.
* generator/StructGen.cs: Add "override" keyword to overriden methods.
* gtk/FileSelection.custom (ActionArea): Add "new" keyword.
svn path=/trunk/gtk-sharp/; revision=5782
2002-07-13 20:31:23 +00:00
|
|
|
|
|
|
|
GenMethods (sw, null, null, false);
|
2002-06-21 20:25:43 +00:00
|
|
|
AppendCustom(sw);
|
2002-01-17 00:26:46 +00:00
|
|
|
sw.WriteLine ("\t}");
|
2002-06-21 20:25:43 +00:00
|
|
|
CloseWriter (sw);
|
2002-02-19 03:12:47 +00:00
|
|
|
Statistics.BoxedCount++;
|
2002-01-17 00:26:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|