Ryujinx-GtkSharp/generator/Signal.cs
Rachel Hestilow 1f4ff5bb86 2002-06-24 Rachel Hestilow <hestilow@ximian.com>
* glib/EnumWrapper.cs: New class which holds an enum int.

	* glib/Value.cs: Add support for glib enum types. We needed
	to use EnumWrapper for this because otherwise the int operator
	wouldn't know which glib function to use.

	* generator/BoxedGen.cs, ClassBase.cs, Ctor.cs, EnumGen.cs,
	InterfaceGen.cs, Method.cs, ObjectGen.cs, Signal.cs, StructGen.cs:
	Create more doc stubs.

	* generator/Property.cs: Generate enum values correctly.

	* generator/Ctor.cs: Refactor generation to honor metadata-specified
	collision preference.

	* parser/Gtk.metadata: Added constructor collision preferences to
	all known clashes.

	* parse/Gdk.metadata: Added (for Pixbuf clashes).

svn path=/trunk/gtk-sharp/; revision=5437
2002-06-24 22:04:10 +00:00

94 lines
2.3 KiB
C#

// GtkSharp.Generation.Signal.cs - The Signal Generatable.
//
// Author: Mike Kestner <mkestner@speakeasy.net>
//
// (c) 2001-2002 Mike Kestner
namespace GtkSharp.Generation {
using System;
using System.Collections;
using System.IO;
using System.Xml;
public class Signal {
private string marsh;
private string name;
private XmlElement elem;
public Signal (XmlElement elem)
{
this.elem = elem;
this.name = elem.GetAttribute ("name");
}
public string Name {
get {
return name;
}
set {
name = value;
}
}
public bool Validate ()
{
marsh = SignalHandler.GetName(elem);
if ((Name == "") || (marsh == "")) {
Console.Write ("bad signal " + Name);
Statistics.ThrottledCount++;
return false;
}
return true;
}
public void GenerateDecl (StreamWriter sw)
{
GenComments (sw);
if (elem.HasAttribute("new_flag"))
sw.Write("new ");
sw.WriteLine ("\t\tevent EventHandler " + Name + ";");
}
public void GenComments (StreamWriter sw)
{
sw.WriteLine();
sw.WriteLine("\t\t/// <summary> " + Name + " Event </summary>");
sw.WriteLine("\t\t/// <remarks>");
// FIXME: Generate some signal docs
sw.WriteLine("\t\t/// </remarks>");
}
public void Generate (StreamWriter sw, bool gen_docs)
{
string cname = "\"" + elem.GetAttribute("cname") + "\"";
marsh = "GtkSharp." + marsh;
if (gen_docs)
GenComments (sw);
sw.Write("\t\tpublic ");
if (elem.HasAttribute("new_flag"))
sw.Write("new ");
sw.WriteLine("event EventHandler " + Name + " {");
sw.WriteLine("\t\t\tadd {");
sw.WriteLine("\t\t\t\tif (EventList[" + cname + "] == null)");
sw.Write("\t\t\t\t\tSignals[" + cname + "] = new " + marsh);
sw.WriteLine("(this, Handle, " + cname + ", value);");
sw.WriteLine("\t\t\t\tEventList.AddHandler(" + cname + ", value);");
sw.WriteLine("\t\t\t}");
sw.WriteLine("\t\t\tremove {");
sw.WriteLine("\t\t\t\tEventList.RemoveHandler(" + cname + ", value);");
sw.WriteLine("\t\t\t\tif (EventList[" + cname + "] == null)");
sw.WriteLine("\t\t\t\t\tSignals.Remove(" + cname + ");");
sw.WriteLine("\t\t\t}");
sw.WriteLine("\t\t}");
sw.WriteLine();
Statistics.SignalCount++;
}
}
}