2004-12-27 Mike Kestner <mkestner@novell.com>
* generator/EnumGen.cs : rework for a single pass thru ChildNodes. * generator/Parameters.cs : simplify PassAs logic. * generator/SimpleBase.cs : mark abstract. svn path=/trunk/gtk-sharp/; revision=38111
This commit is contained in:
parent
5562bf645f
commit
bf9ed95944
4 changed files with 35 additions and 51 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
2004-12-27 Mike Kestner <mkestner@novell.com>
|
||||||
|
|
||||||
|
* generator/EnumGen.cs : rework for a single pass thru ChildNodes.
|
||||||
|
* generator/Parameters.cs : simplify PassAs logic.
|
||||||
|
* generator/SimpleBase.cs : mark abstract.
|
||||||
|
|
||||||
2004-12-27 Mike Kestner <mkestner@novell.com>
|
2004-12-27 Mike Kestner <mkestner@novell.com>
|
||||||
|
|
||||||
* generator/AliasGen.cs : derive from SimpleBase.
|
* generator/AliasGen.cs : derive from SimpleBase.
|
||||||
|
|
|
@ -22,12 +22,34 @@
|
||||||
namespace GtkSharp.Generation {
|
namespace GtkSharp.Generation {
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
|
|
||||||
public class EnumGen : GenBase {
|
public class EnumGen : GenBase {
|
||||||
|
|
||||||
public EnumGen (XmlElement ns, XmlElement elem) : base (ns, elem) {}
|
string enum_type = String.Empty;
|
||||||
|
ArrayList members = new ArrayList ();
|
||||||
|
|
||||||
|
public EnumGen (XmlElement ns, XmlElement elem) : base (ns, elem)
|
||||||
|
{
|
||||||
|
foreach (XmlElement member in elem.ChildNodes) {
|
||||||
|
if (member.Name != "member")
|
||||||
|
continue;
|
||||||
|
|
||||||
|
string result = "\t\t" + member.GetAttribute("name");
|
||||||
|
if (member.HasAttribute("value")) {
|
||||||
|
string value = member.GetAttribute("value");
|
||||||
|
if (value.EndsWith("U")) {
|
||||||
|
enum_type = " : uint";
|
||||||
|
value = value.TrimEnd('U');
|
||||||
|
}
|
||||||
|
result += " = " + value;
|
||||||
|
}
|
||||||
|
members.Add (result + ",");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public override string MarshalType {
|
public override string MarshalType {
|
||||||
get {
|
get {
|
||||||
|
@ -59,51 +81,13 @@ namespace GtkSharp.Generation {
|
||||||
sw.WriteLine ("\t[Flags]");
|
sw.WriteLine ("\t[Flags]");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ok, this is obscene. We need to go through the enums first
|
|
||||||
// to find "large" values. If we find some, we need to change
|
|
||||||
// the base type of the enum.
|
|
||||||
|
|
||||||
string enum_type = null;
|
|
||||||
|
|
||||||
foreach (XmlNode node in Elem.ChildNodes) {
|
|
||||||
if (!(node is XmlElement) || node.Name != "member") {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
XmlElement member = (XmlElement) node;
|
|
||||||
|
|
||||||
if (member.HasAttribute("value")) {
|
|
||||||
string value = member.GetAttribute("value");
|
|
||||||
if (value.EndsWith("U")) {
|
|
||||||
enum_type = "uint";
|
|
||||||
member.SetAttribute("value", value.TrimEnd('U'));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
sw.WriteLine ("#region Autogenerated code");
|
sw.WriteLine ("#region Autogenerated code");
|
||||||
|
|
||||||
if (enum_type != null)
|
sw.WriteLine ("\tpublic enum " + Name + enum_type + " {");
|
||||||
sw.WriteLine ("\tpublic enum " + Name + " : " + enum_type + " {");
|
|
||||||
else
|
|
||||||
sw.WriteLine ("\tpublic enum " + Name + " {");
|
|
||||||
|
|
||||||
sw.WriteLine ();
|
sw.WriteLine ();
|
||||||
|
|
||||||
foreach (XmlNode node in Elem.ChildNodes) {
|
foreach (string member in members)
|
||||||
if (!(node is XmlElement) || node.Name != "member") {
|
sw.WriteLine (member);
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
XmlElement member = (XmlElement) node;
|
|
||||||
|
|
||||||
sw.Write ("\t\t" + member.GetAttribute("name"));
|
|
||||||
if (member.HasAttribute("value")) {
|
|
||||||
sw.WriteLine (" = " + member.GetAttribute("value") + ",");
|
|
||||||
} else {
|
|
||||||
sw.WriteLine (",");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
sw.WriteLine ("\t}");
|
sw.WriteLine ("\t}");
|
||||||
sw.WriteLine ("#endregion");
|
sw.WriteLine ("#endregion");
|
||||||
|
|
|
@ -172,16 +172,10 @@ namespace GtkSharp.Generation {
|
||||||
if (elem.HasAttribute ("pass_as"))
|
if (elem.HasAttribute ("pass_as"))
|
||||||
return elem.GetAttribute ("pass_as");
|
return elem.GetAttribute ("pass_as");
|
||||||
|
|
||||||
if (IsArray)
|
if (IsArray || CSType.EndsWith ("IntPtr"))
|
||||||
return "";
|
return "";
|
||||||
|
|
||||||
if (Generatable is SimpleGen && !(Generatable is ConstStringGen) && CType.EndsWith ("*") && !CSType.EndsWith ("IntPtr"))
|
if (CType.EndsWith ("*") && (Generatable is SimpleGen || Generatable is EnumGen))
|
||||||
return "out";
|
|
||||||
|
|
||||||
if ((Generatable is LPGen || Generatable is LPUGen) && CType.EndsWith ("*"))
|
|
||||||
return "out";
|
|
||||||
|
|
||||||
if (Generatable is EnumGen && CType.EndsWith ("*"))
|
|
||||||
return "out";
|
return "out";
|
||||||
|
|
||||||
return "";
|
return "";
|
||||||
|
|
|
@ -23,7 +23,7 @@ namespace GtkSharp.Generation {
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
public class SimpleBase : IGeneratable {
|
public abstract class SimpleBase : IGeneratable {
|
||||||
|
|
||||||
string type;
|
string type;
|
||||||
string ctype;
|
string ctype;
|
||||||
|
|
Loading…
Reference in a new issue