From 43d872882975df02c0c73b5ecbfa94b78e7072dd Mon Sep 17 00:00:00 2001 From: levlam Date: Mon, 1 Oct 2018 05:22:56 +0300 Subject: [PATCH] Move some templates implementations to Td.h. GitOrigin-RevId: e6068e9abd1f1f993a61cf0b1fe27bfab8fa64ec --- td/telegram/AnimationsManager.h | 2 -- td/telegram/CallbackQueriesManager.h | 3 --- td/telegram/Td.cpp | 16 ---------------- td/telegram/Td.h | 17 +++++++++++++---- 4 files changed, 13 insertions(+), 25 deletions(-) diff --git a/td/telegram/AnimationsManager.h b/td/telegram/AnimationsManager.h index f1919fcbc..d8d3c6c15 100644 --- a/td/telegram/AnimationsManager.h +++ b/td/telegram/AnimationsManager.h @@ -24,8 +24,6 @@ namespace td { class Td; -template -class Promise; } // namespace td namespace td { diff --git a/td/telegram/CallbackQueriesManager.h b/td/telegram/CallbackQueriesManager.h index 213ccff08..e12174af6 100644 --- a/td/telegram/CallbackQueriesManager.h +++ b/td/telegram/CallbackQueriesManager.h @@ -24,9 +24,6 @@ namespace td { class Td; -template -class Promise; - class CallbackQueriesManager { public: explicit CallbackQueriesManager(Td *td); diff --git a/td/telegram/Td.cpp b/td/telegram/Td.cpp index d7d4d9471..3fc99d668 100644 --- a/td/telegram/Td.cpp +++ b/td/telegram/Td.cpp @@ -4211,17 +4211,6 @@ void Td::answer_ok_query(uint64 id, Status status) { } } -template -Promise Td::create_request_promise(uint64 id) { - return PromiseCreator::lambda([id = id, actor_id = actor_id(this)](Result r_state) { - if (r_state.is_error()) { - send_closure(actor_id, &Td::send_error, id, r_state.move_as_error()); - } else { - send_closure(actor_id, &Td::send_result, id, r_state.move_as_ok()); - } - }); -} - Promise Td::create_ok_request_promise(uint64 id) { return PromiseCreator::lambda([id = id, actor_id = actor_id(this)](Result result) mutable { if (result.is_error()) { @@ -6714,11 +6703,6 @@ void Td::on_request(uint64 id, const td_api::getLanguagePackString &request) { UNREACHABLE(); } -template -td_api::object_ptr Td::do_static_request(const T &request) { - return make_error(400, "Function can't be executed synchronously"); -} - td_api::object_ptr Td::do_static_request(const td_api::getTextEntities &request) { if (!check_utf8(request.text_)) { return make_error(400, "Text must be encoded in UTF-8"); diff --git a/td/telegram/Td.h b/td/telegram/Td.h index 752bb7293..d63e3fc5e 100644 --- a/td/telegram/Td.h +++ b/td/telegram/Td.h @@ -17,6 +17,7 @@ #include "td/telegram/td_api.h" #include "td/actor/actor.h" +#include "td/actor/PromiseFuture.h" #include "td/actor/Timeout.h" #include "td/utils/buffer.h" @@ -62,8 +63,6 @@ class VideosManager; class VoiceNotesManager; class WebPagesManager; -template -class Promise; } // namespace td namespace td { @@ -306,7 +305,15 @@ class Td final : public NetQueryCallback { static int *get_log_verbosity_level(Slice name); template - Promise create_request_promise(uint64 id); + Promise create_request_promise(uint64 id) { + return PromiseCreator::lambda([id = id, actor_id = actor_id(this)](Result r_state) { + if (r_state.is_error()) { + send_closure(actor_id, &Td::send_error, id, r_state.move_as_error()); + } else { + send_closure(actor_id, &Td::send_result, id, r_state.move_as_ok()); + } + }); + } Promise create_ok_request_promise(uint64 id); @@ -921,7 +928,9 @@ class Td final : public NetQueryCallback { void on_request(uint64 id, td_api::testCallVectorStringObject &request); template - static td_api::object_ptr do_static_request(const T &request); + static td_api::object_ptr do_static_request(const T &request) { + return td_api::make_object(400, "Function can't be executed synchronously"); + } static td_api::object_ptr do_static_request(const td_api::getTextEntities &request); static td_api::object_ptr do_static_request(td_api::parseTextEntities &request); static td_api::object_ptr do_static_request(const td_api::getFileMimeType &request);