Use separate type int53 in generated C++ code.

GitOrigin-RevId: 0316bec46dc5838858528456bb6947f92e350480
This commit is contained in:
levlam 2020-03-24 20:52:33 +03:00
parent 6943db4d52
commit 24a4104ac2
5 changed files with 23 additions and 7 deletions

View File

@ -12,6 +12,7 @@ class DoxygenTlDocumentationGenerator extends TlDocumentationGenerator
case 'int32':
return 'std::int32_t ';
case 'int53':
return 'int53 ';
case 'int64':
return 'std::int64_t ';
case 'double':
@ -70,6 +71,7 @@ class DoxygenTlDocumentationGenerator extends TlDocumentationGenerator
case 'int32':
return 'std::int32_t';
case 'int53':
return 'int53';
case 'int64':
return 'std::int64_t';
case 'double':
@ -165,11 +167,18 @@ class DoxygenTlDocumentationGenerator extends TlDocumentationGenerator
* Contains declarations of all functions and types which represent a public TDLib interface.
*/
EOT
);
$this->addDocumentation('using int53 = std::int64_t;', <<<EOT
/**
* This type is used to store 53-bit signed integers, which can be represented as Number in JSON.
*/
EOT
);
$this->addDocumentation('using bytes = std::string;', <<<EOT
/**
* This class is used to store arbitrary sequence of bytes.
* This type is used to store arbitrary sequence of bytes.
*/
EOT
);

View File

@ -56,6 +56,8 @@ std::string TD_TL_writer_h::gen_output_begin() const {
ext_forward_declaration + "namespace " + tl_name +
" {\n\n"
"using int53 = std::int64_t;\n\n"
"using bytes = " +
bytes_type +
";\n\n"

View File

@ -86,7 +86,7 @@ std::string TD_TL_writer_jni_cpp::gen_vector_fetch(std::string field_name, const
if (vector_type == "std::int32_t") {
array_type = "jintArray";
}
if (vector_type == "std::int64_t") {
if (vector_type == "int53" || vector_type == "std::int64_t") {
array_type = "jlongArray";
}
if (vector_type == "double") {
@ -248,8 +248,8 @@ std::string TD_TL_writer_jni_cpp::gen_vector_store(const std::string &field_name
if (vector_type == "bool") {
assert(false); // TODO
}
if (vector_type == "std::int32_t" || vector_type == "std::int64_t" || vector_type == "double" ||
vector_type == string_type || vector_type.compare(0, 11, "std::vector") == 0 ||
if (vector_type == "std::int32_t" || vector_type == "int53" || vector_type == "std::int64_t" ||
vector_type == "double" || vector_type == string_type || vector_type.compare(0, 11, "std::vector") == 0 ||
vector_type.compare(0, 10, "object_ptr") == 0) {
return "{ "
"auto arr_tmp_ = jni::store_vector(env, " +

View File

@ -79,6 +79,8 @@ std::string TD_TL_writer_jni_h::gen_output_begin() const {
tl_name +
" {\n\n"
"using int53 = std::int64_t;\n\n"
"using bytes = " +
bytes_type +
";\n\n"

View File

@ -172,7 +172,10 @@ std::string TD_TL_writer::gen_type_name(const tl::tl_tree_type *tree_type) const
if (name == "Int" || name == "Int32") {
return "std::int32_t";
}
if (name == "Long" || name == "Int53" || name == "Int64") {
if (name == "Int53") {
return "int53";
}
if (name == "Long" || name == "Int64") {
return "std::int64_t";
}
if (name == "Double") {
@ -239,8 +242,8 @@ std::string TD_TL_writer::gen_constructor_parameter(int field_num, const std::st
}
std::string res = (field_num == 0 ? "" : ", ");
if (field_type == "bool " || field_type == "std::int32_t " || field_type == "std::int64_t " ||
field_type == "double ") {
if (field_type == "bool " || field_type == "std::int32_t " || field_type == "int53 " ||
field_type == "std::int64_t " || field_type == "double ") {
res += field_type;
} else if (field_type == "UInt128 " || field_type == "UInt256 " || field_type == string_type + " " ||
(string_type == bytes_type && field_type == "bytes ")) {