mirror of
https://github.com/Ryujinx/GtkSharp.git
synced 2024-09-16 11:34:47 +02:00
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:
parent
fc06f3829a
commit
71e9b3c99a
@ -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>
|
2007-08-13 Mike Kestner <mkestner@novell.com>
|
||||||
|
|
||||||
* generator/*.cs : switch to IntPtr marshaling for struct types
|
* generator/*.cs : switch to IntPtr marshaling for struct types
|
||||||
|
@ -24,36 +24,39 @@ namespace GtkSharp.Generation {
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
public class ByRefGen : SimpleBase {
|
public class ByRefGen : SimpleBase, IManualMarshaler {
|
||||||
|
|
||||||
public ByRefGen (string ctype, string type) : base (ctype, type) {}
|
public ByRefGen (string ctype, string type) : base (ctype, type) {}
|
||||||
|
|
||||||
public override string MarshalType {
|
public override string MarshalType {
|
||||||
get {
|
get {
|
||||||
return "ref " + QualifiedName;
|
return "IntPtr";
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public override string MarshalReturnType {
|
|
||||||
get {
|
|
||||||
return QualifiedName;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public override string ToNativeReturnType {
|
|
||||||
get {
|
|
||||||
return QualifiedName;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string CallByName (string var_name)
|
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 + ")";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -240,7 +240,7 @@ namespace GtkSharp.Generation {
|
|||||||
if (PassAs != "out")
|
if (PassAs != "out")
|
||||||
result += " = " + (gen as IManualMarshaler).AllocNative (CallName);
|
result += " = " + (gen as IManualMarshaler).AllocNative (CallName);
|
||||||
return new string [] { result + ";" };
|
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 [] { gen.MarshalType + " native_" + CallName + ";" };
|
||||||
|
|
||||||
return new string [0];
|
return new string [0];
|
||||||
@ -256,7 +256,7 @@ namespace GtkSharp.Generation {
|
|||||||
return SymbolTable.Table.CallByName (CType, CallName + "_wrapper");
|
return SymbolTable.Table.CallByName (CType, CallName + "_wrapper");
|
||||||
else if (PassAs != String.Empty) {
|
else if (PassAs != String.Empty) {
|
||||||
call_parm = PassAs + " ";
|
call_parm = PassAs + " ";
|
||||||
if (CSType != MarshalType && !(gen is ByRefGen))
|
if (CSType != MarshalType)
|
||||||
call_parm += "native_";
|
call_parm += "native_";
|
||||||
call_parm += CallName;
|
call_parm += CallName;
|
||||||
} else if (gen is IManualMarshaler)
|
} else if (gen is IManualMarshaler)
|
||||||
@ -279,7 +279,7 @@ namespace GtkSharp.Generation {
|
|||||||
if (PassAs != "out")
|
if (PassAs != "out")
|
||||||
result [i] = (gen as IManualMarshaler).ReleaseNative ("native_" + CallName) + ";";
|
result [i] = (gen as IManualMarshaler).ReleaseNative ("native_" + CallName) + ";";
|
||||||
return result;
|
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 [] { CallName + " = " + gen.FromNative ("native_" + CallName) + ";" };
|
||||||
return new string [0];
|
return new string [0];
|
||||||
}
|
}
|
||||||
@ -630,7 +630,7 @@ namespace GtkSharp.Generation {
|
|||||||
}
|
}
|
||||||
} else if (p.CType == "GError**")
|
} else if (p.CType == "GError**")
|
||||||
p = new ErrorParameter (parm);
|
p = new ErrorParameter (parm);
|
||||||
else if (gen is StructBase) {
|
else if (gen is StructBase || gen is ByRefGen) {
|
||||||
p = new StructParameter (parm);
|
p = new StructParameter (parm);
|
||||||
} else if (gen is CallbackGen) {
|
} else if (gen is CallbackGen) {
|
||||||
has_cb = true;
|
has_cb = true;
|
||||||
|
Loading…
Reference in New Issue
Block a user