GtkSharp/generator/Signature.cs
Martin Willemoes Hansen c2d4c12e67 * generator/Method.cs: Methods which returns void and has a single out parameter
like void Foobar (..., out int baz, ...) are turned into the more .NET like
          signature int Foobar (...), this fixes bug 46392
        * generator/Signature.cs: Ditto
        * generator/MethodBody.cs: Ditto
        * gtk/ListStore.custom: Ditto
        * gtk/TextBuffer.custom: Ditto
        * gtk/TreeStore.custom: Ditto

svn path=/trunk/gtk-sharp/; revision=22126
2004-01-15 21:18:46 +00:00

126 lines
2.4 KiB
C#

// GtkSharp.Generation.Signature.cs - The Signature Generation Class.
//
// Author: Mike Kestner <mkestner@ximian.com>
//
// (c) 2003 Novell, Inc.
namespace GtkSharp.Generation {
using System;
using System.Collections;
using System.Xml;
public class Signature {
private ArrayList parms = new ArrayList ();
public Signature (Parameters parms)
{
if (parms == null)
return;
bool has_cb = parms.HideData;
for (int i = 0; i < parms.Count; i++) {
Parameter p = parms [i];
if (i > 0 && p.IsLength && parms [i - 1].IsString)
continue;
if (p.IsCount && ((i > 0 && parms [i - 1].IsArray) || (i < parms.Count - 1 && parms [i + 1].IsArray)))
continue;
has_cb = has_cb || p.Generatable is CallbackGen;
if (p.IsUserData && has_cb && (i == parms.Count - 1))
continue;
if (p.CType == "GError**")
continue;
this.parms.Add (p);
}
}
public override string ToString ()
{
if (parms.Count == 0)
return "";
string[] result = new string [parms.Count];
int i = 0;
foreach (Parameter p in parms) {
result [i] = p.PassAs != "" ? p.PassAs + " " : "";
result [i++] += p.CSType + " " + p.Name;
}
return String.Join (", ", result);
}
public string Types {
get {
if (parms.Count == 0)
return "";
string[] result = new string [parms.Count];
int i = 0;
foreach (Parameter p in parms)
result [i++] = p.CSType;
return String.Join (":", result);
}
}
public bool IsAccessor {
get {
int count = 0;
foreach (Parameter p in parms) {
if (p.PassAs == "out")
count++;
if (count > 1)
return false;
}
return count == 1;
}
}
public string AccessorType {
get {
foreach (Parameter p in parms)
if (p.PassAs == "out")
return p.CSType;
return null;
}
}
public string AccessorName {
get {
foreach (Parameter p in parms)
if (p.PassAs == "out")
return p.Name;
return null;
}
}
public string AsAccessor {
get {
string[] result = new string [parms.Count - 1];
int i = 0;
foreach (Parameter p in parms) {
if (p.PassAs == "out")
continue;
result [i] = p.PassAs != "" ? p.PassAs + " " : "";
result [i++] += p.CSType + " " + p.Name;
}
return String.Join (", ", result);
}
}
}
}