//PCOPYASSIGNMOVE(ppreprocessor, delete) //~ppreprocessor() = default; /// \brief process stream /// /// \param filename a filename or identifier identifying the stream. /// /// FIXME: this is sub-optimal. Refactor input_context into pinput_context /// and pass this to ppreprocessor. /// //template <typename T> public string process(istream_uptr istrm, string filename) //pstring process(T &&istrm, const pstring &filename) { m_outbuf = m_outbuf.clear_(); m_stack.emplace_back(new input_context(istrm, plib.util.path(filename), filename)); //m_stack.emplace_back(input_context(istrm.release_stream(),plib::util::path(filename), filename)); process_stack(); return(m_outbuf); }
protected ptoken_reader() { m_idx = 0; m_token_store = null; // add a first entry to the stack m_source_location.emplace_back(new plib.source_location("Unknown", 0)); }
public void run(netlist_state_t nlstate) { foreach (var net in nlstate.nets()) { nlstate.log().verbose.op("processing {0}", net.name()); if (!net.is_rail_net() && !nlstate.core_terms(net).empty()) { nlstate.log().verbose.op(" ==> not a rail net"); // Must be an analog net var n = (analog_net_t)net; //auto &n = dynamic_cast<analog_net_t &>(*net); if (!already_processed(n)) { groupspre.emplace_back(new nld_solver_net_list_t()); process_net(nlstate, n); } } } foreach (var g in groupspre) { if (!g.empty()) { groups.push_back(g); } } }
// toolbar protected override void inkey_export() { std.vector <game_driver> list = new std.vector <game_driver>(); if (m_populated_favorites) { // iterate over favorites mame_machine_manager.instance().favorite().apply((info) => { assert(info.driver != null); if (info.startempty != 0) { list.push_back(info.driver); } }); } else { list.reserve(m_displaylist.size()); foreach (ui_system_info info in m_displaylist) { list.emplace_back(info.driver); } } throw new emu_unimplemented(); #if false #endif }
//virtual ~input_code_poller(); public virtual void reset() { // iterate over device classes and devices m_axis_memory.clear(); m_switch_memory.clear(); for (input_device_class classno = input_device_class.DEVICE_CLASS_FIRST_VALID; input_device_class.DEVICE_CLASS_LAST_VALID >= classno; ++classno) { input_class devclass = m_manager.device_class(classno); if (devclass.enabled()) { for (int devnum = 0; devclass.maxindex() >= devnum; ++devnum) { // fetch the device; ignore if nullptr input_device device = devclass.device(devnum); if (device != null) { // iterate over items within each device for (input_item_id itemid = input_item_id.ITEM_ID_FIRST_VALID; device.maxitem() >= itemid; ++itemid) { // for any non-switch items, set memory to the current value input_device_item item = device.item(itemid); if (item != null && (item.itemclass() != input_item_class.ITEM_CLASS_SWITCH)) { m_axis_memory.emplace_back(new std.pair <input_device_item, s32>(item, m_manager.code_value(item.code()))); } } } } } } m_axis_memory.Sort(); //std::sort(m_axis_memory.begin(), m_axis_memory.end()); }
// register for save states /*------------------------------------------------- * register_save - register for save states * -------------------------------------------------*/ public void register_save() { assert(m_save_order.empty()); assert(m_save_data == null); // make space for the data m_save_order.clear(); m_save_order.reserve(m_itemtable.size()); m_save_data = new s32 [m_itemtable.size()]; //m_save_data = std::make_unique<s32 []>(m_itemtable.size()); // sort existing outputs by name and register for save foreach (var item in m_itemtable) { m_save_order.emplace_back(item.second()); } m_save_order.Sort((l, r) => { return(string.Compare(l.name(), r.name())); }); //std::sort(m_save_order.begin(), m_save_order.end(), [] (auto const &l, auto const &r) { return l.get().name() < r.get().name(); }); // register the reserved space for saving //throw new emu_unimplemented(); #if false machine().save().save_pointer(nullptr, "output", nullptr, 0, NAME(m_save_data), m_itemtable.size()); #endif if (OUTPUT_VERBOSE) { osd_printf_verbose("Registered {0} outputs for save states\n", m_itemtable.size()); } }
//------------------------------------------------- // start_new_line //------------------------------------------------- void start_new_line(float height) { // update the current line m_current_line = new line(actual_height(), height * yscale()); //m_current_line = m_lines.emplace_back(std::make_unique<line>(actual_height(), height * yscale())).get(); m_lines.emplace_back(m_current_line); m_last_break = 0; m_truncating = false; }
/************************************* * * Register to be involved in config * save/load * *************************************/ public void config_register(string nodename, load_delegate load, save_delegate save) { config_element element = new config_element(); element.name = nodename; element.load = load; element.save = save; m_typelist.emplace_back(element); }
// construction/destruction //------------------------------------------------- // driver_device - constructor //------------------------------------------------- public driver_device(machine_config mconfig, device_type type, string tag) : base(mconfig, type, tag, null, 0) { m_system = mconfig.gamedrv(); m_flip_screen_x = 0; m_flip_screen_y = 0; // set the search path to include all parents and cache it because devices search system paths m_searchpath.emplace_back(m_system.name); std.set <game_driver> seen = new std.set <game_driver>(); for (int ancestor = driver_list.clone(m_system); 0 <= ancestor; ancestor = driver_list.clone((size_t)ancestor)) { if (!seen.insert(driver_list.driver((size_t)ancestor))) { throw new emu_fatalerror("driver_device({0}): parent/clone relationships form a loop", m_system.name); } m_searchpath.emplace_back(driver_list.driver((size_t)ancestor).name); } }
//bool header_exists(const char *description) const; // configuration //------------------------------------------------- // add_entry - adds an entry //------------------------------------------------- protected void add_entry(entry entry, string after_header = null) { // update the entry map foreach (string name in entry.names()) { // append the entry add_to_entry_map(name, entry); } // and add the entry to the vector m_entries.emplace_back(entry); }
// methods //------------------------------------------------- // line::add_character //------------------------------------------------- public void add_character(text_layout layout, char32_t ch, char_style style, source_info source) { // get the width of this character float chwidth = layout.get_char_width(ch, style.size); // append the positioned character m_characters.emplace_back(new positioned_char() { character = ch, style = style, source = source, xoffset = m_width, xwidth = chwidth }); m_width += chwidth; // we might be bigger m_height = std.max(m_height, style.size * layout.yscale()); }
//bool header_exists(const char *description) const; // configuration //------------------------------------------------- // add_entry - adds an entry //------------------------------------------------- protected void add_entry(entry entry, string after_header = null) { // update the entry map foreach (string name in entry.names()) { // append the entry add_to_entry_map(name, entry); // for booleans, add the "-noXYZ" option as well if (entry.type() == option_type.BOOLEAN) { add_to_entry_map("no" + name, entry); } } // and add the entry to the vector m_entries.emplace_back(entry); }
void mismatched_patch(memory_units_descriptor <int_Width, int_AddrShift> descriptor, u8 rkey, std.vector <mapping> mappings, ref handler_entry_read <int_Width, int_AddrShift> target) { u8 ukey = descriptor.rkey_to_ukey(rkey); handler_entry_read <int_Width, int_AddrShift> original = target.is_units() ? target : null; handler_entry_read <int_Width, int_AddrShift> replacement = null; foreach (var p in mappings) { if (p.ukey == ukey && p.original == original) { replacement = p.patched; break; } } if (replacement == null) { if (original != null) { replacement = new handler_entry_read_units <int_Width, int_AddrShift>(descriptor, ukey, (handler_entry_read_units <int_Width, int_AddrShift>)original); } else { replacement = new handler_entry_read_units <int_Width, int_AddrShift>(descriptor, ukey, m_space); } mappings.emplace_back(new mapping() { original = original, patched = replacement, ukey = ukey }); } else { replacement.ref_(); } target.unref(); target = replacement; }
public void compile_infix(string expr, std.vector <string> inputs) //void compile_infix(const pstring &expr, const inputs_container &inputs = inputs_container()) noexcept(false); { // Shunting-yard infix parsing std.vector <string> sep = new std.vector <string> { "(", ")", ",", "*", "/", "+", "-", "^", "<=", ">=", "==", "!=", "<", ">" }; std.vector <string> sexpr2 = plib.pg.psplit(plib.pg.replace_all(expr, " ", ""), sep); std.stack <string> opstk = new std.stack <string>(); std.vector <string> postfix = new std.vector <string>(); std.vector <string> sexpr1 = new std.vector <string>(); std.vector <string> sexpr = new std.vector <string>(); // FIXME: We really need to switch to ptokenizer and fix negative number // handling in ptokenizer. // copy/paste to the int version below // Fix numbers exponential numbers for (size_t i = 0; i < sexpr2.size();) { if (i + 2 < sexpr2.size() && sexpr2[i].length() > 1) { var r = plib.pg.right(sexpr2[i], 1); var ne = sexpr2[i + 1]; if (is_number(sexpr2[i]) && (r == "e" || r == "E") && (ne == "-" || ne == "+")) { sexpr1.push_back(sexpr2[i] + ne + sexpr2[i + 2]); i += 3; } else { sexpr1.push_back(sexpr2[i++]); } } else { sexpr1.push_back(sexpr2[i++]); } } // Fix numbers with unary minus/plus for (size_t i = 0; i < sexpr1.size();) { if (sexpr1[i] == "-" && (i + 1 < sexpr1.size()) && is_number(sexpr1[i + 1])) { if (i == 0 || !(is_number(sexpr1[i - 1]) || sexpr1[i - 1] == ")" || is_id(sexpr1[i - 1]))) { sexpr.push_back("-" + sexpr1[i + 1]); i += 2; } else { sexpr.push_back(sexpr1[i++]); } } else if (sexpr1[i] == "-" && (i + 1 < sexpr1.size()) && (is_id(sexpr1[i + 1]) || sexpr1[i + 1] == "(")) { if (i == 0 || !(is_number(sexpr1[i - 1]) || sexpr1[i - 1] == ")" || is_id(sexpr1[i - 1]))) { sexpr.emplace_back("neg"); sexpr.push_back(sexpr1[i + 1]); i += 2; } else { sexpr.push_back(sexpr1[i++]); } } else { sexpr.push_back(sexpr1[i++]); } } for (size_t i = 0; i < sexpr.size(); i++) { string s = sexpr[i]; if (s == "(") { opstk.push(s); } else if (s == ")") { string x = pop_check(opstk, expr); while (x != "(") { postfix.push_back(x); x = pop_check(opstk, expr); } if (!opstk.empty() && get_prio(opstk.top()) == 0) { postfix.push_back(pop_check(opstk, expr)); } } else if (s == ",") { string x = pop_check(opstk, expr); while (x != "(") { postfix.push_back(x); x = pop_check(opstk, expr); } opstk.push(x); } else { int prio = get_prio(s); if (prio > 0) { if (opstk.empty()) { opstk.push(s); } else { if (get_prio(opstk.top()) >= prio) { postfix.push_back(pop_check(opstk, expr)); } opstk.push(s); } } else if (prio == 0) // Function or variable { if ((i + 1 < sexpr.size()) && sexpr[i + 1] == "(") { opstk.push(s); } else { postfix.push_back(s); } } else { postfix.push_back(s); } } } while (!opstk.empty()) { postfix.push_back(opstk.top()); opstk.pop(); } //for (auto &e : postfix) // printf("\t%s\n", e.c_str()); compile_postfix(inputs, postfix, expr); }
//------------------------------------------------- // populate search list //------------------------------------------------- void populate_search() { // ensure search list is populated if (m_searchlist.empty()) { var sorted = m_persistent_data.sorted_list(); m_searchlist.reserve(sorted.size()); foreach (ui_system_info info in sorted) { m_searchlist.emplace_back(new std.pair <double, ui_system_info>(1.0, info)); } } // keep track of what we matched against string ucs_search = ustr_from_utf8(normalize_unicode(m_search, unicode_normalization_form.D, true)); //const std::u32string ucs_search(ustr_from_utf8(normalize_unicode(m_search, unicode_normalization_form::D, true))); // check available search data if (m_persistent_data.is_available(system_list.available.AVAIL_UCS_SHORTNAME)) { m_searched_fields |= (unsigned)system_list.available.AVAIL_UCS_SHORTNAME; } if (m_persistent_data.is_available(system_list.available.AVAIL_UCS_DESCRIPTION)) { m_searched_fields |= (unsigned)system_list.available.AVAIL_UCS_DESCRIPTION; } if (m_persistent_data.is_available(system_list.available.AVAIL_UCS_MANUF_DESC)) { m_searched_fields |= (unsigned)system_list.available.AVAIL_UCS_MANUF_DESC; } if (m_persistent_data.is_available(system_list.available.AVAIL_UCS_DFLT_DESC)) { m_searched_fields |= (unsigned)system_list.available.AVAIL_UCS_DFLT_DESC; } if (m_persistent_data.is_available(system_list.available.AVAIL_UCS_MANUF_DFLT_DESC)) { m_searched_fields |= (unsigned)system_list.available.AVAIL_UCS_MANUF_DFLT_DESC; } for (int i = 0; i < m_searchlist.Count; i++) //for (std::pair<double, std::reference_wrapper<ui_system_info const> > &info : m_searchlist) { var info = m_searchlist[i]; m_searchlist[i] = std.make_pair(1.0, info.second); ui_system_info sys = info.second; // match shortnames if ((m_searched_fields & (unsigned)system_list.available.AVAIL_UCS_SHORTNAME) != 0) { m_searchlist[i] = std.make_pair(util.edit_distance(ucs_search, sys.ucs_shortname), info.second); } // match reading if (info.first != 0 && !sys.ucs_reading_description.empty()) { m_searchlist[i] = std.make_pair(std.min(util.edit_distance(ucs_search, sys.ucs_reading_description), info.first), info.second); // match "<manufacturer> <reading>" if (info.first != 0) { m_searchlist[i] = std.make_pair(std.min(util.edit_distance(ucs_search, sys.ucs_manufacturer_reading_description), info.first), info.second); } } // match descriptions if (info.first != 0 && (m_searched_fields & (unsigned)system_list.available.AVAIL_UCS_DESCRIPTION) != 0) { m_searchlist[i] = std.make_pair(std.min(util.edit_distance(ucs_search, sys.ucs_description), info.first), info.second); } // match "<manufacturer> <description>" if (info.first != 0 && (m_searched_fields & (unsigned)system_list.available.AVAIL_UCS_MANUF_DESC) != 0) { m_searchlist[i] = std.make_pair(std.min(util.edit_distance(ucs_search, sys.ucs_manufacturer_description), info.first), info.second); } // match default description if (info.first != 0 && (m_searched_fields & (unsigned)system_list.available.AVAIL_UCS_DFLT_DESC) != 0 && !sys.ucs_default_description.empty()) { m_searchlist[i] = std.make_pair(std.min(util.edit_distance(ucs_search, sys.ucs_default_description), info.first), info.second); // match "<manufacturer> <default description>" if (info.first != 0 && (m_searched_fields & (unsigned)system_list.available.AVAIL_UCS_MANUF_DFLT_DESC) != 0) { m_searchlist[i] = std.make_pair(std.min(util.edit_distance(ucs_search, sys.ucs_manufacturer_default_description), info.first), info.second); } } } // sort according to edit distance //std::stable_sort( // m_searchlist.begin(), // m_searchlist.end()); // [] (auto const &lhs, auto const &rhs) { return lhs.first < rhs.first; }); m_searchlist.Sort((lhs, rhs) => { return(lhs.first.CompareTo(rhs.first)); }); }
public device_sound_interface add_route(u32 output, device_t base_, string target, double gain, u32 input, u32 mixoutput) { assert(!device().started()); m_route_list.emplace_back(new sound_route(output, input, mixoutput, (float)gain, base_, target)); return(this); }
protected override void populate(ref float customtop, ref float custombottom) { foreach (var icon in m_icons) // TODO: why is this here? maybe better on resize or setting change? { icon.second().texture = null; //icon.second().texture.reset(); } set_switch_image(); bool have_prev_selected = false; int old_item_selected = -1; if (!isfavorite()) { if (m_populated_favorites) { m_prev_selected = null; } m_populated_favorites = false; m_displaylist.clear(); machine_filter flt = m_persistent_data.filter_data().get_current_filter(); // if search is not empty, find approximate matches if (!string.IsNullOrEmpty(m_search)) { populate_search(); if (flt != null) { for (int i = 0; i < m_searchlist.Count && MAX_VISIBLE_SEARCH > m_displaylist.size(); i++) //for (auto it = m_searchlist.begin(); (m_searchlist.end() != it) && (MAX_VISIBLE_SEARCH > m_displaylist.size()); ++it) { var it = m_searchlist[i]; if (flt.apply(it.second)) { m_displaylist.emplace_back(it.second); } } } else { //std.transform( // m_searchlist.begin(), // std.next(m_searchlist.begin(), std.min(m_searchlist.size(), MAX_VISIBLE_SEARCH)), // std.back_inserter(m_displaylist), // [] (auto const &entry) { return entry.second; }); foreach (var it in m_searchlist) { m_displaylist.Add(it.second); } } } else { // if filter is set on category, build category list var sorted = m_persistent_data.sorted_list(); if (flt == null) { foreach (ui_system_info sysinfo in sorted) { m_displaylist.emplace_back(sysinfo); } } else { foreach (ui_system_info sysinfo in sorted) { if (flt.apply(sysinfo)) { m_displaylist.emplace_back(sysinfo); } } } } // iterate over entries int curitem = 0; foreach (ui_system_info elem in m_displaylist) { have_prev_selected = have_prev_selected || (elem == m_prev_selected); if ((old_item_selected == -1) && (elem.driver.name == reselect_last.driver())) { old_item_selected = curitem; } item_append(elem.description, elem.is_clone ? FLAG_INVERT : 0, elem); curitem++; } } else { // populate favorites list if (!m_populated_favorites) { m_prev_selected = null; } m_populated_favorites = true; m_search = ""; //m_search.clear(); int curitem = 0; mame_machine_manager.instance().favorite().apply_sorted( (info) => //[this, &have_prev_selected, &old_item_selected, curitem = 0] (ui_software_info const &info) mutable { have_prev_selected = have_prev_selected || (info == (ui_software_info)m_prev_selected); if (info.startempty != 0) { if (old_item_selected == -1 && info.shortname == reselect_last.driver()) { old_item_selected = curitem; } bool cloneof = std.strcmp(info.driver.parent, "0") != 0; if (cloneof) { int cx = driver_list.find(info.driver.parent); if ((0 <= cx) && ((driver_list.driver((size_t)cx).flags & machine_flags.type.IS_BIOS_ROOT) != 0)) { cloneof = false; } } item_append(info.longname, cloneof ? FLAG_INVERT : 0, info); } else { if (old_item_selected == -1 && info.shortname == reselect_last.driver()) { old_item_selected = curitem; } item_append(info.longname, info.devicetype, info.parentname.empty() ? 0 : FLAG_INVERT, info); } curitem++; }); } // add special items if (stack_has_special_main_menu()) { item_append(menu_item_type.SEPARATOR, 0); item_append(__("Configure Options"), 0, CONF_OPTS); item_append(__("Configure Machine"), 0, CONF_MACHINE); skip_main_items = 3; if (m_prev_selected != null && !have_prev_selected) { m_prev_selected = item(0).ref_(); } } else { skip_main_items = 0; } // configure the custom rendering customtop = 3.0f * ui().get_line_height() + 5.0f * ui().box_tb_border(); custombottom = 4.0f * ui().get_line_height() + 3.0f * ui().box_tb_border(); // reselect prior game launched, if any if (old_item_selected != -1) { set_selected_index(old_item_selected); if (ui_globals.visible_main_lines == 0) { top_line = (selected_index() != 0) ? selected_index() - 1 : 0; } else { top_line = selected_index() - (ui_globals.visible_main_lines / 2); } if (reselect_last.software().empty()) { reselect_last.reset(); } } else { reselect_last.reset(); } }