mirror of
https://github.com/Ryujinx/GtkSharp.git
synced 2024-09-09 00:13:20 +02:00
2002-01-06 Mike Kestner <mkestner@speakeasy.net>
* generator/EnumGen.cs : Open stream Create only. * generator/ObjectGen.cs : New generatable for GObject subclasses. * generator/Parser.cs : Add the object element hook. * generator/StructBase.cs : Handle bits element in GenField. * generator/StructGen.cs : Open stream Create only. * generator/SymbolTable.cs : Additions to simple_types hash. * parser/gapi2xml.pl : Parse bitflags into the bits element. svn path=/trunk/gtk-sharp/; revision=1871
This commit is contained in:
parent
43a19345ca
commit
ca64721a09
10
ChangeLog
10
ChangeLog
@ -1,3 +1,13 @@
|
||||
2002-01-06 Mike Kestner <mkestner@speakeasy.net>
|
||||
|
||||
* generator/EnumGen.cs : Open stream Create only.
|
||||
* generator/ObjectGen.cs : New generatable for GObject subclasses.
|
||||
* generator/Parser.cs : Add the object element hook.
|
||||
* generator/StructBase.cs : Handle bits element in GenField.
|
||||
* generator/StructGen.cs : Open stream Create only.
|
||||
* generator/SymbolTable.cs : Additions to simple_types hash.
|
||||
* parser/gapi2xml.pl : Parse bitflags into the bits element.
|
||||
|
||||
2002-01-05 Mike Kestner <mkestner@speakeasy.net>
|
||||
|
||||
* generator/SymbolTable.cs : First pass at simple_types hash.
|
||||
|
@ -58,7 +58,7 @@ namespace GtkSharp.Generation {
|
||||
{
|
||||
String filename = "..\\" + ns.ToLower() + "\\generated\\" + Name + ".cs";
|
||||
|
||||
FileStream stream = new FileStream (filename, FileMode.OpenOrCreate, FileAccess.Write);
|
||||
FileStream stream = new FileStream (filename, FileMode.Create, FileAccess.Write);
|
||||
StreamWriter sw = new StreamWriter (stream);
|
||||
|
||||
sw.WriteLine ("// Generated File. Do not modify.");
|
||||
|
120
generator/ObjectGen.cs
Normal file
120
generator/ObjectGen.cs
Normal file
@ -0,0 +1,120 @@
|
||||
// GtkSharp.Generation.ObjectGen.cs - The Object Generatable.
|
||||
//
|
||||
// Author: Mike Kestner <mkestner@speakeasy.net>
|
||||
//
|
||||
// (c) 2001 Mike Kestner
|
||||
|
||||
namespace GtkSharp.Generation {
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Xml;
|
||||
|
||||
public class ObjectGen : StructBase, IGeneratable {
|
||||
|
||||
public ObjectGen (String ns, XmlElement elem) : base (ns, elem) {}
|
||||
|
||||
public String Name {
|
||||
get
|
||||
{
|
||||
return elem.GetAttribute("name");
|
||||
}
|
||||
}
|
||||
|
||||
public String QualifiedName {
|
||||
get
|
||||
{
|
||||
return ns + "." + elem.GetAttribute("name");
|
||||
}
|
||||
}
|
||||
|
||||
public String CName {
|
||||
get
|
||||
{
|
||||
return elem.GetAttribute("cname");
|
||||
}
|
||||
}
|
||||
|
||||
public String MarshalType {
|
||||
get
|
||||
{
|
||||
return "IntPtr";
|
||||
}
|
||||
}
|
||||
|
||||
public String CallByName (String var_name)
|
||||
{
|
||||
return var_name + ".RawObject";
|
||||
}
|
||||
|
||||
public void Generate (SymbolTable table)
|
||||
{
|
||||
String filename = "..\\" + ns.ToLower() + "\\generated\\" + 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 ();
|
||||
|
||||
String parent = elem.GetAttribute("parent");
|
||||
String cs_parent = table.GetCSType(parent);
|
||||
sw.Write ("\tpublic class " + Name);
|
||||
if (cs_parent == "") {
|
||||
sw.WriteLine (" {");
|
||||
Console.WriteLine ("Unknown type " + parent);
|
||||
} else {
|
||||
sw.WriteLine (" : " + cs_parent + " {");
|
||||
}
|
||||
sw.WriteLine ();
|
||||
|
||||
foreach (XmlNode node in elem.ChildNodes) {
|
||||
|
||||
XmlElement member = (XmlElement) node;
|
||||
|
||||
switch (node.Name) {
|
||||
case "field":
|
||||
// GenField(member, table, sw);
|
||||
break;
|
||||
|
||||
case "callback":
|
||||
break;
|
||||
|
||||
case "constructor":
|
||||
break;
|
||||
|
||||
case "method":
|
||||
break;
|
||||
|
||||
case "property":
|
||||
break;
|
||||
|
||||
case "signal":
|
||||
break;
|
||||
|
||||
default:
|
||||
Console.WriteLine ("Unexpected node");
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
sw.WriteLine ("\t}");
|
||||
sw.WriteLine ();
|
||||
sw.WriteLine ("}");
|
||||
|
||||
sw.Flush();
|
||||
sw.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -81,6 +81,7 @@ namespace GtkSharp.Generation {
|
||||
break;
|
||||
|
||||
case "object":
|
||||
table.AddType (new ObjectGen (ns_name, elem));
|
||||
break;
|
||||
|
||||
case "struct":
|
||||
|
@ -23,13 +23,27 @@ namespace GtkSharp.Generation {
|
||||
|
||||
protected void GenField (XmlElement field, SymbolTable table, StreamWriter sw)
|
||||
{
|
||||
String c_type = field.GetAttribute("type");
|
||||
sw.Write ("\t\t" + table.GetCSType(c_type));
|
||||
if (field.HasAttribute("array_len")) {
|
||||
sw.Write ("[]");
|
||||
}
|
||||
String c_type;
|
||||
|
||||
sw.WriteLine (" " + field.GetAttribute("cname") + ";");
|
||||
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 == "") {
|
||||
Console.WriteLine ("Unknown Type {0}", c_type);
|
||||
return;
|
||||
}
|
||||
|
||||
sw.Write ("\t\t" + cs_type);
|
||||
if (field.HasAttribute("array_len")) {
|
||||
sw.Write ("[]");
|
||||
}
|
||||
sw.WriteLine (" " + field.GetAttribute("cname") + ";");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ namespace GtkSharp.Generation {
|
||||
{
|
||||
String filename = "..\\" + ns.ToLower() + "\\generated\\" + Name + ".cs";
|
||||
|
||||
FileStream stream = new FileStream (filename, FileMode.OpenOrCreate, FileAccess.Write);
|
||||
FileStream stream = new FileStream (filename, FileMode.Create, FileAccess.Write);
|
||||
StreamWriter sw = new StreamWriter (stream);
|
||||
|
||||
sw.WriteLine ("// Generated File. Do not modify.");
|
||||
@ -76,6 +76,7 @@ namespace GtkSharp.Generation {
|
||||
|
||||
switch (node.Name) {
|
||||
case "field":
|
||||
// GenField(member, table, sw);
|
||||
break;
|
||||
|
||||
case "callback":
|
||||
|
@ -21,6 +21,7 @@ namespace GtkSharp.Generation {
|
||||
simple_types.Add ("gint", "int");
|
||||
simple_types.Add ("guint", "uint");
|
||||
simple_types.Add ("glong", "long");
|
||||
simple_types.Add ("gshort", "short");
|
||||
simple_types.Add ("guint32", "uint");
|
||||
simple_types.Add ("const-gchar", "String");
|
||||
simple_types.Add ("gchar", "String");
|
||||
@ -30,7 +31,10 @@ namespace GtkSharp.Generation {
|
||||
simple_types.Add ("gint8", "byte");
|
||||
simple_types.Add ("guint8", "byte");
|
||||
simple_types.Add ("gint16", "short");
|
||||
simple_types.Add ("gint32", "int");
|
||||
simple_types.Add ("guint16", "ushort");
|
||||
simple_types.Add ("guint1", "bool");
|
||||
simple_types.Add ("gpointer", "IntPtr");
|
||||
simple_types.Add ("guchar", "byte");
|
||||
simple_types.Add ("GValue", "GLib.Value");
|
||||
simple_types.Add ("GtkType", "int");
|
||||
@ -38,12 +42,15 @@ namespace GtkSharp.Generation {
|
||||
simple_types.Add ("gulong", "ulong");
|
||||
simple_types.Add ("GQuark", "int");
|
||||
simple_types.Add ("int", "int");
|
||||
simple_types.Add ("char", "char");
|
||||
simple_types.Add ("double", "double");
|
||||
simple_types.Add ("gunichar", "String");
|
||||
simple_types.Add ("uint1", "bool");
|
||||
|
||||
// FIXME: These ought to be handled properly.
|
||||
simple_types.Add ("GList", "IntPtr");
|
||||
simple_types.Add ("GSList", "IntPtr");
|
||||
simple_types.Add ("GHashTable", "IntPtr");
|
||||
simple_types.Add ("va_list", "IntPtr");
|
||||
simple_types.Add ("GParamSpec", "IntPtr");
|
||||
}
|
||||
|
File diff suppressed because one or more lines are too long
@ -302,11 +302,13 @@ sub addFieldElems
|
||||
if ($tok =~ /(\w+)\s*\[(.*)\]/) {
|
||||
$elem = addNameElem($parent, 'field', $1);
|
||||
$elem->setAttribute('array_len', "$2");
|
||||
$elem->setAttribute('type', "$type");
|
||||
} elsif ($tok =~ /(\w+)\s*\:\s*(\d+)/) {
|
||||
$elem = addNameElem($parent, 'field', $1);
|
||||
$elem->setAttribute('bits', "$2");
|
||||
} else {
|
||||
$elem = addNameElem($parent, 'field', $symb);
|
||||
$elem->setAttribute('type', "$type");
|
||||
}
|
||||
$elem->setAttribute('type', "$type");
|
||||
}
|
||||
} else {
|
||||
die "$field\n";
|
||||
|
Loading…
Reference in New Issue
Block a user