Browse Source

Added support to generate text before and after the argument in CLIMarshal.cs.

pull/1/head
triton 13 years ago
parent
commit
257a372573
  1. 11
      src/Generator/Generators/CLI/CLIMarshal.cs
  2. 7
      src/Generator/Generators/CLI/CLISourcesTemplate.cs

11
src/Generator/Generators/CLI/CLIMarshal.cs

@ -220,8 +220,10 @@ namespace Cxxi.Generators.CLI
public class CLIMarshalManagedToNativePrinter : ITypeVisitor<bool>, public class CLIMarshalManagedToNativePrinter : ITypeVisitor<bool>,
IDeclVisitor<bool> IDeclVisitor<bool>
{ {
public TextGenerator Support; public TextGenerator SupportBefore;
public TextGenerator SupportAfter;
public TextGenerator Return; public TextGenerator Return;
public TextGenerator ArgumentPrefix;
Generator Generator { get; set; } Generator Generator { get; set; }
MarshalContext Context { get; set; } MarshalContext Context { get; set; }
@ -231,7 +233,8 @@ namespace Cxxi.Generators.CLI
Generator = gen; Generator = gen;
Context = ctx; Context = ctx;
Support = new TextGenerator(); SupportBefore = new TextGenerator();
SupportAfter = new TextGenerator();
Return = new TextGenerator(); Return = new TextGenerator();
} }
@ -291,7 +294,7 @@ namespace Cxxi.Generators.CLI
if (pointee.IsPrimitiveType(PrimitiveType.Char)) if (pointee.IsPrimitiveType(PrimitiveType.Char))
{ {
Support.Write( SupportBefore.Write(
"auto _{0} = clix::marshalString<clix::E_UTF8>({1});", "auto _{0} = clix::marshalString<clix::E_UTF8>({1});",
Context.ArgName, Context.Parameter.Name); Context.ArgName, Context.Parameter.Name);
@ -396,7 +399,7 @@ namespace Cxxi.Generators.CLI
if (Context.Parameter.Type.IsReference()) if (Context.Parameter.Type.IsReference())
{ {
var argName = string.Format("_{0}", Context.ArgName); var argName = string.Format("_{0}", Context.ArgName);
Support.Write("auto {0} = (::{1}*)&{2};", SupportBefore.Write("auto {0} = (::{1}*)&{2};",
argName, @class.OriginalName, argName, @class.OriginalName,
Context.Parameter.Name); Context.Parameter.Name);
Return.Write("*{0}", argName); Return.Write("*{0}", argName);

7
src/Generator/Generators/CLI/CLISourcesTemplate.cs

@ -304,13 +304,14 @@ namespace Cxxi.Generators.CLI
if (string.IsNullOrEmpty(marshal.Return)) if (string.IsNullOrEmpty(marshal.Return))
return null; return null;
if (!string.IsNullOrWhiteSpace(marshal.Support)) if (!string.IsNullOrWhiteSpace(marshal.SupportBefore))
WriteLine(marshal.Support); WriteLine(marshal.SupportBefore);
Write("auto {0} = ", argName); Write("auto {0} = ", argName);
WriteLine("{0};", marshal.Return); WriteLine("{0};", marshal.Return);
@params.Add(new ParamMarshal { Name = argName, Param = param }); if (!string.IsNullOrWhiteSpace(marshal.SupportAfter))
WriteLine(marshal.SupportAfter);
} }
} }

Loading…
Cancel
Save