diff --git a/td/generate/DoxygenTlDocumentationGenerator.php b/td/generate/DoxygenTlDocumentationGenerator.php index afe94559f..4c84ea807 100644 --- a/td/generate/DoxygenTlDocumentationGenerator.php +++ b/td/generate/DoxygenTlDocumentationGenerator.php @@ -17,8 +17,9 @@ class DoxygenTlDocumentationGenerator extends TlDocumentationGenerator case 'double': return 'double '; case 'string': - case 'bytes': return 'std::string const &'; + case 'bytes': + return 'bytes const &'; default: if (substr($type, 0, 6) === 'vector') { @@ -74,8 +75,9 @@ class DoxygenTlDocumentationGenerator extends TlDocumentationGenerator case 'double': return 'double'; case 'string': - case 'bytes': return 'std::string'; + case 'bytes': + return 'bytes'; case 'bool': case 'int': case 'long': @@ -163,6 +165,13 @@ class DoxygenTlDocumentationGenerator extends TlDocumentationGenerator * Contains declarations of all functions and types which represent a public TDLib interface. */ EOT +); + + $this->addDocumentation('using bytes = std::string;', <<addDocumentation('using BaseObject', <<"; } if (name == "Bytes") { - return "TlFetchBytes<" + bytes_type + ">"; + return "TlFetchBytes"; } if (name == "Vector") { @@ -662,7 +662,7 @@ std::string TD_TL_writer_cpp::gen_constructor_field_init(int field_num, const st } std::string move_begin; std::string move_end; - if ((field_type == bytes_type || field_type.compare(0, 11, "std::vector") == 0 || + if ((field_type == "bytes" || field_type.compare(0, 11, "std::vector") == 0 || field_type.compare(0, 10, "object_ptr") == 0) && !is_default) { move_begin = "std::move("; diff --git a/td/generate/tl_writer_h.cpp b/td/generate/tl_writer_h.cpp index 82880695c..d78f534e5 100644 --- a/td/generate/tl_writer_h.cpp +++ b/td/generate/tl_writer_h.cpp @@ -56,6 +56,10 @@ std::string TD_TL_writer_h::gen_output_begin() const { ext_forward_declaration + "namespace " + tl_name + " {\n\n" + "using bytes = " + + bytes_type + + ";\n\n" + "using BaseObject = ::td::TlObject;\n\n" "template \n" diff --git a/td/generate/tl_writer_jni_cpp.cpp b/td/generate/tl_writer_jni_cpp.cpp index cc7bee25e..edf7a5461 100644 --- a/td/generate/tl_writer_jni_cpp.cpp +++ b/td/generate/tl_writer_jni_cpp.cpp @@ -107,7 +107,7 @@ std::string TD_TL_writer_jni_cpp::gen_vector_fetch(std::string field_name, const template_type = gen_main_class_name(child->type); } template_type = "std::vector<" + template_type + ">"; - } else if (vector_type == bytes_type) { + } else if (vector_type == "bytes") { std::fprintf(stderr, "Vector of Bytes is not supported\n"); assert(false); } else { @@ -262,7 +262,7 @@ std::string TD_TL_writer_jni_cpp::gen_vector_store(const std::string &field_name "env->DeleteLocalRef(arr_tmp_); " "} }"; } - if (vector_type == bytes_type) { + if (vector_type == "bytes") { std::fprintf(stderr, "Vector of Bytes is not supported\n"); assert(false); } diff --git a/td/generate/tl_writer_jni_h.cpp b/td/generate/tl_writer_jni_h.cpp index 0a56d298e..efbeacaf6 100644 --- a/td/generate/tl_writer_jni_h.cpp +++ b/td/generate/tl_writer_jni_h.cpp @@ -79,6 +79,10 @@ std::string TD_TL_writer_jni_h::gen_output_begin() const { tl_name + " {\n\n" + "using bytes = " + + bytes_type + + ";\n\n" + "class " + gen_base_tl_class_name() + ";\n" diff --git a/td/generate/tl_writer_td.cpp b/td/generate/tl_writer_td.cpp index 0b2f64ff2..123e87080 100644 --- a/td/generate/tl_writer_td.cpp +++ b/td/generate/tl_writer_td.cpp @@ -188,7 +188,7 @@ std::string TD_TL_writer::gen_type_name(const tl::tl_tree_type *tree_type) const return "UInt256"; } if (name == "Bytes") { - return bytes_type; + return "bytes"; } if (name == "Vector") { @@ -242,9 +242,10 @@ std::string TD_TL_writer::gen_constructor_parameter(int field_num, const std::st if (field_type == "bool " || field_type == "std::int32_t " || field_type == "std::int64_t " || field_type == "double ") { res += field_type; - } else if (field_type == "UInt128 " || field_type == "UInt256 " || field_type == string_type + " ") { + } else if (field_type == "UInt128 " || field_type == "UInt256 " || field_type == string_type + " " || + (string_type == bytes_type && field_type == "bytes ")) { res += field_type + "const &"; - } else if (field_type.compare(0, 11, "std::vector") == 0 || field_type == bytes_type + " ") { + } else if (field_type.compare(0, 11, "std::vector") == 0 || field_type == "bytes ") { res += field_type + "&&"; } else if (field_type.compare(0, 10, "object_ptr") == 0) { res += field_type + "&&";