Emulation.Common cleanups

This commit is contained in:
adelikat 2017-04-27 11:37:26 -05:00
parent b98d428a64
commit a8c15a652b
13 changed files with 49 additions and 41 deletions

View File

@ -31,5 +31,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion(VersionInfo.MAINVERSION + "." + SubWCRev.SVN_REV)]
[assembly: AssemblyFileVersion(VersionInfo.MAINVERSION + "." + SubWCRev.SVN_REV)]
[assembly: AssemblyVersion(VersionInfo.Mainversion + "." + SubWCRev.SVN_REV)]
[assembly: AssemblyFileVersion(VersionInfo.Mainversion + "." + SubWCRev.SVN_REV)]

View File

@ -31,5 +31,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion(VersionInfo.MAINVERSION + "." + SubWCRev.SVN_REV)]
[assembly: AssemblyFileVersion(VersionInfo.MAINVERSION + "." + SubWCRev.SVN_REV)]
[assembly: AssemblyVersion(VersionInfo.Mainversion + "." + SubWCRev.SVN_REV)]
[assembly: AssemblyFileVersion(VersionInfo.Mainversion + "." + SubWCRev.SVN_REV)]

View File

@ -26,7 +26,7 @@ namespace BizHawk.Client.EmuHawk
private void BizBox_Load(object sender, EventArgs e)
{
string mainversion = VersionInfo.MAINVERSION;
string mainversion = VersionInfo.Mainversion;
if (IntPtr.Size == 8)
mainversion += " (x64)";
if (VersionInfo.DeveloperBuild)

View File

@ -31,5 +31,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion(VersionInfo.MAINVERSION + "." + SubWCRev.SVN_REV)]
[assembly: AssemblyFileVersion(VersionInfo.MAINVERSION + "." + SubWCRev.SVN_REV)]
[assembly: AssemblyVersion(VersionInfo.Mainversion + "." + SubWCRev.SVN_REV)]
[assembly: AssemblyFileVersion(VersionInfo.Mainversion + "." + SubWCRev.SVN_REV)]

View File

@ -53,8 +53,8 @@ namespace BizHawk.Client.EmuHawk
{
return AutoCheckEnabled &&
LatestVersion != IgnoreVersion &&
ParseVersion(VersionInfo.MAINVERSION) != 0 && // Avoid notifying if current version string is invalid
ParseVersion(LatestVersion) > ParseVersion(VersionInfo.MAINVERSION);
ParseVersion(VersionInfo.Mainversion) != 0 && // Avoid notifying if current version string is invalid
ParseVersion(LatestVersion) > ParseVersion(VersionInfo.Mainversion);
}
}

View File

@ -30,5 +30,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion(VersionInfo.MAINVERSION + "." + SubWCRev.SVN_REV)]
[assembly: AssemblyFileVersion(VersionInfo.MAINVERSION + "." + SubWCRev.SVN_REV)]
[assembly: AssemblyVersion(VersionInfo.Mainversion + "." + SubWCRev.SVN_REV)]
[assembly: AssemblyFileVersion(VersionInfo.Mainversion + "." + SubWCRev.SVN_REV)]

View File

