(
output: &mut UnrealCppAutogen,
module_prefix: &str,
module: &ModuleDef,
visibility: CodegenVisibility,
api_macro: &str,
module_name: &str,
)
| 2402 | } |
| 2403 | |
| 2404 | fn generate_procedure_bindings( |
| 2405 | output: &mut UnrealCppAutogen, |
| 2406 | module_prefix: &str, |
| 2407 | module: &ModuleDef, |
| 2408 | visibility: CodegenVisibility, |
| 2409 | api_macro: &str, |
| 2410 | module_name: &str, |
| 2411 | ) { |
| 2412 | let procedure_count: usize = iter_procedures(module, visibility).count(); |
| 2413 | if procedure_count > 0 { |
| 2414 | // --------------------------------------------------------------------- |
| 2415 | // Per-module typed Procedure tagged union + typed Event |
| 2416 | // --------------------------------------------------------------------- |
| 2417 | writeln!(output, "UENUM(BlueprintType, Category = \"SpacetimeDB\")"); |
| 2418 | writeln!(output, "enum class E{module_prefix}ProcedureTag : uint8"); |
| 2419 | writeln!(output, "{{"); |
| 2420 | { |
| 2421 | let mut first = true; |
| 2422 | for procedure in iter_procedures(module, visibility) { |
| 2423 | let procedure_name = procedure.name.deref().to_case(Case::Pascal); |
| 2424 | if !first { |
| 2425 | writeln!(output, ","); |
| 2426 | } else { |
| 2427 | first = false; |
| 2428 | } |
| 2429 | write!(output, " {procedure_name}"); |
| 2430 | } |
| 2431 | writeln!(output); |
| 2432 | } |
| 2433 | writeln!(output, "}};"); |
| 2434 | writeln!(output); |
| 2435 | |
| 2436 | // F{module_prefix}Procedure: tagged union over procedure args, with optional metadata |
| 2437 | writeln!(output, "USTRUCT(BlueprintType)"); |
| 2438 | writeln!(output, "struct {api_macro} F{module_prefix}Procedure"); |
| 2439 | writeln!(output, "{{"); |
| 2440 | writeln!(output, " GENERATED_BODY()"); |
| 2441 | writeln!(output); |
| 2442 | writeln!(output, "public:"); |
| 2443 | writeln!(output, " UPROPERTY(BlueprintReadOnly, Category = \"SpacetimeDB\")"); |
| 2444 | writeln!( |
| 2445 | output, |
| 2446 | " E{module_prefix}ProcedureTag Tag = static_cast<E{module_prefix}ProcedureTag>(0);" |
| 2447 | ); |
| 2448 | writeln!(output); |
| 2449 | write!(output, " TVariant<"); |
| 2450 | { |
| 2451 | let mut first = true; |
| 2452 | for procedure in iter_procedures(module, visibility) { |
| 2453 | let procedure_pascal = format!("{module_prefix}{}", procedure.name.deref().to_case(Case::Pascal)); |
| 2454 | if !first { |
| 2455 | write!(output, ", "); |
| 2456 | } else { |
| 2457 | first = false; |
| 2458 | } |
| 2459 | write!(output, "F{procedure_pascal}Args"); |
| 2460 | } |
| 2461 | } |
no test coverage detected
searching dependent graphs…