From fa086e086c340ba331b1a1ded1f20fb512d08f7a Mon Sep 17 00:00:00 2001 From: Dimitar Dobrev Date: Thu, 4 Aug 2016 21:18:33 +0300 Subject: [PATCH] Ensured __int128, __uint128_t and __fp16 are ignored without crashing in the C# generator. Signed-off-by: Dimitar Dobrev --- src/Generator/Generators/CSharp/CSharpSources.cs | 12 ++++++++---- src/Generator/Generators/CSharp/CSharpTypePrinter.cs | 3 +++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/Generator/Generators/CSharp/CSharpSources.cs b/src/Generator/Generators/CSharp/CSharpSources.cs index aa32e2bc..84d342ec 100644 --- a/src/Generator/Generators/CSharp/CSharpSources.cs +++ b/src/Generator/Generators/CSharp/CSharpSources.cs @@ -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); diff --git a/src/Generator/Generators/CSharp/CSharpTypePrinter.cs b/src/Generator/Generators/CSharp/CSharpTypePrinter.cs index cbf732c4..6bd20bcc 100644 --- a/src/Generator/Generators/CSharp/CSharpTypePrinter.cs +++ b/src/Generator/Generators/CSharp/CSharpTypePrinter.cs @@ -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