|
|
|
@ -186,13 +186,39 @@ namespace CppSharp
@@ -186,13 +186,39 @@ namespace CppSharp
|
|
|
|
|
|
|
|
|
|
if (@enum.Items.Count > 0) |
|
|
|
|
{ |
|
|
|
|
@enum.BuiltinType = new BuiltinType(GetUnderlyingTypeForEnumValue(maxValue)); |
|
|
|
|
@enum.Type = @enum.BuiltinType; |
|
|
|
|
@enum.Namespace = unitToAttach; |
|
|
|
|
|
|
|
|
|
unitToAttach.Declarations.Add(@enum); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return @enum; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private static PrimitiveType GetUnderlyingTypeForEnumValue(ulong maxValue) |
|
|
|
|
{ |
|
|
|
|
if (maxValue < (byte)sbyte.MaxValue) |
|
|
|
|
return PrimitiveType.SChar; |
|
|
|
|
|
|
|
|
|
if (maxValue < byte.MaxValue) |
|
|
|
|
return PrimitiveType.UChar; |
|
|
|
|
|
|
|
|
|
if (maxValue < (ushort)short.MaxValue) |
|
|
|
|
return PrimitiveType.Short; |
|
|
|
|
|
|
|
|
|
if (maxValue < ushort.MaxValue) |
|
|
|
|
return PrimitiveType.UShort; |
|
|
|
|
|
|
|
|
|
if (maxValue < int.MaxValue) |
|
|
|
|
return PrimitiveType.Int; |
|
|
|
|
|
|
|
|
|
if (maxValue < uint.MaxValue) |
|
|
|
|
return PrimitiveType.UInt; |
|
|
|
|
|
|
|
|
|
throw new NotImplementedException(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Class Helpers
|
|
|
|
|