Browse Source

Fixed void-return function pointers to use Action. Added a method to check for primitive types.

pull/1/head
triton 13 years ago
parent
commit
4193645beb
  1. 18
      src/Bridge/Type.cs

18
src/Bridge/Type.cs

@ -13,6 +13,14 @@ namespace Cxxi @@ -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 @@ -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 @@ -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 @@ -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));
}

Loading…
Cancel
Save