2018-12-31 20:04:05 +01:00
|
|
|
//
|
2022-12-31 22:28:08 +01:00
|
|
|
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2023
|
2018-12-31 20:04:05 +01:00
|
|
|
//
|
|
|
|
// 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 "tl_writer_cpp.h"
|
|
|
|
#include "tl_writer_h.h"
|
|
|
|
#include "tl_writer_hpp.h"
|
|
|
|
#include "tl_writer_jni_cpp.h"
|
|
|
|
#include "tl_writer_jni_h.h"
|
|
|
|
|
|
|
|
#include "td/tl/tl_config.h"
|
|
|
|
#include "td/tl/tl_generate.h"
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
2023-07-31 17:29:15 +02:00
|
|
|
template <bool generate_multiple_headers = false, class WriterCpp = td::TD_TL_writer_cpp,
|
|
|
|
class WriterH = td::TD_TL_writer_h, class WriterHpp = td::TD_TL_writer_hpp>
|
2018-12-31 20:04:05 +01:00
|
|
|
static void generate_cpp(const std::string &directory, const std::string &tl_name, const std::string &string_type,
|
|
|
|
const std::string &bytes_type, const std::vector<std::string> &ext_cpp_includes,
|
|
|
|
const std::vector<std::string> &ext_h_includes) {
|
|
|
|
std::string path = directory + "/" + tl_name;
|
2023-06-26 14:33:02 +02:00
|
|
|
td::tl::tl_config config = td::tl::read_tl_config_from_file("tlo/" + tl_name + ".tlo");
|
2018-01-21 12:45:24 +01:00
|
|
|
td::tl::write_tl_to_file(config, path + ".cpp", WriterCpp(tl_name, string_type, bytes_type, ext_cpp_includes));
|
2023-07-13 17:26:12 +02:00
|
|
|
if (generate_multiple_headers) {
|
|
|
|
td::tl::write_tl_to_multiple_files(config, path, ".h", WriterH(tl_name, string_type, bytes_type, ext_h_includes));
|
|
|
|
} else {
|
|
|
|
td::tl::write_tl_to_file(config, path + ".h", WriterH(tl_name, string_type, bytes_type, ext_h_includes));
|
|
|
|
}
|
2018-01-21 12:45:24 +01:00
|
|
|
td::tl::write_tl_to_file(config, path + ".hpp", WriterHpp(tl_name, string_type, bytes_type));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
int main() {
|
2023-06-26 14:33:02 +02:00
|
|
|
generate_cpp<>("td/telegram", "telegram_api", "std::string", "BufferSlice",
|
2018-01-21 12:45:24 +01:00
|
|
|
{"\"td/tl/tl_object_parse.h\"", "\"td/tl/tl_object_store.h\""}, {"\"td/utils/buffer.h\""});
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2023-06-26 14:33:02 +02:00
|
|
|
generate_cpp<>("td/telegram", "secret_api", "std::string", "BufferSlice",
|
2018-01-21 12:45:24 +01:00
|
|
|
{"\"td/tl/tl_object_parse.h\"", "\"td/tl/tl_object_store.h\""}, {"\"td/utils/buffer.h\""});
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2023-06-26 14:33:02 +02:00
|
|
|
generate_cpp<>("td/mtproto", "mtproto_api", "Slice", "Slice",
|
2018-12-21 17:03:26 +01:00
|
|
|
{"\"td/tl/tl_object_parse.h\"", "\"td/tl/tl_object_store.h\""},
|
|
|
|
{"\"td/utils/Slice.h\"", "\"td/utils/UInt.h\""});
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2018-01-21 12:45:24 +01:00
|
|
|
#ifdef TD_ENABLE_JNI
|
2023-07-31 17:29:15 +02:00
|
|
|
generate_cpp<false, td::TD_TL_writer_jni_cpp, td::TD_TL_writer_jni_h>(
|
|
|
|
"td/telegram", "td_api", "std::string", "std::string", {"\"td/tl/tl_jni_object.h\""}, {"<string>"});
|
2018-12-31 20:04:05 +01:00
|
|
|
#else
|
2023-06-26 14:33:02 +02:00
|
|
|
generate_cpp<>("td/telegram", "td_api", "std::string", "std::string", {}, {"<string>"});
|
2018-12-31 20:04:05 +01:00
|
|
|
#endif
|
|
|
|
}
|