From 7be2a4ef2b0ab5bebb749de81b593604669b3f7d Mon Sep 17 00:00:00 2001 From: triton Date: Wed, 30 Jan 2013 16:06:17 +0000 Subject: [PATCH] Added support for function to instance method conversions in the CLI generator. This boils down to ignoring the first argument when we are generating the method parameters and calling NativePtr when we need access to the first argument. --- src/Generator/Generators/CLI/CLIHelpers.cs | 4 ++++ src/Generator/Generators/CLI/CLIMarshal.cs | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/src/Generator/Generators/CLI/CLIHelpers.cs b/src/Generator/Generators/CLI/CLIHelpers.cs index 231f2237..07938eb1 100644 --- a/src/Generator/Generators/CLI/CLIHelpers.cs +++ b/src/Generator/Generators/CLI/CLIHelpers.cs @@ -438,6 +438,10 @@ namespace Cxxi.Generators.CLI { for (var i = 0; i < method.Parameters.Count; ++i) { + if (method.Conversion == MethodConversionType.FunctionToInstanceMethod + && i == 0) + continue; + var param = method.Parameters[i]; Write("{0}", TypeSig.GetArgumentString(param)); if (i < method.Parameters.Count - 1) diff --git a/src/Generator/Generators/CLI/CLIMarshal.cs b/src/Generator/Generators/CLI/CLIMarshal.cs index 8a801f3c..100b7f15 100644 --- a/src/Generator/Generators/CLI/CLIMarshal.cs +++ b/src/Generator/Generators/CLI/CLIMarshal.cs @@ -436,6 +436,15 @@ namespace Cxxi.Generators.CLI if (!Context.Parameter.Type.IsPointer()) Return.Write("*"); + var method = Context.Function as Method; + if (method != null + && method.Conversion == MethodConversionType.FunctionToInstanceMethod + && Context.ParameterIndex == 0) + { + Return.Write("NativePtr"); + return true; + } + Return.Write("{0}->NativePtr", Context.Parameter.Name); }