Browse Source

Added long doubles to the marshalling structures in the C# generator. (#842)

pull/843/head
Kimon Topouzidis 8 years ago committed by Dimitar Dobrev
parent
commit
797cacadb8
  1. 5
      src/Generator/Generators/CSharp/CSharpSources.cs
  2. 4
      src/Generator/Generators/CSharp/CSharpTypePrinter.cs
  3. 12
      tests/Common/Common.h

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

@ -637,15 +637,14 @@ namespace CppSharp.Generators.CSharp @@ -637,15 +637,14 @@ namespace CppSharp.Generators.CSharp
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) ||
if (coreType.IsPrimitiveType(PrimitiveType.Int128) ||
coreType.IsPrimitiveType(PrimitiveType.UInt128) ||
coreType.IsPrimitiveType(PrimitiveType.Half))
return;
TypePrinterResult retType = TypePrinter.VisitFieldDecl(
new Field { Name = field.Name, QualifiedType = field.QualifiedType });
PushBlock(BlockKind.Field);
if (!Options.GenerateSequentialLayout || @class.IsUnion)

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

@ -517,8 +517,8 @@ namespace CppSharp.Generators.CSharp @@ -517,8 +517,8 @@ namespace CppSharp.Generators.CSharp
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
case PrimitiveType.LongDouble: return "decimal";
case PrimitiveType.LongDouble: return new TypePrinterResult { Type = "fixed byte",
NameSuffix = $"[{Context.TargetInfo.LongDoubleWidth}]"};
case PrimitiveType.IntPtr: return IntPtrType;
case PrimitiveType.UIntPtr: return "global::System.UIntPtr";
case PrimitiveType.Null: return "void*";

12
tests/Common/Common.h

@ -7,6 +7,12 @@ @@ -7,6 +7,12 @@
#include <string>
#include <vector>
class TestPrimitiveTypes
{
public:
long double longDouble;
};
class DLL_API IgnoredType
{
class IgnoredNested
@ -1180,12 +1186,6 @@ class HasSystemBase : public std::string @@ -1180,12 +1186,6 @@ class HasSystemBase : public std::string
typedef SpecialisesVoid<std::vector<std::string>> SpecialisesWithNestedSystemTypes;
struct HasLongDoubles
{
long double simple;
long double array[4];
};
enum
{
EmptyEnumsWithSameMemberPrefix1,

Loading…
Cancel
Save