2009-08-13 Christian Hoff <christian_hoff@gmx.net>
* generator/IGeneratable.cs: Remove MarshalReturnType, ToNativeReturnType, FromNativeReturn and ToNativeReturn as they never returned something else than MarshalType, FromNative/AllocNative and CallByName, respectively. * generator/Signal.cs: Use AllocNative for IManualMarshalers. svn path=/trunk/gtk-sharp/; revision=139849
This commit is contained in:
parent
b244c750d3
commit
08b43fbd76
12 changed files with 33 additions and 124 deletions
|
@ -1,3 +1,10 @@
|
|||
2009-08-13 Christian Hoff <christian_hoff@gmx.net>
|
||||
|
||||
* generator/IGeneratable.cs: Remove MarshalReturnType, ToNativeReturnType,
|
||||
FromNativeReturn and ToNativeReturn as they never returned something else
|
||||
than MarshalType, FromNative/AllocNative and CallByName, respectively.
|
||||
* generator/Signal.cs: Use AllocNative for IManualMarshalers.
|
||||
|
||||
2009-08-12 Christian Hoff <christian_hoff@gmx.net>
|
||||
|
||||
* configure.in.in: Detect GDK backend.
|
||||
|
|
|
@ -40,11 +40,6 @@ namespace GtkSharp.Generation {
|
|||
return "GLib.Marshaller.Utf8PtrToString (" + var + ")";
|
||||
}
|
||||
|
||||
public override string ToNativeReturn (string var)
|
||||
{
|
||||
return "GLib.Marshaller.StringToPtrGStrdup (" + var + ")";
|
||||
}
|
||||
|
||||
public string AllocNative (string managed_var)
|
||||
{
|
||||
return "GLib.Marshaller.StringToPtrGStrdup (" + managed_var + ")";
|
||||
|
|
|
@ -115,7 +115,7 @@ namespace GtkSharp.Generation {
|
|||
if (getterName != null) {
|
||||
sw.WriteLine (indent + "[DllImport (\"{0}\")]", gen_info.GluelibName);
|
||||
sw.WriteLine (indent + "extern static {0} {1} ({2} raw);",
|
||||
table.GetMarshalReturnType (CType), getterName,
|
||||
table.GetMarshalType (CType), getterName,
|
||||
container_type.MarshalType);
|
||||
}
|
||||
|
||||
|
@ -164,7 +164,7 @@ namespace GtkSharp.Generation {
|
|||
} else if (getterName != null) {
|
||||
sw.WriteLine (indent + "\tget {");
|
||||
container_type.Prepare (sw, indent + "\t\t");
|
||||
sw.WriteLine (indent + "\t\t" + CSType + " result = " + table.FromNativeReturn (ctype, getterName + " (" + container_type.CallByName () + ")") + ";");
|
||||
sw.WriteLine (indent + "\t\t" + CSType + " result = " + table.FromNative (ctype, getterName + " (" + container_type.CallByName () + ")") + ";");
|
||||
container_type.Finish (sw, indent + "\t\t");
|
||||
sw.WriteLine (indent + "\t\treturn result;");
|
||||
sw.WriteLine (indent + "\t}");
|
||||
|
@ -175,13 +175,16 @@ namespace GtkSharp.Generation {
|
|||
sw.WriteLine (indent + "\t\t\t" + CSType + "* raw_ptr = (" + CSType + "*)(((byte*)" + container_type.CallByName () + ") + " + offsetName + ");");
|
||||
sw.WriteLine (indent + "\t\t\treturn *raw_ptr;");
|
||||
} else {
|
||||
sw.WriteLine (indent + "\t\t\t" + table.GetMarshalReturnType (CType) + "* raw_ptr = (" + table.GetMarshalReturnType (CType) + "*)(((byte*)" + container_type.CallByName () + ") + " + offsetName + ");");
|
||||
sw.WriteLine (indent + "\t\t\treturn " + table.FromNativeReturn (ctype, "(*raw_ptr)") + ";");
|
||||
sw.WriteLine (indent + "\t\t\t" + table.GetMarshalType (CType) + "* raw_ptr = (" + table.GetMarshalType (CType) + "*)(((byte*)" + container_type.CallByName () + ") + " + offsetName + ");");
|
||||
sw.WriteLine (indent + "\t\t\treturn " + table.FromNative (ctype, "(*raw_ptr)") + ";");
|
||||
}
|
||||
sw.WriteLine (indent + "\t\t}");
|
||||
sw.WriteLine (indent + "\t}");
|
||||
}
|
||||
|
||||
IGeneratable gen = table [CType];
|
||||
string to_native = (gen is IManualMarshaler) ? (gen as IManualMarshaler).AllocNative ("value") : gen.CallByName ("value");
|
||||
|
||||
if (Setter != null) {
|
||||
sw.Write (indent + "\tset ");
|
||||
Setter.GenerateBody (gen_info, container_type, "\t");
|
||||
|
@ -189,7 +192,7 @@ namespace GtkSharp.Generation {
|
|||
} else if (setterName != null) {
|
||||
sw.WriteLine (indent + "\tset {");
|
||||
container_type.Prepare (sw, indent + "\t\t");
|
||||
sw.WriteLine (indent + "\t\t" + setterName + " (" + container_type.CallByName () + ", " + table.CallByName (ctype, "value") + ");");
|
||||
sw.WriteLine (indent + "\t\t" + setterName + " (" + container_type.CallByName () + ", " + to_native + ");");
|
||||
container_type.Finish (sw, indent + "\t\t");
|
||||
sw.WriteLine (indent + "\t}");
|
||||
} else if (Writable && offsetName != null) {
|
||||
|
@ -199,8 +202,8 @@ namespace GtkSharp.Generation {
|
|||
sw.WriteLine (indent + "\t\t\t" + CSType + "* raw_ptr = (" + CSType + "*)(((byte*)" + container_type.CallByName () + ") + " + offsetName + ");");
|
||||
sw.WriteLine (indent + "\t\t\t*raw_ptr = value;");
|
||||
} else {
|
||||
sw.WriteLine (indent + "\t\t\t" + table.GetMarshalReturnType (CType) + "* raw_ptr = (" + table.GetMarshalReturnType (CType) + "*)(((byte*)" + container_type.CallByName () + ") + " + offsetName + ");");
|
||||
sw.WriteLine (indent + "\t\t\t*raw_ptr = " + table.ToNativeReturn (ctype, "value") + ";");
|
||||
sw.WriteLine (indent + "\t\t\t" + table.GetMarshalType (CType) + "* raw_ptr = (" + table.GetMarshalType (CType) + "*)(((byte*)" + container_type.CallByName () + ") + " + offsetName + ");");
|
||||
sw.WriteLine (indent + "\t\t\t*raw_ptr = " + to_native + ";");
|
||||
}
|
||||
sw.WriteLine (indent + "\t\t}");
|
||||
sw.WriteLine (indent + "\t}");
|
||||
|
|
|
@ -72,12 +72,6 @@ namespace GtkSharp.Generation {
|
|||
}
|
||||
}
|
||||
|
||||
public virtual string MarshalReturnType {
|
||||
get {
|
||||
return MarshalType;
|
||||
}
|
||||
}
|
||||
|
||||
public abstract string MarshalType { get; }
|
||||
|
||||
public string Name {
|
||||
|
@ -100,12 +94,6 @@ namespace GtkSharp.Generation {
|
|||
}
|
||||
}
|
||||
|
||||
public virtual string ToNativeReturnType {
|
||||
get {
|
||||
return MarshalType;
|
||||
}
|
||||
}
|
||||
|
||||
protected void AppendCustom (StreamWriter sw, string custom_dir)
|
||||
{
|
||||
AppendCustom (sw, custom_dir, Name);
|
||||
|
@ -130,16 +118,6 @@ namespace GtkSharp.Generation {
|
|||
|
||||
public abstract string FromNative (string var);
|
||||
|
||||
public virtual string FromNativeReturn (string var)
|
||||
{
|
||||
return FromNative (var);
|
||||
}
|
||||
|
||||
public virtual string ToNativeReturn (string var)
|
||||
{
|
||||
return CallByName (var);
|
||||
}
|
||||
|
||||
public abstract bool Validate ();
|
||||
|
||||
public void Generate ()
|
||||
|
|
|
@ -58,16 +58,6 @@ namespace GtkSharp.Generation {
|
|||
return FromNative (var, false);
|
||||
}
|
||||
|
||||
public string FromNativeReturn (string var, bool owned)
|
||||
{
|
||||
return FromNative (var, owned);
|
||||
}
|
||||
|
||||
public override string FromNativeReturn (string var)
|
||||
{
|
||||
return FromNativeReturn (var, false);
|
||||
}
|
||||
|
||||
public void WriteAccessors (StreamWriter sw, string indent, string var)
|
||||
{
|
||||
sw.WriteLine (indent + "get {");
|
||||
|
|
|
@ -37,14 +37,6 @@ namespace GtkSharp.Generation {
|
|||
// signature when passing this generatable to unmanaged code
|
||||
string MarshalType {get;}
|
||||
|
||||
// The type to use as the return type in an import signature when
|
||||
// receiving this generatable back from unmanaged code
|
||||
string MarshalReturnType {get;}
|
||||
|
||||
// The type to use in a managed callback signature when returning this
|
||||
// generatable to unmanaged code
|
||||
string ToNativeReturnType {get;}
|
||||
|
||||
// The value returned by callbacks that are interrupted prematurely
|
||||
// by managed exceptions or other conditions where an appropriate
|
||||
// value can't be otherwise obtained.
|
||||
|
@ -56,12 +48,6 @@ namespace GtkSharp.Generation {
|
|||
// Generates an expression to convert var from MarshalType
|
||||
string FromNative (string var);
|
||||
|
||||
// Generates an expression to convert var from MarshalReturnType
|
||||
string FromNativeReturn (string var);
|
||||
|
||||
// Generates an expression to convert var to ToNativeReturnType
|
||||
string ToNativeReturn (string var);
|
||||
|
||||
bool Validate ();
|
||||
|
||||
void Generate ();
|
||||
|
|
|
@ -141,8 +141,10 @@ namespace GtkSharp.Generation {
|
|||
continue;
|
||||
else if (igen is StructBase || igen is ByRefGen)
|
||||
ret += indent + String.Format ("if ({0} != IntPtr.Zero) System.Runtime.InteropServices.Marshal.StructureToPtr (my{0}, {0}, false);\n", p.Name);
|
||||
else if (igen is IManualMarshaler)
|
||||
ret += String.Format ("{0}{1} = {2};", indent, p.Name, (igen as IManualMarshaler).AllocNative ("my" + p.Name));
|
||||
else
|
||||
ret += indent + p.Name + " = " + igen.ToNativeReturn ("my" + p.Name) + ";\n";
|
||||
ret += indent + p.Name + " = " + igen.CallByName ("my" + p.Name) + ";\n";
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
|
|
@ -102,7 +102,7 @@ namespace GtkSharp.Generation {
|
|||
return String.Empty;
|
||||
else if (is_null_term)
|
||||
return "IntPtr";
|
||||
return IGen.MarshalReturnType + (is_array ? "[]" : String.Empty);
|
||||
return IGen.MarshalType + (is_array ? "[]" : String.Empty);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -110,7 +110,7 @@ namespace GtkSharp.Generation {
|
|||
get {
|
||||
if (IGen == null)
|
||||
return String.Empty;
|
||||
return IGen.ToNativeReturnType + (is_array || is_null_term ? "[]" : String.Empty);
|
||||
return IGen.MarshalType + (is_array || is_null_term ? "[]" : String.Empty);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -130,7 +130,7 @@ namespace GtkSharp.Generation {
|
|||
else if (is_null_term)
|
||||
return String.Format ("GLib.Marshaller.NullTermPtrToStringArray ({0}, {1})", var, owned ? "true" : "false");
|
||||
else
|
||||
return IGen.FromNativeReturn (var);
|
||||
return IGen.FromNative (var);
|
||||
}
|
||||
|
||||
public string ToNative (string var)
|
||||
|
@ -151,7 +151,7 @@ namespace GtkSharp.Generation {
|
|||
else if (IGen is OpaqueGen && owned)
|
||||
return var + " == null ? IntPtr.Zero : " + var + ".OwnedCopy";
|
||||
else
|
||||
return IGen.ToNativeReturn (var);
|
||||
return IGen.CallByName (var);
|
||||
}
|
||||
|
||||
public bool Validate ()
|
||||
|
|
|
@ -178,10 +178,12 @@ namespace GtkSharp.Generation {
|
|||
} else
|
||||
sw.WriteLine("\t\t\t\targs.Args[" + idx + "] = " + p.FromNative ("arg" + idx) + ";");
|
||||
}
|
||||
if (igen is StructBase && p.PassAs == "ref")
|
||||
if ((igen is StructBase || igen is ByRefGen) && p.PassAs != "")
|
||||
finish += "\t\t\t\tif (arg" + idx + " != IntPtr.Zero) System.Runtime.InteropServices.Marshal.StructureToPtr (args.Args[" + idx + "], arg" + idx + ", false);\n";
|
||||
else if (igen is IManualMarshaler && p.PassAs != "")
|
||||
finish += String.Format ("\t\t\t\targ{0} = {1};\n", idx, (igen as IManualMarshaler).AllocNative ("args.Args[" + idx + "]"));
|
||||
else if (p.PassAs != "")
|
||||
finish += "\t\t\t\targ" + idx + " = " + igen.ToNativeReturn ("((" + p.CSType + ")args.Args[" + idx + "])") + ";\n";
|
||||
finish += "\t\t\t\targ" + idx + " = " + igen.CallByName ("((" + p.CSType + ")args.Args[" + idx + "])") + ";\n";
|
||||
}
|
||||
return finish;
|
||||
}
|
||||
|
@ -198,7 +200,7 @@ namespace GtkSharp.Generation {
|
|||
sw.WriteLine ("\t\t\t\tif (args.RetVal == null)");
|
||||
sw.WriteLine ("\t\t\t\t\treturn false;");
|
||||
}
|
||||
sw.WriteLine("\t\t\t\treturn " + SymbolTable.Table.ToNativeReturn (retval.CType, "((" + retval.CSType + ")args.RetVal)") + ";");
|
||||
sw.WriteLine ("\t\t\t\treturn {0};", retval.ToNative (String.Format ("(({0}) args.RetVal)", retval.CSType)));
|
||||
}
|
||||
sw.WriteLine("\t\t\t} catch (Exception) {");
|
||||
sw.WriteLine ("\t\t\t\tException ex = new Exception (\"args.RetVal or 'out' property unset or set to incorrect type in " + EventHandlerQualifiedName + " callback\");");
|
||||
|
|
|
@ -66,24 +66,12 @@ namespace GtkSharp.Generation {
|
|||
}
|
||||
}
|
||||
|
||||
public virtual string MarshalReturnType {
|
||||
get {
|
||||
return MarshalType;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual string DefaultValue {
|
||||
get {
|
||||
return default_value;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual string ToNativeReturnType {
|
||||
get {
|
||||
return MarshalType;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual string CallByName (string var)
|
||||
{
|
||||
return var;
|
||||
|
@ -94,16 +82,6 @@ namespace GtkSharp.Generation {
|
|||
return var;
|
||||
}
|
||||
|
||||
public virtual string FromNativeReturn(string var)
|
||||
{
|
||||
return FromNative (var);
|
||||
}
|
||||
|
||||
public virtual string ToNativeReturn(string var)
|
||||
{
|
||||
return CallByName (var);
|
||||
}
|
||||
|
||||
public bool Validate ()
|
||||
{
|
||||
return true;
|
||||
|
|
|
@ -134,7 +134,7 @@ namespace GtkSharp.Generation {
|
|||
sw.WriteLine ();
|
||||
if (Access != "private") {
|
||||
sw.WriteLine (indent + Access + " " + wrapped + " " + wrapped_name + " {");
|
||||
sw.WriteLine (indent + "\tget { return " + table.FromNativeReturn (CType, Name) + "; }");
|
||||
sw.WriteLine (indent + "\tget { return " + table.FromNative (CType, Name) + "; }");
|
||||
sw.WriteLine (indent + "}");
|
||||
}
|
||||
} else if (IsPointer && CSType != "string") {
|
||||
|
|
|
@ -213,22 +213,6 @@ namespace GtkSharp.Generation {
|
|||
return types [type];
|
||||
}
|
||||
|
||||
public string FromNativeReturn(string c_type, string val)
|
||||
{
|
||||
IGeneratable gen = this[c_type];
|
||||
if (gen == null)
|
||||
return "";
|
||||
return gen.FromNativeReturn (val);
|
||||
}
|
||||
|
||||
public string ToNativeReturn(string c_type, string val)
|
||||
{
|
||||
IGeneratable gen = this[c_type];
|
||||
if (gen == null)
|
||||
return "";
|
||||
return gen.ToNativeReturn (val);
|
||||
}
|
||||
|
||||
public string FromNative(string c_type, string val)
|
||||
{
|
||||
IGeneratable gen = this[c_type];
|
||||
|
@ -253,22 +237,6 @@ namespace GtkSharp.Generation {
|
|||
return gen.Name;
|
||||
}
|
||||
|
||||
public string GetMarshalReturnType(string c_type)
|
||||
{
|
||||
IGeneratable gen = this[c_type];
|
||||
if (gen == null)
|
||||
return "";
|
||||
return gen.MarshalReturnType;
|
||||
}
|
||||
|
||||
public string GetToNativeReturnType(string c_type)
|
||||
{
|
||||
IGeneratable gen = this[c_type];
|
||||
if (gen == null)
|
||||
return "";
|
||||
return gen.ToNativeReturnType;
|
||||
}
|
||||
|
||||
public string GetMarshalType(string c_type)
|
||||
{
|
||||
IGeneratable gen = this[c_type];
|
||||
|
|
Loading…
Reference in a new issue