2007-08-13 Mike Kestner <mkestner@novell.com>

* generator/ByRefGen.cs : implement IManualMarshaler.
	* generator/Parameter.cs : use StructParameter for ByRefGen.

svn path=/trunk/gtk-sharp/; revision=83978
This commit is contained in:
Mike Kestner 2007-08-13 17:48:24 +00:00
parent fc06f3829a
commit 71e9b3c99a
3 changed files with 29 additions and 21 deletions

View File

@ -1,3 +1,8 @@
2007-08-13 Mike Kestner <mkestner@novell.com>
* generator/ByRefGen.cs : implement IManualMarshaler.
* generator/Parameter.cs : use StructParameter for ByRefGen.
2007-08-13 Mike Kestner <mkestner@novell.com>
* generator/*.cs : switch to IntPtr marshaling for struct types

View File

@ -24,36 +24,39 @@ namespace GtkSharp.Generation {
using System;
public class ByRefGen : SimpleBase {
public class ByRefGen : SimpleBase, IManualMarshaler {
public ByRefGen (string ctype, string type) : base (ctype, type) {}
public override string MarshalType {
get {
return "ref " + QualifiedName;
}
}
public override string MarshalReturnType {
get {
return QualifiedName;
}
}
public override string ToNativeReturnType {
get {
return QualifiedName;
return "IntPtr";
}
}
public override string CallByName (string var_name)
{
return "ref " + var_name;
return "native_" + var_name;
}
public override string ToNativeReturn(string var)
public string AllocNative ()
{
return var;
return "Marshal.AllocHGlobal (Marshal.SizeOf (typeof (" + QualifiedName + ")))";
}
public string AllocNative (string var_name)
{
return "GLib.Marshaller.StructureToPtrAlloc (" + var_name + ")";
}
public override string FromNative (string var_name)
{
return String.Format ("({0}) Marshal.PtrToStructure ({1}, typeof ({0}))", QualifiedName, var_name);
}
public string ReleaseNative (string var_name)
{
return "GLib.Marshaller.Free (" + var_name + ")";
}
}
}

View File

@ -240,7 +240,7 @@ namespace GtkSharp.Generation {
if (PassAs != "out")
result += " = " + (gen as IManualMarshaler).AllocNative (CallName);
return new string [] { result + ";" };
} else if (PassAs == "out" && CSType != MarshalType && !(gen is StructBase || gen is ByRefGen))
} else if (PassAs == "out" && CSType != MarshalType)
return new string [] { gen.MarshalType + " native_" + CallName + ";" };
return new string [0];
@ -256,7 +256,7 @@ namespace GtkSharp.Generation {
return SymbolTable.Table.CallByName (CType, CallName + "_wrapper");
else if (PassAs != String.Empty) {
call_parm = PassAs + " ";
if (CSType != MarshalType && !(gen is ByRefGen))
if (CSType != MarshalType)
call_parm += "native_";
call_parm += CallName;
} else if (gen is IManualMarshaler)
@ -279,7 +279,7 @@ namespace GtkSharp.Generation {
if (PassAs != "out")
result [i] = (gen as IManualMarshaler).ReleaseNative ("native_" + CallName) + ";";
return result;
} else if (PassAs != String.Empty && MarshalType != CSType && !(gen is StructBase || gen is ByRefGen))
} else if (PassAs != String.Empty && MarshalType != CSType)
return new string [] { CallName + " = " + gen.FromNative ("native_" + CallName) + ";" };
return new string [0];
}
@ -630,7 +630,7 @@ namespace GtkSharp.Generation {
}
} else if (p.CType == "GError**")
p = new ErrorParameter (parm);
else if (gen is StructBase) {
else if (gen is StructBase || gen is ByRefGen) {
p = new StructParameter (parm);
} else if (gen is CallbackGen) {
has_cb = true;