MCPcopy Create free account
hub / github.com/clockworklabs/SpacetimeDB / generate_remote_reducer_calls

Function generate_remote_reducer_calls

crates/codegen/src/unrealcpp.rs:4914–5091  ·  view source on GitHub ↗
(
    output: &mut UnrealCppAutogen,
    module: &ModuleDef,
    visibility: CodegenVisibility,
    module_prefix: &str,
    module_name: &str,
)

Source from the content-addressed store, hash-verified

4912}
4913
4914fn generate_remote_reducer_calls(
4915 output: &mut UnrealCppAutogen,
4916 module: &ModuleDef,
4917 visibility: CodegenVisibility,
4918 module_prefix: &str,
4919 module_name: &str,
4920) {
4921 // Reducer implementations
4922 for reducer in iter_reducers(module, visibility) {
4923 let reducer_name = reducer.name.deref().to_case(Case::Pascal);
4924 let reducer_pascal = format!("{module_prefix}{reducer_name}");
4925 let reducer_snake = reducer.name.deref();
4926
4927 // Call method implementation
4928 write!(output, "void U{module_prefix}RemoteReducers::{reducer_name}(");
4929 let mut first = true;
4930 for (param_name, param_type) in &reducer.params_for_generate.elements {
4931 if !first {
4932 write!(output, ", ");
4933 }
4934 first = false;
4935 // Use Blueprint-compatible types (same as UFUNCTION and delegates)
4936 let type_str = cpp_ty_fmt_blueprint_compatible(module_prefix, module, param_type, module_name).to_string();
4937 if should_pass_by_value_in_delegate(module, param_type) {
4938 // Primitives use const by-value in U{module_prefix}RemoteReducers methods (same as UFUNCTION)
4939 write!(
4940 output,
4941 "const {} {}",
4942 type_str,
4943 param_name.deref().to_case(Case::Pascal)
4944 );
4945 } else {
4946 // Complex types (including FSpacetimeDB structs) use const references
4947 write!(
4948 output,
4949 "const {}& {}",
4950 type_str,
4951 param_name.deref().to_case(Case::Pascal)
4952 );
4953 }
4954 }
4955 writeln!(output, ")");
4956 writeln!(output, "{{");
4957 writeln!(output, " if (!Conn)");
4958 writeln!(output, " {{");
4959 writeln!(
4960 output,
4961 " UE_LOG(LogTemp, Error, TEXT(\"SpacetimeDB connection is null\"));"
4962 );
4963 writeln!(output, " return;");
4964 writeln!(output, " }}");
4965 writeln!(output);
4966 // Call reducer using typed helper to hide serialization
4967 if reducer.params_for_generate.elements.is_empty() {
4968 writeln!(output, "\tF{reducer_pascal}Args ReducerArgs;");
4969 writeln!(
4970 output,
4971 "\tconst uint32 RequestId = Conn->CallReducerTyped(TEXT(\"{reducer_snake}\"), ReducerArgs);"

Callers 1

Calls 8

iter_reducersFunction · 0.85
to_caseMethod · 0.80
derefMethod · 0.45
to_stringMethod · 0.45
is_emptyMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…