int icompare(const std::string& s1, const std::string& s2) { // todo: maybe we should replace this preprocessor check with a std::has_facet<bl::collator<char>> check? #ifdef __APPLE__ // https://github.com/wesnoth/wesnoth/issues/2094 return compare(ascii_to_lowercase(s1), ascii_to_lowercase(s2)); #else std::lock_guard<std::mutex> lock(get_mutex()); try { return std::use_facet<bl::collator<char>>(get_manager().get_locale()).compare( bl::collator_base::secondary, s1, s2); } catch(const std::bad_cast&) { static bool bad_cast_once = false; if(!bad_cast_once) { ERR_G << "locale set-up for icompare() is broken, falling back to std::string::compare()\n"; try { //just to be safe. ERR_G << get_manager().debug_description() << "\n"; } catch (const std::exception& e) { ERR_G << e.what() << "\n"; } bad_cast_once = true; } // Let's convert at least ASCII letters to lowercase to get a somewhat case-insensitive comparison. return ascii_to_lowercase(s1).compare(ascii_to_lowercase(s2)); } #endif }
void bind_textdomain(const char* domain, const char* direcory, const char* /*encoding*/) { LOG_G << "adding textdomain '" << domain << "' in directory '" << direcory << "'\n"; get_manager().generator_.add_messages_domain(domain); get_manager().generator_.add_messages_path(direcory); get_manager().update_locale(); }
void bind_textdomain(const char* domain, const char* directory, const char* /*encoding*/) { LOG_G << "adding textdomain '" << domain << "' in directory '" << directory << "'\n"; std::lock_guard<std::mutex> lock(get_mutex()); get_manager().add_messages_domain(domain); get_manager().add_messages_path(directory); get_manager().update_locale(); }
std::ostream& solver::display(std::ostream & out) const { expr_ref_vector fmls(get_manager()); get_assertions(fmls); ast_pp_util visitor(get_manager()); visitor.collect(fmls); visitor.display_decls(out); visitor.display_asserts(out, fmls, true); return out; }
void Scene_object::Render(XMMATRIX& viewMX, XMMATRIX& projMX, shaders& _sh) { XMMATRIX tempModelMX = XMLoadFloat4x4(&modelMX); XMMATRIX mx = tempModelMX*viewMX*projMX; XMMATRIX wvpMX = XMMatrixTranspose(mx); XMStoreFloat4x4(&objbuff.worldViewProj,wvpMX); _sh.set_active(VIbuffer,0); get_manager()->disable_blend(); get_manager()->enable_depthStateLess(); //_dxImmedDC->OMSetBlendState(0, 0, 0xffffffff); //_dxImmedDC->OMSetDepthStencilState(manager->m_depthStencilStateLess, 1); _dxImmedDC->UpdateSubresource(Buffer, 0, 0, &objbuff,0, 0); _dxImmedDC->VSSetConstantBuffers(0,1,&Buffer); _dxImmedDC->DrawIndexed(VIbuffer.index_amount, 0, 0); }
relation_mutator_fn * sieve_relation_plugin::mk_filter_interpreted_fn(const relation_base & rb, app * condition) { if(&rb.get_plugin()!=this) { return 0; } ast_manager & m = get_ast_manager(); const sieve_relation & r = static_cast<const sieve_relation &>(rb); const relation_signature sig = r.get_signature(); unsigned sz = sig.size(); var_idx_set& cond_vars = get_context().get_rule_manager().collect_vars(condition); expr_ref_vector subst_vect(m); subst_vect.resize(sz); unsigned subst_ofs = sz-1; for(unsigned i=0; i<sz; i++) { if(!cond_vars.contains(i)) { continue; } if(!r.is_inner_col(i)) { //If the condition involves columns which do not belong to the inner relation, //we do nothing (which introduces imprecision). //Maybe we might try to do some quantifier elimination... return alloc(identity_relation_mutator_fn); } subst_vect[subst_ofs-i] = m.mk_var(r.m_sig2inner[i], sig[i]); } expr_ref inner_cond(m); get_context().get_var_subst()(condition, subst_vect.size(), subst_vect.c_ptr(), inner_cond); relation_mutator_fn * inner_fun = get_manager().mk_filter_interpreted_fn(r.get_inner(), to_app(inner_cond)); if(!inner_fun) { return 0; } return alloc(filter_fn, inner_fun); }
relation_transformer_fn * sieve_relation_plugin::mk_rename_fn(const relation_base & r0, unsigned cycle_len, const unsigned * permutation_cycle) { if(&r0.get_plugin()!=this) { return 0; } const sieve_relation & r = static_cast<const sieve_relation &>(r0); unsigned sig_sz = r.get_signature().size(); unsigned_vector permutation; add_sequence(0, sig_sz, permutation); permutate_by_cycle(permutation, cycle_len, permutation_cycle); bool inner_identity; unsigned_vector inner_permutation; collect_sub_permutation(permutation, r.m_sig2inner, inner_permutation, inner_identity); svector<bool> result_inner_cols = r.m_inner_cols; permutate_by_cycle(result_inner_cols, cycle_len, permutation_cycle); relation_signature result_sig; relation_signature::from_rename(r.get_signature(), cycle_len, permutation_cycle, result_sig); relation_transformer_fn * inner_fun = get_manager().mk_permutation_rename_fn(r.get_inner(), inner_permutation); if(!inner_fun) { return 0; } return alloc(transformer_fn, inner_fun, result_sig, result_inner_cols.c_ptr()); }
relation_mutator_fn * sieve_relation_plugin::mk_filter_identical_fn(const relation_base & r0, unsigned col_cnt, const unsigned * identical_cols) { if(&r0.get_plugin()!=this) { return 0; } const sieve_relation & r = static_cast<const sieve_relation &>(r0); unsigned_vector inner_icols; //we ignore the columns which do not belong to the inner relation (which introduces imprecision) for(unsigned i=0; i<col_cnt; i++) { unsigned col = identical_cols[i]; if(r.is_inner_col(col)) { inner_icols.push_back(r.get_inner_col(col)); } } if(inner_icols.size()<2) { return alloc(identity_relation_mutator_fn); } relation_mutator_fn * inner_fun = get_manager().mk_filter_identical_fn(r.get_inner(), inner_icols); if(!inner_fun) { return 0; } return alloc(filter_fn, inner_fun); }
theory_fpa::~theory_fpa() { ast_manager & m = get_manager(); dec_ref_map_values(m, m_conversions); dec_ref_map_values(m, m_wraps); dec_ref_map_values(m, m_unwraps); }
relation_transformer_fn * sieve_relation_plugin::mk_project_fn(const relation_base & r0, unsigned col_cnt, const unsigned * removed_cols) { if(&r0.get_plugin()!=this) { return 0; } const sieve_relation & r = static_cast<const sieve_relation &>(r0); unsigned_vector inner_removed_cols; for(unsigned i=0; i<col_cnt; i++) { unsigned col = removed_cols[i]; if(r.is_inner_col(col)) { inner_removed_cols.push_back(r.get_inner_col(col)); } } svector<bool> result_inner_cols = r.m_inner_cols; project_out_vector_columns(result_inner_cols, col_cnt, removed_cols); relation_signature result_sig; relation_signature::from_project(r.get_signature(), col_cnt, removed_cols, result_sig); relation_transformer_fn * inner_fun; if(inner_removed_cols.empty()) { inner_fun = alloc(identity_relation_transformer_fn); } else { inner_fun = get_manager().mk_project_fn(r.get_inner(), inner_removed_cols); } if(!inner_fun) { return 0; } return alloc(transformer_fn, inner_fun, result_sig, result_inner_cols.c_ptr()); }
void set_language(const std::string& language, const std::vector<std::string>* /*alternates*/) { // why shoudl we need alternates? which languages we support shoudl only be related // to which languages we ship with and not which the os supports LOG_G << "setting language to '" << language << "' \n"; get_manager().set_language(language); }
relation_join_fn * sieve_relation_plugin::mk_join_fn(const relation_base & r1, const relation_base & r2, unsigned col_cnt, const unsigned * cols1, const unsigned * cols2) { if( &r1.get_plugin()!=this && &r2.get_plugin()!=this ) { //we create just operations that involve the current plugin return 0; } bool r1_sieved = r1.get_plugin().is_sieve_relation(); bool r2_sieved = r2.get_plugin().is_sieve_relation(); const sieve_relation * sr1 = r1_sieved ? static_cast<const sieve_relation *>(&r1) : 0; const sieve_relation * sr2 = r2_sieved ? static_cast<const sieve_relation *>(&r2) : 0; const relation_base & inner1 = r1_sieved ? sr1->get_inner() : r1; const relation_base & inner2 = r2_sieved ? sr2->get_inner() : r2; unsigned_vector inner_cols1; unsigned_vector inner_cols2; for(unsigned i=0; i<col_cnt; i++) { //if at least one end of an equality is not an inner column, we ignore that equality //(which introduces imprecision) if(r1_sieved && !sr1->is_inner_col(cols1[i])) { continue; } if(r2_sieved && !sr2->is_inner_col(cols2[i])) { continue; } inner_cols1.push_back( r1_sieved ? sr1->get_inner_col(cols1[i]) : cols1[i] ); inner_cols2.push_back( r2_sieved ? sr2->get_inner_col(cols2[i]) : cols2[i] ); } relation_join_fn * inner_join_fun = get_manager().mk_join_fn(inner1, inner2, inner_cols1, inner_cols2, false); if(!inner_join_fun) { return 0; } return alloc(join_fn, *this, r1, r2, col_cnt, cols1, cols2, inner_join_fun); }
cata::optional<zone_type_id> zone_manager::query_type() const { const auto &types = get_manager().get_types(); uilist as_m; as_m.desc_enabled = true; as_m.text = _( "Select zone type:" ); size_t i = 0; for( const auto &pair : types ) { const auto &type = pair.second; as_m.addentry_desc( i++, true, MENU_AUTOASSIGN, type.name(), type.desc() ); } as_m.query(); if( as_m.ret < 0 ) { return {}; } size_t index = as_m.ret; auto iter = types.begin(); std::advance( iter, index ); return iter->first; }
/** \brief return the complement of variables that are currently assigned. */ void theory_wmaxsat::get_assignment(svector<bool>& result) { result.reset(); if (!m_found_optimal) { for (unsigned i = 0; i < m_vars.size(); ++i) { result.push_back(false); } } else { std::sort(m_cost_save.begin(), m_cost_save.end()); for (unsigned i = 0,j = 0; i < m_vars.size(); ++i) { if (j < m_cost_save.size() && m_cost_save[j] == static_cast<theory_var>(i)) { result.push_back(false); ++j; } else { result.push_back(true); } } } TRACE("opt", tout << "cost save: "; for (unsigned i = 0; i < m_cost_save.size(); ++i) { tout << m_cost_save[i] << " "; } tout << "\nvars: "; for (unsigned i = 0; i < m_vars.size(); ++i) { tout << mk_pp(m_vars[i].get(), get_manager()) << " "; } tout << "\nassignment: "; for (unsigned i = 0; i < result.size(); ++i) { tout << result[i] << " "; } tout << "\n";);
simplifier_plugin * user_simplifier_plugin::mk_fresh() { ast_manager & m = get_manager(); user_simplifier_plugin * new_sp = alloc(user_simplifier_plugin, m.get_family_name(get_family_id()), m); new_sp->m_reduce_app_fptr = m_reduce_app_fptr; new_sp->m_reduce_eq_fptr = m_reduce_eq_fptr; new_sp->m_reduce_distinct_fptr = m_reduce_distinct_fptr; return new_sp; }
relation_base * sieve_relation_plugin::mk_full(func_decl* p, const relation_signature & s) { relation_signature empty_sig; relation_plugin& plugin = get_manager().get_appropriate_plugin(s); relation_base * inner = plugin.mk_full(p, empty_sig, null_family_id); svector<bool> inner_cols; inner_cols.resize(s.size(), false); return mk_from_inner(s, inner_cols, inner); }
relation_base * sieve_relation_plugin::mk_empty(const relation_signature & s, family_id kind) { rel_spec spec; m_spec_store.get_relation_spec(s, kind, spec); relation_signature inner_sig; collect_inner_signature(s, spec.m_inner_cols, inner_sig); relation_base * inner = get_manager().mk_empty_relation(inner_sig, spec.m_inner_kind); return mk_from_inner(s, spec.m_inner_cols.c_ptr(), inner); }
std::string strftime(const std::string& format, const std::tm* time) { std::basic_ostringstream<char> dummy; std::lock_guard<std::mutex> lock(get_mutex()); dummy.imbue(get_manager().get_locale()); dummy << std::put_time(time, format.c_str()); return dummy.str(); }
void relation_base::reset() { ast_manager & m = get_plugin().get_ast_manager(); app_ref bottom_ref(m.mk_false(), m); scoped_ptr<relation_mutator_fn> reset_fn = get_manager().mk_filter_interpreted_fn(*this, bottom_ref); if(!reset_fn) { NOT_IMPLEMENTED_YET(); } (*reset_fn)(*this); }
relation_base * product_relation_plugin::mk_empty(const relation_signature & s, family_id kind) { rel_spec spec; m_spec_store.get_relation_spec(s, kind, spec); relation_vector inner_rels; unsigned rel_cnt = spec.size(); for(unsigned i=0; i<rel_cnt; i++) { inner_rels.push_back(get_manager().mk_empty_relation(s, spec[i])); } return alloc(product_relation,*this, s, inner_rels.size(), inner_rels.c_ptr()); }
bool ci_search(const std::string& s1, const std::string& s2) { std::lock_guard<std::mutex> lock(get_mutex()); const std::locale& locale = get_manager().get_locale(); std::string ls1 = bl::to_lower(s1, locale); std::string ls2 = bl::to_lower(s2, locale); return std::search(ls1.begin(), ls1.end(), ls2.begin(), ls2.end()) != ls1.end(); }
void linphone_notify_received(LinphoneCore *lc, LinphoneEvent *lev, const char *eventname, const LinphoneContent *content){ LinphoneCoreManager *mgr; const char * ua = linphone_event_get_custom_header(lev, "User-Agent"); BC_ASSERT_PTR_NOT_NULL_FATAL(content); if (!linphone_content_is_multipart(content) && (!ua || !strstr(ua, "flexisip"))) { /*disable check for full presence serveur support*/ /*hack to disable content checking for list notify */ BC_ASSERT_STRING_EQUAL(notify_content,(const char*)linphone_content_get_buffer(content)); } mgr=get_manager(lc); mgr->stat.number_of_NotifyReceived++; }
int main(int argc, char **argv) { new_manager(); FiberManager *fm = get_manager(); fm->add(hectate_fiber, argc, argv); while (fm->size()) { fm->run(); } delete_manager(); std::wcout << "Goodbye." << std::endl; return 0; }
void linphone_subscription_state_change(LinphoneCore *lc, LinphoneEvent *lev, LinphoneSubscriptionState state) { stats* counters = get_stats(lc); LinphoneCoreManager *mgr=get_manager(lc); LinphoneContent* content; const LinphoneAddress* from_addr = linphone_event_get_from(lev); char* from = linphone_address_as_string(from_addr); content = linphone_core_create_content(lc); linphone_content_set_type(content,"application"); linphone_content_set_subtype(content,"somexml2"); linphone_content_set_buffer(content,notify_content,strlen(notify_content)); ms_message("Subscription state [%s] from [%s]",linphone_subscription_state_to_string(state),from); ms_free(from); switch(state){ case LinphoneSubscriptionNone: break; case LinphoneSubscriptionIncomingReceived: counters->number_of_LinphoneSubscriptionIncomingReceived++; mgr->lev=lev; if (!mgr->decline_subscribe) linphone_event_accept_subscription(lev); else linphone_event_deny_subscription(lev, LinphoneReasonDeclined); break; case LinphoneSubscriptionOutgoingInit: counters->number_of_LinphoneSubscriptionOutgoingInit++; break; case LinphoneSubscriptionPending: counters->number_of_LinphoneSubscriptionPending++; break; case LinphoneSubscriptionActive: counters->number_of_LinphoneSubscriptionActive++; if (linphone_event_get_subscription_dir(lev)==LinphoneSubscriptionIncoming){ mgr->lev=lev; linphone_event_notify(lev,content); } break; case LinphoneSubscriptionTerminated: counters->number_of_LinphoneSubscriptionTerminated++; mgr->lev=NULL; break; case LinphoneSubscriptionError: counters->number_of_LinphoneSubscriptionError++; mgr->lev=NULL; break; case LinphoneSubscriptionExpiring: counters->number_of_LinphoneSubscriptionExpiring++; mgr->lev=NULL; break; } linphone_content_unref(content); }
std::string dsngettext (const char * domainname, const char *singular, const char *plural, int n) { std::string msgval = bl::dngettext(domainname, singular, plural, n, get_manager().get_locale()); if (msgval == singular) { const char* firsthat = std::strrchr (singular, '^'); if (firsthat == nullptr) msgval = singular; else msgval = firsthat + 1; } return msgval; }
std::string dsngettext (const char * domainname, const char *singular, const char *plural, int n) { std::string msgval = boost::locale::dngettext(domainname, singular, plural, n, get_manager().current_locale_); if (msgval == singular) { const char* firsthat = std::strrchr (singular, '^'); if (firsthat == NULL) msgval = singular; else msgval = firsthat + 1; } return msgval; }
void set_language(const std::string& language, const std::vector<std::string>* /*alternates*/) { // why shoudl we need alternates? which languages we support shoudl only be related // to which languages we ship with and not which the os supports LOG_G << "setting language to '" << language << "' \n"; std::string::size_type at_pos = language.rfind('@'); if(language.empty()) { //Don't add "UTF-8" to default language. get_manager().current_language_ = ""; } else if(at_pos != std::string::npos) { get_manager().current_language_ = language.substr(0, at_pos) + ".UTF-8" + language.substr(at_pos); } else { get_manager().current_language_ = language + ".UTF-8"; } get_manager().update_locale(); }
std::string strftime(const std::string& format, const std::tm* time) { std::basic_ostringstream<char> dummy; dummy.imbue(get_manager().get_locale()); // See utils/io.hpp for explanation of this check #if HAVE_PUT_TIME dummy << std::put_time(time, format.c_str()); #else dummy << bl::as::ftime(format) << mktime(const_cast<std::tm*>(time)); #endif return dummy.str(); }
std::string dsngettext (const char * domainname, const char *singular, const char *plural, int n) { //TODO: only the next line needs to be in the lock. std::lock_guard<std::mutex> lock(get_mutex()); std::string msgval = bl::dngettext(domainname, singular, plural, n, get_manager().get_locale()); if (msgval == singular) { const char* firsthat = std::strrchr (singular, '^'); if (firsthat == nullptr) msgval = singular; else msgval = firsthat + 1; } return msgval; }
bool zone_manager::has_loot_dest_near( const tripoint &where ) const { for( const auto &ztype : get_manager().get_types() ) { const zone_type_id &type = ztype.first; if( type == zone_type_id( "CAMP_FOOD" ) || type == zone_type_id( "FARM_PLOT" ) || type == zone_type_id( "LOOT_UNSORTED" ) || type == zone_type_id( "LOOT_IGNORE" ) || type == zone_type_id( "NO_AUTO_PICKUP" ) || type == zone_type_id( "NO_NPC_PICKUP" ) ) { continue; } if( has_near( type, where ) ) { return true; } } return false; }