From 56859e95819a8acba855be3060039d4ec03738e1 Mon Sep 17 00:00:00 2001 From: adelikat Date: Thu, 3 Aug 2017 20:03:40 -0500 Subject: [PATCH] MemoryCallbacks - Change "domain" to "scope" --- .../tools/Debugger/Breakpoint.cs | 20 +++++------ .../CallbackBasedTraceBuffer.cs | 2 +- .../MemoryCallbackSystem.cs | 36 +++++++++---------- .../Interfaces/IMemoryCallbackSystem.cs | 20 +++++++---- 4 files changed, 42 insertions(+), 36 deletions(-) diff --git a/BizHawk.Client.EmuHawk/tools/Debugger/Breakpoint.cs b/BizHawk.Client.EmuHawk/tools/Debugger/Breakpoint.cs index f1f630a56a..3f4aca4106 100644 --- a/BizHawk.Client.EmuHawk/tools/Debugger/Breakpoint.cs +++ b/BizHawk.Client.EmuHawk/tools/Debugger/Breakpoint.cs @@ -9,9 +9,9 @@ namespace BizHawk.Client.EmuHawk { public Action Callback { get; set; } - public void Add(IDebuggable core, string domain, uint address, uint mask, MemoryCallbackType type) + public void Add(IDebuggable core, string scope, uint address, uint mask, MemoryCallbackType type) { - Add(new Breakpoint(core, domain, Callback, address, mask, type)); + Add(new Breakpoint(core, scope, Callback, address, mask, type)); } public new void Clear() @@ -69,9 +69,9 @@ namespace BizHawk.Client.EmuHawk private bool _active; private readonly IDebuggable _core; - public Breakpoint(bool readOnly, IDebuggable core, string domain, Action callBack, uint address, uint mask, MemoryCallbackType type, bool enabled = true) + public Breakpoint(bool readOnly, IDebuggable core, string scope, Action callBack, uint address, uint mask, MemoryCallbackType type, bool enabled = true) { - Domain = domain; + Scope = scope; _core = core; Type = type; Callback = callBack; @@ -83,9 +83,9 @@ namespace BizHawk.Client.EmuHawk ReadOnly = readOnly; } - public Breakpoint(IDebuggable core, string domain, Action callBack, uint address, uint mask, MemoryCallbackType type, bool enabled = true) + public Breakpoint(IDebuggable core, string scope, Action callBack, uint address, uint mask, MemoryCallbackType type, bool enabled = true) { - Domain = domain; + Scope = scope; _core = core; Type = type; Callback = callBack; @@ -96,9 +96,9 @@ namespace BizHawk.Client.EmuHawk Active = enabled; } - public Breakpoint(string name, bool readOnly, IDebuggable core, string domain, Action callBack, uint address, uint mask, MemoryCallbackType type, bool enabled = true) + public Breakpoint(string name, bool readOnly, IDebuggable core, string scope, Action callBack, uint address, uint mask, MemoryCallbackType type, bool enabled = true) { - Domain = domain; + Scope = scope; _core = core; Type = type; Callback = callBack; @@ -110,7 +110,7 @@ namespace BizHawk.Client.EmuHawk ReadOnly = readOnly; } - public string Domain { get; } + public string Scope { get; } public Action Callback { get; } public uint? Address { get; set; } public uint? AddressMask { get; set; } @@ -163,7 +163,7 @@ namespace BizHawk.Client.EmuHawk private void AddCallback() { - _core.MemoryCallbacks.Add(new MemoryCallback(Domain, Type, Name, Callback, Address, AddressMask)); + _core.MemoryCallbacks.Add(new MemoryCallback(Scope, Type, Name, Callback, Address, AddressMask)); } private void RemoveCallback() diff --git a/BizHawk.Emulation.Common/Base Implementations/CallbackBasedTraceBuffer.cs b/BizHawk.Emulation.Common/Base Implementations/CallbackBasedTraceBuffer.cs index 41270104ae..4a93abc213 100644 --- a/BizHawk.Emulation.Common/Base Implementations/CallbackBasedTraceBuffer.cs +++ b/BizHawk.Emulation.Common/Base Implementations/CallbackBasedTraceBuffer.cs @@ -95,7 +95,7 @@ namespace BizHawk.Emulation.Common public uint? AddressMask => null; - public string Domain => ""; // This will be relevant if/when the trace logger can trace anything other than the system bus + public string Scope => ""; // This will be relevant if/when the trace logger can trace anything other than the system bus } } } diff --git a/BizHawk.Emulation.Common/Base Implementations/MemoryCallbackSystem.cs b/BizHawk.Emulation.Common/Base Implementations/MemoryCallbackSystem.cs index 3ec926a27a..dd5deb70f4 100644 --- a/BizHawk.Emulation.Common/Base Implementations/MemoryCallbackSystem.cs +++ b/BizHawk.Emulation.Common/Base Implementations/MemoryCallbackSystem.cs @@ -14,14 +14,14 @@ namespace BizHawk.Emulation.Common /// public class MemoryCallbackSystem : IMemoryCallbackSystem { - public MemoryCallbackSystem(string[] availableDomains) + public MemoryCallbackSystem(string[] availableScopes) { - if (availableDomains == null) + if (availableScopes == null) { - availableDomains = new[] { "System Bus" }; + availableScopes = new[] { "System Bus" }; } - AvailableDomains = availableDomains; + AvailableScopes = availableScopes; ExecuteCallbacksAvailable = true; _reads.CollectionChanged += OnCollectionChanged; @@ -41,13 +41,13 @@ namespace BizHawk.Emulation.Common public bool ExecuteCallbacksAvailable { get; } - public string[] AvailableDomains { get; } + public string[] AvailableScopes { get; } public void Add(IMemoryCallback callback) { - if (!AvailableDomains.Contains(callback.Domain)) + if (!AvailableScopes.Contains(callback.Scope)) { - throw new InvalidOperationException($"{callback.Domain} is not currently supported for callbacks"); + throw new InvalidOperationException($"{callback.Scope} is not currently supported for callbacks"); } switch (callback.Type) @@ -74,38 +74,38 @@ namespace BizHawk.Emulation.Common _empty = false; } - private static void Call(ObservableCollection cbs, uint addr, string domain) + private static void Call(ObservableCollection cbs, uint addr, string scope) { for (int i = 0; i < cbs.Count; i++) { - if (!cbs[i].Address.HasValue || (cbs[i].Domain == domain && cbs[i].Address == (addr & cbs[i].AddressMask))) + if (!cbs[i].Address.HasValue || (cbs[i].Scope == scope && cbs[i].Address == (addr & cbs[i].AddressMask))) { cbs[i].Callback(); } } } - public void CallReads(uint addr, string domain) + public void CallReads(uint addr, string scope) { if (_hasReads) { - Call(_reads, addr, domain); + Call(_reads, addr, scope); } } - public void CallWrites(uint addr, string domain) + public void CallWrites(uint addr, string scope) { if (_hasWrites) { - Call(_writes, addr, domain); + Call(_writes, addr, scope); } } - public void CallExecutes(uint addr, string domain) + public void CallExecutes(uint addr, string scope) { if (_hasExecutes) { - Call(_execs, addr, domain); + Call(_execs, addr, scope); } } @@ -286,7 +286,7 @@ namespace BizHawk.Emulation.Common public class MemoryCallback : IMemoryCallback { - public MemoryCallback(string domain, MemoryCallbackType type, string name, Action callback, uint? address, uint? mask) + public MemoryCallback(string scope, MemoryCallbackType type, string name, Action callback, uint? address, uint? mask) { if (type == MemoryCallbackType.Execute && !address.HasValue) { @@ -298,7 +298,7 @@ namespace BizHawk.Emulation.Common Callback = callback; Address = address; AddressMask = mask ?? 0xFFFFFFFF; - Domain = domain; + Scope = scope; } public MemoryCallbackType Type { get; } @@ -306,6 +306,6 @@ namespace BizHawk.Emulation.Common public Action Callback { get; } public uint? Address { get; } public uint? AddressMask { get; } - public string Domain { get; } + public string Scope { get; } } } diff --git a/BizHawk.Emulation.Common/Interfaces/IMemoryCallbackSystem.cs b/BizHawk.Emulation.Common/Interfaces/IMemoryCallbackSystem.cs index c196795e6e..7e130b1dae 100644 --- a/BizHawk.Emulation.Common/Interfaces/IMemoryCallbackSystem.cs +++ b/BizHawk.Emulation.Common/Interfaces/IMemoryCallbackSystem.cs @@ -42,23 +42,29 @@ namespace BizHawk.Emulation.Common /// If no address is specified the callback will be hooked to all addresses /// Note: an execute callback can not be added without an address, else an InvalidOperationException will occur /// - /// Thrown when the property of the is not in the + /// Thrown when the property of the is not in the void Add(IMemoryCallback callback); /// /// Executes all Read callbacks for the given address and domain /// - void CallReads(uint addr, string domain); + /// The address to check for callbacks + /// The scope that the address pertains to. Must be a value in + void CallReads(uint addr, string scope); /// /// Executes all Write callbacks for the given address and domain /// - void CallWrites(uint addr, string domain); + /// The address to check for callbacks + /// The scope that the address pertains to. Must be a value in + void CallWrites(uint addr, string scope); /// /// Executes all Execute callbacks for the given address and domain /// - void CallExecutes(uint addr, string domain); + /// The address to check for callbacks + /// The scope that the address pertains to. Must be a value in + void CallExecutes(uint addr, string scope); /// /// Removes the given callback from the list @@ -76,10 +82,10 @@ namespace BizHawk.Emulation.Common void Clear(); /// - /// A list of available memory domains that a the property of the can have + /// A list of available "scopes" (memory domains, cpus, etc) that a the property of the can have /// Passing a into the method that is not in this list will result in an /// - string[] AvailableDomains { get; } + string[] AvailableScopes { get; } } /// @@ -93,7 +99,7 @@ namespace BizHawk.Emulation.Common Action Callback { get; } uint? Address { get; } uint? AddressMask { get; } - string Domain { get; } + string Scope { get; } } public enum MemoryCallbackType