GtkSharp/generator/CallbackGen.cs
Mike Kestner 5d67982de9 2002-06-21 Mike Kestner <mkestner@speakeasy.net>
* makefile : remove gdk.imaging from the build
	* gdk.imaging/* : kill
	* generated/BoxedGen.cs : XmlNode namespace handling. Use GenBase.
	* generated/CallbackGen.cs : XmlNode namespace handling.
	* generated/Ctor.cs : construct with libname not ns.
	* generated/EnumGen.cs : XmlNode namespace handling.
	* generated/GenBase.cs : XmlNode namespace handling. Make AppendCustom
	  an instance method so it can use the private fields instead of params.
	* generated/InterfaceGen.cs : XmlNode namespace handling.
	* generated/Method.cs : construct with libname not ns.
	* generated/ObjectGen.cs : XmlNode namespace handling.
	* generated/Parser.cs : Use new XmlNode namespace ctors.
	* generated/Signal.cs : Lose the namespace field.
	* generated/StructBase.cs : derive from ClassBase
	* generated/StructGen.cs : XmlNode namespace handling. Use GenBase.
	* generated/SymbolTable.cs : nuke GetDllName method.
	* generator/gtkapi.xml : Add library name to namespace node.
	* parser/build.pl : refactor for library name param
	* parser/gapi2xml.pl : add libname param handling
	* sample/Makefile.in : build linux on make install, but don't install.

svn path=/trunk/gtk-sharp/; revision=5400
2002-06-21 20:25:43 +00:00

76 lines
1.6 KiB
C#

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