mirror of
https://github.com/Ryujinx/GtkSharp.git
synced 2024-12-23 17:35:33 +00:00
eea6465cf2
* generator/GenBase.cs: new method AppendCustom, moved from ObjectGen. * generator/BoxedGen.cs, ObjectGen.cs, StructGen.cs: Call AppendCustom in Generate (); * generator/Method.cs, Parameters.cs: Add support for "out" parameters. Additionally, output an accessor instead of a regular method if it is an accessor-style function (ie GetStartIter). * generator/Property.cs: Add additional cast to Boxed, if necessary. * glue/textiter.c: New constructor for GtkTextIter. * glue/Makefile.am: Add textiter.c, build with Gtk+ cflags. * configure.in: Check for Gtk+ cflags. * parser/Metadata.pm, Gtk.metadata: Added. * parser/gapi2xml.pl: Call Metadata::fixup on the document. Also work around gtk's screwy boxed type name registration (GtkFoo -> GtkTypeFoo). * gtk/TextIter.custom: Added. svn path=/trunk/gtk-sharp/; revision=5205
103 lines
2.2 KiB
C#
103 lines
2.2 KiB
C#
// GtkSharp.Generation.StructGen.cs - The Structure Generatable.
|
|
//
|
|
// Author: Mike Kestner <mkestner@speakeasy.net>
|
|
//
|
|
// (c) 2001 Mike Kestner
|
|
|
|
namespace GtkSharp.Generation {
|
|
|
|
using System;
|
|
using System.IO;
|
|
using System.Xml;
|
|
|
|
public class StructGen : StructBase, IGeneratable {
|
|
|
|
public StructGen (String ns, XmlElement elem) : base (ns, elem) {}
|
|
|
|
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 ()
|
|
{
|
|
char sep = Path.DirectorySeparatorChar;
|
|
string dir = ".." + sep + ns.ToLower() + sep + "generated";
|
|
if (!Directory.Exists(dir)) {
|
|
Directory.CreateDirectory(dir);
|
|
}
|
|
String filename = dir + sep + Name + ".cs";
|
|
|
|
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 ("\tusing System.Collections;");
|
|
sw.WriteLine ("\tusing System.Runtime.InteropServices;");
|
|
sw.WriteLine ();
|
|
|
|
sw.WriteLine ("\t[StructLayout(LayoutKind.Sequential)]");
|
|
sw.WriteLine ("\tpublic class " + Name + " {");
|
|
sw.WriteLine ();
|
|
|
|
foreach (XmlNode node in elem.ChildNodes) {
|
|
|
|
XmlElement member = (XmlElement) node;
|
|
|
|
switch (node.Name) {
|
|
case "field":
|
|
Statistics.IgnoreCount++;
|
|
// GenField(member, sw);
|
|
break;
|
|
|
|
case "callback":
|
|
Statistics.IgnoreCount++;
|
|
break;
|
|
|
|
case "constructor":
|
|
Statistics.IgnoreCount++;
|
|
break;
|
|
|
|
case "method":
|
|
Statistics.IgnoreCount++;
|
|
break;
|
|
|
|
default:
|
|
Console.WriteLine ("Unexpected node");
|
|
break;
|
|
}
|
|
}
|
|
|
|
GenBase.AppendCustom(ns, Name, sw);
|
|
|
|
sw.WriteLine ("\t}");
|
|
sw.WriteLine ();
|
|
sw.WriteLine ("}");
|
|
|
|
sw.Flush();
|
|
sw.Close();
|
|
Statistics.StructCount++;
|
|
}
|
|
}
|
|
}
|
|
|