Browse Source

Removed the TODO-s about marshalling char and bool because those are not bugs.

See https://msdn.microsoft.com/en-us/library/ef4c3t39.aspx and https://msdn.microsoft.com/en-us/library/75dwhxf7.aspx .

Signed-off-by: Dimitar Dobrev <dpldobrev@yahoo.com>
pull/552/merge
Dimitar Dobrev 11 years ago
parent
commit
c28b8db3e5
  1. 8
      src/Generator/Generators/CSharp/CSharpMarshal.cs
  2. 4
      src/Generator/Generators/CSharp/CSharpTextTemplate.cs
  3. 4
      src/Generator/Generators/CSharp/CSharpTypePrinter.cs

8
src/Generator/Generators/CSharp/CSharpMarshal.cs

@ -208,14 +208,14 @@ namespace CppSharp.Generators.CSharp
case PrimitiveType.Void: case PrimitiveType.Void:
return true; return true;
case PrimitiveType.Char: case PrimitiveType.Char:
// TODO: work around https://github.com/dotnet/coreclr/issues/1485 // returned structs must be blittable and char isn't
if (Context.Driver.Options.MarshalCharAsManagedChar) if (Context.Driver.Options.MarshalCharAsManagedChar)
Context.Return.Write("(char) "); Context.Return.Write("(char) ");
goto default; goto default;
case PrimitiveType.Char16: case PrimitiveType.Char16:
return false; return false;
case PrimitiveType.Bool: case PrimitiveType.Bool:
// TODO: work around https://github.com/dotnet/coreclr/issues/1485 // returned structs must be blittable and bool isn't
Context.Return.Write("{0} != 0", Context.ReturnVarName); Context.Return.Write("{0} != 0", Context.ReturnVarName);
return true; return true;
default: default:
@ -538,14 +538,14 @@ namespace CppSharp.Generators.CSharp
case PrimitiveType.Void: case PrimitiveType.Void:
return true; return true;
case PrimitiveType.Char: case PrimitiveType.Char:
// TODO: work around https://github.com/dotnet/coreclr/issues/1485 // returned structs must be blittable and char isn't
if (Context.Driver.Options.MarshalCharAsManagedChar) if (Context.Driver.Options.MarshalCharAsManagedChar)
Context.Return.Write("(sbyte) "); Context.Return.Write("(sbyte) ");
goto default; goto default;
case PrimitiveType.Char16: case PrimitiveType.Char16:
return false; return false;
case PrimitiveType.Bool: case PrimitiveType.Bool:
// TODO: work around https://github.com/dotnet/coreclr/issues/1485 // returned structs must be blittable and bool isn't
Context.Return.Write("(byte) ({0} ? 1 : 0)", Context.Parameter.Name); Context.Return.Write("(byte) ({0} ? 1 : 0)", Context.Parameter.Name);
return true; return true;
default: default:

4
src/Generator/Generators/CSharp/CSharpTextTemplate.cs

@ -2480,7 +2480,7 @@ namespace CppSharp.Generators.CSharp
&& !string.IsNullOrWhiteSpace(param.Context.ArgumentPrefix)) && !string.IsNullOrWhiteSpace(param.Context.ArgumentPrefix))
name.Append(param.Context.ArgumentPrefix); name.Append(param.Context.ArgumentPrefix);
// TODO: work around https://github.com/dotnet/coreclr/issues/1485 // returned structs must be blittable and bool isn't
if ((param.Param.Type.GetFinalPointee() ?? param.Param.Type).IsPrimitiveType(PrimitiveType.Bool)) if ((param.Param.Type.GetFinalPointee() ?? param.Param.Type).IsPrimitiveType(PrimitiveType.Bool))
{ {
var typePrinter = new CSharpTypePrinter(Driver); var typePrinter = new CSharpTypePrinter(Driver);
@ -2664,7 +2664,7 @@ namespace CppSharp.Generators.CSharp
Function function = null) Function function = null)
{ {
PrimitiveType primitive; PrimitiveType primitive;
// TODO: work around https://github.com/dotnet/coreclr/issues/1485 // returned structs must be blittable and bool and char aren't
if (param.Type.IsPrimitiveType(out primitive) && if (param.Type.IsPrimitiveType(out primitive) &&
primitive != PrimitiveType.Char && primitive != PrimitiveType.Bool) primitive != PrimitiveType.Char && primitive != PrimitiveType.Bool)
{ {

4
src/Generator/Generators/CSharp/CSharpTypePrinter.cs

@ -480,13 +480,13 @@ namespace CppSharp.Generators.CSharp
switch (primitive) switch (primitive)
{ {
case PrimitiveType.Bool: case PrimitiveType.Bool:
// TODO: work around https://github.com/dotnet/coreclr/issues/1485 // returned structs must be blittable and bool isn't
return ContextKind == CSharpTypePrinterContextKind.Native ? "byte" : "bool"; return ContextKind == CSharpTypePrinterContextKind.Native ? "byte" : "bool";
case PrimitiveType.Void: return "void"; case PrimitiveType.Void: return "void";
case PrimitiveType.Char16: case PrimitiveType.Char16:
case PrimitiveType.WideChar: return "char"; case PrimitiveType.WideChar: return "char";
case PrimitiveType.Char: case PrimitiveType.Char:
// TODO: work around https://github.com/dotnet/coreclr/issues/1485 // returned structs must be blittable and char isn't
return driver.Options.MarshalCharAsManagedChar && return driver.Options.MarshalCharAsManagedChar &&
ContextKind != CSharpTypePrinterContextKind.Native ContextKind != CSharpTypePrinterContextKind.Native
? "char" ? "char"

Loading…
Cancel
Save