Skip to content

Commit 16c8e17

Browse files
committed
chore: removed a bunch of deprecated ctx.write calls
1 parent 91503c3 commit 16c8e17

File tree

17 files changed

+267
-310
lines changed

17 files changed

+267
-310
lines changed

rt_entt_codegen/core/check_error.cc

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ static auto print_check_add_component_error_template_specialization(
4545
const auto method_name =
4646
"ecsact::entt::check_add_component_error<" + cpp_component_ident + ">";
4747

48-
ctx.write("template<>\n");
48+
ctx.writef("template<>\n");
4949

5050
auto printer = //
5151
method_printer{ctx, method_name}
@@ -57,11 +57,11 @@ static auto print_check_add_component_error_template_specialization(
5757
for_each_entity_field(component_id, [&](auto field_name) {
5858
auto field_var = "ecsact::entt::entity_id{component." + field_name + "}";
5959
block(ctx, "if(!registry.valid(" + field_var + "))", [&] {
60-
ctx.write("return ECSACT_ADD_ERR_ENTITY_INVALID;\n");
60+
ctx.writef("return ECSACT_ADD_ERR_ENTITY_INVALID;\n");
6161
});
6262
});
6363

64-
ctx.write("return ECSACT_ADD_OK;");
64+
ctx.writef("return ECSACT_ADD_OK;");
6565
}
6666

6767
static auto print_check_update_component_error_template_specialization(
@@ -78,7 +78,7 @@ static auto print_check_update_component_error_template_specialization(
7878
const auto method_name =
7979
"ecsact::entt::check_update_component_error<" + cpp_component_ident + ">";
8080

81-
ctx.write("template<>\n");
81+
ctx.writef("template<>\n");
8282

8383
auto printer = //
8484
method_printer{ctx, method_name}
@@ -90,11 +90,11 @@ static auto print_check_update_component_error_template_specialization(
9090
for_each_entity_field(component_id, [&](auto field_name) {
9191
auto field_var = "ecsact::entt::entity_id{component." + field_name + "}";
9292
block(ctx, "if(!registry.valid(" + field_var + "))", [&] {
93-
ctx.write("return ECSACT_UPDATE_ERR_ENTITY_INVALID;\n");
93+
ctx.writef("return ECSACT_UPDATE_ERR_ENTITY_INVALID;\n");
9494
});
9595
});
9696

97-
ctx.write("return ECSACT_UPDATE_OK;");
97+
ctx.writef("return ECSACT_UPDATE_OK;");
9898
}
9999

100100
static auto print_check_action_error_template_specialization(
@@ -111,24 +111,24 @@ static auto print_check_action_error_template_specialization(
111111
const auto method_name =
112112
"ecsact::entt::check_action_error<" + cpp_action_ident + ">";
113113

114-
ctx.write("template<>\n");
114+
ctx.writef("template<>\n");
115115

116116
auto printer = //
117117
method_printer{ctx, method_name}
118118
.parameter("ecsact::entt::registry_t&", "registry")
119119
.parameter(cpp_action_ident + " const&", "action")
120120
.return_type("ecsact_execute_systems_error");
121121

122-
ctx.write("auto err = ECSACT_EXEC_SYS_OK;\n");
122+
ctx.writef("auto err = ECSACT_EXEC_SYS_OK;\n");
123123

124124
for_each_entity_field(action_id, [&](auto field_name) {
125125
auto field_var = "ecsact::entt::entity_id{action." + field_name + "}";
126126
block(ctx, "if(!registry.valid(" + field_var + "))", [&] {
127-
ctx.write("return ECSACT_EXEC_SYS_ERR_ACTION_ENTITY_INVALID;\n");
127+
ctx.writef("return ECSACT_EXEC_SYS_ERR_ACTION_ENTITY_INVALID;\n");
128128
});
129129
});
130130

131-
ctx.write("return err;\n");
131+
ctx.writef("return err;\n");
132132
}
133133

134134
auto ecsact::rt_entt_codegen::core::print_check_error_template_specializations(

rt_entt_codegen/core/events.cc

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,11 @@ static auto print_trigger_event_fn_call(
1212
std::string event_name,
1313
std::string component_name
1414
) {
15-
ctx.write(
16-
"::ecsact::entt::wrapper::core::_trigger_",
15+
ctx.writef(
16+
"::ecsact::entt::wrapper::core::_trigger_{}"
17+
"_component_event<::{}>(registry_id, events_collector);\n",
1718
event_name,
18-
"_component_event<::",
19-
component_name,
20-
">(registry_id, events_collector);\n"
19+
component_name
2120
);
2221
}
2322

@@ -53,12 +52,12 @@ auto ecsact::rt_entt_codegen::core::print_trigger_ecsact_events_minimal( //
5352
print_trigger_event_fn_call(ctx, "remove", type_name);
5453
}
5554

56-
ctx.write(
55+
ctx.writef(
5756
"ecsact::entt::wrapper::core::_trigger_create_entity_events(registry_id, "
5857
"events_collector);\n"
5958
);
6059

61-
ctx.write(
60+
ctx.writef(
6261
"ecsact::entt::wrapper::core::_trigger_destroy_entity_events(registry_id, "
6362
"events_collector);\n"
6463
);
@@ -101,12 +100,12 @@ auto ecsact::rt_entt_codegen::core::print_trigger_ecsact_events_all( //
101100
print_trigger_event_fn_call(ctx, "remove", type_name);
102101
}
103102

104-
ctx.write(
103+
ctx.writef(
105104
"ecsact::entt::wrapper::core::_trigger_create_entity_events(registry_id, "
106105
"events_collector);\n"
107106
);
108107

109-
ctx.write(
108+
ctx.writef(
110109
"ecsact::entt::wrapper::core::_trigger_destroy_entity_events(registry_id, "
111110
"events_collector);\n"
112111
);
@@ -128,11 +127,10 @@ auto ecsact::rt_entt_codegen::core::print_cleanup_ecsact_component_events( //
128127

129128
for(auto component_id : details.all_components) {
130129
auto type_name = cpp_identifier(decl_full_name(component_id));
131-
ctx.write(
130+
ctx.writef(
132131
"ecsact::entt::wrapper::core::clear_component",
133-
"<::",
134-
type_name,
135-
">(registry_id);\n"
132+
"<::{}>(registry_id);\n",
133+
type_name
136134
);
137135
}
138136
}

rt_entt_codegen/core/execution_options.cc

Lines changed: 31 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,17 @@ inline auto print_static_maps(
2020
[&] {
2121
for(auto component_id : details.all_components) {
2222
auto type_name = cpp_identifier(decl_full_name(component_id));
23-
ctx.write(
24-
"{",
25-
"ecsact_id_cast<ecsact_component_like_id>(",
26-
type_name,
27-
"::id), ",
28-
"&ecsact::entt::wrapper::core::add_component_exec_options",
29-
"<::",
30-
type_name,
31-
"> },\n"
23+
ctx.writef(
24+
"{"
25+
"ecsact_id_cast<ecsact_component_like_id>({0}::id), "
26+
"&ecsact::entt::wrapper::core::add_component_exec_options<::{0}>"
27+
"},\n",
28+
type_name
3229
);
3330
}
3431
}
3532
);
36-
ctx.write(";\n");
33+
ctx.writef(";\n");
3734

3835
block(
3936
ctx,
@@ -62,7 +59,7 @@ inline auto print_static_maps(
6259
}
6360
}
6461
);
65-
ctx.write(";\n");
62+
ctx.writef(";\n");
6663

6764
block(
6865
ctx,
@@ -85,7 +82,7 @@ inline auto print_static_maps(
8582
}
8683
}
8784
);
88-
ctx.write(";\n");
85+
ctx.writef(";\n");
8986

9087
block(
9188
ctx,
@@ -109,7 +106,7 @@ inline auto print_static_maps(
109106
}
110107
);
111108

112-
ctx.write(";\n");
109+
ctx.writef(";\n");
113110
}
114111

115112
auto ecsact::rt_entt_codegen::core::print_execution_options(
@@ -128,22 +125,22 @@ auto ecsact::rt_entt_codegen::core::print_execution_options(
128125
.return_type("ecsact_execute_systems_error");
129126

130127
print_static_maps(ctx, details);
131-
ctx.write("auto& reg = ecsact::entt::get_registry(registry_id);\n");
128+
ctx.writef("auto& reg = ecsact::entt::get_registry(registry_id);\n");
132129

133130
block(ctx, "for(int i = 0; i < options.actions_length; i++)", [&] {
134-
ctx.write("auto action = options.actions[i];\n");
135-
ctx.write(
131+
ctx.writef("auto action = options.actions[i];\n");
132+
ctx.writef(
136133
"auto err = action_error_fns.at(action.action_id)(registry_id, "
137134
"action.action_data);\n"
138135
);
139136
block(ctx, "if(err != ECSACT_EXEC_SYS_OK)", [&] {
140-
ctx.write("return err;\n");
137+
ctx.writef("return err;\n");
141138
});
142139
});
143140

144141
block(ctx, "for(int i = 0; i < options.create_entities_length; i++)", [&] {
145-
ctx.write("auto entity = ecsact::entt::entity_id(reg.create());\n");
146-
ctx.write(
142+
ctx.writef("auto entity = ecsact::entt::entity_id(reg.create());\n");
143+
ctx.writef(
147144
"reg.template emplace<ecsact::entt::detail::created_entity>(entity, "
148145
"options.create_entities[i]);\n"
149146
);
@@ -152,10 +149,10 @@ auto ecsact::rt_entt_codegen::core::print_execution_options(
152149
"for(int j = 0; j < options.create_entities_components_length[i]; "
153150
"j++)",
154151
[&] {
155-
ctx.write(
152+
ctx.writef(
156153
"auto& component = options.create_entities_components[i][j];\n"
157154
);
158-
ctx.write(
155+
ctx.writef(
159156
"execution_add_fns.at(ecsact_id_cast<ecsact_component_like_id>("
160157
"component.component_id))(registry_id, "
161158
"entity, "
@@ -166,10 +163,10 @@ auto ecsact::rt_entt_codegen::core::print_execution_options(
166163
});
167164

168165
block(ctx, "for(int i = 0; i < options.add_components_length; i++)", [&] {
169-
ctx.write("auto& component = options.add_components[i];\n");
170-
ctx.write("auto entity = options.add_components_entities[i];\n\n");
166+
ctx.writef("auto& component = options.add_components[i];\n");
167+
ctx.writef("auto entity = options.add_components_entities[i];\n\n");
171168

172-
ctx.write(
169+
ctx.writef(
173170
"execution_add_fns.at(ecsact_id_cast<ecsact_component_like_id>("
174171
"component.component_id))(registry_id, "
175172
"ecsact::entt::entity_id(entity), "
@@ -178,10 +175,10 @@ auto ecsact::rt_entt_codegen::core::print_execution_options(
178175
});
179176

180177
block(ctx, "for(int i = 0; i < options.update_components_length; i++)", [&] {
181-
ctx.write("auto& component = options.update_components[i];\n");
182-
ctx.write("auto entity = options.update_components_entities[i];\n\n");
178+
ctx.writef("auto& component = options.update_components[i];\n");
179+
ctx.writef("auto entity = options.update_components_entities[i];\n\n");
183180

184-
ctx.write(
181+
ctx.writef(
185182
"execution_update_fns.at(ecsact_id_cast<ecsact_component_like_id>("
186183
"component.component_id))(registry_id, "
187184
"ecsact::entt::entity_id(entity), "
@@ -190,10 +187,10 @@ auto ecsact::rt_entt_codegen::core::print_execution_options(
190187
});
191188

192189
block(ctx, "for(int i = 0; i < options.remove_components_length; i++)", [&] {
193-
ctx.write("auto& component_id = options.remove_components[i];\n");
194-
ctx.write("auto entity = options.remove_components_entities[i];\n\n");
190+
ctx.writef("auto& component_id = options.remove_components[i];\n");
191+
ctx.writef("auto entity = options.remove_components_entities[i];\n\n");
195192

196-
ctx.write(
193+
ctx.writef(
197194
"execution_remove_fns.at(ecsact_id_cast<ecsact_component_like_id>("
198195
"component_id))(registry_id, "
199196
"ecsact::entt::entity_id(entity), "
@@ -202,14 +199,14 @@ auto ecsact::rt_entt_codegen::core::print_execution_options(
202199
});
203200

204201
block(ctx, "for(int i = 0; i < options.destroy_entities_length; i++)", [&] {
205-
ctx.write("auto entity = options.destroy_entities[i];\n");
206-
ctx.write("reg.destroy(ecsact::entt::entity_id(entity));\n");
207-
ctx.write(
202+
ctx.writef("auto entity = options.destroy_entities[i];\n");
203+
ctx.writef("reg.destroy(ecsact::entt::entity_id(entity));\n");
204+
ctx.writef(
208205
"reg.template "
209206
"emplace<ecsact::entt::detail::destroyed_entity>(ecsact::entt::entity_id("
210207
"entity));\n"
211208
);
212209
});
213210

214-
ctx.write("return ECSACT_EXEC_SYS_OK;\n");
211+
ctx.writef("return ECSACT_EXEC_SYS_OK;\n");
215212
}

rt_entt_codegen/core/init_registry_storage.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,25 @@ auto ecsact::rt_entt_codegen::core::print_init_registry_storage(
1616
.parameter("::entt::registry&", "registry")
1717
.return_type("void");
1818

19-
ctx.write(
19+
ctx.writef(
2020
"registry.template storage<ecsact::entt::detail::destroyed_entity>();\n\n"
2121
);
2222

2323
for(auto comp_id : details.all_components) {
2424
auto cpp_comp_name = cpp_identifier(decl_full_name(comp_id));
2525

26-
ctx.write(std::format(
26+
ctx.writef(
2727
"ecsact::entt::wrapper::core::prepare_component<{}>(registry);\n",
2828
cpp_comp_name
29-
));
29+
);
3030
}
3131

3232
for(auto system_id : details.all_systems) {
3333
auto cpp_sys_name = cpp_identifier(decl_full_name(system_id));
3434

35-
ctx.write(std::format(
35+
ctx.writef(
3636
"ecsact::entt::wrapper::core::prepare_system<{}>(registry);\n",
3737
cpp_sys_name
38-
));
38+
);
3939
}
4040
}

0 commit comments

Comments
 (0)