mirror of
https://github.com/Ryujinx/GtkSharp.git
synced 2025-01-11 13:15:38 +00:00
2003-10-06 Mike Kestner <mkestner@ximian.com>
* generator/InterfaceGen.cs (Generate): gen the EventHandlers for sigs * generator/Signal.cs (GetHandlerName): kill this and split it into EventHandlerName and EventHandlerArgsName props instead of the ugly out param hack. (GenEventHandler): make public void and add gen_info param. open stream with gen_info. use new *Name props. (Generate): only gen the EventHandler if we're genning the container, not for implementors. svn path=/trunk/gtk-sharp/; revision=18684
This commit is contained in:
parent
06a02e97b4
commit
9877690874
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,14 @@
|
||||||
|
2003-10-06 Mike Kestner <mkestner@ximian.com>
|
||||||
|
|
||||||
|
* generator/InterfaceGen.cs (Generate): gen the EventHandlers for sigs
|
||||||
|
* generator/Signal.cs (GetHandlerName): kill this and split it into
|
||||||
|
EventHandlerName and EventHandlerArgsName props instead of the ugly
|
||||||
|
out param hack.
|
||||||
|
(GenEventHandler): make public void and add gen_info param. open
|
||||||
|
stream with gen_info. use new *Name props.
|
||||||
|
(Generate): only gen the EventHandler if we're genning the container,
|
||||||
|
not for implementors.
|
||||||
|
|
||||||
2003-10-06 Mike Kestner <mkestner@ximian.com>
|
2003-10-06 Mike Kestner <mkestner@ximian.com>
|
||||||
|
|
||||||
* generator/CodeGenerator.cs (Main): use new ObjectGen.GenerateMappers.
|
* generator/CodeGenerator.cs (Main): use new ObjectGen.GenerateMappers.
|
||||||
|
|
|
@ -33,8 +33,10 @@ namespace GtkSharp.Generation {
|
||||||
sw.WriteLine ();
|
sw.WriteLine ();
|
||||||
|
|
||||||
foreach (Signal sig in sigs.Values) {
|
foreach (Signal sig in sigs.Values) {
|
||||||
if (sig.Validate ())
|
if (sig.Validate ()) {
|
||||||
sig.GenerateDecl (sw);
|
sig.GenerateDecl (sw);
|
||||||
|
sig.GenEventHandler (gen_info);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (Method method in methods.Values) {
|
foreach (Method method in methods.Values) {
|
||||||
|
|
|
@ -54,57 +54,65 @@ namespace GtkSharp.Generation {
|
||||||
|
|
||||||
public void GenerateDecl (StreamWriter sw)
|
public void GenerateDecl (StreamWriter sw)
|
||||||
{
|
{
|
||||||
string argsname;
|
|
||||||
string handler = GetHandlerName (out argsname);
|
|
||||||
if (handler != "EventHandler")
|
|
||||||
handler = container_type.NS + "Sharp." + handler;
|
|
||||||
|
|
||||||
if (elem.HasAttribute("new_flag") || (container_type != null && container_type.GetSignalRecursively (Name) != null))
|
if (elem.HasAttribute("new_flag") || (container_type != null && container_type.GetSignalRecursively (Name) != null))
|
||||||
sw.Write("new ");
|
sw.Write("new ");
|
||||||
|
|
||||||
sw.WriteLine ("\t\tevent " + handler + " " + Name + ";");
|
sw.WriteLine ("\t\tevent " + EventHandlerQualifiedName + " " + Name + ";");
|
||||||
}
|
}
|
||||||
|
|
||||||
private string GetHandlerName (out string argsname)
|
private string EventArgsName {
|
||||||
{
|
get {
|
||||||
if (sig_handler.Name == "voidObjectSignal") {
|
if (sig_handler.Name == "voidObjectSignal")
|
||||||
argsname = "System.EventArgs";
|
return "EventArgs";
|
||||||
return "EventHandler";
|
else
|
||||||
}
|
return Name + "Args";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private string EventArgsQualifiedName {
|
||||||
|
get {
|
||||||
|
if (sig_handler.Name == "voidObjectSignal")
|
||||||
|
return "System.EventArgs";
|
||||||
|
else
|
||||||
|
return container_type.NS + "Sharp." + Name + "Args";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private string EventHandlerName {
|
||||||
|
get {
|
||||||
|
if (sig_handler.Name == "voidObjectSignal")
|
||||||
|
return "EventHandler";
|
||||||
|
else
|
||||||
|
return Name + "Handler";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private string EventHandlerQualifiedName {
|
||||||
|
get {
|
||||||
|
if (sig_handler.Name == "voidObjectSignal")
|
||||||
|
return "System.EventHandler";
|
||||||
|
else
|
||||||
|
return container_type.NS + "Sharp." + Name + "Handler";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
argsname = Name + "Args";
|
public void GenEventHandler (GenerationInfo gen_info)
|
||||||
return Name + "Handler";
|
|
||||||
}
|
|
||||||
|
|
||||||
private string GenHandler (out string argsname)
|
|
||||||
{
|
{
|
||||||
string handler = GetHandlerName (out argsname);
|
if (EventHandlerName == "EventHandler")
|
||||||
if (handler == "EventHandler")
|
return;
|
||||||
return handler;
|
|
||||||
|
|
||||||
string ns = container_type.NS;
|
string ns = container_type.NS;
|
||||||
char sep = Path.DirectorySeparatorChar;
|
|
||||||
string dir = ".." + sep + ns.ToLower() + sep + "generated";
|
|
||||||
|
|
||||||
if (!Directory.Exists (dir))
|
StreamWriter sw = gen_info.OpenStream (ns + "Sharp." + EventHandlerName);
|
||||||
Directory.CreateDirectory (dir);
|
|
||||||
|
|
||||||
string filename = dir + sep + ns + "Sharp." + handler + ".cs";
|
|
||||||
|
|
||||||
FileStream stream = new FileStream (filename, FileMode.Create, FileAccess.Write);
|
|
||||||
StreamWriter sw = new StreamWriter (stream);
|
|
||||||
|
|
||||||
sw.WriteLine ("// This file was generated by the Gtk# Code generator.");
|
|
||||||
sw.WriteLine ("// Any changes made will be lost if regenerated.");
|
|
||||||
sw.WriteLine ();
|
|
||||||
sw.WriteLine ("namespace " + ns + "Sharp {");
|
sw.WriteLine ("namespace " + ns + "Sharp {");
|
||||||
sw.WriteLine ();
|
sw.WriteLine ();
|
||||||
sw.WriteLine ("\tusing System;");
|
sw.WriteLine ("\tusing System;");
|
||||||
|
|
||||||
sw.WriteLine ();
|
sw.WriteLine ();
|
||||||
sw.WriteLine ("\tpublic delegate void " + handler + "(object o, " + argsname + " args);");
|
sw.WriteLine ("\tpublic delegate void " + EventHandlerName + "(object o, " + EventArgsName + " args);");
|
||||||
sw.WriteLine ();
|
sw.WriteLine ();
|
||||||
sw.WriteLine ("\tpublic class " + argsname + " : GtkSharp.SignalArgs {");
|
sw.WriteLine ("\tpublic class " + EventArgsName + " : GtkSharp.SignalArgs {");
|
||||||
if (parms != null) {
|
if (parms != null) {
|
||||||
for (int i = 1; i < parms.Count; i++) {
|
for (int i = 1; i < parms.Count; i++) {
|
||||||
sw.WriteLine ("\t\tpublic " + parms[i].CSType + " " + parms[i].StudlyName + "{");
|
sw.WriteLine ("\t\tpublic " + parms[i].CSType + " " + parms[i].StudlyName + "{");
|
||||||
|
@ -118,8 +126,6 @@ namespace GtkSharp.Generation {
|
||||||
sw.WriteLine ("\t}");
|
sw.WriteLine ("\t}");
|
||||||
sw.WriteLine ("}");
|
sw.WriteLine ("}");
|
||||||
sw.Close ();
|
sw.Close ();
|
||||||
argsname = ns + "Sharp." + argsname;
|
|
||||||
return ns + "Sharp." + handler;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Generate (GenerationInfo gen_info, ClassBase implementor)
|
public void Generate (GenerationInfo gen_info, ClassBase implementor)
|
||||||
|
@ -127,27 +133,25 @@ namespace GtkSharp.Generation {
|
||||||
StreamWriter sw = gen_info.Writer;
|
StreamWriter sw = gen_info.Writer;
|
||||||
string cname = "\"" + elem.GetAttribute("cname") + "\"";
|
string cname = "\"" + elem.GetAttribute("cname") + "\"";
|
||||||
string ns;
|
string ns;
|
||||||
if (implementor == null)
|
if (implementor == null) {
|
||||||
ns = container_type.NS;
|
ns = container_type.NS;
|
||||||
else
|
GenEventHandler (gen_info);
|
||||||
|
} else
|
||||||
ns = implementor.NS;
|
ns = implementor.NS;
|
||||||
|
|
||||||
sig_handler.Generate (ns, gen_info);
|
sig_handler.Generate (ns, gen_info);
|
||||||
string qual_marsh = ns + "Sharp." + sig_handler.Name;
|
string qual_marsh = ns + "Sharp." + sig_handler.Name;
|
||||||
|
|
||||||
string argsname;
|
|
||||||
string handler = GenHandler (out argsname);
|
|
||||||
|
|
||||||
sw.WriteLine("\t\t[GLib.Signal("+ cname + ")]");
|
sw.WriteLine("\t\t[GLib.Signal("+ cname + ")]");
|
||||||
sw.Write("\t\tpublic ");
|
sw.Write("\t\tpublic ");
|
||||||
if (elem.HasAttribute("new_flag") || (container_type != null && container_type.GetSignalRecursively (Name) != null) || (implementor != null && implementor.GetSignalRecursively (Name) != null))
|
if (elem.HasAttribute("new_flag") || (container_type != null && container_type.GetSignalRecursively (Name) != null) || (implementor != null && implementor.GetSignalRecursively (Name) != null))
|
||||||
sw.Write("new ");
|
sw.Write("new ");
|
||||||
sw.WriteLine("event " + handler + " " + Name + " {");
|
sw.WriteLine("event " + EventHandlerQualifiedName + " " + Name + " {");
|
||||||
sw.WriteLine("\t\t\tadd {");
|
sw.WriteLine("\t\t\tadd {");
|
||||||
sw.WriteLine("\t\t\t\tif (EventList[" + cname + "] == null)");
|
sw.WriteLine("\t\t\t\tif (EventList[" + cname + "] == null)");
|
||||||
sw.Write("\t\t\t\t\tSignals[" + cname + "] = new " + qual_marsh);
|
sw.Write("\t\t\t\t\tSignals[" + cname + "] = new " + qual_marsh);
|
||||||
sw.Write("(this, Handle, " + cname + ", value, System.Type.GetType(\"" + argsname);
|
sw.Write("(this, Handle, " + cname + ", value, System.Type.GetType(\"" + EventArgsQualifiedName);
|
||||||
if (argsname != "System.EventArgs")
|
if (EventArgsQualifiedName != "System.EventArgs")
|
||||||
sw.Write("," + gen_info.AssemblyName);
|
sw.Write("," + gen_info.AssemblyName);
|
||||||
sw.WriteLine("\"));\n\t\t\t\telse");
|
sw.WriteLine("\"));\n\t\t\t\telse");
|
||||||
sw.WriteLine("\t\t\t\t\t((GtkSharp.SignalCallback) Signals [{0}]).AddDelegate (value);", cname);
|
sw.WriteLine("\t\t\t\t\t((GtkSharp.SignalCallback) Signals [{0}]).AddDelegate (value);", cname);
|
||||||
|
|
Loading…
Reference in a new issue