From 896ddae3c5a06e43862c7e21859f1ec8195611d9 Mon Sep 17 00:00:00 2001 From: Maarten Bosmans Date: Fri, 12 Jun 2009 16:37:08 +0200 Subject: [PATCH] Fix generator to use MiniObject.OwnedHandle for parameters with owned="true" --- generator/MiniObjectGen.cs | 5 +++++ generator/ObjectGen.cs | 5 +++++ generator/Parameters.cs | 6 +++++- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/generator/MiniObjectGen.cs b/generator/MiniObjectGen.cs index 308308d..c44f59c 100644 --- a/generator/MiniObjectGen.cs +++ b/generator/MiniObjectGen.cs @@ -312,6 +312,11 @@ namespace GtkSharp.Generation { sw.Close (); } + public string CallByName (string name, bool owned) + { + return name + " == null ? IntPtr.Zero : " + name + (owned ? ".OwnedHandle" : ".Handle"); + } + public override string FromNative (string var, bool owned) { return "Gst.MiniObject.GetObject(" + var + (owned ? ", true" : "") + ") as " + QualifiedName; diff --git a/generator/ObjectGen.cs b/generator/ObjectGen.cs index 7a7d561..74a6da7 100644 --- a/generator/ObjectGen.cs +++ b/generator/ObjectGen.cs @@ -411,6 +411,11 @@ namespace GtkSharp.Generation { sw.WriteLine ("}"); sw.Close (); } + + public string CallByName (string name, bool owned) + { + return name + " == null ? IntPtr.Zero : " + name + (owned ? ".OwnedHandle" : ".Handle"); + } } } diff --git a/generator/Parameters.cs b/generator/Parameters.cs index a7effc8..ec131b5 100644 --- a/generator/Parameters.cs +++ b/generator/Parameters.cs @@ -262,8 +262,12 @@ namespace GtkSharp.Generation { call_parm += CallName; } else if (gen is IManualMarshaler) call_parm = "native_" + CallName; + else if (gen is MiniObjectGen) + call_parm = ((MiniObjectGen) gen).CallByName(CallName, Owned); + else if (gen is ObjectGen) + call_parm = ((ObjectGen) gen).CallByName(CallName, Owned); else - call_parm = SymbolTable.Table.CallByName(CType, CallName); + call_parm = gen.CallByName(CallName); return call_parm; } -- 2.7.4