2002-01-08 21:05:47 +01:00
|
|
|
// GtkSharp.Generation.CallbackGen.cs - The Callback Generatable.
|
|
|
|
//
|
|
|
|
// Author: Mike Kestner <mkestner@speakeasy.net>
|
|
|
|
//
|
2002-04-04 18:20:53 +02:00
|
|
|
// (c) 2002 Mike Kestner
|
2002-01-08 21:05:47 +01:00
|
|
|
|
|
|
|
namespace GtkSharp.Generation {
|
|
|
|
|
|
|
|
using System;
|
|
|
|
using System.IO;
|
|
|
|
using System.Xml;
|
|
|
|
|
2002-05-24 01:43:25 +02:00
|
|
|
public class CallbackGen : GenBase, IGeneratable {
|
|
|
|
|
|
|
|
private Parameters parms;
|
|
|
|
|
|
|
|
public CallbackGen (String ns, XmlElement elem) : base (ns, elem)
|
|
|
|
{
|
|
|
|
if (elem ["parameters"] != null)
|
|
|
|
parms = new Parameters (elem ["parameters"]);
|
2002-01-08 21:05:47 +01:00
|
|
|
}
|
2002-05-24 01:43:25 +02:00
|
|
|
|
2002-01-08 21:05:47 +01:00
|
|
|
public String MarshalType {
|
|
|
|
get
|
|
|
|
{
|
2002-04-04 18:20:53 +02:00
|
|
|
return QualifiedName;
|
2002-01-08 21:05:47 +01:00
|
|
|
}
|
|
|
|
}
|
2002-05-24 01:43:25 +02:00
|
|
|
|
2002-01-08 21:05:47 +01:00
|
|
|
public String CallByName (String var_name)
|
|
|
|
{
|
2002-04-04 18:20:53 +02:00
|
|
|
return var_name;
|
2002-01-08 21:05:47 +01:00
|
|
|
}
|
2002-05-24 01:43:25 +02:00
|
|
|
|
2002-02-09 00:56:27 +01:00
|
|
|
public String FromNative(String var)
|
|
|
|
{
|
2002-04-04 18:20:53 +02:00
|
|
|
return var;
|
2002-02-09 00:56:27 +01:00
|
|
|
}
|
2002-05-24 01:43:25 +02:00
|
|
|
|
|
|
|
public void Generate ()
|
2002-01-08 21:05:47 +01:00
|
|
|
{
|
2002-05-24 01:43:25 +02:00
|
|
|
XmlElement ret_elem = Elem["return-type"];
|
2002-04-04 18:20:53 +02:00
|
|
|
if (ret_elem == null) {
|
2002-05-24 01:43:25 +02:00
|
|
|
Console.WriteLine("No return type in callback " + CName);
|
2002-04-04 18:20:53 +02:00
|
|
|
Statistics.ThrottledCount++;
|
|
|
|
return;
|
|
|
|
}
|
2002-05-24 01:43:25 +02:00
|
|
|
|
2002-04-04 18:20:53 +02:00
|
|
|
string rettype = ret_elem.GetAttribute("type");
|
2002-05-24 01:43:25 +02:00
|
|
|
string s_ret = SymbolTable.GetCSType(rettype);
|
2002-04-04 18:20:53 +02:00
|
|
|
if (s_ret == "") {
|
|
|
|
Console.WriteLine("rettype: " + rettype + " in callback " + CName);
|
|
|
|
Statistics.ThrottledCount++;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2002-05-24 01:43:25 +02:00
|
|
|
if ((parms != null) && !parms.Validate ()) {
|
|
|
|
Console.WriteLine(" in callback " + CName);
|
|
|
|
Statistics.ThrottledCount++;
|
|
|
|
return;
|
2002-04-04 18:20:53 +02:00
|
|
|
}
|
2002-05-24 01:43:25 +02: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 18:20:53 +02:00
|
|
|
}
|
2002-01-08 21:05:47 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|