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-05-23 23:43:25 +00:00
|
|
|
protected bool GenCtor(XmlElement ctor, StreamWriter sw, Hashtable clash_map)
|
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
|
|
|
String sig, isig, call, sigtypes;
|
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
|
|
|
XmlElement parms = ctor["parameters"];
|
|
|
|
|
|
|
|
if (parms == null) {
|
2002-02-08 23:56:27 +00:00
|
|
|
call = sig = "()";
|
|
|
|
isig = "();";
|
2002-02-03 03:44:10 +00:00
|
|
|
sigtypes = "";
|
2002-05-23 23:43:25 +00:00
|
|
|
} else if (GetSignature(parms, out sig, out sigtypes) &&
|
|
|
|
GetImportSig(parms, out isig) &&
|
|
|
|
GetCallString(parms, out call)) {
|
2002-02-08 23:56:27 +00:00
|
|
|
sig = "(" + sig + ")";
|
|
|
|
isig = "(" + isig + ");";
|
|
|
|
call = "(" + call + ")";
|
|
|
|
} else {
|
2002-02-03 03:44:10 +00:00
|
|
|
Console.Write("ctor ");
|
2002-02-19 03:12:47 +00:00
|
|
|
Statistics.ThrottledCount++;
|
2002-02-03 03:44:10 +00:00
|
|
|
return false;
|
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
|
|
|
bool clash = false;
|
|
|
|
if (clash_map.ContainsKey(sigtypes)) {
|
|
|
|
clash = true;
|
|
|
|
} else {
|
|
|
|
clash_map[sigtypes] = ctor;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
String cname = ctor.GetAttribute("cname");
|
|
|
|
|
2002-06-22 22:12:51 +00:00
|
|
|
sw.WriteLine("\t\t[DllImport(\"" + LibraryName + "\")]");
|
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
|
|
|
sw.WriteLine("\t\tstatic extern IntPtr " + cname + isig);
|
|
|
|
sw.WriteLine();
|
2002-02-03 03:44:10 +00:00
|
|
|
|
|
|
|
if (clash) {
|
|
|
|
String mname = cname.Substring(cname.IndexOf("new"));
|
2002-02-18 19:26:33 +00:00
|
|
|
mname = mname.Substring(0,1).ToUpper() + mname.Substring(1);
|
|
|
|
int idx;
|
|
|
|
while ((idx = mname.IndexOf("_")) > 0) {
|
|
|
|
mname = mname.Substring(0, idx) + mname.Substring(idx+1, 1).ToUpper() + mname.Substring(idx+2);
|
|
|
|
}
|
|
|
|
|
2002-02-03 03:44:10 +00:00
|
|
|
sw.WriteLine("\t\tpublic static " + Name + " " + mname + sig);
|
|
|
|
sw.WriteLine("\t\t{");
|
|
|
|
sw.WriteLine("\t\t\treturn new " + Name + "(" + cname + call + ");");
|
|
|
|
} else {
|
|
|
|
sw.WriteLine("\t\tpublic " + Name + sig);
|
|
|
|
sw.WriteLine("\t\t{");
|
2002-02-19 19:46:44 +00:00
|
|
|
sw.WriteLine("\t\t\tRaw = " + cname + call + ";");
|
2002-02-03 03:44:10 +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
|
|
|
sw.WriteLine("\t\t}");
|
|
|
|
sw.WriteLine();
|
|
|
|
|
2002-02-19 03:12:47 +00:00
|
|
|
Statistics.CtorCount++;
|
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
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
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-05-23 23:43:25 +00:00
|
|
|
String cs_type = SymbolTable.GetCSType(c_type);
|
2002-01-06 13:33:25 +00:00
|
|
|
|
|
|
|
if (cs_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-01-08 20:30:29 +00:00
|
|
|
sw.Write ("\t\t public " + cs_type);
|
2002-01-06 13:33:25 +00:00
|
|
|
if (field.HasAttribute("array_len")) {
|
|
|
|
sw.Write ("[]");
|
|
|
|
}
|
|
|
|
sw.WriteLine (" " + 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-05-23 23:43:25 +00:00
|
|
|
protected bool GenMethod(XmlElement method, StreamWriter sw)
|
2002-02-08 23:56:27 +00:00
|
|
|
{
|
|
|
|
String sig, isig, call, sigtypes;
|
|
|
|
XmlElement parms = method["parameters"];
|
|
|
|
|
|
|
|
if (parms == null) {
|
2002-02-09 13:58:21 +00:00
|
|
|
call = "(Handle)";
|
|
|
|
sig = "()";
|
|
|
|
isig = "(IntPtr raw);";
|
2002-02-08 23:56:27 +00:00
|
|
|
sigtypes = "";
|
2002-05-23 23:43:25 +00:00
|
|
|
} else if (GetSignature(parms, out sig, out sigtypes) &&
|
|
|
|
GetImportSig(parms, out isig) &&
|
|
|
|
GetCallString(parms, out call)) {
|
2002-02-08 23:56:27 +00:00
|
|
|
sig = "(" + sig + ")";
|
|
|
|
isig = "(IntPtr raw, " + isig + ");";
|
|
|
|
call = "(Handle, " + call + ")";
|
|
|
|
} else {
|
|
|
|
Console.Write("method ");
|
2002-02-19 03:12:47 +00:00
|
|
|
Statistics.ThrottledCount++;
|
2002-02-08 23:56:27 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2002-02-10 23:11:25 +00:00
|
|
|
XmlElement ret_elem = method["return-type"];
|
|
|
|
if (ret_elem == null) {
|
|
|
|
Console.Write("Missing return type in method ");
|
2002-02-19 03:12:47 +00:00
|
|
|
Statistics.ThrottledCount++;
|
2002-02-10 23:11:25 +00:00
|
|
|
return false;
|
2002-02-08 23:56:27 +00:00
|
|
|
}
|
|
|
|
|
2002-02-10 23:11:25 +00:00
|
|
|
String rettype = ret_elem.GetAttribute("type");
|
|
|
|
|
2002-05-23 23:43:25 +00:00
|
|
|
String m_ret = SymbolTable.GetMarshalType(rettype);
|
|
|
|
String s_ret = SymbolTable.GetCSType(rettype);
|
2002-02-08 23:56:27 +00:00
|
|
|
if (m_ret == "" || s_ret == "") {
|
|
|
|
Console.Write("rettype: " + rettype + " method ");
|
2002-02-19 03:12:47 +00:00
|
|
|
Statistics.ThrottledCount++;
|
2002-02-08 23:56:27 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
String cname = method.GetAttribute("cname");
|
|
|
|
String name = method.GetAttribute("name");
|
|
|
|
|
2002-03-26 01:29:43 +00:00
|
|
|
if (cname[0] == '_') {
|
|
|
|
Statistics.ThrottledCount++;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2002-06-22 22:12:51 +00:00
|
|
|
sw.WriteLine("\t\t[DllImport(\"" + LibraryName + "\")]");
|
2002-02-08 23:56:27 +00:00
|
|
|
sw.Write("\t\tstatic extern " + m_ret + " " + cname + isig);
|
|
|
|
sw.WriteLine();
|
|
|
|
|
|
|
|
sw.WriteLine("\t\tpublic " + s_ret + " " + name + sig);
|
|
|
|
sw.WriteLine("\t\t{");
|
|
|
|
sw.Write("\t\t\t");
|
|
|
|
if (m_ret == "void") {
|
|
|
|
sw.WriteLine(cname + call + ";");
|
|
|
|
} else {
|
2002-05-23 23:43:25 +00:00
|
|
|
sw.WriteLine("return " + SymbolTable.FromNative(rettype, cname + call) + ";");
|
2002-02-08 23:56:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sw.WriteLine("\t\t}");
|
|
|
|
sw.WriteLine();
|
|
|
|
|
2002-02-19 03:12:47 +00:00
|
|
|
Statistics.MethodCount++;
|
2002-02-08 23:56:27 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2002-05-23 23:43:25 +00:00
|
|
|
private bool GetCallString(XmlElement parms, out String call)
|
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-08 23:56:27 +00:00
|
|
|
call = "";
|
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
|
|
|
bool need_comma = false;
|
|
|
|
|
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
|
|
|
foreach (XmlNode parm in parms.ChildNodes) {
|
2002-06-26 13:10:48 +00:00
|
|
|
if (!(parm is XmlElement) || parm.Name != "parameter") {
|
2002-02-17 20:54:54 +00:00
|
|
|
Console.Write(parm.Name + " node ");
|
|
|
|
return false;
|
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
|
|
|
}
|
|
|
|
|
|
|
|
XmlElement elem = (XmlElement) parm;
|
2002-02-06 20:09:14 +00:00
|
|
|
String type = elem.GetAttribute("type");
|
|
|
|
String name = elem.GetAttribute("name");
|
|
|
|
name = MangleName(name);
|
2002-05-23 23:43:25 +00:00
|
|
|
String call_parm = SymbolTable.CallByName(type, name);
|
2002-02-06 20:09:14 +00:00
|
|
|
|
|
|
|
if (call_parm == "") {
|
|
|
|
Console.Write("Name: " + name + " Type: " + type + " ");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (need_comma) {
|
|
|
|
call += ", ";
|
|
|
|
} else {
|
|
|
|
need_comma = true;
|
|
|
|
}
|
|
|
|
call += call_parm;
|
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
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2002-05-23 23:43:25 +00:00
|
|
|
private bool GetImportSig(XmlElement parms, out String isig)
|
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-08 23:56:27 +00:00
|
|
|
isig = "";
|
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-06 20:09:14 +00:00
|
|
|
bool need_comma = false;
|
|
|
|
|
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
|
|
|
foreach (XmlNode parm in parms.ChildNodes) {
|
2002-06-26 13:10:48 +00:00
|
|
|
if (!(parm is XmlElement) || parm.Name != "parameter") {
|
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
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
XmlElement elem = (XmlElement) parm;
|
2002-02-06 20:09:14 +00:00
|
|
|
String type = elem.GetAttribute("type");
|
2002-05-23 23:43:25 +00:00
|
|
|
String m_type = SymbolTable.GetMarshalType(type);
|
2002-02-06 20:09:14 +00:00
|
|
|
String name = elem.GetAttribute("name");
|
|
|
|
name = MangleName(name);
|
|
|
|
|
|
|
|
if ((m_type == "") || (name == "")) {
|
|
|
|
Console.Write("Name: " + name + " Type: " + type + " ");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (elem.HasAttribute("array")) {
|
|
|
|
m_type += "[]";
|
|
|
|
}
|
|
|
|
|
|
|
|
if (need_comma) {
|
|
|
|
isig += ", ";
|
|
|
|
} else {
|
|
|
|
need_comma = true;
|
|
|
|
}
|
|
|
|
isig += (m_type + " " + name);
|
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
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2002-01-05 12:45:55 +00:00
|
|
|
|
2002-05-23 23:43:25 +00:00
|
|
|
private bool GetSignature(XmlElement parms, out String sig, out String sigtypes)
|
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-08 23:56:27 +00:00
|
|
|
sigtypes = sig = "";
|
2002-02-03 03:44:10 +00:00
|
|
|
bool need_comma = false;
|
|
|
|
|
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
|
|
|
foreach (XmlNode parm in parms.ChildNodes) {
|
|
|
|
if (parm.Name != "parameter") {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
XmlElement elem = (XmlElement) parm;
|
2002-02-03 03:44:10 +00:00
|
|
|
String type = elem.GetAttribute("type");
|
2002-05-23 23:43:25 +00:00
|
|
|
String cs_type = SymbolTable.GetCSType(type);
|
2002-02-03 03:44:10 +00:00
|
|
|
String name = elem.GetAttribute("name");
|
|
|
|
name = MangleName(name);
|
|
|
|
|
|
|
|
if ((cs_type == "") || (name == "")) {
|
|
|
|
Console.Write("Name: " + name + " Type: " + type + " ");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (elem.HasAttribute("array")) {
|
|
|
|
cs_type += "[]";
|
|
|
|
}
|
|
|
|
|
|
|
|
if (need_comma) {
|
|
|
|
sig += ", ";
|
|
|
|
sigtypes += ":";
|
|
|
|
} else {
|
|
|
|
need_comma = true;
|
|
|
|
}
|
|
|
|
sig += (cs_type + " " + name);
|
|
|
|
sigtypes += cs_type;
|
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
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2002-02-03 03:44:10 +00:00
|
|
|
|
|
|
|
private String MangleName(String name)
|
|
|
|
{
|
|
|
|
if (name == "string") {
|
|
|
|
return "str1ng";
|
2002-02-17 20:54:54 +00:00
|
|
|
} else if (name == "event") {
|
|
|
|
return "evnt";
|
|
|
|
} else if (name == "object") {
|
|
|
|
return "objekt";
|
2002-02-03 03:44:10 +00:00
|
|
|
} else {
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
}
|
2002-01-05 12:45:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|