|
|
|
@ -60,10 +60,11 @@ namespace CppSharp.Generators.CLI
@@ -60,10 +60,11 @@ namespace CppSharp.Generators.CLI
|
|
|
|
|
// const char* and const char[] are the same so we can use a string
|
|
|
|
|
if (array.Type.Desugar().IsPrimitiveType(PrimitiveType.Char) && |
|
|
|
|
array.QualifiedType.Qualifiers.IsConst) |
|
|
|
|
return VisitPointerType(new PointerType |
|
|
|
|
{ |
|
|
|
|
QualifiedPointee = array.QualifiedType |
|
|
|
|
}, quals); |
|
|
|
|
{ |
|
|
|
|
var pointer = new PointerType { QualifiedPointee = array.QualifiedType }; |
|
|
|
|
Context.ReturnType = new QualifiedType(pointer); |
|
|
|
|
return this.VisitPointerType(pointer, quals); |
|
|
|
|
} |
|
|
|
|
goto case ArrayType.ArraySize.Variable; |
|
|
|
|
|
|
|
|
|
case ArrayType.ArraySize.Variable: |
|
|
|
@ -100,13 +101,6 @@ namespace CppSharp.Generators.CLI
@@ -100,13 +101,6 @@ namespace CppSharp.Generators.CLI
|
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (pointer.IsConstCharString()) |
|
|
|
|
{ |
|
|
|
|
Context.Return.Write(MarshalStringToManaged(Context.ReturnVarName, |
|
|
|
|
pointer.Pointee.Desugar() as BuiltinType)); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
PrimitiveType primitive; |
|
|
|
|
var param = Context.Parameter; |
|
|
|
|
if (param != null && (param.IsOut || param.IsInOut) && |
|
|
|
@ -167,29 +161,6 @@ namespace CppSharp.Generators.CLI
@@ -167,29 +161,6 @@ namespace CppSharp.Generators.CLI
|
|
|
|
|
return pointer.QualifiedPointee.Visit(this); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private string MarshalStringToManaged(string varName, BuiltinType type) |
|
|
|
|
{ |
|
|
|
|
var encoding = type.Type == PrimitiveType.Char ? |
|
|
|
|
Encoding.ASCII : Encoding.Unicode; |
|
|
|
|
|
|
|
|
|
if (Equals(encoding, Encoding.ASCII)) |
|
|
|
|
encoding = Context.Context.Options.Encoding; |
|
|
|
|
|
|
|
|
|
string param; |
|
|
|
|
if (Equals(encoding, Encoding.ASCII)) |
|
|
|
|
param = "E_UTF8"; |
|
|
|
|
else if (Equals(encoding, Encoding.Unicode) || |
|
|
|
|
Equals(encoding, Encoding.BigEndianUnicode)) |
|
|
|
|
param = "E_UTF16"; |
|
|
|
|
else |
|
|
|
|
throw new NotSupportedException(string.Format("{0} is not supported yet.", |
|
|
|
|
Context.Context.Options.Encoding.EncodingName)); |
|
|
|
|
|
|
|
|
|
return string.Format( |
|
|
|
|
"({0} == 0 ? nullptr : clix::marshalString<clix::{1}>({0}))", |
|
|
|
|
varName, param); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public override bool VisitMemberPointerType(MemberPointerType member, |
|
|
|
|
TypeQualifiers quals) |
|
|
|
|
{ |
|
|
|
@ -513,18 +484,6 @@ namespace CppSharp.Generators.CLI
@@ -513,18 +484,6 @@ namespace CppSharp.Generators.CLI
|
|
|
|
|
|
|
|
|
|
var pointee = pointer.Pointee.Desugar(); |
|
|
|
|
|
|
|
|
|
if ((pointee.IsPrimitiveType(PrimitiveType.Char) || |
|
|
|
|
pointee.IsPrimitiveType(PrimitiveType.WideChar)) && |
|
|
|
|
pointer.QualifiedPointee.Qualifiers.IsConst) |
|
|
|
|
{ |
|
|
|
|
Context.Before.WriteLine( |
|
|
|
|
"auto _{0} = clix::marshalString<clix::E_UTF8>({1});", |
|
|
|
|
Context.ArgName, Context.Parameter.Name); |
|
|
|
|
|
|
|
|
|
Context.Return.Write("_{0}.c_str()", Context.ArgName); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (pointee is FunctionType) |
|
|
|
|
{ |
|
|
|
|
var cppTypePrinter = new CppTypePrinter(); |
|
|
|
|