2002-01-05 13:45:55 +01:00
|
|
|
// GtkSharp.Generation.StructBase.cs - The Structure/Object Base Class.
|
|
|
|
//
|
|
|
|
// Author: Mike Kestner <mkestner@speakeasy.net>
|
|
|
|
//
|
|
|
|
// (c) 2001 Mike Kestner
|
|
|
|
|
|
|
|
namespace GtkSharp.Generation {
|
|
|
|
|
|
|
|
using System;
|
|
|
|
using System.IO;
|
|
|
|
using System.Xml;
|
|
|
|
|
|
|
|
public class StructBase {
|
|
|
|
|
|
|
|
protected String ns;
|
|
|
|
protected XmlElement elem;
|
|
|
|
|
|
|
|
public StructBase (String ns, XmlElement elem) {
|
|
|
|
|
|
|
|
this.ns = ns;
|
|
|
|
this.elem = elem;
|
|
|
|
}
|
|
|
|
|
2002-01-10 16:01:31 +01:00
|
|
|
protected bool GenField (XmlElement field, SymbolTable table, StreamWriter sw)
|
2002-01-05 13:45:55 +01:00
|
|
|
{
|
2002-01-06 14:33:25 +01:00
|
|
|
String c_type;
|
|
|
|
|
|
|
|
if (field.HasAttribute("bits") && (field.GetAttribute("bits") == "1")) {
|
|
|
|
c_type = "gboolean";
|
|
|
|
} else {
|
|
|
|
c_type = field.GetAttribute("type");
|
|
|
|
}
|
|
|
|
char[] ast = {'*'};
|
|
|
|
c_type = c_type.TrimEnd(ast);
|
|
|
|
String cs_type = table.GetCSType(c_type);
|
|
|
|
|
|
|
|
if (cs_type == "") {
|
2002-01-10 16:01:31 +01:00
|
|
|
Console.WriteLine ("Field has unknown Type {0}", c_type);
|
|
|
|
return false;
|
2002-01-06 14:33:25 +01:00
|
|
|
}
|
|
|
|
|
2002-01-08 21:30:29 +01:00
|
|
|
sw.Write ("\t\t public " + cs_type);
|
2002-01-06 14:33:25 +01:00
|
|
|
if (field.HasAttribute("array_len")) {
|
|
|
|
sw.Write ("[]");
|
|
|
|
}
|
|
|
|
sw.WriteLine (" " + field.GetAttribute("cname") + ";");
|
2002-01-10 16:01:31 +01:00
|
|
|
return true;
|
2002-01-05 13:45:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|