tdtl: pass class_name to constructor generators.
GitOrigin-RevId: 217c0cbd9eb99777f8970879d9b3da42cd6c8a02
This commit is contained in:
parent
ed54c461ae
commit
8c45a03244
@ -346,7 +346,8 @@ class TlWriterCCommon : public tl::TL_writer {
|
||||
(fields_num ? "" : "void");
|
||||
return ss.str();
|
||||
}
|
||||
std::string gen_constructor_parameter(int field_num, const tl::arg &a, bool is_default) const override {
|
||||
std::string gen_constructor_parameter(int field_num, const std::string &class_name, const tl::arg &a,
|
||||
bool is_default) const override {
|
||||
if (!is_default || is_header_ == -1) {
|
||||
return "";
|
||||
}
|
||||
@ -356,7 +357,8 @@ class TlWriterCCommon : public tl::TL_writer {
|
||||
ss << field_type << gen_field_name(a.name);
|
||||
return ss.str();
|
||||
}
|
||||
std::string gen_constructor_field_init(int field_num, const tl::arg &a, bool is_default) const override {
|
||||
std::string gen_constructor_field_init(int field_num, const std::string &class_name, const tl::arg &a,
|
||||
bool is_default) const override {
|
||||
return "";
|
||||
}
|
||||
std::string gen_constructor_end(const tl::tl_combinator *t, int fields_num, bool is_default) const override {
|
||||
|
@ -636,7 +636,8 @@ std::string TD_TL_writer_cpp::gen_constructor_begin(int fields_num, const std::s
|
||||
return "\n" + class_name + "::" + class_name + "(";
|
||||
}
|
||||
|
||||
std::string TD_TL_writer_cpp::gen_constructor_field_init(int field_num, const tl::arg &a, bool is_default) const {
|
||||
std::string TD_TL_writer_cpp::gen_constructor_field_init(int field_num, const std::string &class_name, const tl::arg &a,
|
||||
bool is_default) const {
|
||||
std::string field_type = gen_field_type(a);
|
||||
if (field_type.empty()) {
|
||||
return "";
|
||||
|
@ -97,7 +97,8 @@ class TD_TL_writer_cpp : public TD_TL_writer {
|
||||
std::string gen_fetch_switch_end() const override;
|
||||
|
||||
std::string gen_constructor_begin(int fields_num, const std::string &class_name, bool is_default) const override;
|
||||
std::string gen_constructor_field_init(int field_num, const tl::arg &a, bool is_default) const override;
|
||||
std::string gen_constructor_field_init(int field_num, const std::string &class_name, const tl::arg &a,
|
||||
bool is_default) const override;
|
||||
std::string gen_constructor_end(const tl::tl_combinator *t, int fields_num, bool is_default) const override;
|
||||
};
|
||||
|
||||
|
@ -338,7 +338,8 @@ std::string TD_TL_writer_h::gen_constructor_begin(int fields_num, const std::str
|
||||
std::string(fields_num == 1 ? "explicit " : "") + class_name + "(";
|
||||
}
|
||||
|
||||
std::string TD_TL_writer_h::gen_constructor_field_init(int field_num, const tl::arg &a, bool is_default) const {
|
||||
std::string TD_TL_writer_h::gen_constructor_field_init(int field_num, const std::string &class_name, const tl::arg &a,
|
||||
bool is_default) const {
|
||||
return "";
|
||||
}
|
||||
|
||||
|
@ -83,7 +83,8 @@ class TD_TL_writer_h : public TD_TL_writer {
|
||||
std::string gen_fetch_switch_end() const override;
|
||||
|
||||
std::string gen_constructor_begin(int fields_num, const std::string &class_name, bool is_default) const override;
|
||||
std::string gen_constructor_field_init(int field_num, const tl::arg &a, bool is_default) const override;
|
||||
std::string gen_constructor_field_init(int field_num, const std::string &class_name, const tl::arg &a,
|
||||
bool is_default) const override;
|
||||
std::string gen_constructor_end(const tl::tl_combinator *t, int fields_num, bool is_default) const override;
|
||||
};
|
||||
|
||||
|
@ -242,11 +242,13 @@ std::string TD_TL_writer_hpp::gen_constructor_begin(int fields_num, const std::s
|
||||
return "";
|
||||
}
|
||||
|
||||
std::string TD_TL_writer_hpp::gen_constructor_parameter(int field_num, const tl::arg &a, bool is_default) const {
|
||||
std::string TD_TL_writer_hpp::gen_constructor_parameter(int field_num, const std::string &class_name, const tl::arg &a,
|
||||
bool is_default) const {
|
||||
return "";
|
||||
}
|
||||
|
||||
std::string TD_TL_writer_hpp::gen_constructor_field_init(int field_num, const tl::arg &a, bool is_default) const {
|
||||
std::string TD_TL_writer_hpp::gen_constructor_field_init(int field_num, const std::string &class_name, const tl::arg &a,
|
||||
bool is_default) const {
|
||||
return "";
|
||||
}
|
||||
|
||||
|
@ -84,8 +84,10 @@ class TD_TL_writer_hpp : public TD_TL_writer {
|
||||
std::string gen_fetch_switch_end() const override;
|
||||
|
||||
std::string gen_constructor_begin(int fields_num, const std::string &class_name, bool is_default) const override;
|
||||
std::string gen_constructor_parameter(int field_num, const tl::arg &a, bool is_default) const override;
|
||||
std::string gen_constructor_field_init(int field_num, const tl::arg &a, bool is_default) const override;
|
||||
std::string gen_constructor_parameter(int field_num, const std::string &class_name, const tl::arg &a,
|
||||
bool is_default) const override;
|
||||
std::string gen_constructor_field_init(int field_num, const std::string &class_name, const tl::arg &a,
|
||||
bool is_default) const override;
|
||||
std::string gen_constructor_end(const tl::tl_combinator *t, int fields_num, bool is_default) const override;
|
||||
|
||||
std::string gen_additional_function(const std::string &function_name, const tl::tl_combinator *t,
|
||||
|
@ -500,7 +500,8 @@ std::string TD_TL_writer_java::gen_constructor_begin(int fields_num, const std::
|
||||
class_name + "(";
|
||||
}
|
||||
|
||||
std::string TD_TL_writer_java::gen_constructor_parameter(int field_num, const tl::arg &a, bool is_default) const {
|
||||
std::string TD_TL_writer_java::gen_constructor_parameter(int field_num, const std::string &class_name, const tl::arg &a,
|
||||
bool is_default) const {
|
||||
if (is_default) {
|
||||
return "";
|
||||
}
|
||||
@ -517,7 +518,8 @@ std::string TD_TL_writer_java::gen_constructor_parameter(int field_num, const tl
|
||||
return (field_num == 0 ? "" : ", ") + field_type + gen_field_name(a.name);
|
||||
}
|
||||
|
||||
std::string TD_TL_writer_java::gen_constructor_field_init(int field_num, const tl::arg &a, bool is_default) const {
|
||||
std::string TD_TL_writer_java::gen_constructor_field_init(int field_num, const std::string &class_name,
|
||||
const tl::arg &a, bool is_default) const {
|
||||
std::string field_type = gen_field_type(a);
|
||||
if (field_type.empty()) {
|
||||
return "";
|
||||
|
@ -108,8 +108,10 @@ class TD_TL_writer_java : public tl::TL_writer {
|
||||
std::string gen_fetch_switch_end() const override;
|
||||
|
||||
std::string gen_constructor_begin(int fields_num, const std::string &class_name, bool is_default) const override;
|
||||
std::string gen_constructor_parameter(int field_num, const tl::arg &a, bool is_default) const override;
|
||||
std::string gen_constructor_field_init(int field_num, const tl::arg &a, bool is_default) const override;
|
||||
std::string gen_constructor_parameter(int field_num, const std::string &class_name, const tl::arg &a,
|
||||
bool is_default) const override;
|
||||
std::string gen_constructor_field_init(int field_num, const std::string &class_name, const tl::arg &a,
|
||||
bool is_default) const override;
|
||||
std::string gen_constructor_end(const tl::tl_combinator *t, int fields_num, bool is_default) const override;
|
||||
};
|
||||
|
||||
|
@ -217,7 +217,8 @@ std::string TD_TL_writer::gen_int_const(const tl::tl_tree *tree_c, const std::ve
|
||||
return std::string();
|
||||
}
|
||||
|
||||
std::string TD_TL_writer::gen_constructor_parameter(int field_num, const tl::arg &a, bool is_default) const {
|
||||
std::string TD_TL_writer::gen_constructor_parameter(int field_num, const std::string &class_name, const tl::arg &a,
|
||||
bool is_default) const {
|
||||
if (is_default) {
|
||||
return "";
|
||||
}
|
||||
|
@ -55,7 +55,8 @@ class TD_TL_writer : public tl::TL_writer {
|
||||
|
||||
std::string gen_int_const(const tl::tl_tree *tree_c, const std::vector<tl::var_description> &vars) const override;
|
||||
|
||||
std::string gen_constructor_parameter(int field_num, const tl::arg &a, bool is_default) const override;
|
||||
std::string gen_constructor_parameter(int field_num, const std::string &class_name, const tl::arg &a,
|
||||
bool is_default) const override;
|
||||
};
|
||||
|
||||
} // namespace td
|
||||
|
@ -54,13 +54,13 @@ static void write_class_constructor(tl_outputer &out, const tl_combinator *t, co
|
||||
// std::fprintf(stderr, "Gen constructor %s\n", class_name.c_str());
|
||||
int fields_num = 0;
|
||||
for (std::size_t i = 0; i < t->args.size(); i++) {
|
||||
fields_num += !w.gen_constructor_parameter(0, t->args[i], is_default).empty();
|
||||
fields_num += !w.gen_constructor_parameter(0, class_name, t->args[i], is_default).empty();
|
||||
}
|
||||
|
||||
out.append(w.gen_constructor_begin(fields_num, class_name, is_default));
|
||||
int field_num = 0;
|
||||
for (std::size_t i = 0; i < t->args.size(); i++) {
|
||||
std::string parameter_init = w.gen_constructor_parameter(field_num, t->args[i], is_default);
|
||||
std::string parameter_init = w.gen_constructor_parameter(field_num, class_name, t->args[i], is_default);
|
||||
if (parameter_init.size()) {
|
||||
out.append(parameter_init);
|
||||
field_num++;
|
||||
@ -70,7 +70,7 @@ static void write_class_constructor(tl_outputer &out, const tl_combinator *t, co
|
||||
|
||||
field_num = 0;
|
||||
for (std::size_t i = 0; i < t->args.size(); i++) {
|
||||
std::string field_init = w.gen_constructor_field_init(field_num, t->args[i], is_default);
|
||||
std::string field_init = w.gen_constructor_field_init(field_num, class_name, t->args[i], is_default);
|
||||
if (field_init.size()) {
|
||||
out.append(field_init);
|
||||
field_num++;
|
||||
|
@ -139,8 +139,10 @@ class TL_writer {
|
||||
virtual std::string gen_fetch_switch_end() const = 0;
|
||||
|
||||
virtual std::string gen_constructor_begin(int fields_num, const std::string &class_name, bool is_default) const = 0;
|
||||
virtual std::string gen_constructor_parameter(int field_num, const arg &a, bool is_default) const = 0;
|
||||
virtual std::string gen_constructor_field_init(int field_num, const arg &a, bool is_default) const = 0;
|
||||
virtual std::string gen_constructor_parameter(int field_num, const std::string &class_name, const arg &a,
|
||||
bool is_default) const = 0;
|
||||
virtual std::string gen_constructor_field_init(int field_num, const std::string &class_name, const arg &a,
|
||||
bool is_default) const = 0;
|
||||
virtual std::string gen_constructor_end(const tl_combinator *t, int fields_num, bool is_default) const = 0;
|
||||
|
||||
virtual std::string gen_additional_function(const std::string &function_name, const tl_combinator *t,
|
||||
|
Reference in New Issue
Block a user