Fix g++ Internal Compiler Error 2.

GitOrigin-RevId: d1881c8bc7ca03bfb6e48d93cd4217a0a14ab7d2
This commit is contained in:
levlam 2018-04-09 21:53:43 +03:00
parent 50ab1fd175
commit 1c3ba5c3a3
2 changed files with 49 additions and 35 deletions

View File

@ -192,13 +192,8 @@ PhoneNumberManager::PhoneNumberManager(PhoneNumberManager::Type type, ActorShare
: type_(type), parent_(std::move(parent)) {
}
void PhoneNumberManager::set_phone_number(uint64 query_id, string phone_number, bool allow_flash_call,
bool is_current_phone_number) {
if (phone_number.empty()) {
return on_query_error(query_id, Status::Error(8, "Phone number can't be empty"));
}
auto process_send_code = [&](auto r_send_code) {
template <class T>
void PhoneNumberManager::process_send_code_result(uint64 query_id, T r_send_code) {
if (r_send_code.is_error()) {
return on_query_error(query_id, r_send_code.move_as_error());
}
@ -206,18 +201,24 @@ void PhoneNumberManager::set_phone_number(uint64 query_id, string phone_number,
on_new_query(query_id);
start_net_query(NetQueryType::SendCode, G()->net_query_creator().create(create_storer(r_send_code.move_as_ok())));
};
}
void PhoneNumberManager::set_phone_number(uint64 query_id, string phone_number, bool allow_flash_call,
bool is_current_phone_number) {
if (phone_number.empty()) {
return on_query_error(query_id, Status::Error(8, "Phone number can't be empty"));
}
switch (type_) {
case Type::ChangePhone:
return process_send_code(
send_code_helper_.send_change_phone_code(phone_number, allow_flash_call, is_current_phone_number));
return process_send_code_result(
query_id, send_code_helper_.send_change_phone_code(phone_number, allow_flash_call, is_current_phone_number));
case Type::VerifyPhone:
return process_send_code(
send_code_helper_.send_verify_phone_code(phone_number, allow_flash_call, is_current_phone_number));
return process_send_code_result(
query_id, send_code_helper_.send_verify_phone_code(phone_number, allow_flash_call, is_current_phone_number));
case Type::ConfirmPhone:
return process_send_code(
send_code_helper_.send_confirm_phone_code(phone_number, allow_flash_call, is_current_phone_number));
return process_send_code_result(
query_id, send_code_helper_.send_confirm_phone_code(phone_number, allow_flash_call, is_current_phone_number));
default:
UNREACHABLE();
}
@ -240,25 +241,28 @@ void PhoneNumberManager::resend_authentication_code(uint64 query_id) {
NetQuery::Type::Common, NetQuery::AuthFlag::Off));
}
template <class T>
void PhoneNumberManager::send_new_check_code_query(const T &query) {
start_net_query(NetQueryType::CheckCode, G()->net_query_creator().create(create_storer(query)));
}
void PhoneNumberManager::check_code(uint64 query_id, string code) {
if (state_ != State::WaitCode) {
return on_query_error(query_id, Status::Error(8, "checkAuthenticationCode unexpected"));
}
on_new_query(query_id);
auto send_new_query = [&](auto q) {
start_net_query(NetQueryType::CheckCode, G()->net_query_creator().create(create_storer(q)));
};
switch (type_) {
case Type::ChangePhone:
return send_new_query(telegram_api::account_changePhone(send_code_helper_.phone_number().str(),
send_code_helper_.phone_code_hash().str(), code));
return send_new_check_code_query(telegram_api::account_changePhone(
send_code_helper_.phone_number().str(), send_code_helper_.phone_code_hash().str(), code));
case Type::ConfirmPhone:
return send_new_query(telegram_api::account_confirmPhone(send_code_helper_.phone_code_hash().str(), code));
return send_new_check_code_query(
telegram_api::account_confirmPhone(send_code_helper_.phone_code_hash().str(), code));
case Type::VerifyPhone:
return send_new_query(telegram_api::account_verifyPhone(send_code_helper_.phone_number().str(),
send_code_helper_.phone_code_hash().str(), code));
return send_new_check_code_query(telegram_api::account_verifyPhone(
send_code_helper_.phone_number().str(), send_code_helper_.phone_code_hash().str(), code));
default:
UNREACHABLE();
}
@ -303,22 +307,23 @@ void PhoneNumberManager::start_net_query(NetQueryType net_query_type, NetQueryPt
G()->net_query_dispatcher().dispatch_with_callback(std::move(net_query), actor_shared(this));
}
void PhoneNumberManager::on_check_code_result(NetQueryPtr &result) {
auto process_result = [&](auto result) {
template <class T>
void PhoneNumberManager::process_check_code_result(T result) {
if (result.is_error()) {
return on_query_error(result.move_as_error());
}
state_ = State::Ok;
on_query_ok();
};
}
void PhoneNumberManager::on_check_code_result(NetQueryPtr &result) {
switch (type_) {
case Type::ChangePhone:
return process_result(fetch_result<telegram_api::account_changePhone>(result->ok()));
return process_check_code_result(fetch_result<telegram_api::account_changePhone>(result->ok()));
case Type::VerifyPhone:
return process_result(fetch_result<telegram_api::account_verifyPhone>(result->ok()));
return process_check_code_result(fetch_result<telegram_api::account_verifyPhone>(result->ok()));
case Type::ConfirmPhone:
return process_result(fetch_result<telegram_api::account_confirmPhone>(result->ok()));
return process_check_code_result(fetch_result<telegram_api::account_confirmPhone>(result->ok()));
default:
UNREACHABLE();
}

View File

@ -123,6 +123,15 @@ class PhoneNumberManager : public NetActor {
void on_query_ok();
void start_net_query(NetQueryType net_query_type, NetQueryPtr net_query);
template <class T>
void process_send_code_result(uint64 query_id, T r_send_code);
template <class T>
void send_new_check_code_query(const T &query);
template <class T>
void process_check_code_result(T result);
void on_check_code_result(NetQueryPtr &result);
void on_send_code_result(NetQueryPtr &result);
void on_result(NetQueryPtr result) override;