|
|
@ -1,4 +1,5 @@ |
|
|
|
using CppSharp.AST; |
|
|
|
using CppSharp.AST; |
|
|
|
|
|
|
|
using CppSharp.AST.Extensions; |
|
|
|
using CppSharp.Generators; |
|
|
|
using CppSharp.Generators; |
|
|
|
using CppSharp.Generators.CLI; |
|
|
|
using CppSharp.Generators.CLI; |
|
|
|
using CppSharp.Generators.CSharp; |
|
|
|
using CppSharp.Generators.CSharp; |
|
|
@ -113,6 +114,10 @@ namespace CppSharp.Types.Std |
|
|
|
{ |
|
|
|
{ |
|
|
|
var templateType = Type as TemplateSpecializationType; |
|
|
|
var templateType = Type as TemplateSpecializationType; |
|
|
|
var type = templateType.Arguments[0].Type; |
|
|
|
var type = templateType.Arguments[0].Type; |
|
|
|
|
|
|
|
var isPointerToPrimitive = type.Type.IsPointerToPrimitiveType(); |
|
|
|
|
|
|
|
var managedType = isPointerToPrimitive |
|
|
|
|
|
|
|
? new CILType(typeof(System.IntPtr)) |
|
|
|
|
|
|
|
: type.Type; |
|
|
|
|
|
|
|
|
|
|
|
var entryString = (ctx.Parameter != null) ? ctx.Parameter.Name |
|
|
|
var entryString = (ctx.Parameter != null) ? ctx.Parameter.Name |
|
|
|
: ctx.ArgName; |
|
|
|
: ctx.ArgName; |
|
|
@ -125,7 +130,7 @@ namespace CppSharp.Types.Std |
|
|
|
ctx.SupportBefore.WriteLine("auto {0} = std::vector<{1}>();", |
|
|
|
ctx.SupportBefore.WriteLine("auto {0} = std::vector<{1}>();", |
|
|
|
tmpVarName, nativeType); |
|
|
|
tmpVarName, nativeType); |
|
|
|
ctx.SupportBefore.WriteLine("for each({0} _element in {1})", |
|
|
|
ctx.SupportBefore.WriteLine("for each({0} _element in {1})", |
|
|
|
type.ToString(), entryString); |
|
|
|
managedType, entryString); |
|
|
|
ctx.SupportBefore.WriteStartBraceIndent(); |
|
|
|
ctx.SupportBefore.WriteStartBraceIndent(); |
|
|
|
{ |
|
|
|
{ |
|
|
|
var param = new Parameter |
|
|
|
var param = new Parameter |
|
|
@ -146,6 +151,10 @@ namespace CppSharp.Types.Std |
|
|
|
if (!string.IsNullOrWhiteSpace(marshal.Context.SupportBefore)) |
|
|
|
if (!string.IsNullOrWhiteSpace(marshal.Context.SupportBefore)) |
|
|
|
ctx.SupportBefore.Write(marshal.Context.SupportBefore); |
|
|
|
ctx.SupportBefore.Write(marshal.Context.SupportBefore); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (isPointerToPrimitive) |
|
|
|
|
|
|
|
ctx.SupportBefore.WriteLine("auto _marshalElement = {0}.ToPointer();", |
|
|
|
|
|
|
|
marshal.Context.Return); |
|
|
|
|
|
|
|
else |
|
|
|
ctx.SupportBefore.WriteLine("auto _marshalElement = {0};", |
|
|
|
ctx.SupportBefore.WriteLine("auto _marshalElement = {0};", |
|
|
|
marshal.Context.Return); |
|
|
|
marshal.Context.Return); |
|
|
|
|
|
|
|
|
|
|
@ -162,11 +171,15 @@ namespace CppSharp.Types.Std |
|
|
|
{ |
|
|
|
{ |
|
|
|
var templateType = Type as TemplateSpecializationType; |
|
|
|
var templateType = Type as TemplateSpecializationType; |
|
|
|
var type = templateType.Arguments[0].Type; |
|
|
|
var type = templateType.Arguments[0].Type; |
|
|
|
|
|
|
|
var isPointerToPrimitive = type.Type.IsPointerToPrimitiveType(); |
|
|
|
|
|
|
|
var managedType = isPointerToPrimitive |
|
|
|
|
|
|
|
? new CILType(typeof(System.IntPtr)) |
|
|
|
|
|
|
|
: type.Type; |
|
|
|
var tmpVarName = "_tmp" + ctx.ArgName; |
|
|
|
var tmpVarName = "_tmp" + ctx.ArgName; |
|
|
|
|
|
|
|
|
|
|
|
ctx.SupportBefore.WriteLine( |
|
|
|
ctx.SupportBefore.WriteLine( |
|
|
|
"auto {0} = gcnew System::Collections::Generic::List<{1}>();", |
|
|
|
"auto {0} = gcnew System::Collections::Generic::List<{1}>();", |
|
|
|
tmpVarName, type.ToString()); |
|
|
|
tmpVarName, managedType); |
|
|
|
ctx.SupportBefore.WriteLine("for(auto _element : {0})", |
|
|
|
ctx.SupportBefore.WriteLine("for(auto _element : {0})", |
|
|
|
ctx.ReturnVarName); |
|
|
|
ctx.ReturnVarName); |
|
|
|
ctx.SupportBefore.WriteStartBraceIndent(); |
|
|
|
ctx.SupportBefore.WriteStartBraceIndent(); |
|
|
@ -186,6 +199,10 @@ namespace CppSharp.Types.Std |
|
|
|
ctx.SupportBefore.WriteLine("auto _marshalElement = {0};", |
|
|
|
ctx.SupportBefore.WriteLine("auto _marshalElement = {0};", |
|
|
|
marshal.Context.Return); |
|
|
|
marshal.Context.Return); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (isPointerToPrimitive) |
|
|
|
|
|
|
|
ctx.SupportBefore.WriteLine("{0}->Add({1}(_marshalElement));", |
|
|
|
|
|
|
|
tmpVarName, managedType); |
|
|
|
|
|
|
|
else |
|
|
|
ctx.SupportBefore.WriteLine("{0}->Add(_marshalElement);", |
|
|
|
ctx.SupportBefore.WriteLine("{0}->Add(_marshalElement);", |
|
|
|
tmpVarName); |
|
|
|
tmpVarName); |
|
|
|
} |
|
|
|
} |
|
|
@ -276,4 +293,23 @@ namespace CppSharp.Types.Std |
|
|
|
throw new System.NotImplementedException(); |
|
|
|
throw new System.NotImplementedException(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[TypeMap("std::ostream")] |
|
|
|
|
|
|
|
public class OStream : TypeMap |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
public override string CLISignature(CLITypePrinterContext ctx) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return "System::IO::TextWriter^"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public override void CLIMarshalToNative(MarshalContext ctx) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
var marshal = ctx.MarshalToNative as CLIMarshalManagedToNativePrinter; |
|
|
|
|
|
|
|
marshal.ArgumentPrefix.Write("*"); |
|
|
|
|
|
|
|
var marshalCtxName = string.Format("ctx_{0}", ctx.Parameter.Name); |
|
|
|
|
|
|
|
ctx.SupportBefore.WriteLine("msclr::interop::marshal_context {0};", marshalCtxName); |
|
|
|
|
|
|
|
ctx.Return.Write("{0}.marshal_as<std::ostream*>({1})", |
|
|
|
|
|
|
|
marshalCtxName, ctx.Parameter.Name); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|