@ -311,14 +311,22 @@ namespace BizHawk.Emulation.Common.BizInvoke
var nativeParamTypes = new List<Type>();
var returnType = baseMethod.ReturnType;
if (returnType != typeof(void) && !returnType.IsPrimitive)
{
throw new InvalidOperationException("Only primitive return types are supported");
}
// define a field on the type to hold the entry pointer
var field = type.DefineField("EntryPtrField" + baseMethod.Name, typeof(IntPtr),
var field = type.DefineField(
"EntryPtrField" + baseMethod.Name,
typeof(IntPtr),
FieldAttributes.Public);
var method = type.DefineMethod(baseMethod.Name, MethodAttributes.Virtual | MethodAttributes.Public,
CallingConventions.HasThis, returnType, paramTypes);
var method = type.DefineMethod(
baseMethod.Name,
MethodAttributes.Virtual | MethodAttributes.Public,
CallingConventions.HasThis,
returnType,
paramTypes);
var il = method.GetILGenerator();

View File

@ -8,17 +8,6 @@ using BizHawk.Common.BufferExtensions;
namespace BizHawk.Emulation.Common
{
public class CompactGameInfo
{
public string Name { get; set; }
public string System { get; set; }
public string MetaData { get; set; }
public string Hash { get; set; }
public string Region { get; set; }
public RomStatus Status { get; set; }
public string ForcedCore { get; set; }
}
public static class Database
{
private static readonly Dictionary<string, CompactGameInfo> DB = new Dictionary<string, CompactGameInfo>();
@ -42,8 +31,8 @@ namespace BizHawk.Emulation.Common
public static GameInfo CheckDatabase(string hash)
{
CompactGameInfo cgi;
var hash_notype = RemoveHashType(hash);
DB.TryGetValue(hash_notype, out cgi);
var hashNotype = RemoveHashType(hash);
DB.TryGetValue(hashNotype, out cgi);
if (cgi == null)
{
Console.WriteLine("DB: hash " + hash + " not in game database.");
@ -237,7 +226,7 @@ namespace BizHawk.Emulation.Common
CRC32.Calculate(romData),
System.Security.Cryptography.MD5.Create().ComputeHash(romData).BytesToHexString());
var ext = Path.GetExtension(fileName).ToUpperInvariant();
var ext = Path.GetExtension(fileName)?.ToUpperInvariant();
switch (ext)
{
@ -344,10 +333,10 @@ namespace BizHawk.Emulation.Common
break;
}
game.Name = Path.GetFileNameWithoutExtension(fileName).Replace('_', ' ');
game.Name = Path.GetFileNameWithoutExtension(fileName)?.Replace('_', ' ');
// If filename is all-caps, then attempt to proper-case the title.
if (game.Name == game.Name.ToUpperInvariant())
if (!string.IsNullOrWhiteSpace(game.Name) && game.Name == game.Name.ToUpperInvariant())
{
game.Name = Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(game.Name.ToLower());
}
@ -355,4 +344,15 @@ namespace BizHawk.Emulation.Common
return game;
}
}
public class CompactGameInfo
{
public string Name { get; set; }
public string System { get; set; }
public string MetaData { get; set; }
public string Hash { get; set; }
public string Region { get; set; }
public RomStatus Status { get; set; }
public string ForcedCore { get; set; }
}
}

View File

@ -341,7 +341,7 @@ namespace BizHawk.Emulation.Common.IEmulatorExtensions
// If async is not provided by the implementation this method will throw an exception
// We need to figure out a reliable way to check specifically for a NotImplementedException, then maybe this method will be more useful
// If a method is not marked but all it does is throw an exception, consider it not implemented
//return !info.ThrowsError();
////return !info.ThrowsError();
return true;
}

View File

@ -31,5 +31,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion(VersionInfo.MAINVERSION + "." + SubWCRev.SVN_REV)]
[assembly: AssemblyFileVersion(VersionInfo.MAINVERSION + "." + SubWCRev.SVN_REV)]
[assembly: AssemblyVersion(VersionInfo.Mainversion + "." + SubWCRev.SVN_REV)]
[assembly: AssemblyFileVersion(VersionInfo.Mainversion + "." + SubWCRev.SVN_REV)]

View File

@ -31,5 +31,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion(VersionInfo.MAINVERSION + "." + SubWCRev.SVN_REV)]
[assembly: AssemblyFileVersion(VersionInfo.MAINVERSION + "." + SubWCRev.SVN_REV)]
[assembly: AssemblyVersion(VersionInfo.Mainversion + "." + SubWCRev.SVN_REV)]
[assembly: AssemblyFileVersion(VersionInfo.Mainversion + "." + SubWCRev.SVN_REV)]

View File

@ -31,5 +31,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion(VersionInfo.MAINVERSION + "." + SubWCRev.SVN_REV)]
[assembly: AssemblyFileVersion(VersionInfo.MAINVERSION + "." + SubWCRev.SVN_REV)]
[assembly: AssemblyVersion(VersionInfo.Mainversion + "." + SubWCRev.SVN_REV)]
[assembly: AssemblyFileVersion(VersionInfo.Mainversion + "." + SubWCRev.SVN_REV)]