mirror of
https://github.com/holub/mame
synced 2025-10-05 00:38:58 +03:00
more cleanup (nw)
This commit is contained in:
parent
b61ed2c7a4
commit
715c86f1c7
@ -162,13 +162,12 @@ void menu_network_devices::populate()
|
||||
{
|
||||
int curr = network.get_interface();
|
||||
const char *title = nullptr;
|
||||
const osd_netdev::entry_t *entry = netdev_first();
|
||||
while(entry) {
|
||||
for(auto &entry : get_netdev_list())
|
||||
{
|
||||
if(entry->id==curr) {
|
||||
title = entry->description;
|
||||
break;
|
||||
}
|
||||
entry = entry->m_next;
|
||||
}
|
||||
|
||||
item_append(network.device().tag(), (title) ? title : "------", FLAG_LEFT_ARROW | FLAG_RIGHT_ARROW, (void *)network);
|
||||
|
@ -30,7 +30,7 @@
|
||||
#include "../input/input_windows.h"
|
||||
|
||||
|
||||
class debugger_windows : public osd_module, public debug_module, protected debugger_windows_interface
|
||||
class debugger_windows : public osd_module, public debug_module, public debugger_windows_interface
|
||||
{
|
||||
public:
|
||||
debugger_windows() :
|
||||
@ -76,7 +76,7 @@ private:
|
||||
running_machine *m_machine;
|
||||
std::unique_ptr<ui_metrics> m_metrics;
|
||||
bool m_waiting_for_debugger;
|
||||
simple_list<debugwin_info> m_window_list;
|
||||
std::vector<std::unique_ptr<debugwin_info>> m_window_list;
|
||||
consolewin_info *m_main_console;
|
||||
};
|
||||
|
||||
@ -84,8 +84,8 @@ private:
|
||||
void debugger_windows::exit()
|
||||
{
|
||||
// loop over windows and free them
|
||||
while (m_window_list.first() != nullptr)
|
||||
m_window_list.first()->destroy();
|
||||
while (!m_window_list.empty())
|
||||
m_window_list.front()->destroy();
|
||||
|
||||
m_main_console = nullptr;
|
||||
m_metrics.reset();
|
||||
@ -164,8 +164,8 @@ void debugger_windows::debugger_update()
|
||||
m_machine->debugger().cpu().get_visible_cpu()->debug()->halt_on_next_instruction("User-initiated break\n");
|
||||
|
||||
// if we were focused on some window's edit box, reset it to default
|
||||
for (debugwin_info &info : m_window_list)
|
||||
info.restore_field(focuswnd);
|
||||
for (auto &info : m_window_list)
|
||||
info->restore_field(focuswnd);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -224,39 +224,40 @@ bool debugger_windows::seq_pressed() const
|
||||
|
||||
void debugger_windows::remove_window(debugwin_info &info)
|
||||
{
|
||||
m_window_list.remove(info);
|
||||
for (auto it = m_window_list.begin(); it != m_window_list.end(); ++it)
|
||||
if (it->get() == &info) {
|
||||
m_window_list.erase(it);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void debugger_windows::show_all()
|
||||
{
|
||||
for (debugwin_info &info : m_window_list)
|
||||
info.show();
|
||||
for (auto &info : m_window_list)
|
||||
info->show();
|
||||
}
|
||||
|
||||
|
||||
void debugger_windows::hide_all()
|
||||
{
|
||||
SetForegroundWindow(osd_common_t::s_window_list.front()->platform_window<HWND>());
|
||||
for (debugwin_info &info : m_window_list)
|
||||
info.hide();
|
||||
for (auto &info : m_window_list)
|
||||
info->hide();
|
||||
}
|
||||
|
||||
|
||||
template <typename T> T *debugger_windows::create_window()
|
||||
{
|
||||
// allocate memory
|
||||
T *info = global_alloc(T(*this));
|
||||
std::unique_ptr<T> info = std::make_unique<T>(*this);
|
||||
if (info->is_valid())
|
||||
{
|
||||
m_window_list.prepend(*info);
|
||||
return info;
|
||||
m_window_list.push_back(std::move(info));
|
||||
T *ptr = dynamic_cast<T*>(m_window_list.back().get());
|
||||
return ptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
global_free(info);
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -24,7 +24,6 @@ bool debugwin_info::s_window_class_registered = false;
|
||||
debugwin_info::debugwin_info(debugger_windows_interface &debugger, bool is_main_console, LPCSTR title, WNDPROC handler) :
|
||||
debugbase_info(debugger),
|
||||
m_is_main_console(is_main_console),
|
||||
m_next(nullptr),
|
||||
m_wnd(nullptr),
|
||||
m_handler(handler),
|
||||
m_minwidth(200),
|
||||
|
@ -19,13 +19,10 @@
|
||||
class debugwin_info : protected debugbase_info
|
||||
{
|
||||
public:
|
||||
template<class U> friend class simple_list;
|
||||
|
||||
debugwin_info(debugger_windows_interface &debugger, bool is_main_console, LPCSTR title, WNDPROC handler);
|
||||
virtual ~debugwin_info();
|
||||
|
||||
bool is_valid() const { return m_wnd != nullptr; }
|
||||
debugwin_info *next() const { return m_next; }
|
||||
|
||||
void set_ignore_char_lparam(LPARAM value) { m_ignore_char_lparam = value >> 16; }
|
||||
bool check_ignore_char_lparam(LPARAM value)
|
||||
@ -131,7 +128,6 @@ private:
|
||||
|
||||
bool const m_is_main_console;
|
||||
|
||||
debugwin_info *m_next;
|
||||
HWND m_wnd;
|
||||
WNDPROC const m_handler;
|
||||
|
||||
|
@ -88,7 +88,7 @@ public:
|
||||
// force symbols to be cached
|
||||
void cache_symbols() { scan_file_for_address(0, true); }
|
||||
|
||||
void reset_cache() { m_cache.reset(); }
|
||||
void reset_cache() { m_cache.clear(); }
|
||||
private:
|
||||
// internal helpers
|
||||
bool query_system_for_address(FPTR address);
|
||||
@ -103,14 +103,12 @@ private:
|
||||
struct cache_entry
|
||||
{
|
||||
cache_entry(FPTR address, const char *symbol) :
|
||||
m_next(nullptr), m_address(address), m_name(symbol) { }
|
||||
cache_entry *next() const { return m_next; }
|
||||
m_address(address), m_name(symbol) { }
|
||||
|
||||
cache_entry * m_next;
|
||||
FPTR m_address;
|
||||
std::string m_name;
|
||||
};
|
||||
simple_list<cache_entry> m_cache;
|
||||
std::vector<std::unique_ptr<cache_entry>> m_cache;
|
||||
|
||||
std::string m_mapfile;
|
||||
std::string m_symfile;
|
||||
@ -445,7 +443,7 @@ void symbol_manager::scan_file_for_address(FPTR address, bool create_cache)
|
||||
|
||||
// also create a cache entry if we can
|
||||
if (create_cache)
|
||||
m_cache.append(*global_alloc(cache_entry(addr, symbol.c_str())));
|
||||
m_cache.push_back(std::make_unique<cache_entry>(addr, symbol.c_str()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -470,13 +468,13 @@ void symbol_manager::scan_cache_for_address(FPTR address)
|
||||
FPTR best_addr = 0;
|
||||
|
||||
// walk the cache, looking for valid entries
|
||||
for (cache_entry &entry : m_cache)
|
||||
for (auto &entry : m_cache)
|
||||
|
||||
// if this is the best one so far, remember it
|
||||
if (entry.m_address <= address && entry.m_address > best_addr)
|
||||
if (entry->m_address <= address && entry->m_address > best_addr)
|
||||
{
|
||||
best_addr = entry.m_address;
|
||||
best_symbol = entry.m_name;
|
||||
best_addr = entry->m_address;
|
||||
best_symbol = entry->m_name;
|
||||
}
|
||||
|
||||
// format the symbol and remember the last base
|
||||
|
@ -3,38 +3,35 @@
|
||||
#include "emu.h"
|
||||
#include "osdnet.h"
|
||||
|
||||
static class simple_list<osd_netdev::entry_t> netdev_list;
|
||||
static class std::vector<std::unique_ptr<osd_netdev::entry_t>> netdev_list;
|
||||
|
||||
void add_netdev(const char *name, const char *description, create_netdev func)
|
||||
{
|
||||
auto entry = global_alloc_clear<osd_netdev::entry_t>();
|
||||
entry->id = netdev_list.count();
|
||||
auto entry = make_unique_clear<osd_netdev::entry_t>();
|
||||
entry->id = netdev_list.size();
|
||||
strncpy(entry->name, name, 255);
|
||||
entry->name[255] = '\0';
|
||||
strncpy(entry->description, (description != nullptr) ? description : "(no name)", 255);
|
||||
entry->description[255] = '\0';
|
||||
entry->func = func;
|
||||
netdev_list.append(*entry);
|
||||
netdev_list.push_back(std::move(entry));
|
||||
}
|
||||
|
||||
void clear_netdev()
|
||||
{
|
||||
netdev_list.reset();
|
||||
netdev_list.clear();
|
||||
}
|
||||
|
||||
const osd_netdev::entry_t *netdev_first() {
|
||||
return netdev_list.first();
|
||||
const std::vector<std::unique_ptr<osd_netdev::entry_t>>& get_netdev_list()
|
||||
{
|
||||
return netdev_list;
|
||||
}
|
||||
|
||||
class osd_netdev *open_netdev(int id, class device_network_interface *ifdev, int rate)
|
||||
{
|
||||
osd_netdev::entry_t *entry = netdev_list.first();
|
||||
while(entry) {
|
||||
for(auto &entry : netdev_list)
|
||||
if(entry->id==id)
|
||||
return entry->func(entry->name, ifdev, rate);
|
||||
entry = entry->m_next;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -110,13 +107,13 @@ const char *osd_netdev::get_mac()
|
||||
|
||||
int netdev_count()
|
||||
{
|
||||
return netdev_list.count();
|
||||
return netdev_list.size();
|
||||
}
|
||||
|
||||
void osd_list_network_adapters(void)
|
||||
{
|
||||
#ifdef USE_NETWORK
|
||||
int num_devs = netdev_list.count();
|
||||
int num_devs = netdev_list.size();
|
||||
|
||||
if (num_devs == 0)
|
||||
{
|
||||
@ -125,10 +122,9 @@ void osd_list_network_adapters(void)
|
||||
}
|
||||
|
||||
printf("Available network adapters:\n");
|
||||
const osd_netdev::entry_t *entry = netdev_first();
|
||||
while(entry) {
|
||||
for (auto &entry : netdev_list)
|
||||
{
|
||||
printf(" %s\n", entry->description);
|
||||
entry = entry->m_next;
|
||||
}
|
||||
|
||||
#else
|
||||
|
@ -19,7 +19,6 @@ public:
|
||||
char name[256];
|
||||
char description[256];
|
||||
create_netdev func;
|
||||
entry_t *m_next;
|
||||
};
|
||||
osd_netdev(class device_network_interface *ifdev, int rate);
|
||||
virtual ~osd_netdev();
|
||||
@ -45,6 +44,6 @@ private:
|
||||
class osd_netdev *open_netdev(int id, class device_network_interface *ifdev, int rate);
|
||||
void add_netdev(const char *name, const char *description, create_netdev func);
|
||||
void clear_netdev();
|
||||
const osd_netdev::entry_t *netdev_first();
|
||||
const std::vector<std::unique_ptr<osd_netdev::entry_t>>& get_netdev_list();
|
||||
int netdev_count();
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user