generator: Fix generation of SetGValue method
Some types need special methods to convert an object to a GLib.Value. The type system will look for a SetGValue method with a "ref GLib.Value" parameter and invoke it. A special case in the generation is needed because this is a non-static method with the Handle being passed as the second parameter and the GLib.Value as the first. Without this fix, the generator would generate the Handle for the first parameter and then the GLib.Value. Signed-off-by: Bertrand Lorentz <bertrand.lorentz@gmail.com>
This commit is contained in:
parent
dee590926a
commit
016891bb7a
1 changed files with 17 additions and 3 deletions
|
@ -59,8 +59,8 @@ namespace GtkSharp.Generation {
|
|||
|
||||
SymbolTable table = SymbolTable.Table;
|
||||
|
||||
Method ref_, unref, dispose;
|
||||
GetSpecialMethods (out ref_, out unref, out dispose);
|
||||
Method ref_, unref, dispose, set_gvalue;
|
||||
GetSpecialMethods (out ref_, out unref, out dispose, out set_gvalue);
|
||||
|
||||
if (IsDeprecated)
|
||||
sw.WriteLine ("\t[Obsolete]");
|
||||
|
@ -184,6 +184,17 @@ namespace GtkSharp.Generation {
|
|||
sw.WriteLine ();
|
||||
}
|
||||
#endif
|
||||
if (set_gvalue != null) {
|
||||
sw.WriteLine ("\t\t[DllImport(\"{0}\", CallingConvention = CallingConvention.Cdecl)]", LibraryName);
|
||||
sw.WriteLine ("\t\tstatic extern void {0}(ref GLib.Value val, IntPtr obj);", set_gvalue.CName);
|
||||
sw.WriteLine ();
|
||||
sw.WriteLine ("\t\tpublic void SetGValue (ref GLib.Value val)");
|
||||
sw.WriteLine ("\t\t{");
|
||||
sw.WriteLine ("\t\t\t{0} (ref val, Handle);", set_gvalue.CName);
|
||||
sw.WriteLine ("\t\t}");
|
||||
sw.WriteLine ();
|
||||
}
|
||||
|
||||
sw.WriteLine ("#endregion");
|
||||
|
||||
sw.WriteLine ("\t}");
|
||||
|
@ -194,7 +205,7 @@ namespace GtkSharp.Generation {
|
|||
Statistics.OpaqueCount++;
|
||||
}
|
||||
|
||||
void GetSpecialMethods (out Method ref_, out Method unref, out Method dispose)
|
||||
void GetSpecialMethods (out Method ref_, out Method unref, out Method dispose, out Method set_gvalue)
|
||||
{
|
||||
ref_ = CheckSpecialMethod (GetMethod ("Ref"));
|
||||
unref = CheckSpecialMethod (GetMethod ("Unref"));
|
||||
|
@ -206,6 +217,9 @@ namespace GtkSharp.Generation {
|
|||
dispose = GetMethod ("Dispose");
|
||||
}
|
||||
dispose = CheckSpecialMethod (dispose);
|
||||
|
||||
set_gvalue = GetMethod ("SetGValue");
|
||||
Methods.Remove ("SetGValue");
|
||||
}
|
||||
|
||||
Method CheckSpecialMethod (Method method)
|
||||
|
|
Loading…
Reference in a new issue