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 10 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 @@ -208,14 +208,14 @@ namespace CppSharp.Generators.CSharp
case PrimitiveType.Void:
return true;
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)
Context.Return.Write("(char) ");
goto default;
case PrimitiveType.Char16:
return false;
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);
return true;
default:
@ -538,14 +538,14 @@ namespace CppSharp.Generators.CSharp @@ -538,14 +538,14 @@ namespace CppSharp.Generators.CSharp
case PrimitiveType.Void:
return true;
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)
Context.Return.Write("(sbyte) ");
goto default;
case PrimitiveType.Char16:
return false;
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);
return true;
default:

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

@ -2480,7 +2480,7 @@ namespace CppSharp.Generators.CSharp @@ -2480,7 +2480,7 @@ namespace CppSharp.Generators.CSharp
&& !string.IsNullOrWhiteSpace(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))
{
var typePrinter = new CSharpTypePrinter(Driver);
@ -2664,7 +2664,7 @@ namespace CppSharp.Generators.CSharp @@ -2664,7 +2664,7 @@ namespace CppSharp.Generators.CSharp
Function function = null)
{
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) &&
primitive != PrimitiveType.Char && primitive != PrimitiveType.Bool)
{

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

@ -480,13 +480,13 @@ namespace CppSharp.Generators.CSharp @@ -480,13 +480,13 @@ namespace CppSharp.Generators.CSharp
switch (primitive)
{
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";
case PrimitiveType.Void: return "void";
case PrimitiveType.Char16:
case PrimitiveType.WideChar: return "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 &&
ContextKind != CSharpTypePrinterContextKind.Native
? "char"

Loading…
Cancel
Save