Rename PlatformLinkedLibSingleton and children

This commit is contained in:
YoshiRulz 2019-05-18 15:38:51 +10:00
parent d76e1a8a8b
commit 58c738957c
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
14 changed files with 38 additions and 38 deletions

View File

@ -89,7 +89,7 @@ namespace SevenZip
// private static string _LibraryVersion;
private static bool? _modifyCapabale;
private static readonly PlatformLinkedLibSingleton.PlatformLinkedLibManager libLoader = PlatformLinkedLibSingleton.LinkedLibManager;
private static readonly OSTailoredCode.ILinkedLibManager libLoader = OSTailoredCode.LinkedLibManager;
private static void InitUserInFormat(object user, InArchiveFormat format)
{

View File

@ -113,8 +113,8 @@
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\BizHawk.Common\PlatformLinkedLibSingleton.cs">
<Link>PlatformLinkedLibSingleton.cs</Link>
<Compile Include="..\BizHawk.Common\OSTailoredCode.cs">
<Link>OSTailoredCode.cs</Link>
</Compile>
<Compile Include="..\Version\svnrev.cs">
<Link>svnrev.cs</Link>
@ -2283,4 +2283,4 @@
<PreBuildEvent />
</PropertyGroup>
<Import Project="$(SolutionDir)Build\Common.targets" />
</Project>
</Project>

View File

@ -123,7 +123,7 @@ namespace BizHawk.Client.EmuHawk
public static void Initialize()
{
if (PlatformLinkedLibSingleton.CurrentOS == PlatformLinkedLibSingleton.DistinctOS.Windows)
if (OSTailoredCode.CurrentOS == OSTailoredCode.DistinctOS.Windows)
{
KeyInput.Initialize();
IPCKeyInput.Initialize();
@ -140,7 +140,7 @@ namespace BizHawk.Client.EmuHawk
public static void Cleanup()
{
if (PlatformLinkedLibSingleton.CurrentOS == PlatformLinkedLibSingleton.DistinctOS.Windows)
if (OSTailoredCode.CurrentOS == OSTailoredCode.DistinctOS.Windows)
{
KeyInput.Cleanup();
GamePad.Cleanup();
@ -331,10 +331,10 @@ namespace BizHawk.Client.EmuHawk
{
while (true)
{
var keyEvents = PlatformLinkedLibSingleton.CurrentOS == PlatformLinkedLibSingleton.DistinctOS.Windows
var keyEvents = OSTailoredCode.CurrentOS == OSTailoredCode.DistinctOS.Windows
? KeyInput.Update().Concat(IPCKeyInput.Update())
: OTK_Keyboard.Update();
if (PlatformLinkedLibSingleton.CurrentOS == PlatformLinkedLibSingleton.DistinctOS.Windows)
if (OSTailoredCode.CurrentOS == OSTailoredCode.DistinctOS.Windows)
{
GamePad.UpdateAll();
GamePad360.UpdateAll();

View File

@ -22,9 +22,9 @@ namespace BizHawk.Client.EmuHawk
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
if (EXE_PROJECT.PlatformLinkedLibSingleton.CurrentOS == EXE_PROJECT.PlatformLinkedLibSingleton.DistinctOS.Windows)
if (EXE_PROJECT.OSTailoredCode.CurrentOS == EXE_PROJECT.OSTailoredCode.DistinctOS.Windows)
{
var libLoader = EXE_PROJECT.PlatformLinkedLibSingleton.LinkedLibManager;
var libLoader = EXE_PROJECT.OSTailoredCode.LinkedLibManager;
//http://www.codeproject.com/Articles/310675/AppDomain-AssemblyResolve-Event-Tips
@ -141,7 +141,7 @@ namespace BizHawk.Client.EmuHawk
GlobalWin.GLManager = GLManager.Instance;
//now create the "GL" context for the display method. we can reuse the IGL_TK context if opengl display method is chosen
if (EXE_PROJECT.PlatformLinkedLibSingleton.CurrentOS != EXE_PROJECT.PlatformLinkedLibSingleton.DistinctOS.Windows)
if (EXE_PROJECT.OSTailoredCode.CurrentOS != EXE_PROJECT.OSTailoredCode.DistinctOS.Windows)
Global.Config.DispMethod = Config.EDispMethod.GdiPlus;
REDO_DISPMETHOD:
@ -189,7 +189,7 @@ REDO_DISPMETHOD:
goto REDO_DISPMETHOD;
}
if (EXE_PROJECT.PlatformLinkedLibSingleton.CurrentOS == EXE_PROJECT.PlatformLinkedLibSingleton.DistinctOS.Windows)
if (EXE_PROJECT.OSTailoredCode.CurrentOS == EXE_PROJECT.OSTailoredCode.DistinctOS.Windows)
{
//WHY do we have to do this? some intel graphics drivers (ig7icd64.dll 10.18.10.3304 on an unknown chip on win8.1) are calling SetDllDirectory() for the process, which ruins stuff.
//The relevant initialization happened just before in "create IGL context".

View File

@ -41,7 +41,7 @@ namespace BizHawk.Client.EmuHawk
//TODO implement
}
}
private static PlatformSpecificScreenBlankInterface screenBlankInterface = PlatformLinkedLibSingleton.CurrentOS == PlatformLinkedLibSingleton.DistinctOS.Windows
private static PlatformSpecificScreenBlankInterface screenBlankInterface = OSTailoredCode.CurrentOS == OSTailoredCode.DistinctOS.Windows
? (PlatformSpecificScreenBlankInterface) new WinScreenBlankInterface()
: (PlatformSpecificScreenBlankInterface) new MiscUnixScreenBlankInterface();

View File

@ -27,7 +27,7 @@ namespace BizHawk.Client.EmuHawk
{
if (Global.Config.SoundOutputMethod == Config.ESoundOutputMethod.OpenAL)
_outputDevice = new OpenALSoundOutput(this);
if (PlatformLinkedLibSingleton.CurrentOS == PlatformLinkedLibSingleton.DistinctOS.Windows)
if (OSTailoredCode.CurrentOS == OSTailoredCode.DistinctOS.Windows)
{
if (Global.Config.SoundOutputMethod == Config.ESoundOutputMethod.DirectSound)
_outputDevice = new DirectSoundSoundOutput(this, mainWindowHandle);

View File

@ -160,7 +160,7 @@ namespace BizHawk.Client.EmuHawk
return timeBeginPeriod(ms);
}
}
static PlatformSpecificSysTimer sysTimer = PlatformLinkedLibSingleton.CurrentOS != PlatformLinkedLibSingleton.DistinctOS.Windows ? (PlatformSpecificSysTimer) new UnixMonoSysTimer() : (PlatformSpecificSysTimer) new WinSysTimer();
static PlatformSpecificSysTimer sysTimer = OSTailoredCode.CurrentOS != OSTailoredCode.DistinctOS.Windows ? (PlatformSpecificSysTimer) new UnixMonoSysTimer() : (PlatformSpecificSysTimer) new WinSysTimer();
static uint TimeBeginPeriod(uint ms)
{
return sysTimer.TimeBeginPeriod(ms);

View File

@ -71,7 +71,7 @@ namespace BizHawk.Client.EmuHawk
protected override void OnMouseClick(MouseEventArgs e)
{
if (PlatformLinkedLibSingleton.CurrentOS == PlatformLinkedLibSingleton.DistinctOS.Windows) HideCaret(Handle);
if (OSTailoredCode.CurrentOS == OSTailoredCode.DistinctOS.Windows) HideCaret(Handle);
base.OnMouseClick(e);
}
@ -264,7 +264,7 @@ namespace BizHawk.Client.EmuHawk
protected override void OnGotFocus(EventArgs e)
{
if (PlatformLinkedLibSingleton.CurrentOS == PlatformLinkedLibSingleton.DistinctOS.Windows) HideCaret(Handle);
if (OSTailoredCode.CurrentOS == OSTailoredCode.DistinctOS.Windows) HideCaret(Handle);
}
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)

View File

@ -186,7 +186,7 @@ namespace BizHawk.Client.EmuHawk
}
var currentScripts = LuaImp?.ScriptList; // Temp fix for now
LuaImp = PlatformLinkedLibSingleton.CurrentOS == PlatformLinkedLibSingleton.DistinctOS.Windows
LuaImp = OSTailoredCode.CurrentOS == OSTailoredCode.DistinctOS.Windows
? (PlatformEmuLuaLibrary) new EmuLuaLibrary(Emulator.ServiceProvider)
: (PlatformEmuLuaLibrary) new NotReallyLuaLibrary();
if (currentScripts != null)

View File

@ -740,7 +740,7 @@ namespace BizHawk.Client.EmuHawk
return false;
}
if (t == typeof(LuaConsole) && PlatformLinkedLibSingleton.CurrentOS != PlatformLinkedLibSingleton.DistinctOS.Windows) return false;
if (t == typeof(LuaConsole) && OSTailoredCode.CurrentOS != OSTailoredCode.DistinctOS.Windows) return false;
var tool = Assembly
.GetExecutingAssembly()

View File

@ -85,7 +85,7 @@
<Compile Include="MruStack.cs" />
<Compile Include="MutableIntRange.cs" />
<Compile Include="NDBDatabase.cs" />
<Compile Include="PlatformLinkedLibSingleton.cs" />
<Compile Include="OSTailoredCode.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="QuickCollections.cs" />
<Compile Include="Serializer.cs" />

View File

@ -8,12 +8,12 @@ namespace BizHawk.Common.BizInvoke
public class DynamicLibraryImportResolver : IImportResolver, IDisposable
{
private IntPtr _p;
private readonly PlatformLinkedLibSingleton.PlatformLinkedLibManager libLoader = PlatformLinkedLibSingleton.LinkedLibManager;
private readonly OSTailoredCode.ILinkedLibManager libLoader = OSTailoredCode.LinkedLibManager;
public DynamicLibraryImportResolver(string dllName)
{
_p = libLoader.LoadPlatformSpecific(dllName);
if (_p == IntPtr.Zero) throw new InvalidOperationException($"null pointer returned by {nameof(PlatformLinkedLibSingleton.PlatformLinkedLibManager.LoadPlatformSpecific)}");
if (_p == IntPtr.Zero) throw new InvalidOperationException($"null pointer returned by {nameof(libLoader.LoadPlatformSpecific)}");
}
public IntPtr Resolve(string entryPoint)

View File

@ -10,28 +10,28 @@ namespace EXE_PROJECT
namespace BizHawk.Common
#endif
{
public sealed class PlatformLinkedLibSingleton
public sealed class OSTailoredCode
{
/// <remarks>macOS doesn't use PlatformID.MacOSX</remarks>
public static readonly DistinctOS CurrentOS = Environment.OSVersion.Platform == PlatformID.Unix
? currentIsMacOS() ? DistinctOS.macOS : DistinctOS.Linux
: DistinctOS.Windows;
private static readonly Lazy<PlatformLinkedLibManager> lazy = new Lazy<PlatformLinkedLibManager>(() =>
private static readonly Lazy<ILinkedLibManager> lazy = new Lazy<ILinkedLibManager>(() =>
{
switch (CurrentOS)
{
case DistinctOS.Linux:
case DistinctOS.macOS:
return new UnixMonoLinkedLibManager();
return new UnixMonoLLManager();
case DistinctOS.Windows:
return new Win32LinkedLibManager();
return new WindowsLLManager();
default:
throw new ArgumentOutOfRangeException();
}
});
public static PlatformLinkedLibManager LinkedLibManager => lazy.Value;
public static ILinkedLibManager LinkedLibManager => lazy.Value;
private static bool currentIsMacOS()
{
@ -49,19 +49,19 @@ namespace BizHawk.Common
return proc.StandardOutput.ReadLine() == "Darwin";
}
private PlatformLinkedLibSingleton() {}
private OSTailoredCode() {}
public interface PlatformLinkedLibManager
public interface ILinkedLibManager
{
IntPtr LoadPlatformSpecific(string dllToLoad);
IntPtr GetProcAddr(IntPtr hModule, string procName);
int FreePlatformSpecific(IntPtr hModule);
}
private class UnixMonoLinkedLibManager : PlatformLinkedLibManager
/// <remarks>This class is copied from a tutorial, so don't git blame and then email me expecting insight.</remarks>
private class UnixMonoLLManager : ILinkedLibManager
{
// This class is copied from a tutorial, so don't git blame and then email me expecting insight.
const int RTLD_NOW = 2;
private const int RTLD_NOW = 2;
[DllImport("libdl.so.2")]
private static extern IntPtr dlopen(string fileName, int flags);
[DllImport("libdl.so.2")]
@ -88,10 +88,10 @@ namespace BizHawk.Common
}
}
private class Win32LinkedLibManager : PlatformLinkedLibManager
private class WindowsLLManager : ILinkedLibManager
{
[DllImport("kernel32.dll")]
private static extern UInt32 GetLastError();
private static extern uint GetLastError();
// was annotated `[DllImport("kernel32.dll", BestFitMapping = false, ThrowOnUnmappableChar = true)]` in SevenZip.NativeMethods
// param dllToLoad was annotated `[MarshalAs(UnmanagedType.LPStr)]` in SevenZip.NativeMethods
[DllImport("kernel32.dll")]
@ -121,9 +121,9 @@ namespace BizHawk.Common
public enum DistinctOS : byte
{
Linux = 0,
macOS = 1,
Windows = 2
Linux,
macOS,
Windows
}
}
}

View File

@ -27,7 +27,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64.NativeApi
bool event_frameend = false;
bool event_breakpoint = false;
private static readonly PlatformLinkedLibSingleton.PlatformLinkedLibManager libLoader = PlatformLinkedLibSingleton.LinkedLibManager;
private static readonly OSTailoredCode.ILinkedLibManager libLoader = OSTailoredCode.LinkedLibManager;
public enum m64p_error
{