tracking of event groups for compilation to standalone-C++

This commit is contained in:
Vern Paxson 2025-09-15 14:07:29 -07:00 committed by Tim Wojtulewicz
parent b25a844210
commit 973cc00c42
17 changed files with 155 additions and 69 deletions

View file

@ -365,13 +365,19 @@ void CPPCompile::RegisterCompiledBody(const string& f) {
ASSERT(fi != func_index.end());
auto type_signature = casting_index[fi->second];
auto h = body_hashes[f];
auto p = body_priorities[f];
auto loc = body_locs[f];
auto body_info = Fmt(p) + ", " + Fmt(h) + ", \"" + loc->FileName() + " (C++)\", " + Fmt(loc->FirstLine());
const auto& bi = body_info[f];
auto body_info =
Fmt(bi.priority) + ", " + Fmt(bi.hash) + ", \"" + bi.loc->FileName() + " (C++)\", " + Fmt(bi.loc->FirstLine());
Emit("\tCPP_RegisterBody(\"%s\", (void*) %s, %s, %s, std::vector<std::string>(%s)),", f, f, Fmt(type_signature),
body_info, events);
string module_group = "\"" + bi.module + "\"";
string attr_groups = "{";
for ( const auto& g : bi.groups )
attr_groups += " \"" + g + "\",";
attr_groups += " }";
Emit("\tCPP_RegisterBody(\"%s\", (void*) %s, %s, %s, std::vector<std::string>(%s), %s, %s),", f, f,
Fmt(type_signature), body_info, events, module_group, attr_groups);
}
void CPPCompile::GenEpilog() {
@ -555,8 +561,12 @@ void CPPCompile::GenRegisterBodies() {
"auto f = make_intrusive<CPPDynStmt>(b.func_name.c_str(), b.func, b.type_signature, "
"b.filename, b.line_num);");
auto reg = standalone ? "register_standalone_body" : "register_body";
Emit("%s__CPP(f, b.priority, b.h, b.events, finish_init__CPP);", reg);
if ( standalone )
Emit(
"register_standalone_body__CPP(f, b.priority, b.h, b.events, b.module_group, b.attr_groups, "
"finish_init__CPP);");
else
Emit("register_body__CPP(f, b.priority, b.h, b.events, finish_init__CPP);");
EndBlock();
EndBlock();