Skip to main content

uika_codegen/cpp_gen/
func_ids.rs

1// C++ UikaFuncIds.h generation.
2
3use crate::context::FuncEntry;
4use crate::rust_gen::func_ids::func_id_const_name;
5
6/// Generate the UikaFuncIds.h header file.
7pub fn generate_cpp_func_ids(entries: &[FuncEntry]) -> String {
8    let mut out = String::with_capacity(entries.len() * 60 + 512);
9
10    out.push_str("// Auto-generated by uika-codegen. Do not edit.\n\n");
11    out.push_str("#pragma once\n\n");
12    out.push_str("#include <cstdint>\n\n");
13    out.push_str("namespace UikaFuncId {\n\n");
14
15    for entry in entries {
16        let const_name = func_id_const_name(&entry.class_name, &entry.func_name);
17        let id = entry.func_id;
18        out.push_str(&format!("    constexpr uint32_t {const_name} = {id};\n"));
19    }
20
21    out.push('\n');
22    out.push_str(&format!(
23        "    constexpr uint32_t FUNC_COUNT = {};\n",
24        entries.len()
25    ));
26
27    out.push_str("\n} // namespace UikaFuncId\n");
28
29    out
30}