2002-01-08 20:05:47 +00:00
|
|
|
// GtkSharp.Generation.CallbackGen.cs - The Callback Generatable.
|
|
|
|
//
|
|
|
|
// Author: Mike Kestner <mkestner@speakeasy.net>
|
|
|
|
//
|
|
|
|
// (c) 2001 Mike Kestner
|
|
|
|
|
|
|
|
namespace GtkSharp.Generation {
|
|
|
|
|
|
|
|
using System;
|
|
|
|
using System.IO;
|
|
|
|
using System.Xml;
|
|
|
|
|
|
|
|
public class CallbackGen : IGeneratable {
|
|
|
|
|
|
|
|
private String ns;
|
|
|
|
private XmlElement elem;
|
|
|
|
|
|
|
|
public CallbackGen (String ns, XmlElement elem) {
|
|
|
|
|
|
|
|
this.ns = ns;
|
|
|
|
this.elem = elem;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String Name {
|
|
|
|
get
|
|
|
|
{
|
|
|
|
return elem.GetAttribute("name");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public String CName {
|
|
|
|
get
|
|
|
|
{
|
|
|
|
return elem.GetAttribute("cname");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public String QualifiedName {
|
|
|
|
get
|
|
|
|
{
|
2002-01-08 20:30:29 +00:00
|
|
|
return ns + "." + elem.GetAttribute("name");
|
2002-01-08 20:05:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public String MarshalType {
|
|
|
|
get
|
|
|
|
{
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public String CallByName (String var_name)
|
|
|
|
{
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
2002-02-08 23:56:27 +00:00
|
|
|
public String FromNative(String var)
|
|
|
|
{
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
2002-01-08 20:05:47 +00:00
|
|
|
public void Generate (SymbolTable table)
|
|
|
|
{
|
2002-03-24 17:04:25 +00:00
|
|
|
char sep = Path.DirectorySeparatorChar;
|
|
|
|
string dir = ".." + sep + ns.ToLower() + sep + "generated";
|
|
|
|
if (!Directory.Exists(dir)) {
|
|
|
|
Directory.CreateDirectory(dir);
|
2002-01-08 20:05:47 +00:00
|
|
|
}
|
2002-03-24 17:04:25 +00:00
|
|
|
String filename = dir + sep + Name + ".cs";
|
2002-01-08 20:05:47 +00:00
|
|
|
|
|
|
|
FileStream stream = new FileStream (filename, FileMode.Create, FileAccess.Write);
|
|
|
|
StreamWriter sw = new StreamWriter (stream);
|
|
|
|
|
|
|
|
sw.WriteLine ("// Generated File. Do not modify.");
|
|
|
|
sw.WriteLine ("// <c> 2001 Mike Kestner");
|
|
|
|
sw.WriteLine ();
|
|
|
|
|
|
|
|
sw.WriteLine ("namespace " + ns + " {");
|
|
|
|
sw.WriteLine ();
|
|
|
|
sw.WriteLine ("\tusing System;");
|
|
|
|
sw.WriteLine ();
|
|
|
|
|
|
|
|
sw.WriteLine ("\tpublic delegate void " + Name + "();");
|
|
|
|
sw.WriteLine ();
|
|
|
|
|
|
|
|
foreach (XmlNode node in elem.ChildNodes) {
|
|
|
|
if (node.Name != "member") {
|
|
|
|
continue;
|
|
|
|
}
|
2002-02-19 03:12:47 +00:00
|
|
|
//FIXME: Generate the method.
|
2002-01-08 20:05:47 +00:00
|
|
|
XmlElement member = (XmlElement) node;
|
|
|
|
}
|
|
|
|
|
|
|
|
sw.WriteLine ("}");
|
|
|
|
sw.Flush();
|
|
|
|
sw.Close();
|
2002-02-19 03:12:47 +00:00
|
|
|
Statistics.CBCount++;
|
2002-01-08 20:05:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|