inline bool operator == (const name_t& x, const name_t& y) { /* The test case for equal strings is "optimized" because names are stored in hash tables and will often match on a find because the compiler will pool string constants. */ if (x.c_str() == y.c_str()) return true; return adobe::strcmp(x.c_str(), y.c_str()) == 0; }
void basic_sheet_t::add_interface(name_t name, const any_regular_t& value) { interface_cell_set_m.push_back(interface_cell_t(value)); interface_cell_t* cell(&interface_cell_set_m.back()); variable_index_m.insert(std::make_pair(name.c_str(), cell)); interface_index_m.insert(std::make_pair(name.c_str(), cell)); }
device::device(name_t const &name) : m_device(nullptr, &alcCloseDevice) { m_device.reset(alcOpenDevice(name.c_str())); if(!m_device) { throw std::runtime_error("Unable to open device: " + name); } }
sf::Packet BaseMessages::create(name_t msgName) { if (!sendable.exists(msgName)) Console::PrintError("Message name doesn't exist '%s'", msgName.c_str()); return create(sendable.get(msgName).getId()); }
modifiers_t name_to_modifer(name_t name) { /* REVISIT (sparent) : need a little lookup table here. I would still like to see us get to a semantic notion for modifiers. */ if (name == key_modifier_option) return modifiers_any_option_s; if (name == key_modifier_command) return modifiers_any_command_s; if (name == key_modifier_control) return modifiers_any_control_s; if (name == key_modifier_shift) return modifiers_any_shift_s; // REVISIT (sparent) : put an assert here later to clean out these older names. if (name == key_modifiers_cmd) return modifiers_any_command_s; if (name == key_modifiers_ctl) return modifiers_any_control_s; if (name == key_modifiers_ctlcmd) return modifiers_any_control_s | modifiers_any_command_s; if (name == key_modifiers_opt) return modifiers_any_option_s; if (name == key_modifiers_optcmd) return modifiers_any_option_s | modifiers_any_command_s; if (name == key_modifiers_optctl) return modifiers_any_option_s | modifiers_any_control_s; if (name == key_modifiers_optctlcmd) return modifiers_any_option_s | modifiers_any_control_s | modifiers_any_command_s; std::string error("unknown modifier: "); error << name.c_str(); throw std::invalid_argument(error); }
inline std::size_t hash_value(name_t name) { std::size_t seed = 0; for (const char* first = name.c_str(); *first; ++first) { seed = 5 * seed + *first; } return seed; }
void basic_sheet_t::add_constant(name_t name, const any_regular_t& value) { constant_cell_set_m.push_back(cell_t(value)); const cell_t* cell(&constant_cell_set_m.back()); variable_index_m.insert(std::make_pair(name.c_str(), cell)); }
any_regular_t vm_lookup_t::aproc(name_t name, const array_t& argument_set) const { array_function_map_t::const_iterator found(amap_m.find(name)); if (found != amap_m.end()) return found->second(argument_set); throw std::runtime_error(adobe::make_string("AFunction ", name.c_str(), " not found.")); }
inline void throw_parser_exception(name_t expected, name_t found, const line_position_t& position) { throw_parser_exception(expected.c_str(), found.c_str(), position); }
inline bool operator<(const name_t& x, const name_t& y) { return adobe::strcmp(x.c_str(), y.c_str()) < 0; }
std::size_t basic_sheet_t::count_interface(name_t name) const { return interface_index_m.count(name.c_str()); }