mirror of
https://github.com/Ryujinx/GtkSharp.git
synced 2024-09-09 08:23:19 +02:00
![Rachel Hestilow](/assets/img/avatar_default.png)
* 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
94 lines
2.3 KiB
C#
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++;
|
|
}
|
|
}
|
|
}
|
|
|