Skip to content

Commit 65edc5c

Browse files
committed
feat: add some codegen metadata
1 parent dfbd85e commit 65edc5c

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

Source/EcsactUnrealCodegenPlugin/EcsactUnrealCodegenPlugin.cpp

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,11 +240,45 @@ static auto print_ustruct(ecsact::codegen_plugin_context& ctx, auto in_compo_id)
240240
ctx.writef(";\n\n");
241241
}
242242

243+
static auto print_ecsact_unreal_package_meta( //
244+
std::string_view prefix,
245+
ecsact::codegen_plugin_context& ctx
246+
) -> void {
247+
auto system_like_ids = ecsact::meta::get_all_system_like_ids(ctx.package_id);
248+
ctx.writef(
249+
"constexpr auto {}SystemLikeIds = "
250+
"std::array<ecsact_system_like_id, {}>{{\n",
251+
prefix,
252+
system_like_ids.size()
253+
);
254+
for(auto id : system_like_ids) {
255+
ctx.writef(
256+
"\tstatic_cast<ecsact_system_like_id>({} /* {} */),\n",
257+
static_cast<int>(id),
258+
ecsact::meta::decl_full_name(id)
259+
);
260+
}
261+
ctx.writef("}};\n\n");
262+
263+
ctx.writef(
264+
"constexpr auto {}ExportNames = "
265+
"std::array<const char*, {}>{{\n",
266+
prefix,
267+
system_like_ids.size()
268+
);
269+
for(auto id : system_like_ids) {
270+
ctx.writef("\t\"{}\",\n", c_identifier(ecsact::meta::decl_full_name(id)));
271+
}
272+
ctx.writef("}};\n");
273+
}
274+
243275
static auto generate_header(ecsact::codegen_plugin_context ctx) -> void {
244276
ctx.writef("#pragma once\n\n");
245277

246278
inc_header(ctx, "CoreMinimal.h");
247279
inc_header(ctx, "UObject/Interface.h");
280+
ctx.writef("#include <array>\n");
281+
inc_header(ctx, "ecsact/runtime/common.h");
248282
inc_header(ctx, "EcsactUnreal/EcsactRunnerSubsystem.h");
249283
inc_package_header(ctx, ctx.package_id, ".hh");
250284
inc_package_header_no_ext(ctx, ctx.package_id, "__ecsact__ue.generated.h");
@@ -254,6 +288,11 @@ static auto generate_header(ecsact::codegen_plugin_context ctx) -> void {
254288

255289
ctx.writef("\n\n");
256290

291+
block(ctx, "namespace EcsactUnreal::CodegenMeta", [&] {
292+
print_ecsact_unreal_package_meta(prefix, ctx);
293+
});
294+
ctx.writef("\n\n");
295+
257296
for(auto comp_id : ecsact::meta::get_component_ids(ctx.package_id)) {
258297
print_ustruct(ctx, comp_id);
259298
}

0 commit comments

Comments
 (0)