* 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
This commit is contained in:
Martin Willemoes Hansen 2004-01-15 21:18:46 +00:00
parent 80a630a8a4
commit c2d4c12e67
7 changed files with 87 additions and 14 deletions

View file

@ -1,3 +1,14 @@
2004-01-15 Martin Willemoes Hansen <mwh@sysrq.dk>
* 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
2004-01-13 Tambet Ingo <tambet@ximian.com>
* gtk-sharp.pc.in : add libdir var

View file

@ -220,6 +220,8 @@ namespace GtkSharp.Generation {
else
sw.Write (Name);
sw.WriteLine(" { ");
} else if (IsAccessor) {
sw.Write (sig.AccessorType + " " + Name + "(" + sig.AsAccessor + ")");
} else {
sw.Write(s_ret + " " + Name + "(" + (sig != null ? sig.ToString() : "") + ")");
}
@ -342,6 +344,8 @@ namespace GtkSharp.Generation {
{
StreamWriter sw = gen_info.Writer;
sw.WriteLine(" {");
if (IsAccessor)
body.InitAccessor (sw, sig, indent);
body.Initialize(gen_info, is_get, is_set, indent);
SymbolTable table = SymbolTable.Table;
@ -374,9 +378,17 @@ namespace GtkSharp.Generation {
sw.WriteLine (indent + "\t\t\treturn " + parms.AccessorName + ";");
else if (m_ret != "void")
sw.WriteLine (indent + "\t\t\treturn ret;");
else if (IsAccessor)
body.FinishAccessor (sw, sig, indent);
sw.Write(indent + "\t\t}");
}
bool IsAccessor {
get {
return s_ret == "void" && sig.IsAccessor;
}
}
}
}

View file

@ -142,6 +142,11 @@ namespace GtkSharp.Generation {
sw.WriteLine (indent + "\t\t\tIntPtr error = IntPtr.Zero;");
}
public void InitAccessor (StreamWriter sw, Signature sig, string indent)
{
sw.WriteLine (indent + "\t\t\t" + sig.AccessorType + " " + sig.AccessorName + ";");
}
public void Finish (StreamWriter sw, string indent)
{
if (parameters == null)
@ -161,6 +166,11 @@ namespace GtkSharp.Generation {
}
}
public void FinishAccessor (StreamWriter sw, Signature sig, string indent)
{
sw.WriteLine (indent + "\t\t\treturn " + sig.AccessorName + ";");
}
public void HandleException (StreamWriter sw, string indent)
{
if (!ThrowsException)

View file

@ -70,6 +70,57 @@ namespace GtkSharp.Generation {
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);
}
}
}
}

View file

@ -61,8 +61,7 @@
}
public Gtk.TreeIter AppendValues (Array values) {
Gtk.TreeIter iter;
Append (out iter);
Gtk.TreeIter iter = Append();
int col = 0;
foreach (object value in values) {

View file

@ -14,15 +14,6 @@ public void Clear ()
Delete (StartIter, EndIter);
}
public Gtk.TextIter GetIterAtOffset(int char_offset)
{
Gtk.TextIter iter;
gtk_text_buffer_get_iter_at_offset(Handle, out iter, char_offset);
return iter;
}
// overload to paste clipboard contents at cursor editable by default.
[DllImport("libgtk-win32-2.0-0.dll")]
static extern void gtk_text_buffer_paste_clipboard (IntPtr raw, IntPtr clip, IntPtr iter, bool default_edit);

View file

@ -148,8 +148,7 @@
}
public Gtk.TreeIter AppendValues (Gtk.TreeIter parent, Array values) {
Gtk.TreeIter iter;
Append (out iter, parent);
Gtk.TreeIter iter = Append (parent);
_AppendValues (iter, values);
return iter;
}