|
|
@ -644,7 +644,7 @@ namespace Cxxi.Generators.CLI |
|
|
|
var @params = GenerateFunctionParamsMarshal(function.Parameters, function); |
|
|
|
var @params = GenerateFunctionParamsMarshal(function.Parameters, function); |
|
|
|
|
|
|
|
|
|
|
|
if (needsReturn) |
|
|
|
if (needsReturn) |
|
|
|
Write("auto ret = "); |
|
|
|
Write("auto {0}ret = ",(function.ReturnType.IsReference())? "&": string.Empty); |
|
|
|
|
|
|
|
|
|
|
|
if (isValueType) |
|
|
|
if (isValueType) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -668,6 +668,30 @@ namespace Cxxi.Generators.CLI |
|
|
|
GenerateFunctionParams(@params); |
|
|
|
GenerateFunctionParams(@params); |
|
|
|
WriteLine(");"); |
|
|
|
WriteLine(");"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach(var paramInfo in @params) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
var param = paramInfo.Param; |
|
|
|
|
|
|
|
if(param.Usage != ParameterUsage.Out && param.Usage != ParameterUsage.Ref) |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var nativeVarName = paramInfo.Name; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var ctx = new MarshalContext(Driver) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
ArgName = nativeVarName, |
|
|
|
|
|
|
|
ReturnVarName = nativeVarName, |
|
|
|
|
|
|
|
ReturnType = param.Type |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var marshal = new CLIMarshalNativeToManagedPrinter(ctx); |
|
|
|
|
|
|
|
param.Visit(marshal); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(marshal.Context.SupportBefore)) |
|
|
|
|
|
|
|
Write(marshal.Context.SupportBefore); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
WriteLine("{0} = {1};",param.Name,marshal.Context.Return); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (needsReturn) |
|
|
|
if (needsReturn) |
|
|
|
{ |
|
|
|
{ |
|
|
|
var ctx = new MarshalContext(Driver) |
|
|
|
var ctx = new MarshalContext(Driver) |
|
|
@ -728,28 +752,42 @@ namespace Cxxi.Generators.CLI |
|
|
|
|
|
|
|
|
|
|
|
var argName = "arg" + paramIndex.ToString(CultureInfo.InvariantCulture); |
|
|
|
var argName = "arg" + paramIndex.ToString(CultureInfo.InvariantCulture); |
|
|
|
|
|
|
|
|
|
|
|
var ctx = new MarshalContext(Driver) |
|
|
|
if (param.Usage == ParameterUsage.Out) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Parameter = param, |
|
|
|
var paramType = param.Type; |
|
|
|
ParameterIndex = paramIndex, |
|
|
|
if (paramType.IsReference()) |
|
|
|
ArgName = argName, |
|
|
|
paramType = (paramType as PointerType).Pointee; |
|
|
|
Function = function |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var marshal = new CLIMarshalManagedToNativePrinter(ctx); |
|
|
|
var typePrinter = new CppTypePrinter(Driver.TypeDatabase); |
|
|
|
|
|
|
|
var type = paramType.Visit(typePrinter); |
|
|
|
|
|
|
|
|
|
|
|
param.Visit(marshal); |
|
|
|
WriteLine("{0} {1};", type, argName); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
var ctx = new MarshalContext(Driver) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
Parameter = param, |
|
|
|
|
|
|
|
ParameterIndex = paramIndex, |
|
|
|
|
|
|
|
ArgName = argName, |
|
|
|
|
|
|
|
Function = function |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(marshal.Context.Return)) |
|
|
|
var marshal = new CLIMarshalManagedToNativePrinter(ctx); |
|
|
|
throw new Exception("Cannot marshal argument of function"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(marshal.Context.SupportBefore)) |
|
|
|
param.Visit(marshal); |
|
|
|
Write(marshal.Context.SupportBefore); |
|
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(marshal.Context.Return)) |
|
|
|
|
|
|
|
throw new Exception("Cannot marshal argument of function"); |
|
|
|
|
|
|
|
|
|
|
|
WriteLine("auto {0}{1} = {2};", marshal.VarPrefix, argName, marshal.Context.Return); |
|
|
|
if (!string.IsNullOrWhiteSpace(marshal.Context.SupportBefore)) |
|
|
|
|
|
|
|
Write(marshal.Context.SupportBefore); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
WriteLine("auto {0}{1} = {2};", marshal.VarPrefix, argName, marshal.Context.Return); |
|
|
|
|
|
|
|
argName = marshal.ArgumentPrefix + argName; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var argText = marshal.ArgumentPrefix + argName; |
|
|
|
return new ParamMarshal {Name = argName, Param = param}; |
|
|
|
return new ParamMarshal {Name = argText, Param = param}; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void GenerateFunctionParams(List<ParamMarshal> @params) |
|
|
|
public void GenerateFunctionParams(List<ParamMarshal> @params) |
|
|
|