mirror of
https://github.com/github/codeql.git
synced 2025-12-17 01:03:14 +01:00
Codegen: add const overload of forEachLabel
This commit is contained in:
@@ -42,34 +42,12 @@ struct {{name}}{{#has_bases}} : {{#bases}}{{^first}}, {{/first}}{{ref.name}}{{/b
|
|||||||
{{/final}}
|
{{/final}}
|
||||||
template <typename F>
|
template <typename F>
|
||||||
void forEachLabel(F f) {
|
void forEachLabel(F f) {
|
||||||
{{#final}}
|
{{>cpp_for_each_label_body}}
|
||||||
f("id", -1, id);
|
}
|
||||||
{{/final}}
|
|
||||||
{{#bases}}
|
template <typename F>
|
||||||
{{ref.name}}::forEachLabel(f);
|
void forEachLabel(F f) const {
|
||||||
{{/bases}}
|
{{>cpp_for_each_label_body}}
|
||||||
{{#fields}}
|
|
||||||
{{#is_label}}
|
|
||||||
{{#is_repeated}}
|
|
||||||
for (auto i = 0u; i < {{field_name}}.size(); ++i) {
|
|
||||||
{{#is_optional}}
|
|
||||||
if ({{field_name}}[i]) f("{{field_name}}", i, *{{field_name}}[i]);
|
|
||||||
{{/is_optional}}
|
|
||||||
{{^is_optional}}
|
|
||||||
f("{{field_name}}", i, {{field_name}}[i]);
|
|
||||||
{{/is_optional}}
|
|
||||||
}
|
|
||||||
{{/is_repeated}}
|
|
||||||
{{^is_repeated}}
|
|
||||||
{{#is_optional}}
|
|
||||||
if ({{field_name}}) f("{{field_name}}", -1, *{{field_name}});
|
|
||||||
{{/is_optional}}
|
|
||||||
{{^is_optional}}
|
|
||||||
f("{{field_name}}", -1, {{field_name}});
|
|
||||||
{{/is_optional}}
|
|
||||||
{{/is_repeated}}
|
|
||||||
{{/is_label}}
|
|
||||||
{{/fields}}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|||||||
28
misc/codegen/templates/cpp_for_each_label_body.mustache
Normal file
28
misc/codegen/templates/cpp_for_each_label_body.mustache
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
{{#final}}
|
||||||
|
f("id", -1, id);
|
||||||
|
{{/final}}
|
||||||
|
{{#bases}}
|
||||||
|
{{ref.name}}::forEachLabel(f);
|
||||||
|
{{/bases}}
|
||||||
|
{{#fields}}
|
||||||
|
{{#is_label}}
|
||||||
|
{{#is_repeated}}
|
||||||
|
for (auto i = 0u; i < {{field_name}}.size(); ++i) {
|
||||||
|
{{#is_optional}}
|
||||||
|
if ({{field_name}}[i]) f("{{field_name}}", i, *{{field_name}}[i]);
|
||||||
|
{{/is_optional}}
|
||||||
|
{{^is_optional}}
|
||||||
|
f("{{field_name}}", i, {{field_name}}[i]);
|
||||||
|
{{/is_optional}}
|
||||||
|
}
|
||||||
|
{{/is_repeated}}
|
||||||
|
{{^is_repeated}}
|
||||||
|
{{#is_optional}}
|
||||||
|
if ({{field_name}}) f("{{field_name}}", -1, *{{field_name}});
|
||||||
|
{{/is_optional}}
|
||||||
|
{{^is_optional}}
|
||||||
|
f("{{field_name}}", -1, {{field_name}});
|
||||||
|
{{/is_optional}}
|
||||||
|
{{/is_repeated}}
|
||||||
|
{{/is_label}}
|
||||||
|
{{/fields}}
|
||||||
@@ -23,11 +23,12 @@ struct {{name}}Trap {
|
|||||||
|
|
||||||
template <typename F>
|
template <typename F>
|
||||||
void forEachLabel(F f) {
|
void forEachLabel(F f) {
|
||||||
{{#fields}}
|
{{>cpp_for_each_label_body}}
|
||||||
{{#is_label}}
|
}
|
||||||
f("{{field_name}}", -1, {{field_name}});
|
|
||||||
{{/is_label}}
|
template <typename F>
|
||||||
{{/fields}}
|
void forEachLabel(F f) const {
|
||||||
|
{{>cpp_for_each_label_body}}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user