mirror of
https://github.com/ton-blockchain/ton
synced 2025-03-09 15:40:10 +00:00
pow-testgiver support
This commit is contained in:
parent
5890a98b65
commit
b84e3e9735
257 changed files with 6665 additions and 2608 deletions
|
@ -25,6 +25,7 @@
|
|||
|
||||
Copyright 2017-2020 Telegram Systems LLP
|
||||
*/
|
||||
#include "td/tl/tl_writer.h"
|
||||
#include "tl_writer_cpp.h"
|
||||
#include "tl_writer_h.h"
|
||||
#include "tl_writer_hpp.h"
|
||||
|
@ -66,7 +67,8 @@ int main() {
|
|||
{"\"tl/tl_object_parse.h\"", "\"tl/tl_object_store.h\"", "\"td/utils/int_types.h\"",
|
||||
"\"crypto/common/bitstring.h\""},
|
||||
{"<string>", "\"td/utils/buffer.h\"", "\"crypto/common/bitstring.h\""});
|
||||
td::gen_json_converter(td::tl::read_tl_config_from_file("scheme/ton_api.tlo"), "auto/tl/ton_api_json", "ton_api");
|
||||
td::gen_json_converter(td::tl::read_tl_config_from_file("scheme/ton_api.tlo"), "auto/tl/ton_api_json", "ton_api",
|
||||
td::tl::TL_writer::Mode::All);
|
||||
|
||||
#ifdef TONLIB_ENABLE_JNI
|
||||
generate_cpp<td::TD_TL_writer_jni_cpp, td::TD_TL_writer_jni_h>(
|
||||
|
@ -79,5 +81,5 @@ int main() {
|
|||
{"<string>", "\"td/utils/SharedSlice.h\""});
|
||||
#endif
|
||||
td::gen_json_converter(td::tl::read_tl_config_from_file("scheme/tonlib_api.tlo"), "auto/tl/tonlib_api_json",
|
||||
"tonlib_api");
|
||||
"tonlib_api", td::tl::TL_writer::Mode::All);
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include "td/tl/tl_simple.h"
|
||||
|
||||
#include "td/utils/buffer.h"
|
||||
#include "td/utils/common.h"
|
||||
#include "td/utils/filesystem.h"
|
||||
#include "td/utils/logging.h"
|
||||
#include "td/utils/Slice.h"
|
||||
|
@ -30,6 +31,8 @@
|
|||
|
||||
namespace td {
|
||||
|
||||
using Mode = tl::TL_writer::Mode;
|
||||
|
||||
namespace {
|
||||
std::string tl_name = "ton_api";
|
||||
}
|
||||
|
@ -39,23 +42,25 @@ void gen_to_json_constructor(StringBuilder &sb, const T *constructor, bool is_he
|
|||
sb << "void to_json(JsonValueScope &jv, "
|
||||
<< "const " << tl_name << "::" << tl::simple::gen_cpp_name(constructor->name) << " &object)";
|
||||
if (is_header) {
|
||||
sb << ";\n";
|
||||
sb << ";\n\n";
|
||||
return;
|
||||
}
|
||||
sb << " {\n";
|
||||
sb << " auto jo = jv.enter_object();\n";
|
||||
sb << " jo << ctie(\"@type\", \"" << constructor->name << "\");\n";
|
||||
sb << " jo(\"@type\", \"" << constructor->name << "\");\n";
|
||||
for (auto &arg : constructor->args) {
|
||||
auto field = tl::simple::gen_cpp_field_name(arg.name);
|
||||
auto field_name = tl::simple::gen_cpp_field_name(arg.name);
|
||||
// TODO: or as null
|
||||
bool is_custom = arg.type->type == tl::simple::Type::Custom;
|
||||
|
||||
if (is_custom) {
|
||||
sb << " if (object." << field << ") {\n ";
|
||||
sb << " if (object." << field_name << ") {\n ";
|
||||
}
|
||||
auto object = PSTRING() << "object." << tl::simple::gen_cpp_field_name(arg.name);
|
||||
if (arg.type->type == tl::simple::Type::Bytes || arg.type->type == tl::simple::Type::SecureBytes) {
|
||||
object = PSTRING() << "JsonBytes{" << object << "}";
|
||||
} else if (arg.type->type == tl::simple::Type::Bool) {
|
||||
object = PSTRING() << "JsonBool{" << object << "}";
|
||||
} else if (arg.type->type == tl::simple::Type::Int64) {
|
||||
object = PSTRING() << "JsonInt64{" << object << "}";
|
||||
} else if (arg.type->type == tl::simple::Type::Vector &&
|
||||
|
@ -66,7 +71,7 @@ void gen_to_json_constructor(StringBuilder &sb, const T *constructor, bool is_he
|
|||
arg.type->vector_value_type->type == tl::simple::Type::Int64) {
|
||||
object = PSTRING() << "JsonVectorInt64{" << object << "}";
|
||||
}
|
||||
sb << " jo << ctie(\"" << arg.name << "\", ToJson(" << object << "));\n";
|
||||
sb << " jo(\"" << arg.name << "\", ToJson(" << object << "));\n";
|
||||
if (is_custom) {
|
||||
sb << " }\n";
|
||||
}
|
||||
|
@ -127,14 +132,15 @@ void gen_from_json_constructor(StringBuilder &sb, const T *constructor, bool is_
|
|||
<< "\", JsonValue::Type::Null, true));\n";
|
||||
sb << " if (value.type() != JsonValue::Type::Null) {\n";
|
||||
if (arg.type->type == tl::simple::Type::Bytes || arg.type->type == tl::simple::Type::SecureBytes) {
|
||||
sb << " TRY_STATUS(from_json_bytes(to." << tl::simple::gen_cpp_field_name(arg.name) << ", value));\n";
|
||||
sb << " TRY_STATUS(from_json_bytes(to." << tl::simple::gen_cpp_field_name(arg.name)
|
||||
<< ", std::move(value)));\n";
|
||||
} else if (arg.type->type == tl::simple::Type::Vector &&
|
||||
(arg.type->vector_value_type->type == tl::simple::Type::Bytes ||
|
||||
arg.type->vector_value_type->type == tl::simple::Type::SecureBytes)) {
|
||||
sb << " TRY_STATUS(from_json_vector_bytes(to." << tl::simple::gen_cpp_field_name(arg.name)
|
||||
<< ", value));\n";
|
||||
<< ", std::move(value)));\n";
|
||||
} else {
|
||||
sb << " TRY_STATUS(from_json(to." << tl::simple::gen_cpp_field_name(arg.name) << ", value));\n";
|
||||
sb << " TRY_STATUS(from_json(to." << tl::simple::gen_cpp_field_name(arg.name) << ", std::move(value)));\n";
|
||||
}
|
||||
sb << " }\n";
|
||||
sb << " }\n";
|
||||
|
@ -144,12 +150,19 @@ void gen_from_json_constructor(StringBuilder &sb, const T *constructor, bool is_
|
|||
}
|
||||
}
|
||||
|
||||
void gen_from_json(StringBuilder &sb, const tl::simple::Schema &schema, bool is_header) {
|
||||
void gen_from_json(StringBuilder &sb, const tl::simple::Schema &schema, bool is_header, Mode mode) {
|
||||
for (auto *custom_type : schema.custom_types) {
|
||||
if (!((custom_type->is_query_ && mode != Mode::Client) || (custom_type->is_result_ && mode != Mode::Server)) &&
|
||||
mode != Mode::All) {
|
||||
continue;
|
||||
}
|
||||
for (auto *constructor : custom_type->constructors) {
|
||||
gen_from_json_constructor(sb, constructor, is_header);
|
||||
}
|
||||
}
|
||||
if (mode == Mode::Client) {
|
||||
return;
|
||||
}
|
||||
for (auto *function : schema.functions) {
|
||||
gen_from_json_constructor(sb, function, is_header);
|
||||
}
|
||||
|
@ -159,7 +172,7 @@ using Vec = std::vector<std::pair<int32, std::string>>;
|
|||
void gen_tl_constructor_from_string(StringBuilder &sb, Slice name, const Vec &vec, bool is_header) {
|
||||
sb << "Result<int32> tl_constructor_from_string(" << tl_name << "::" << name << " *object, const std::string &str)";
|
||||
if (is_header) {
|
||||
sb << ";\n";
|
||||
sb << ";\n\n";
|
||||
return;
|
||||
}
|
||||
sb << " {\n";
|
||||
|
@ -177,15 +190,19 @@ void gen_tl_constructor_from_string(StringBuilder &sb, Slice name, const Vec &ve
|
|||
sb << "\n };\n";
|
||||
sb << " auto it = m.find(str);\n";
|
||||
sb << " if (it == m.end()) {\n"
|
||||
<< " return Status::Error(str + \"Unknown class\");\n"
|
||||
<< " return Status::Error(PSLICE() << \"Unknown class \\\"\" << str << \"\\\"\");\n"
|
||||
<< " }\n"
|
||||
<< " return it->second;\n";
|
||||
sb << "}\n";
|
||||
sb << "}\n\n";
|
||||
}
|
||||
|
||||
void gen_tl_constructor_from_string(StringBuilder &sb, const tl::simple::Schema &schema, bool is_header) {
|
||||
void gen_tl_constructor_from_string(StringBuilder &sb, const tl::simple::Schema &schema, bool is_header, Mode mode) {
|
||||
Vec vec_for_nullary;
|
||||
for (auto *custom_type : schema.custom_types) {
|
||||
if (!((custom_type->is_query_ && mode != Mode::Client) || (custom_type->is_result_ && mode != Mode::Server)) &&
|
||||
mode != Mode::All) {
|
||||
continue;
|
||||
}
|
||||
Vec vec;
|
||||
for (auto *constructor : custom_type->constructors) {
|
||||
vec.push_back(std::make_pair(constructor->id, constructor->name));
|
||||
|
@ -198,6 +215,9 @@ void gen_tl_constructor_from_string(StringBuilder &sb, const tl::simple::Schema
|
|||
}
|
||||
gen_tl_constructor_from_string(sb, "Object", vec_for_nullary, is_header);
|
||||
|
||||
if (mode == Mode::Client) {
|
||||
return;
|
||||
}
|
||||
Vec vec_for_function;
|
||||
for (auto *function : schema.functions) {
|
||||
vec_for_function.push_back(std::make_pair(function->id, function->name));
|
||||
|
@ -205,7 +225,8 @@ void gen_tl_constructor_from_string(StringBuilder &sb, const tl::simple::Schema
|
|||
gen_tl_constructor_from_string(sb, "Function", vec_for_function, is_header);
|
||||
}
|
||||
|
||||
void gen_json_converter_file(const tl::simple::Schema &schema, const std::string &file_name_base, bool is_header) {
|
||||
void gen_json_converter_file(const tl::simple::Schema &schema, const std::string &file_name_base, bool is_header,
|
||||
Mode mode) {
|
||||
auto file_name = is_header ? file_name_base + ".h" : file_name_base + ".cpp";
|
||||
//file_name = "auto/" + file_name;
|
||||
auto old_file_content = [&] {
|
||||
|
@ -241,31 +262,43 @@ 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 ton {\n";
|
||||
sb << "namespace " << tl_name << "{\n";
|
||||
sb << " using namespace td;\n";
|
||||
gen_tl_constructor_from_string(sb, schema, is_header);
|
||||
gen_from_json(sb, schema, is_header);
|
||||
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);
|
||||
sb << "} // namespace " << tl_name << "\n";
|
||||
sb << "} // namespace ton\n";
|
||||
|
||||
CHECK(!sb.is_error());
|
||||
buf.resize(sb.as_cslice().size());
|
||||
#if TD_WINDOWS
|
||||
string new_file_content;
|
||||
for (auto c : buf) {
|
||||
if (c == '\n') {
|
||||
new_file_content += '\r';
|
||||
}
|
||||
new_file_content += c;
|
||||
}
|
||||
#else
|
||||
auto new_file_content = std::move(buf);
|
||||
#endif
|
||||
if (new_file_content != old_file_content.as_slice()) {
|
||||
write_file(file_name, new_file_content).ensure();
|
||||
}
|
||||
}
|
||||
|
||||
void gen_json_converter(const tl::tl_config &config, const std::string &file_name, const std::string &new_tl_name) {
|
||||
void gen_json_converter(const tl::tl_config &config, const std::string &file_name, const std::string &new_tl_name,
|
||||
Mode mode) {
|
||||
tl_name = new_tl_name;
|
||||
|
||||
tl::simple::Schema schema(config);
|
||||
gen_json_converter_file(schema, file_name, true);
|
||||
gen_json_converter_file(schema, file_name, false);
|
||||
gen_json_converter_file(schema, file_name, true, mode);
|
||||
gen_json_converter_file(schema, file_name, false, mode);
|
||||
}
|
||||
|
||||
} // namespace td
|
||||
|
|
|
@ -1,29 +1,40 @@
|
|||
/*
|
||||
This file is part of TON Blockchain Library.
|
||||
This file is part of TON Blockchain source code.
|
||||
|
||||
TON Blockchain Library is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
TON Blockchain is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
TON Blockchain Library is distributed in the hope that it will be useful,
|
||||
TON Blockchain is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with TON Blockchain. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
In addition, as a special exception, the copyright holders give permission
|
||||
to link the code of portions of this program with the OpenSSL library.
|
||||
You must obey the GNU General Public License in all respects for all
|
||||
of the code used other than OpenSSL. If you modify file(s) with this
|
||||
exception, you may extend this exception to your version of the file(s),
|
||||
but you are not obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. If you delete this exception statement
|
||||
from all source files in the program, then also delete it here.
|
||||
|
||||
Copyright 2017-2020 Telegram Systems LLP
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "td/tl/tl_config.h"
|
||||
#include "td/tl/tl_writer.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace td {
|
||||
|
||||
void gen_json_converter(const tl::tl_config &config, const std::string &file_name, const std::string &tl_name);
|
||||
void gen_json_converter(const tl::tl_config &config, const std::string &file_name, const std::string &tl_name,
|
||||
tl::TL_writer::Mode mode);
|
||||
|
||||
} // namespace td
|
||||
|
|
|
@ -44,7 +44,7 @@ std::string TD_TL_writer_cpp::gen_output_begin() const {
|
|||
"std::string to_string(const BaseObject &value) {\n"
|
||||
" td::TlStorerToString storer;\n"
|
||||
" value.store(storer, \"\");\n"
|
||||
" return storer.str();\n"
|
||||
" return storer.move_as_str();\n"
|
||||
"}\n";
|
||||
}
|
||||
|
||||
|
|
|
@ -94,7 +94,7 @@ void to_json(JsonValueScope &jv, const std::vector<T> &v) {
|
|||
}
|
||||
}
|
||||
|
||||
inline Status from_json(std::int32_t &to, JsonValue &from) {
|
||||
inline Status from_json(std::int32_t &to, JsonValue from) {
|
||||
if (from.type() != JsonValue::Type::Number && from.type() != JsonValue::Type::String) {
|
||||
return Status::Error(PSLICE() << "Expected number, got " << from.type());
|
||||
}
|
||||
|
@ -104,10 +104,10 @@ inline Status from_json(std::int32_t &to, JsonValue &from) {
|
|||
return Status::OK();
|
||||
}
|
||||
|
||||
inline Status from_json(bool &to, JsonValue &from) {
|
||||
inline Status from_json(bool &to, JsonValue from) {
|
||||
if (from.type() != JsonValue::Type::Boolean) {
|
||||
int32 x;
|
||||
auto status = from_json(x, from);
|
||||
auto status = from_json(x, std::move(from));
|
||||
if (status.is_ok()) {
|
||||
to = x != 0;
|
||||
return Status::OK();
|
||||
|
@ -118,7 +118,7 @@ inline Status from_json(bool &to, JsonValue &from) {
|
|||
return Status::OK();
|
||||
}
|
||||
|
||||
inline Status from_json(std::int64_t &to, JsonValue &from) {
|
||||
inline Status from_json(std::int64_t &to, JsonValue from) {
|
||||
if (from.type() != JsonValue::Type::Number && from.type() != JsonValue::Type::String) {
|
||||
return Status::Error(PSLICE() << "Expected number, got " << from.type());
|
||||
}
|
||||
|
@ -127,7 +127,7 @@ inline Status from_json(std::int64_t &to, JsonValue &from) {
|
|||
to = res;
|
||||
return Status::OK();
|
||||
}
|
||||
inline Status from_json(double &to, JsonValue &from) {
|
||||
inline Status from_json(double &to, JsonValue from) {
|
||||
if (from.type() != JsonValue::Type::Number) {
|
||||
return Status::Error(PSLICE() << "Expected number, got " << from.type());
|
||||
}
|
||||
|
@ -135,7 +135,7 @@ inline Status from_json(double &to, JsonValue &from) {
|
|||
return Status::OK();
|
||||
}
|
||||
|
||||
inline Status from_json(string &to, JsonValue &from) {
|
||||
inline Status from_json(string &to, JsonValue from) {
|
||||
if (from.type() != JsonValue::Type::String) {
|
||||
return Status::Error(PSLICE() << "Expected string, got " << from.type());
|
||||
}
|
||||
|
@ -143,7 +143,7 @@ inline Status from_json(string &to, JsonValue &from) {
|
|||
return Status::OK();
|
||||
}
|
||||
|
||||
inline Status from_json(SecureString &to, JsonValue &from) {
|
||||
inline Status from_json(SecureString &to, JsonValue from) {
|
||||
if (from.type() != JsonValue::Type::String) {
|
||||
return Status::Error(PSLICE() << "Expected string, got " << from.type());
|
||||
}
|
||||
|
@ -151,7 +151,7 @@ inline Status from_json(SecureString &to, JsonValue &from) {
|
|||
return Status::OK();
|
||||
}
|
||||
|
||||
inline Status from_json(Slice &to, JsonValue &from) {
|
||||
inline Status from_json(Slice &to, JsonValue from) {
|
||||
if (from.type() != JsonValue::Type::String) {
|
||||
return Status::Error(PSLICE() << "Expected string, got " << from.type());
|
||||
}
|
||||
|
@ -159,7 +159,7 @@ inline Status from_json(Slice &to, JsonValue &from) {
|
|||
return Status::OK();
|
||||
}
|
||||
|
||||
inline Status from_json_bytes(string &to, JsonValue &from) {
|
||||
inline Status from_json_bytes(string &to, JsonValue from) {
|
||||
if (from.type() != JsonValue::Type::String) {
|
||||
return Status::Error(PSLICE() << "Expected string, got " << from.type());
|
||||
}
|
||||
|
@ -168,7 +168,7 @@ inline Status from_json_bytes(string &to, JsonValue &from) {
|
|||
return Status::OK();
|
||||
}
|
||||
|
||||
inline Status from_json_bytes(SecureString &to, JsonValue &from) {
|
||||
inline Status from_json_bytes(SecureString &to, JsonValue from) {
|
||||
if (from.type() != JsonValue::Type::String) {
|
||||
return Status::Error(PSLICE() << "Expected string, got " << from.type());
|
||||
}
|
||||
|
@ -177,7 +177,7 @@ inline Status from_json_bytes(SecureString &to, JsonValue &from) {
|
|||
return Status::OK();
|
||||
}
|
||||
|
||||
inline Status from_json_bytes(BufferSlice &to, JsonValue &from) {
|
||||
inline Status from_json_bytes(BufferSlice &to, JsonValue from) {
|
||||
if (from.type() != JsonValue::Type::String) {
|
||||
return Status::Error(PSLICE() << "Expected string, got " << from.type());
|
||||
}
|
||||
|
@ -186,7 +186,7 @@ inline Status from_json_bytes(BufferSlice &to, JsonValue &from) {
|
|||
return Status::OK();
|
||||
}
|
||||
|
||||
inline Status from_json_bytes(Slice &to, JsonValue &from) {
|
||||
inline Status from_json_bytes(Slice &to, JsonValue from) {
|
||||
if (from.type() != JsonValue::Type::String) {
|
||||
return Status::Error(PSLICE() << "Expected string, got " << from.type());
|
||||
}
|
||||
|
@ -198,9 +198,9 @@ inline Status from_json_bytes(Slice &to, JsonValue &from) {
|
|||
}
|
||||
|
||||
template <unsigned size>
|
||||
inline Status from_json(td::BitArray<size> &to, JsonValue &from) {
|
||||
inline Status from_json(td::BitArray<size> &to, JsonValue from) {
|
||||
string raw;
|
||||
TRY_STATUS(from_json_bytes(raw, from));
|
||||
TRY_STATUS(from_json_bytes(raw, std::move(from)));
|
||||
auto S = to.as_slice();
|
||||
if (raw.size() != S.size()) {
|
||||
return Status::Error("Wrong length for UInt");
|
||||
|
@ -210,28 +210,28 @@ inline Status from_json(td::BitArray<size> &to, JsonValue &from) {
|
|||
}
|
||||
|
||||
template <class T>
|
||||
Status from_json(std::vector<T> &to, JsonValue &from) {
|
||||
Status from_json(std::vector<T> &to, JsonValue from) {
|
||||
if (from.type() != JsonValue::Type::Array) {
|
||||
return Status::Error(PSLICE() << "Expected array, got " << from.type());
|
||||
}
|
||||
to = std::vector<T>(from.get_array().size());
|
||||
size_t i = 0;
|
||||
for (auto &value : from.get_array()) {
|
||||
TRY_STATUS(from_json(to[i], value));
|
||||
TRY_STATUS(from_json(to[i], std::move(value)));
|
||||
i++;
|
||||
}
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline Status from_json_vector_bytes(std::vector<T> &to, JsonValue &from) {
|
||||
inline Status from_json_vector_bytes(std::vector<T> &to, JsonValue from) {
|
||||
if (from.type() != JsonValue::Type::Array) {
|
||||
return Status::Error(PSLICE() << "Expected array, got " << from.type());
|
||||
}
|
||||
to = std::vector<T>(from.get_array().size());
|
||||
size_t i = 0;
|
||||
for (auto &value : from.get_array()) {
|
||||
TRY_STATUS(from_json_bytes(to[i], value));
|
||||
TRY_STATUS(from_json_bytes(to[i], std::move(value)));
|
||||
i++;
|
||||
}
|
||||
return Status::OK();
|
||||
|
@ -253,7 +253,7 @@ class DowncastHelper : public T {
|
|||
};
|
||||
|
||||
template <class T>
|
||||
std::enable_if_t<!std::is_constructible<T>::value, Status> from_json(ton::tl_object_ptr<T> &to, JsonValue &from) {
|
||||
std::enable_if_t<!std::is_constructible<T>::value, Status> from_json(ton::tl_object_ptr<T> &to, JsonValue from) {
|
||||
if (from.type() != JsonValue::Type::Object) {
|
||||
if (from.type() == JsonValue::Type::Null) {
|
||||
to = nullptr;
|
||||
|
@ -290,7 +290,7 @@ std::enable_if_t<!std::is_constructible<T>::value, Status> from_json(ton::tl_obj
|
|||
}
|
||||
|
||||
template <class T>
|
||||
std::enable_if_t<std::is_constructible<T>::value, Status> from_json(ton::tl_object_ptr<T> &to, JsonValue &from) {
|
||||
std::enable_if_t<std::is_constructible<T>::value, Status> from_json(ton::tl_object_ptr<T> &to, JsonValue from) {
|
||||
if (from.type() != JsonValue::Type::Object) {
|
||||
if (from.type() == JsonValue::Type::Null) {
|
||||
to = nullptr;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue