Skip to main content

rusteal_codegen/cpp_gen/
func_ids.rs

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