Browse Source

Fixed marshaling of C++ references.

pull/1/head
triton 13 years ago
parent
commit
da2030c25c
  1. 18
      src/Generator/Generators/CLI/CLIMarshal.cs

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

@ -57,9 +57,6 @@ namespace Cxxi.Generators.CLI
if (!pointee.Visit(this, quals)) if (!pointee.Visit(this, quals))
return false; return false;
if (pointer.IsReference)
Return = string.Format("&{0}", Return);
return true; return true;
} }
@ -165,7 +162,8 @@ namespace Cxxi.Generators.CLI
public bool VisitEnumDecl(Enumeration @enum) public bool VisitEnumDecl(Enumeration @enum)
{ {
Return = string.Format("({0}){1}", ToCLITypeName(@enum), Context.ReturnVarName); Return = string.Format("({0}){1}", ToCLITypeName(@enum),
Context.ReturnVarName);
return true; return true;
} }
@ -354,10 +352,22 @@ namespace Cxxi.Generators.CLI
public bool VisitClassDecl(Class @class) public bool VisitClassDecl(Class @class)
{ {
if (@class.IsValueType) if (@class.IsValueType)
{
if (Context.Parameter.Type.IsReference())
{
var argName = string.Format("_{0}", Context.ArgName);
Support = string.Format("auto {0} = (::{1}*)&{2};",
argName, @class.OriginalName,
Context.Parameter.Name);
Return = string.Format("*{0}", argName);
}
else
{ {
Return = string.Format("(::{0}*)&{1}", @class.OriginalName, Return = string.Format("(::{0}*)&{1}", @class.OriginalName,
Context.Parameter.Name); Context.Parameter.Name);
} }
}
else else
{ {
Return = string.Format("{0}->NativePtr", Context.Parameter.Name); Return = string.Format("{0}->NativePtr", Context.Parameter.Name);

Loading…
Cancel
Save