HRESULT CAnalyzer::hAddClassifyingCategories(CHasher * pco_wf) { if (pco_wf == NULL || m_pDb == NULL) { return E_FAIL; } CEString str_query (L"select * from descriptor where id = " + CEString::sToString<__int64>(pco_wf->m_llLexemeId)); CEString str_MainSymbol = L""; m_pDb->PrepareForSelect(str_query); m_pDb->bGetRow(); m_pDb->GetData(4, str_MainSymbol); ET_MainSymbol eoMs = m_mapMainSymbol[str_MainSymbol]; switch (eoMs) { case MS_M: pco_wf->m_eGender = GENDER_M; pco_wf->m_eAnimacy = ANIM_NO; break; case MS_MO: pco_wf->m_eGender = GENDER_M; pco_wf->m_eAnimacy = ANIM_YES; break; case MS_ZH: pco_wf->m_eGender = GENDER_F; pco_wf->m_eAnimacy = ANIM_NO; break; case MS_ZHO: pco_wf->m_eGender = GENDER_F; pco_wf->m_eAnimacy = ANIM_YES; break; case MS_S: pco_wf->m_eGender = GENDER_N; pco_wf->m_eAnimacy = ANIM_NO; break; case MS_SO: pco_wf->m_eGender = GENDER_N; pco_wf->m_eAnimacy = ANIM_YES; break; case MS_MO_ZHO: pco_wf->m_eAnimacy = ANIM_YES; break; case MS_MN_NEOD: pco_wf->m_eAnimacy = ANIM_NO; break; case MS_MN_ODUSH: pco_wf->m_eAnimacy = ANIM_YES; break; case MS_SV: pco_wf->m_eAspect = ASPECT_PERFECTIVE; break; case MS_NSV: pco_wf->m_eAspect = ASPECT_IMPERFECTIVE; break; } // switch return S_OK; }
// (PHP-CALLBACK entry-point) This manually gets a lock where needed but // avoids holding one most of the time as this can be a quite slow operation. void runCallback() { hphp_session_init(Treadmill::SessionKind::Watchman); auto context = g_context.getNoCheck(); SCOPE_EXIT { hphp_context_exit(); hphp_session_exit(); { std::lock_guard<std::mutex> g(s_sharedDataMutex); processNextUpdate(); } }; try { std::string json_data; { std::lock_guard<std::mutex> g(s_sharedDataMutex); if (m_unprocessedCallbackData.empty()) { return; } auto& data = m_unprocessedCallbackData.back(); json_data = toJson(data); m_unprocessedCallbackData.pop_back(); } bool initial; auto unit = lookupUnit( String(m_callbackFile.c_str()).get(), "", &initial, Native::s_noNativeFuncs); if (!unit) { throw std::runtime_error( folly::sformat("Unit '{}' no longer exists.", m_callbackFile)); } auto unit_result = Variant::attach(context->invokeUnit(unit)); auto func = Unit::loadFunc(String(m_callbackFunc.c_str()).get()); if (!func) { throw std::runtime_error( folly::sformat("Callback '{}' no longer exists", m_callbackFunc)); } String str_path(m_path.c_str()); String str_query(m_query.c_str()); String str_name(m_name.c_str()); String str_json_data(json_data.c_str()); String str_socket_path(m_socketPath.c_str()); TypedValue args[] = { str_path.toCell(), str_query.toCell(), str_name.toCell(), str_json_data.toCell(), str_socket_path.toCell(), }; tvDecRefGen( context->invokeFuncFew(func, nullptr, // thisOrCls nullptr, // invName 5, // argc args) ); } catch(Exception& e) { if (m_error.empty()) { m_error = e.getMessage(); } } catch(Object& e) { if (m_error.empty()) { try { m_error = e->invokeToString().data(); } catch(...) { m_error = "PHP exception which cannot be turned into a string"; } } } catch(const std::exception& e) { if (m_error.empty()) { m_error = folly::exceptionStr(e).toStdString(); } } catch(...) { if (m_error.empty()) { m_error = "Unknown error (non std::exception)"; } } }