mirror of
https://github.com/ton-blockchain/ton
synced 2025-03-09 15:40:10 +00:00
Fix typos, UBs and warnings (#625)
This commit is contained in:
parent
5a47495d87
commit
0578cb4a42
19 changed files with 193 additions and 139 deletions
|
@ -34,6 +34,7 @@ int TD_TL_writer_hpp::get_additional_function_type(const std::string &additional
|
|||
std::vector<std::string> TD_TL_writer_hpp::get_additional_functions() const {
|
||||
std::vector<std::string> additional_functions;
|
||||
additional_functions.push_back("downcast_call");
|
||||
additional_functions.push_back("downcast_construct");
|
||||
return additional_functions;
|
||||
}
|
||||
|
||||
|
@ -202,24 +203,40 @@ std::string TD_TL_writer_hpp::gen_additional_proxy_function_begin(const std::str
|
|||
const tl::tl_type *type,
|
||||
const std::string &class_name, int arity,
|
||||
bool is_function) const {
|
||||
assert(function_name == "downcast_call");
|
||||
return "/**\n"
|
||||
" * Calls specified function object with the specified object downcasted to the most-derived type.\n"
|
||||
" * \\param[in] obj Object to pass as an argument to the function object.\n"
|
||||
" * \\param[in] func Function object to which the object will be passed.\n"
|
||||
" * \\returns whether function object call has happened. Should always return true for correct parameters.\n"
|
||||
" */\n"
|
||||
"template <class T>\n"
|
||||
"bool downcast_call(" +
|
||||
class_name +
|
||||
" &obj, const T &func) {\n"
|
||||
" switch (obj.get_id()) {\n";
|
||||
if (function_name == "downcast_call") {
|
||||
return "/**\n"
|
||||
" * Calls specified function object with the specified object downcasted to the most-derived type.\n"
|
||||
" * \\param[in] obj Object to pass as an argument to the function object.\n"
|
||||
" * \\param[in] func Function object to which the object will be passed.\n"
|
||||
" * \\returns whether function object call has happened. Should always return true for correct parameters.\n"
|
||||
" */\n"
|
||||
"template <class T>\n"
|
||||
"bool downcast_call(" +
|
||||
class_name +
|
||||
" &obj, const T &func) {\n"
|
||||
" switch (obj.get_id()) {\n";
|
||||
}
|
||||
if (function_name == "downcast_construct") {
|
||||
return "/**\n"
|
||||
"* Constructs tl_object_ptr with the object of the same type as the specified object, calls the specified "
|
||||
"function.\n"
|
||||
" * \\param[in] obj Object to get the type from.\n"
|
||||
" * \\param[in] func Function object to which the new object will be passed.\n"
|
||||
" * \\returns whether function object call has happened. Should always return true for correct parameters.\n"
|
||||
"*/"
|
||||
"template <class T>\n"
|
||||
"bool downcast_construct(" +
|
||||
class_name +
|
||||
" &obj, const T &func) {\n"
|
||||
"switch (obj.get_id()) {";
|
||||
}
|
||||
assert(false);
|
||||
}
|
||||
|
||||
std::string TD_TL_writer_hpp::gen_additional_proxy_function_case(const std::string &function_name,
|
||||
const tl::tl_type *type, const std::string &class_name,
|
||||
int arity) const {
|
||||
assert(function_name == "downcast_call");
|
||||
//assert(function_name == "downcast_call");
|
||||
assert(false);
|
||||
return "";
|
||||
}
|
||||
|
@ -227,18 +244,28 @@ std::string TD_TL_writer_hpp::gen_additional_proxy_function_case(const std::stri
|
|||
std::string TD_TL_writer_hpp::gen_additional_proxy_function_case(const std::string &function_name,
|
||||
const tl::tl_type *type, const tl::tl_combinator *t,
|
||||
int arity, bool is_function) const {
|
||||
assert(function_name == "downcast_call");
|
||||
return " case " + gen_class_name(t->name) +
|
||||
"::ID:\n"
|
||||
" func(static_cast<" +
|
||||
gen_class_name(t->name) +
|
||||
" &>(obj));\n"
|
||||
" return true;\n";
|
||||
if (function_name == "downcast_call") {
|
||||
return " case " + gen_class_name(t->name) +
|
||||
"::ID:\n"
|
||||
" func(static_cast<" +
|
||||
gen_class_name(t->name) +
|
||||
" &>(obj));\n"
|
||||
" return true;\n";
|
||||
}
|
||||
if (function_name == "downcast_construct") {
|
||||
return " case " + gen_class_name(t->name) +
|
||||
"::ID:\n"
|
||||
" func(create_tl_object<" +
|
||||
gen_class_name(t->name) +
|
||||
">());\n"
|
||||
" return true;\n";
|
||||
}
|
||||
assert(false);
|
||||
}
|
||||
|
||||
std::string TD_TL_writer_hpp::gen_additional_proxy_function_end(const std::string &function_name,
|
||||
const tl::tl_type *type, bool is_function) const {
|
||||
assert(function_name == "downcast_call");
|
||||
assert(function_name == "downcast_call" || function_name == "downcast_construct");
|
||||
return " default:\n"
|
||||
" return false;\n"
|
||||
" }\n"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue