Fix default referring to non-nullable type

This commit is contained in:
YoshiRulz 2019-12-23 04:12:02 +10:00
parent c20ae5b16c
commit 264b27475e
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
6 changed files with 9 additions and 9 deletions

View File

@ -85,7 +85,7 @@ namespace BizHawk.Client.Common
if (DebuggableCore != null)
{
var registers = DebuggableCore.GetCpuFlagsAndRegisters();
return registers.ContainsKey(name) ? registers[name].Value : default;
return registers.ContainsKey(name) ? registers[name].Value : (ulong?) null;
}
}
catch (NotImplementedException) {}

View File

@ -68,7 +68,7 @@ namespace BizHawk.Client.Common
{
foreach (var button in Global.ActiveController.Definition.BoolButtons)
{
Set(button, buttons.TryGetValue(button, out var state) ? state : default, controller);
Set(button, buttons.TryGetValue(button, out var state) ? state : (bool?) null, controller);
}
}

View File

@ -95,7 +95,7 @@ namespace BizHawk.Common.BizInvoke
}
}
public IntPtr? GetProcAddrOrNull(string entryPoint) => EntryPoints.TryGetValue(entryPoint, out var ret) ? ret : default;
public IntPtr? GetProcAddrOrNull(string entryPoint) => EntryPoints.TryGetValue(entryPoint, out var ret) ? ret : (IntPtr?) null;
public IntPtr GetProcAddrOrThrow(string entryPoint) => GetProcAddrOrNull(entryPoint) ?? throw new InvalidOperationException($"could not find {entryPoint} in exports");
}

View File

@ -56,7 +56,7 @@ namespace BizHawk.Common
public IntPtr? GetProcAddrOrNull(IntPtr hModule, string procName)
{
var p = dlsym(hModule, procName);
return p == IntPtr.Zero ? default : p;
return p == IntPtr.Zero ? (IntPtr?) null : p;
}
public IntPtr GetProcAddrOrThrow(IntPtr hModule, string procName)
@ -72,7 +72,7 @@ namespace BizHawk.Common
{
const int RTLD_NOW = 2;
var p = dlopen(dllToLoad, RTLD_NOW);
return p == IntPtr.Zero ? default : p;
return p == IntPtr.Zero ? (IntPtr?) null : p;
}
public IntPtr LoadOrThrow(string dllToLoad) => LoadOrNull(dllToLoad) ?? throw new InvalidOperationException($"got null pointer from {nameof(dlopen)}, error: {Marshal.PtrToStringAnsi(dlerror())}");
@ -99,7 +99,7 @@ namespace BizHawk.Common
public IntPtr? GetProcAddrOrNull(IntPtr hModule, string procName)
{
var p = GetProcAddress(hModule, procName);
return p == IntPtr.Zero ? default : p;
return p == IntPtr.Zero ? (IntPtr?) null : p;
}
public IntPtr GetProcAddrOrThrow(IntPtr hModule, string procName) => GetProcAddrOrNull(hModule, procName) ?? throw new InvalidOperationException($"got null pointer from {nameof(GetProcAddress)}, error code: {GetLastError()}");
@ -107,7 +107,7 @@ namespace BizHawk.Common
public IntPtr? LoadOrNull(string dllToLoad)
{
var p = LoadLibrary(dllToLoad);
return p == IntPtr.Zero ? default : p;
return p == IntPtr.Zero ? (IntPtr?) null : p;
}
public IntPtr LoadOrThrow(string dllToLoad) => LoadOrNull(dllToLoad) ?? throw new InvalidOperationException($"got null pointer from {nameof(LoadLibrary)}, error code: {GetLastError()}");

View File

@ -390,7 +390,7 @@ namespace BizHawk.Emulation.Cores.Waterbox
#endregion
public IntPtr? GetProcAddrOrNull(string entryPoint) => _symdict.TryGetValue(entryPoint, out var sym) ? Z.SS(sym.Value + _loadoffset) : default;
public IntPtr? GetProcAddrOrNull(string entryPoint) => _symdict.TryGetValue(entryPoint, out var sym) ? Z.SS(sym.Value + _loadoffset) : (IntPtr?) null;
public IntPtr GetProcAddrOrThrow(string entryPoint) => GetProcAddrOrNull(entryPoint) ?? throw new InvalidOperationException($"could not find {entryPoint} in exports");

View File

@ -301,7 +301,7 @@ namespace BizHawk.Emulation.Cores.Waterbox
}
}
public IntPtr? GetProcAddrOrNull(string entryPoint) => ExportsByName.TryGetValue(entryPoint, out var ret) ? ret : default;
public IntPtr? GetProcAddrOrNull(string entryPoint) => ExportsByName.TryGetValue(entryPoint, out var ret) ? ret : (IntPtr?) null;
public IntPtr GetProcAddrOrThrow(string entryPoint) => GetProcAddrOrNull(entryPoint) ?? throw new InvalidOperationException($"could not find {entryPoint} in exports");