Don't allow to call get_id() on non-abstract classes.

This commit is contained in:
levlam 2024-01-22 19:46:12 +03:00
parent eb80098431
commit ed4f18bfaf

View File

@ -264,8 +264,16 @@ std::string TD_TL_writer_h::gen_forward_class_declaration(const std::string &cla
std::string TD_TL_writer_h::gen_class_begin(const std::string &class_name, const std::string &base_class_name, std::string TD_TL_writer_h::gen_class_begin(const std::string &class_name, const std::string &base_class_name,
bool is_proxy, const tl::tl_tree *result) const { bool is_proxy, const tl::tl_tree *result) const {
return "class " + class_name + (!is_proxy ? " final " : "") + ": public " + base_class_name + if (is_proxy) {
return "class " + class_name + ": public " + base_class_name +
" {\n"
" public:\n";
}
return "class " + class_name + " final : public " + base_class_name +
" {\n" " {\n"
" std::int32_t get_id() const final {\n"
" return ID;\n"
" }\n\n"
" public:\n"; " public:\n";
} }
@ -289,11 +297,7 @@ std::string TD_TL_writer_h::gen_get_id(const std::string &class_name, std::int32
return "\n" return "\n"
" static const std::int32_t ID = " + " static const std::int32_t ID = " +
int_to_string(id) + int_to_string(id) + ";\n";
";\n"
" std::int32_t get_id() const final {\n"
" return ID;\n"
" }\n";
} }
std::string TD_TL_writer_h::gen_function_result_type(const tl::tl_tree *result) const { std::string TD_TL_writer_h::gen_function_result_type(const tl::tl_tree *result) const {