diff options
| author | 2016-04-18 18:53:28 -0400 | |
|---|---|---|
| committer | 2016-04-18 18:53:28 -0400 | |
| commit | 084d3654ca14a79d9ec173bad4ddf00ad0fb5a7f (patch) | |
| tree | 197ae37b68f3169048fb3cadf6947353315f3608 /src/emu/rendlay.cpp | |
| parent | 55d3e544e013174880c8f208264683aac6d711f9 (diff) | |
Iterate over devices C++11 style
Replace the old device_iterator and its specialized versions with functionally equivalent classes that use standard operators to yield references to devices/interfaces rather than pointers. With range-based for loops, they no longer have to be stored in named variables, though they can also be reused concurrently since the iteration state is now maintained by a subclass.
Add a few more typical getters to device_t::subdevice_list.
Diffstat (limited to 'src/emu/rendlay.cpp')
| -rw-r--r-- | src/emu/rendlay.cpp | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/src/emu/rendlay.cpp b/src/emu/rendlay.cpp index fee6cbdaaa2..ea2fc8b4bd5 100644 --- a/src/emu/rendlay.cpp +++ b/src/emu/rendlay.cpp @@ -164,16 +164,15 @@ static int get_variable_value(running_machine &machine, const char *string, char char temp[100]; // screen 0 parameters - screen_device_iterator iter(machine.root_device()); int scrnum = 0; - for (const screen_device *device = iter.first(); device != nullptr; device = iter.next(), scrnum++) + for (const screen_device &device : screen_device_iterator(machine.root_device())) { // native X aspect factor sprintf(temp, "~scr%dnativexaspect~", scrnum); if (!strncmp(string, temp, strlen(temp))) { - int num = device->visible_area().width(); - int den = device->visible_area().height(); + int num = device.visible_area().width(); + int den = device.visible_area().height(); reduce_fraction(num, den); *outputptr += sprintf(*outputptr, "%d", num); return strlen(temp); @@ -183,8 +182,8 @@ static int get_variable_value(running_machine &machine, const char *string, char sprintf(temp, "~scr%dnativeyaspect~", scrnum); if (!strncmp(string, temp, strlen(temp))) { - int num = device->visible_area().width(); - int den = device->visible_area().height(); + int num = device.visible_area().width(); + int den = device.visible_area().height(); reduce_fraction(num, den); *outputptr += sprintf(*outputptr, "%d", den); return strlen(temp); @@ -194,7 +193,7 @@ static int get_variable_value(running_machine &machine, const char *string, char sprintf(temp, "~scr%dwidth~", scrnum); if (!strncmp(string, temp, strlen(temp))) { - *outputptr += sprintf(*outputptr, "%d", device->visible_area().width()); + *outputptr += sprintf(*outputptr, "%d", device.visible_area().width()); return strlen(temp); } @@ -202,9 +201,12 @@ static int get_variable_value(running_machine &machine, const char *string, char sprintf(temp, "~scr%dheight~", scrnum); if (!strncmp(string, temp, strlen(temp))) { - *outputptr += sprintf(*outputptr, "%d", device->visible_area().height()); + *outputptr += sprintf(*outputptr, "%d", device.visible_area().height()); return strlen(temp); } + + // keep count + scrnum++; } // default: copy the first character and continue @@ -2401,10 +2403,7 @@ layout_view::item::item(running_machine &machine, xml_data_node &itemnode, simpl // fetch common data int index = xml_get_attribute_int_with_subst(machine, itemnode, "index", -1); if (index != -1) - { - screen_device_iterator iter(machine.root_device()); - m_screen = iter.byindex(index); - } + m_screen = screen_device_iterator(machine.root_device()).byindex(index); m_input_mask = xml_get_attribute_int_with_subst(machine, itemnode, "inputmask", 0); if (m_output_name[0] != 0 && m_element != nullptr) machine.output().set_value(m_output_name.c_str(), m_element->default_state()); |
