MCPcopy Create free account
hub / github.com/TelegramMessenger/cocoon / gen_fetch_function_begin

Method gen_fetch_function_begin

tl/generate/tl_writer_cpp.cpp:531–558  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

529}
530
531std::string TD_TL_writer_cpp::gen_fetch_function_begin(const std::string &parser_name, const std::string &class_name,
532 const std::string &parent_class_name, int arity,
533 std::vector<tl::var_description> &vars, int parser_type) const {
534 for (std::size_t i = 0; i < vars.size(); i++) {
535 assert(vars[i].is_stored == false);
536 }
537
538 std::string fetched_type = "object_ptr<" + class_name + "> ";
539 std::string returned_type = "object_ptr<" + parent_class_name + "> ";
540 assert(arity == 0);
541
542 if (parser_type == 0) {
543 return "\n" + returned_type + class_name + "::fetch(" + parser_name +
544 " &p) {\n"
545 " return make_object<" +
546 class_name +
547 ">(p);\n"
548 "}\n\n" +
549 class_name + "::" + class_name + "(" + parser_name +
550 " &p)\n"
551 "#define FAIL(error) p.set_error(error)\n";
552 }
553
554 return "\n" + returned_type + class_name + "::fetch(" + parser_name +
555 " &p) {\n"
556 "#define FAIL(error) p.set_error(error); return nullptr;\n" +
557 (parser_type == -1 ? "" : " " + fetched_type + "res = make_object<" + class_name + ">();\n");
558}
559
560std::string TD_TL_writer_cpp::gen_fetch_function_end(bool has_parent, int field_num,
561 const std::vector<tl::var_description> &vars,

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected