@@ -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
115112auto 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}
0 commit comments