Browse Source

Fixed marshaling of reference parameters.

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

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

@ -233,6 +233,7 @@ namespace Cxxi.Generators.CLI
public TextGenerator SupportBefore; public TextGenerator SupportBefore;
public TextGenerator SupportAfter; public TextGenerator SupportAfter;
public TextGenerator Return; public TextGenerator Return;
public TextGenerator VarPrefix;
public TextGenerator ArgumentPrefix; public TextGenerator ArgumentPrefix;
ITypeMapDatabase TypeMapDatabase { get; set; } ITypeMapDatabase TypeMapDatabase { get; set; }
@ -247,6 +248,7 @@ namespace Cxxi.Generators.CLI
SupportBefore = new TextGenerator(); SupportBefore = new TextGenerator();
SupportAfter = new TextGenerator(); SupportAfter = new TextGenerator();
Return = new TextGenerator(); Return = new TextGenerator();
VarPrefix = new TextGenerator();
ArgumentPrefix = new TextGenerator(); ArgumentPrefix = new TextGenerator();
} }
@ -426,8 +428,13 @@ namespace Cxxi.Generators.CLI
private void MarshalRefClass(Class @class) private void MarshalRefClass(Class @class)
{ {
if (!Context.Parameter.Type.IsPointer()) if (!Context.Parameter.Type.IsPointer())
{
Return.Write("*"); Return.Write("*");
if (Context.Parameter.Type.IsReference())
VarPrefix.Write("&");
}
var method = Context.Function as Method; var method = Context.Function as Method;
if (method != null if (method != null
&& method.Conversion == MethodConversionKind.FunctionToInstanceMethod && method.Conversion == MethodConversionKind.FunctionToInstanceMethod

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

@ -403,7 +403,7 @@ namespace Cxxi.Generators.CLI
if (!string.IsNullOrWhiteSpace(marshal.SupportBefore)) if (!string.IsNullOrWhiteSpace(marshal.SupportBefore))
WriteLine(marshal.SupportBefore); WriteLine(marshal.SupportBefore);
WriteLine("auto {0} = {1};", argName, marshal.Return); WriteLine("auto {0}{1} = {2};", marshal.VarPrefix, argName, marshal.Return);
if (!string.IsNullOrWhiteSpace(marshal.SupportAfter)) if (!string.IsNullOrWhiteSpace(marshal.SupportAfter))
WriteLine(marshal.SupportAfter); WriteLine(marshal.SupportAfter);

Loading…
Cancel
Save