2002-01-08 20:05:47 +00:00
|
|
|
// GtkSharp.Generation.CallbackGen.cs - The Callback Generatable.
|
|
|
|
//
|
|
|
|
// Author: Mike Kestner <mkestner@speakeasy.net>
|
|
|
|
//
|
2002-04-04 16:20:53 +00:00
|
|
|
// (c) 2002 Mike Kestner
|
2002-01-08 20:05:47 +00:00
|
|
|
|
|
|
|
namespace GtkSharp.Generation {
|
|
|
|
|
|
|
|
using System;
|
|
|
|
using System.IO;
|
|
|
|
using System.Xml;
|
|
|
|
|
2002-05-23 23:43:25 +00:00
|
|
|
public class CallbackGen : GenBase, IGeneratable {
|
|
|
|
|
|
|
|
private Parameters parms;
|
|
|
|
|
2002-06-21 20:25:43 +00:00
|
|
|
public CallbackGen (XmlElement ns, XmlElement elem) : base (ns, elem)
|
2002-05-23 23:43:25 +00:00
|
|
|
{
|
|
|
|
if (elem ["parameters"] != null)
|
|
|
|
parms = new Parameters (elem ["parameters"]);
|
2002-01-08 20:05:47 +00:00
|
|
|
}
|
2002-05-23 23:43:25 +00:00
|
|
|
|
2002-01-08 20:05:47 +00:00
|
|
|
public String MarshalType {
|
|
|
|
get
|
|
|
|
{
|
2002-04-04 16:20:53 +00:00
|
|
|
return QualifiedName;
|
2002-01-08 20:05:47 +00:00
|
|
|
}
|
|
|
|
}
|
2002-05-23 23:43:25 +00:00
|
|
|
|
2002-01-08 20:05:47 +00:00
|
|
|
public String CallByName (String var_name)
|
|
|
|
{
|
2002-04-04 16:20:53 +00:00
|
|
|
return var_name;
|
2002-01-08 20:05:47 +00:00
|
|
|
}
|
2002-05-23 23:43:25 +00:00
|
|
|
|
2002-02-08 23:56:27 +00:00
|
|
|
public String FromNative(String var)
|
|
|
|
{
|
2002-04-04 16:20:53 +00:00
|
|
|
return var;
|
2002-02-08 23:56:27 +00:00
|
|
|
}
|
2002-05-23 23:43:25 +00:00
|
|
|
|
|
|
|
public void Generate ()
|
2002-01-08 20:05:47 +00:00
|
|
|
{
|
2002-05-23 23:43:25 +00:00
|
|
|
XmlElement ret_elem = Elem["return-type"];
|
2002-04-04 16:20:53 +00:00
|
|
|
if (ret_elem == null) {
|
2002-05-23 23:43:25 +00:00
|
|
|
Console.WriteLine("No return type in callback " + CName);
|
2002-04-04 16:20:53 +00:00
|
|
|
Statistics.ThrottledCount++;
|
|
|
|
return;
|
|
|
|
}
|
2002-05-23 23:43:25 +00:00
|
|
|
|
2002-04-04 16:20:53 +00:00
|
|
|
string rettype = ret_elem.GetAttribute("type");
|
2002-05-23 23:43:25 +00:00
|
|
|
string s_ret = SymbolTable.GetCSType(rettype);
|
2002-04-04 16:20:53 +00:00
|
|
|
if (s_ret == "") {
|
|
|
|
Console.WriteLine("rettype: " + rettype + " in callback " + CName);
|
|
|
|
Statistics.ThrottledCount++;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2002-05-23 23:43:25 +00:00
|
|
|
if ((parms != null) && !parms.Validate ()) {
|
2002-05-29 08:13:46 +00:00
|
|
|
Console.WriteLine(" in callback " + CName + " **** Stubbing it out ****");
|
2002-05-23 23:43:25 +00:00
|
|
|
Statistics.ThrottledCount++;
|
2002-05-29 08:13:46 +00:00
|
|
|
parms = null;
|
2002-04-04 16:20:53 +00:00
|
|
|
}
|
2002-05-23 23:43:25 +00:00
|
|
|
|
|
|
|
StreamWriter sw = CreateWriter ();
|
|
|
|
|
|
|
|
string sig = "";
|
|
|
|
if (parms != null)
|
|
|
|
sig = parms.Signature;
|
|
|
|
|
|
|
|
sw.WriteLine ("\tpublic delegate " + s_ret + " " + Name + "(" + sig + ");");
|
|
|
|
|
|
|
|
CloseWriter (sw);
|
|
|
|
Statistics.CBCount++;
|
2002-04-04 16:20:53 +00:00
|
|
|
}
|
2002-01-08 20:05:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|