Support generation of multiple headers in generate_common.

This commit is contained in:
levlam 2023-07-13 18:26:12 +03:00
parent 6ece751ccd
commit 0d0b31c811

View File

@ -16,7 +16,7 @@
#include <string>
#include <vector>
template <class WriterCpp = td::TD_TL_writer_cpp, class WriterH = td::TD_TL_writer_h,
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>
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,
@ -24,7 +24,11 @@ static void generate_cpp(const std::string &directory, const std::string &tl_nam
std::string path = directory + "/" + tl_name;
td::tl::tl_config config = td::tl::read_tl_config_from_file("tlo/" + tl_name + ".tlo");
td::tl::write_tl_to_file(config, path + ".cpp", WriterCpp(tl_name, string_type, bytes_type, ext_cpp_includes));
td::tl::write_tl_to_file(config, path + ".h", WriterH(tl_name, string_type, bytes_type, ext_h_includes));
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));
}
td::tl::write_tl_to_file(config, path + ".hpp", WriterHpp(tl_name, string_type, bytes_type));
}
@ -40,7 +44,7 @@ int main() {
{"\"td/utils/Slice.h\"", "\"td/utils/UInt.h\""});
#ifdef TD_ENABLE_JNI
generate_cpp<td::TD_TL_writer_jni_cpp, td::TD_TL_writer_jni_h>("td/telegram", "td_api", "std::string", "std::string",
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>"});
#else
generate_cpp<>("td/telegram", "td_api", "std::string", "std::string", {}, {"<string>"});