From 4193645beb78e56536e4325349627e7be023886e Mon Sep 17 00:00:00 2001 From: triton Date: Wed, 5 Sep 2012 20:07:19 +0100 Subject: [PATCH] Fixed void-return function pointers to use Action. Added a method to check for primitive types. --- src/Bridge/Type.cs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/Bridge/Type.cs b/src/Bridge/Type.cs index a1109843..00d9390b 100644 --- a/src/Bridge/Type.cs +++ b/src/Bridge/Type.cs @@ -13,6 +13,14 @@ namespace Cxxi { } + public bool IsPrimitiveType(PrimitiveType Primitive) + { + var builtin = this as BuiltinType; + if (builtin != null) + return builtin.Type == Primitive; + return false; + } + public override string ToString() { return ToCSharp(); @@ -67,7 +75,10 @@ namespace Cxxi public override string ToCSharp() { - return string.Format("{0}[{1}]", Type, Size); + // C# only supports fixed arrays in unsafe sections + // and they are constrained to a set of built-in types. + + return string.Format("{0}[]", Type); } } @@ -81,6 +92,8 @@ namespace Cxxi public override string ToCSharp() { + if (ReturnType.IsPrimitiveType(PrimitiveType.Void)) + return string.Format("Action"); return string.Format("Func<{0}>", ReturnType); } } @@ -130,6 +143,9 @@ namespace Cxxi if (Pointee is FunctionType) return Pointee.ToCSharp(); + if (Pointee is TagType) + return Pointee.ToCSharp(); + return string.Format("{0}{1}", Pointee, ConvertModifierToString(Modifier)); }