1
0
mirror of https://github.com/TomHarte/CLK.git synced 2025-02-16 18:30:32 +00:00

Attempts to fix the macOS version, plus some implicit type conversions.

This commit is contained in:
Thomas Harte 2020-03-18 23:29:09 -04:00
parent c6f35c9aac
commit 9995d776de
3 changed files with 29 additions and 40 deletions

View File

@ -586,9 +586,9 @@ struct ActivityObserver: public Activity::Observer {
@synchronized(self) { @synchronized(self) {
_useFastLoadingHack = useFastLoadingHack; _useFastLoadingHack = useFastLoadingHack;
Configurable::SelectionSet selection_set; auto options = configurable_device->get_options();
append_quick_load_tape_selection(selection_set, useFastLoadingHack ? true : false); Reflection::set(*options, "quickload", useFastLoadingHack ? true : false);
configurable_device->set_selections(selection_set); configurable_device->set_options(options);
} }
} }
@ -599,7 +599,6 @@ struct ActivityObserver: public Activity::Observer {
@synchronized(self) { @synchronized(self) {
_videoSignal = videoSignal; _videoSignal = videoSignal;
Configurable::SelectionSet selection_set;
Configurable::Display display; Configurable::Display display;
switch(videoSignal) { switch(videoSignal) {
case CSMachineVideoSignalRGB: display = Configurable::Display::RGB; break; case CSMachineVideoSignalRGB: display = Configurable::Display::RGB; break;
@ -607,8 +606,10 @@ struct ActivityObserver: public Activity::Observer {
case CSMachineVideoSignalComposite: display = Configurable::Display::CompositeColour; break; case CSMachineVideoSignalComposite: display = Configurable::Display::CompositeColour; break;
case CSMachineVideoSignalMonochromeComposite: display = Configurable::Display::CompositeMonochrome; break; case CSMachineVideoSignalMonochromeComposite: display = Configurable::Display::CompositeMonochrome; break;
} }
append_display_selection(selection_set, display);
configurable_device->set_selections(selection_set); auto options = configurable_device->get_options();
Reflection::set(*options, "output", int(display));
configurable_device->set_options(options);
} }
} }
@ -617,35 +618,23 @@ struct ActivityObserver: public Activity::Observer {
if(!configurable_device) return NO; if(!configurable_device) return NO;
// Get the options this machine provides. // Get the options this machine provides.
std::vector<std::unique_ptr<Configurable::Option>> options;
@synchronized(self) { @synchronized(self) {
options = configurable_device->get_options(); auto options = configurable_device->get_options();
}
// Get the standard option for this video signal. // Get the standard option for this video signal.
Configurable::StandardOptions option; Configurable::Display option;
switch(videoSignal) { switch(videoSignal) {
case CSMachineVideoSignalRGB: option = Configurable::DisplayRGB; break; case CSMachineVideoSignalRGB: option = Configurable::Display::RGB; break;
case CSMachineVideoSignalSVideo: option = Configurable::DisplaySVideo; break; case CSMachineVideoSignalSVideo: option = Configurable::Display::SVideo; break;
case CSMachineVideoSignalComposite: option = Configurable::DisplayCompositeColour; break; case CSMachineVideoSignalComposite: option = Configurable::Display::CompositeColour; break;
case CSMachineVideoSignalMonochromeComposite: option = Configurable::DisplayCompositeMonochrome; break; case CSMachineVideoSignalMonochromeComposite: option = Configurable::Display::CompositeMonochrome; break;
} }
std::unique_ptr<Configurable::Option> display_option = std::move(standard_options(option).front());
Configurable::ListOption *display_list_option = dynamic_cast<Configurable::ListOption *>(display_option.get());
NSAssert(display_list_option, @"Expected display option to be a list");
// See whether the video signal is included in the machine options. // Map to a string and check against returned options for the 'output' field.
for(auto &candidate: options) { const auto string_option = Reflection::Enum::to_string<Configurable::Display>(option);
Configurable::ListOption *list_option = dynamic_cast<Configurable::ListOption *>(candidate.get()); const auto all_values = options->values_for("output");
// Both should be list options return std::find(all_values.begin(), all_values.end(), string_option) != all_values.end();
if(!list_option) continue;
// Check for same name of option.
if(candidate->short_name != display_option->short_name) continue;
// Check that the video signal option is included.
return std::find(list_option->options.begin(), list_option->options.end(), display_list_option->options.front()) != list_option->options.end();
} }
return NO; return NO;
@ -658,9 +647,9 @@ struct ActivityObserver: public Activity::Observer {
@synchronized(self) { @synchronized(self) {
_useAutomaticTapeMotorControl = useAutomaticTapeMotorControl; _useAutomaticTapeMotorControl = useAutomaticTapeMotorControl;
Configurable::SelectionSet selection_set; auto options = configurable_device->get_options();
append_automatic_tape_motor_control_selection(selection_set, useAutomaticTapeMotorControl ? true : false); Reflection::set(*options, "automatic_tape_motor_control", useAutomaticTapeMotorControl ? true : false);
configurable_device->set_selections(selection_set); configurable_device->set_options(options);
} }
} }
@ -671,9 +660,9 @@ struct ActivityObserver: public Activity::Observer {
@synchronized(self) { @synchronized(self) {
_useQuickBootingHack = useQuickBootingHack; _useQuickBootingHack = useQuickBootingHack;
Configurable::SelectionSet selection_set; auto options = configurable_device->get_options();
append_quick_boot_selection(selection_set, useQuickBootingHack ? true : false); Reflection::set(*options, "quickboot", useQuickBootingHack ? true : false);
configurable_device->set_selections(selection_set); configurable_device->set_options(options);
} }
} }

View File

@ -122,7 +122,7 @@ class Enum {
static const std::string &to_string(std::type_index type, int e) { static const std::string &to_string(std::type_index type, int e) {
const auto entry = members_by_type_.find(type); const auto entry = members_by_type_.find(type);
if(entry == members_by_type_.end()) return empty_string_; if(entry == members_by_type_.end()) return empty_string_;
return entry->second[e]; return entry->second[size_t(e)];
} }
/*! /*!

View File

@ -219,10 +219,10 @@ template <typename Owner> class StructImpl: public Struct {
const int next = va_arg(list, int); const int next = va_arg(list, int);
if(next < 0) break; if(next < 0) break;
if(permitted_values.size() <= next) { if(permitted_values.size() <= size_t(next)) {
permitted_values.resize(permitted_values.size() << 1); permitted_values.resize(permitted_values.size() << 1);
} }
permitted_values[next] = true; permitted_values[size_t(next)] = true;
} }
va_end(list); va_end(list);