Working types now allow implicit conversions from longs.
This commit is contained in:
parent
01914552de
commit
c76d850687
|
@ -1,52 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
|
||||
using BizHawk.Common.ReflectionExtensions;
|
||||
using BizHawk.Emulation.Common;
|
||||
using BizHawk.Client.ApiHawk;
|
||||
|
||||
namespace BizHawk.Client.EmuHawk
|
||||
|
||||
{
|
||||
public static class ApiManager
|
||||
{
|
||||
private static ApiContainer container;
|
||||
private static void Register(IEmulatorServiceProvider serviceProvider)
|
||||
{
|
||||
// Register external apis
|
||||
var libs = Assembly
|
||||
.Load("BizHawk.Client.ApiHawk")
|
||||
.GetTypes()
|
||||
.Where(t => typeof(IExternalApi).IsAssignableFrom(t))
|
||||
.Where(t => t.IsSealed)
|
||||
.Where(t => ServiceInjector.IsAvailable(serviceProvider, t))
|
||||
.ToList();
|
||||
|
||||
libs.AddRange(
|
||||
Assembly
|
||||
.GetAssembly(typeof(ApiContainer))
|
||||
.GetTypes()
|
||||
.Where(t => typeof(IExternalApi).IsAssignableFrom(t))
|
||||
.Where(t => t.IsSealed)
|
||||
.Where(t => ServiceInjector.IsAvailable(serviceProvider, t)));
|
||||
|
||||
foreach (var lib in libs)
|
||||
{
|
||||
var instance = (IExternalApi)Activator.CreateInstance(lib);
|
||||
ServiceInjector.UpdateServices(serviceProvider, instance);
|
||||
Libraries.Add(lib, instance);
|
||||
}
|
||||
container = new ApiContainer(Libraries);
|
||||
GlobalWin.ApiProvider = new BasicApiProvider(container);
|
||||
}
|
||||
private static readonly Dictionary<Type, IExternalApi> Libraries = new Dictionary<Type, IExternalApi>();
|
||||
public static void Restart(IEmulatorServiceProvider newServiceProvider)
|
||||
{
|
||||
Libraries.Clear();
|
||||
Register(newServiceProvider);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -14,7 +14,11 @@ namespace BizHawk.Emulation.Common.WorkingTypes
|
|||
private Byte val;
|
||||
public const Byte MaxValue = Byte.MaxValue;
|
||||
public const Byte MinValue = Byte.MinValue;
|
||||
public static implicit operator wbyte(uint value)
|
||||
public static implicit operator wbyte(ulong value)
|
||||
{
|
||||
return new wbyte(value);
|
||||
}
|
||||
public static implicit operator wbyte(wushort value)
|
||||
{
|
||||
return new wbyte(value);
|
||||
}
|
||||
|
@ -26,33 +30,33 @@ namespace BizHawk.Emulation.Common.WorkingTypes
|
|||
{
|
||||
|
||||
}
|
||||
public wbyte(uint value)
|
||||
public wbyte(ulong value)
|
||||
{
|
||||
val = (Byte)(value & 0xFF);
|
||||
}
|
||||
public wbyte(int value)
|
||||
public wbyte(long value)
|
||||
{
|
||||
val = (Byte)(value & 0xFF);
|
||||
}
|
||||
public wbyte(double value)
|
||||
{
|
||||
val = (Byte)(((int)value) & 0xFF);
|
||||
val = (Byte)(((long)value) & 0xFF);
|
||||
}
|
||||
public static wbyte Parse(string s, NumberStyles style, IFormatProvider provider)
|
||||
{
|
||||
return (uint)Byte.Parse(s, style, provider);
|
||||
return (ulong)Byte.Parse(s, style, provider);
|
||||
}
|
||||
public static wbyte Parse(string s, IFormatProvider provider)
|
||||
{
|
||||
return (uint)Byte.Parse(s, provider);
|
||||
return (ulong)Byte.Parse(s, provider);
|
||||
}
|
||||
public static wbyte Parse(string s)
|
||||
{
|
||||
return (uint)Byte.Parse(s);
|
||||
return (ulong)Byte.Parse(s);
|
||||
}
|
||||
public static wbyte Parse(string s, NumberStyles style)
|
||||
{
|
||||
return (uint)Byte.Parse(s, style);
|
||||
return (ulong)Byte.Parse(s, style);
|
||||
}
|
||||
public static bool TryParse(string s, out wbyte result)
|
||||
{
|
||||
|
|
|
@ -13,7 +13,7 @@ namespace BizHawk.Emulation.Common.WorkingTypes
|
|||
private SByte val;
|
||||
public const SByte MaxValue = SByte.MaxValue;
|
||||
public const SByte MinValue = SByte.MinValue;
|
||||
public static implicit operator wsbyte(int value)
|
||||
public static implicit operator wsbyte(long value)
|
||||
{
|
||||
return new wsbyte(value);
|
||||
}
|
||||
|
@ -25,33 +25,33 @@ namespace BizHawk.Emulation.Common.WorkingTypes
|
|||
{
|
||||
|
||||
}
|
||||
public wsbyte(int value)
|
||||
public wsbyte(long value)
|
||||
{
|
||||
val = (SByte)(value & 0xFF);
|
||||
}
|
||||
public wsbyte(uint value)
|
||||
public wsbyte(ulong value)
|
||||
{
|
||||
val = (SByte)(value & 0xFF);
|
||||
}
|
||||
public wsbyte(double value)
|
||||
{
|
||||
val = (SByte)(((uint)value) & 0xFF);
|
||||
val = (SByte)(((ulong)value) & 0xFF);
|
||||
}
|
||||
public static wsbyte Parse(string s, NumberStyles style, IFormatProvider provider)
|
||||
{
|
||||
return (int)SByte.Parse(s, style, provider);
|
||||
return (long)SByte.Parse(s, style, provider);
|
||||
}
|
||||
public static wsbyte Parse(string s, IFormatProvider provider)
|
||||
{
|
||||
return (int)SByte.Parse(s, provider);
|
||||
return (long)SByte.Parse(s, provider);
|
||||
}
|
||||
public static wsbyte Parse(string s)
|
||||
{
|
||||
return (int)SByte.Parse(s);
|
||||
return (long)SByte.Parse(s);
|
||||
}
|
||||
public static wsbyte Parse(string s, NumberStyles style)
|
||||
{
|
||||
return (int)SByte.Parse(s, style);
|
||||
return (long)SByte.Parse(s, style);
|
||||
}
|
||||
public static bool TryParse(string s, out wsbyte result)
|
||||
{
|
||||
|
|
|
@ -13,7 +13,7 @@ namespace BizHawk.Emulation.Common.WorkingTypes
|
|||
private Int16 val;
|
||||
public const Int16 MaxValue = Int16.MaxValue;
|
||||
public const Int16 MinValue = Int16.MinValue;
|
||||
public static implicit operator wshort(int value)
|
||||
public static implicit operator wshort(long value)
|
||||
{
|
||||
return new wshort(value);
|
||||
}
|
||||
|
@ -25,33 +25,33 @@ namespace BizHawk.Emulation.Common.WorkingTypes
|
|||
{
|
||||
|
||||
}
|
||||
public wshort(int value)
|
||||
public wshort(long value)
|
||||
{
|
||||
val = (Int16)(value & 0xFFFF);
|
||||
}
|
||||
public wshort(uint value)
|
||||
public wshort(ulong value)
|
||||
{
|
||||
val = (Int16)(value & 0xFFFF);
|
||||
}
|
||||
public wshort(double value)
|
||||
{
|
||||
val = (Int16)(((uint)value) & 0xFFFF);
|
||||
val = (Int16)(((ulong)value) & 0xFFFF);
|
||||
}
|
||||
public static wshort Parse(string s, NumberStyles style, IFormatProvider provider)
|
||||
{
|
||||
return (int)Int16.Parse(s, style, provider);
|
||||
return (long)Int16.Parse(s, style, provider);
|
||||
}
|
||||
public static wshort Parse(string s, IFormatProvider provider)
|
||||
{
|
||||
return (int)Int16.Parse(s, provider);
|
||||
return (long)Int16.Parse(s, provider);
|
||||
}
|
||||
public static wshort Parse(string s)
|
||||
{
|
||||
return (int)Int16.Parse(s);
|
||||
return (long)Int16.Parse(s);
|
||||
}
|
||||
public static wshort Parse(string s, NumberStyles style)
|
||||
{
|
||||
return (int)Int16.Parse(s, style);
|
||||
return (long)Int16.Parse(s, style);
|
||||
}
|
||||
public static bool TryParse(string s, out wshort result)
|
||||
{
|
||||
|
|
|
@ -14,11 +14,15 @@ namespace BizHawk.Emulation.Common.WorkingTypes
|
|||
private UInt16 val;
|
||||
public const UInt16 MaxValue = UInt16.MaxValue;
|
||||
public const UInt16 MinValue = UInt16.MinValue;
|
||||
public static implicit operator wushort(uint value)
|
||||
public static implicit operator wushort(ulong value)
|
||||
{
|
||||
return new wushort(value);
|
||||
}
|
||||
public static implicit operator ushort(wushort value)
|
||||
public static implicit operator wushort(wbyte value)
|
||||
{
|
||||
return new wushort(value);
|
||||
}
|
||||
public static implicit operator UInt16(wushort value)
|
||||
{
|
||||
return value.val;
|
||||
}
|
||||
|
@ -26,17 +30,17 @@ namespace BizHawk.Emulation.Common.WorkingTypes
|
|||
{
|
||||
|
||||
}
|
||||
public wushort(uint value)
|
||||
public wushort(ulong value)
|
||||
{
|
||||
val = (UInt16)(value & 0xFFFF);
|
||||
}
|
||||
public wushort(int value)
|
||||
public wushort(long value)
|
||||
{
|
||||
val = (UInt16)(value & 0xFFFF);
|
||||
}
|
||||
public wushort(double value)
|
||||
{
|
||||
val = (UInt16)(((int)value) & 0xFFFF);
|
||||
val = (UInt16)(((long)value) & 0xFFFF);
|
||||
}
|
||||
public static wushort Parse(string s, NumberStyles style, IFormatProvider provider)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue