Skip to content

Commit 74ebca8

Browse files
committed
feat: handy block codegen plugin util function
1 parent 9af3ce1 commit 74ebca8

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

ecsact/cpp_codegen_plugin_util.hh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include <vector>
66
#include <string>
77
#include <utility>
8+
#include <concepts>
89
#include "ecsact/codegen_plugin.hh"
910
#include "ecsact/runtime/meta.hh"
1011

@@ -177,4 +178,22 @@ public:
177178
}
178179
};
179180

181+
auto block( //
182+
ecsact::codegen_plugin_context& ctx,
183+
std::invocable auto&& block_body_fn
184+
) {
185+
auto printer = block_printer{ctx};
186+
block_body_fn();
187+
}
188+
189+
auto block( //
190+
ecsact::codegen_plugin_context& ctx,
191+
auto&& block_prefix,
192+
std::invocable auto&& block_body_fn
193+
) {
194+
ctx.write(block_prefix, " ");
195+
auto printer = block_printer{ctx};
196+
block_body_fn();
197+
}
198+
180199
} // namespace ecsact::cpp_codegen_plugin_util

0 commit comments

Comments
 (0)