2002-01-05 12:45:55 +00: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;
|
2002-02-03 03:44:10 +00:00
|
|
|
using System.Collections;
|
2002-01-05 12:45:55 +00:00
|
|
|
using System.IO;
|
2002-02-03 03:44:10 +00:00
|
|
|
using System.Text.RegularExpressions;
|
2002-01-05 12:45:55 +00:00
|
|
|
using System.Xml;
|
|
|
|
|
2002-06-21 20:25:43 +00:00
|
|
|
public class StructBase : ClassBase {
|
2002-01-17 Mike Kestner <mkestner@speakeasy.net>
* generator/BoxedGen.cs : Removed Name, CName, and QualifiedName.
* generator/ObjectGen.cs : Removed Name, CName, and QualifiedName.
* generator/StructBase.cs : Add Name, CName, and QualifiedName. Add
GenCtor method. Stub GetCallString, GetImportSig, and GetSignature
methods.
* generator/StructGen.cs : Removed Name, CName, and QualifiedName.
* generator/SymbolTable.cs : Add GetDllName method.
* parser/gapi2xml.pl : Fix a couple <parameters> bugs.
svn path=/trunk/gtk-sharp/; revision=2030
2002-01-17 23:44:56 +00:00
|
|
|
|
2002-06-21 20:25:43 +00:00
|
|
|
public StructBase (XmlElement ns, XmlElement elem) : base (ns, elem) {}
|
2002-01-17 Mike Kestner <mkestner@speakeasy.net>
* generator/BoxedGen.cs : Removed Name, CName, and QualifiedName.
* generator/ObjectGen.cs : Removed Name, CName, and QualifiedName.
* generator/StructBase.cs : Add Name, CName, and QualifiedName. Add
GenCtor method. Stub GetCallString, GetImportSig, and GetSignature
methods.
* generator/StructGen.cs : Removed Name, CName, and QualifiedName.
* generator/SymbolTable.cs : Add GetDllName method.
* parser/gapi2xml.pl : Fix a couple <parameters> bugs.
svn path=/trunk/gtk-sharp/; revision=2030
2002-01-17 23:44:56 +00:00
|
|
|
|
2002-07-26 06:08:52 +00:00
|
|
|
public override String MarshalType {
|
|
|
|
get
|
|
|
|
{
|
|
|
|
return "ref " + QualifiedName;
|
2002-01-17 Mike Kestner <mkestner@speakeasy.net>
* generator/BoxedGen.cs : Removed Name, CName, and QualifiedName.
* generator/ObjectGen.cs : Removed Name, CName, and QualifiedName.
* generator/StructBase.cs : Add Name, CName, and QualifiedName. Add
GenCtor method. Stub GetCallString, GetImportSig, and GetSignature
methods.
* generator/StructGen.cs : Removed Name, CName, and QualifiedName.
* generator/SymbolTable.cs : Add GetDllName method.
* parser/gapi2xml.pl : Fix a couple <parameters> bugs.
svn path=/trunk/gtk-sharp/; revision=2030
2002-01-17 23:44:56 +00:00
|
|
|
}
|
2002-07-26 06:08:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public override String MarshalReturnType {
|
|
|
|
get
|
|
|
|
{
|
|
|
|
return "IntPtr";
|
2002-02-03 03:44:10 +00:00
|
|
|
}
|
2002-07-26 06:08:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public override String CallByName (String var_name)
|
|
|
|
{
|
|
|
|
return "ref " + var_name;
|
|
|
|
}
|
|
|
|
|
|
|
|
public override String CallByName ()
|
|
|
|
{
|
|
|
|
return "ref this";
|
|
|
|
}
|
|
|
|
|
|
|
|
public override String FromNative(String var)
|
|
|
|
{
|
|
|
|
return var;
|
|
|
|
}
|
|
|
|
|
|
|
|
public override String FromNativeReturn(String var)
|
|
|
|
{
|
|
|
|
return "new " + QualifiedName + " (" + var + ")";
|
2002-01-17 Mike Kestner <mkestner@speakeasy.net>
* generator/BoxedGen.cs : Removed Name, CName, and QualifiedName.
* generator/ObjectGen.cs : Removed Name, CName, and QualifiedName.
* generator/StructBase.cs : Add Name, CName, and QualifiedName. Add
GenCtor method. Stub GetCallString, GetImportSig, and GetSignature
methods.
* generator/StructGen.cs : Removed Name, CName, and QualifiedName.
* generator/SymbolTable.cs : Add GetDllName method.
* parser/gapi2xml.pl : Fix a couple <parameters> bugs.
svn path=/trunk/gtk-sharp/; revision=2030
2002-01-17 23:44:56 +00:00
|
|
|
}
|
|
|
|
|
2002-05-23 23:43:25 +00:00
|
|
|
protected bool GenField (XmlElement field, StreamWriter sw)
|
2002-01-05 12:45:55 +00:00
|
|
|
{
|
2002-01-06 13:33:25 +00: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);
|
2002-07-19 04:27:02 +00:00
|
|
|
String m_type = SymbolTable.GetMarshalType(c_type);
|
2002-01-06 13:33:25 +00:00
|
|
|
|
2002-07-19 04:27:02 +00:00
|
|
|
if (m_type == "") {
|
2002-01-10 15:01:31 +00:00
|
|
|
Console.WriteLine ("Field has unknown Type {0}", c_type);
|
2002-02-19 03:12:47 +00:00
|
|
|
Statistics.ThrottledCount++;
|
2002-01-10 15:01:31 +00:00
|
|
|
return false;
|
2002-01-06 13:33:25 +00:00
|
|
|
}
|
|
|
|
|
2002-07-19 04:27:02 +00:00
|
|
|
sw.Write ("\t\t public " + m_type);
|
2002-01-06 13:33:25 +00:00
|
|
|
if (field.HasAttribute("array_len")) {
|
|
|
|
sw.Write ("[]");
|
|
|
|
}
|
2002-07-18 13:42:31 +00:00
|
|
|
sw.WriteLine (" " + MangleName(field.GetAttribute("cname")) + ";");
|
2002-01-10 15:01:31 +00:00
|
|
|
return true;
|
2002-01-05 12:45:55 +00:00
|
|
|
}
|
2002-01-17 Mike Kestner <mkestner@speakeasy.net>
* generator/BoxedGen.cs : Removed Name, CName, and QualifiedName.
* generator/ObjectGen.cs : Removed Name, CName, and QualifiedName.
* generator/StructBase.cs : Add Name, CName, and QualifiedName. Add
GenCtor method. Stub GetCallString, GetImportSig, and GetSignature
methods.
* generator/StructGen.cs : Removed Name, CName, and QualifiedName.
* generator/SymbolTable.cs : Add GetDllName method.
* parser/gapi2xml.pl : Fix a couple <parameters> bugs.
svn path=/trunk/gtk-sharp/; revision=2030
2002-01-17 23:44:56 +00:00
|
|
|
|
2002-07-26 06:08:52 +00:00
|
|
|
private String MangleName(String name)
|
2002-02-08 23:56:27 +00:00
|
|
|
{
|
2002-07-26 06:08:52 +00:00
|
|
|
if (name == "string") {
|
|
|
|
return "str1ng";
|
|
|
|
} else if (name == "event") {
|
|
|
|
return "evnt";
|
|
|
|
} else if (name == "object") {
|
|
|
|
return "objekt";
|
|
|
|
} else if (name == "in") {
|
|
|
|
return "inn";
|
2002-02-08 23:56:27 +00:00
|
|
|
} else {
|
2002-07-26 06:08:52 +00:00
|
|
|
return name;
|
2002-02-08 23:56:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-07-26 06:08:52 +00:00
|
|
|
public virtual void Generate ()
|
2002-01-17 Mike Kestner <mkestner@speakeasy.net>
* generator/BoxedGen.cs : Removed Name, CName, and QualifiedName.
* generator/ObjectGen.cs : Removed Name, CName, and QualifiedName.
* generator/StructBase.cs : Add Name, CName, and QualifiedName. Add
GenCtor method. Stub GetCallString, GetImportSig, and GetSignature
methods.
* generator/StructGen.cs : Removed Name, CName, and QualifiedName.
* generator/SymbolTable.cs : Add GetDllName method.
* parser/gapi2xml.pl : Fix a couple <parameters> bugs.
svn path=/trunk/gtk-sharp/; revision=2030
2002-01-17 23:44:56 +00:00
|
|
|
{
|
2002-07-26 06:08:52 +00:00
|
|
|
StreamWriter sw = CreateWriter ();
|
2002-01-17 Mike Kestner <mkestner@speakeasy.net>
* generator/BoxedGen.cs : Removed Name, CName, and QualifiedName.
* generator/ObjectGen.cs : Removed Name, CName, and QualifiedName.
* generator/StructBase.cs : Add Name, CName, and QualifiedName. Add
GenCtor method. Stub GetCallString, GetImportSig, and GetSignature
methods.
* generator/StructGen.cs : Removed Name, CName, and QualifiedName.
* generator/SymbolTable.cs : Add GetDllName method.
* parser/gapi2xml.pl : Fix a couple <parameters> bugs.
svn path=/trunk/gtk-sharp/; revision=2030
2002-01-17 23:44:56 +00:00
|
|
|
|
2002-07-26 06:08:52 +00:00
|
|
|
sw.WriteLine ("\tusing System;");
|
|
|
|
sw.WriteLine ("\tusing System.Collections;");
|
|
|
|
sw.WriteLine ("\tusing System.Runtime.InteropServices;");
|
|
|
|
sw.WriteLine ();
|
2002-01-17 Mike Kestner <mkestner@speakeasy.net>
* generator/BoxedGen.cs : Removed Name, CName, and QualifiedName.
* generator/ObjectGen.cs : Removed Name, CName, and QualifiedName.
* generator/StructBase.cs : Add Name, CName, and QualifiedName. Add
GenCtor method. Stub GetCallString, GetImportSig, and GetSignature
methods.
* generator/StructGen.cs : Removed Name, CName, and QualifiedName.
* generator/SymbolTable.cs : Add GetDllName method.
* parser/gapi2xml.pl : Fix a couple <parameters> bugs.
svn path=/trunk/gtk-sharp/; revision=2030
2002-01-17 23:44:56 +00:00
|
|
|
|
2002-07-26 06:08:52 +00:00
|
|
|
sw.WriteLine("\t\t/// <summary> " + Name + " Struct </summary>");
|
|
|
|
sw.WriteLine("\t\t/// <remarks>");
|
|
|
|
sw.WriteLine("\t\t/// </remarks>");
|
2002-01-17 Mike Kestner <mkestner@speakeasy.net>
* generator/BoxedGen.cs : Removed Name, CName, and QualifiedName.
* generator/ObjectGen.cs : Removed Name, CName, and QualifiedName.
* generator/StructBase.cs : Add Name, CName, and QualifiedName. Add
GenCtor method. Stub GetCallString, GetImportSig, and GetSignature
methods.
* generator/StructGen.cs : Removed Name, CName, and QualifiedName.
* generator/SymbolTable.cs : Add GetDllName method.
* parser/gapi2xml.pl : Fix a couple <parameters> bugs.
svn path=/trunk/gtk-sharp/; revision=2030
2002-01-17 23:44:56 +00:00
|
|
|
|
2002-07-26 06:08:52 +00:00
|
|
|
sw.WriteLine ("\t[StructLayout(LayoutKind.Sequential)]");
|
|
|
|
sw.WriteLine ("\tpublic struct " + Name + " {");
|
|
|
|
sw.WriteLine ();
|
2002-01-17 Mike Kestner <mkestner@speakeasy.net>
* generator/BoxedGen.cs : Removed Name, CName, and QualifiedName.
* generator/ObjectGen.cs : Removed Name, CName, and QualifiedName.
* generator/StructBase.cs : Add Name, CName, and QualifiedName. Add
GenCtor method. Stub GetCallString, GetImportSig, and GetSignature
methods.
* generator/StructGen.cs : Removed Name, CName, and QualifiedName.
* generator/SymbolTable.cs : Add GetDllName method.
* parser/gapi2xml.pl : Fix a couple <parameters> bugs.
svn path=/trunk/gtk-sharp/; revision=2030
2002-01-17 23:44:56 +00:00
|
|
|
|
2002-07-26 06:08:52 +00:00
|
|
|
GenCtors (sw);
|
|
|
|
AppendCustom(sw);
|
2002-01-17 Mike Kestner <mkestner@speakeasy.net>
* generator/BoxedGen.cs : Removed Name, CName, and QualifiedName.
* generator/ObjectGen.cs : Removed Name, CName, and QualifiedName.
* generator/StructBase.cs : Add Name, CName, and QualifiedName. Add
GenCtor method. Stub GetCallString, GetImportSig, and GetSignature
methods.
* generator/StructGen.cs : Removed Name, CName, and QualifiedName.
* generator/SymbolTable.cs : Add GetDllName method.
* parser/gapi2xml.pl : Fix a couple <parameters> bugs.
svn path=/trunk/gtk-sharp/; revision=2030
2002-01-17 23:44:56 +00:00
|
|
|
|
2002-07-26 06:08:52 +00:00
|
|
|
sw.WriteLine ("\t}");
|
|
|
|
CloseWriter (sw);
|
2002-01-17 Mike Kestner <mkestner@speakeasy.net>
* generator/BoxedGen.cs : Removed Name, CName, and QualifiedName.
* generator/ObjectGen.cs : Removed Name, CName, and QualifiedName.
* generator/StructBase.cs : Add Name, CName, and QualifiedName. Add
GenCtor method. Stub GetCallString, GetImportSig, and GetSignature
methods.
* generator/StructGen.cs : Removed Name, CName, and QualifiedName.
* generator/SymbolTable.cs : Add GetDllName method.
* parser/gapi2xml.pl : Fix a couple <parameters> bugs.
svn path=/trunk/gtk-sharp/; revision=2030
2002-01-17 23:44:56 +00:00
|
|
|
}
|
2002-02-03 03:44:10 +00:00
|
|
|
|
2002-07-26 06:08:52 +00:00
|
|
|
protected override void GenCtors (StreamWriter sw)
|
2002-02-03 03:44:10 +00:00
|
|
|
{
|
2002-07-26 06:08:52 +00:00
|
|
|
sw.WriteLine("\t\tpublic " + Name + "(IntPtr raw) {}");
|
|
|
|
sw.WriteLine();
|
|
|
|
//base.GenCtors (sw);
|
2002-02-03 03:44:10 +00:00
|
|
|
}
|
2002-07-26 06:08:52 +00:00
|
|
|
|
2002-01-05 12:45:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|