(
output: &mut UnrealCppAutogen,
module_prefix: &str,
module: &ModuleDef,
visibility: CodegenVisibility,
api_macro: &str,
module_name: &str,
)
| 2704 | } |
| 2705 | |
| 2706 | fn generate_remote_reducers_class( |
| 2707 | output: &mut UnrealCppAutogen, |
| 2708 | module_prefix: &str, |
| 2709 | module: &ModuleDef, |
| 2710 | visibility: CodegenVisibility, |
| 2711 | api_macro: &str, |
| 2712 | module_name: &str, |
| 2713 | ) { |
| 2714 | writeln!(output, "// RemoteReducers class"); |
| 2715 | writeln!(output, "UCLASS(BlueprintType)"); |
| 2716 | writeln!( |
| 2717 | output, |
| 2718 | "class {api_macro} U{module_prefix}RemoteReducers : public UObject" |
| 2719 | ); |
| 2720 | writeln!(output, "{{"); |
| 2721 | writeln!(output, " GENERATED_BODY()"); |
| 2722 | writeln!(output); |
| 2723 | writeln!(output, "public:"); |
| 2724 | writeln!(output); |
| 2725 | |
| 2726 | // Generate reducer events and call methods |
| 2727 | for reducer in iter_reducers(module, visibility) { |
| 2728 | let reducer_name = reducer.name.deref().to_case(Case::Pascal); |
| 2729 | let reducer_pascal = format!("{module_prefix}{reducer_name}"); |
| 2730 | |
| 2731 | // Generate delegate for reducer event |
| 2732 | let param_count = reducer.params_for_generate.elements.len() + 1; // +1 for context |
| 2733 | let use_args_struct = param_count > 9; // Unreal only supports up to 9 params in delegates |
| 2734 | |
| 2735 | let mut non_blueprintable_types_for_delegate = Vec::new(); |
| 2736 | let mut non_blueprintable_types_for_function = Vec::new(); |
| 2737 | |
| 2738 | if use_args_struct { |
| 2739 | // For more than 9 params, use a struct to wrap the arguments |
| 2740 | writeln!(output, " DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams("); |
| 2741 | writeln!(output, " F{reducer_pascal}Handler,"); |
| 2742 | writeln!(output, " const F{module_prefix}ReducerEventContext&, Context,"); |
| 2743 | writeln!(output, " const F{reducer_pascal}Args&, Args"); |
| 2744 | writeln!(output, " );"); |
| 2745 | |
| 2746 | // For delegates using args struct, check the actual delegate parameters: |
| 2747 | // 1. F{module_prefix}ReducerEventContext (always blueprintable) |
| 2748 | // 2. F{Reducer}Args struct (always blueprintable as a USTRUCT) |
| 2749 | // So delegates with args struct are always blueprintable |
| 2750 | |
| 2751 | // But functions still need to check individual parameters |
| 2752 | for (_, param_type) in &reducer.params_for_generate.elements { |
| 2753 | if !is_type_blueprintable_for_delegates(module, param_type) { |
| 2754 | let type_str = cpp_ty_fmt_with_module(module_prefix, module, param_type, module_name).to_string(); |
| 2755 | non_blueprintable_types_for_function.push(type_str); |
| 2756 | } |
| 2757 | } |
| 2758 | } else { |
| 2759 | // Use the original approach for 9 or fewer params |
| 2760 | let delegate_macro = match param_count { |
| 2761 | 1 => "DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam", |
| 2762 | 2 => "DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams", |
| 2763 | 3 => "DECLARE_DYNAMIC_MULTICAST_DELEGATE_ThreeParams", |
no test coverage detected
searching dependent graphs…