Browse Source

Ensured __int128, __uint128_t and __fp16 are ignored without crashing in the C# generator.

Signed-off-by: Dimitar Dobrev <dpldobrev@protonmail.com>
pull/685/head
Dimitar Dobrev 10 years ago
parent
commit
fa086e086c
  1. 12
      src/Generator/Generators/CSharp/CSharpSources.cs
  2. 3
      src/Generator/Generators/CSharp/CSharpTypePrinter.cs

12
src/Generator/Generators/CSharp/CSharpSources.cs

@ -802,10 +802,14 @@ namespace CppSharp.Generators.CSharp @@ -802,10 +802,14 @@ namespace CppSharp.Generators.CSharp
return;
var arrayType = field.QualifiedType.Type.Desugar() as ArrayType;
// we do not support long double yet because its representation in C# is problematic
if ((arrayType != null && arrayType.SizeType == ArrayType.ArraySize.Constant &&
arrayType.Type.IsPrimitiveType(PrimitiveType.LongDouble)) ||
field.QualifiedType.Type.IsPrimitiveType(PrimitiveType.LongDouble))
var coreType = field.QualifiedType.Type.Desugar();
if (arrayType != null && arrayType.SizeType == ArrayType.ArraySize.Constant)
coreType = arrayType.Type.Desugar();
// we do not support the primitives below yet because their representation in C# is problematic
if (coreType.IsPrimitiveType(PrimitiveType.LongDouble) ||
coreType.IsPrimitiveType(PrimitiveType.Int128) ||
coreType.IsPrimitiveType(PrimitiveType.UInt128) ||
coreType.IsPrimitiveType(PrimitiveType.Half))
return;
var safeIdentifier = Helpers.SafeIdentifier(field.Name);

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

@ -560,6 +560,9 @@ namespace CppSharp.Generators.CSharp @@ -560,6 +560,9 @@ namespace CppSharp.Generators.CSharp
case PrimitiveType.LongLong:
case PrimitiveType.ULongLong:
return GetIntString(primitive, driver.TargetInfo);
case PrimitiveType.Int128: return "__int128";
case PrimitiveType.UInt128: return "__uint128_t";
case PrimitiveType.Half: return "__fp16";
case PrimitiveType.Float: return "float";
case PrimitiveType.Double: return "double";
// not really supported yet but it's closest, and we don't want crashes when parsing long doubles

Loading…
Cancel
Save