Remove tl_json dependency on td_api.
GitOrigin-RevId: 2453a8ac022cf86b799d24045d98e3e69b4a3d9e
This commit is contained in:
parent
5462265a84
commit
240c092368
@ -218,10 +218,36 @@ void gen_json_converter_file(const tl::simple::Schema &schema, const std::string
|
||||
sb << "#include \"td/utils/common.h\"\n";
|
||||
sb << "#include \"td/utils/Slice.h\"\n\n";
|
||||
|
||||
sb << "#include <functional>\n";
|
||||
sb << "#include <unordered_map>\n\n";
|
||||
}
|
||||
sb << "namespace td {\n";
|
||||
sb << "namespace td_api{\n\n";
|
||||
sb << "namespace td_api {\n";
|
||||
if (is_header) {
|
||||
sb << "\nvoid to_json(JsonValueScope &jv, const Object &object);\n";
|
||||
sb << "\nvoid to_json(JsonValueScope &jv, const Function &object);\n\n";
|
||||
} else {
|
||||
sb << R"ABCD(
|
||||
template <class T>
|
||||
auto lazy_to_json(JsonValueScope &jv, const T &t) -> decltype(td_api::to_json(jv, t)) {
|
||||
return td_api::to_json(jv, t);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void lazy_to_json(std::reference_wrapper<JsonValueScope>, const T &t) {
|
||||
UNREACHABLE();
|
||||
}
|
||||
|
||||
void to_json(JsonValueScope &jv, const Object &object) {
|
||||
downcast_call(const_cast<Object &>(object), [&jv](const auto &object) { lazy_to_json(jv, object); });
|
||||
}
|
||||
|
||||
void to_json(JsonValueScope &jv, const Function &object) {
|
||||
downcast_call(const_cast<Function &>(object), [&jv](const auto &object) { lazy_to_json(jv, object); });
|
||||
}
|
||||
|
||||
)ABCD";
|
||||
}
|
||||
gen_tl_constructor_from_string(sb, schema, is_header, mode);
|
||||
gen_from_json(sb, schema, is_header, mode);
|
||||
gen_to_json(sb, schema, is_header, mode);
|
||||
|
@ -4,20 +4,19 @@
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
#include "td/telegram/ClientActor.h"
|
||||
#include "td/telegram/Log.h"
|
||||
|
||||
#include "td/telegram/td_api_json.h"
|
||||
|
||||
#include "td/actor/actor.h"
|
||||
|
||||
#include "td/tl/tl_json.h" // should be included after td_api_json?
|
||||
|
||||
#include "memprof/memprof.h"
|
||||
|
||||
#include "td/net/HttpQuery.h"
|
||||
#include "td/net/HttpReader.h"
|
||||
|
||||
#include "td/tl/tl_json.h"
|
||||
|
||||
#include "td/telegram/ClientActor.h"
|
||||
#include "td/telegram/Log.h"
|
||||
#include "td/telegram/td_api_json.h"
|
||||
|
||||
#include "td/utils/base64.h"
|
||||
#include "td/utils/buffer.h"
|
||||
#include "td/utils/common.h"
|
||||
|
@ -6,6 +6,8 @@
|
||||
//
|
||||
#pragma once
|
||||
|
||||
#include "td/tl/TlObject.h"
|
||||
|
||||
#include "td/utils/base64.h"
|
||||
#include "td/utils/common.h"
|
||||
#include "td/utils/format.h"
|
||||
@ -15,10 +17,6 @@
|
||||
#include "td/utils/Status.h"
|
||||
#include "td/utils/tl_storers.h"
|
||||
|
||||
#include "td/telegram/td_api.h"
|
||||
#include "td/telegram/td_api.hpp"
|
||||
|
||||
#include <functional>
|
||||
#include <type_traits>
|
||||
|
||||
namespace td {
|
||||
@ -42,24 +40,6 @@ inline void to_json(JsonValueScope &jv, const JsonVectorInt64 &vec) {
|
||||
}
|
||||
}
|
||||
|
||||
template <class T>
|
||||
auto lazy_to_json(JsonValueScope &jv, const T &t) -> decltype(td_api::to_json(jv, t)) {
|
||||
return td_api::to_json(jv, t);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void lazy_to_json(std::reference_wrapper<JsonValueScope>, const T &t) {
|
||||
UNREACHABLE();
|
||||
}
|
||||
|
||||
inline void to_json(JsonValueScope &jv, const td_api::Object &object) {
|
||||
td_api::downcast_call(const_cast<td_api::Object &>(object), [&jv](const auto &object) { lazy_to_json(jv, object); });
|
||||
}
|
||||
inline void to_json(JsonValueScope &jv, const td_api::Function &object) {
|
||||
td_api::downcast_call(const_cast<td_api::Function &>(object),
|
||||
[&jv](const auto &object) { lazy_to_json(jv, object); });
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void to_json(JsonValueScope &jv, const tl_object_ptr<T> &value) {
|
||||
if (value) {
|
||||
|
Reference in New Issue
Block a user