public string BuildMethodSignature(Package.Method m, Package.Class c, bool inHeader) { var text = new CorrmStringBuilder(); // static if (m.IsStatic && inHeader && Generator.ShouldConvertStaticMethods) { text += $"static "; } // Return Type var retn = m.Parameters.Where(item => item.ParamType == Package.Method.Parameter.Type.Return).ToList(); text += (retn.Any() ? retn.First().CppType : $"void") + $" "; // inHeader if (!inHeader) { text += $"{c.NameCpp}::"; } if (m.IsStatic && Generator.ShouldConvertStaticMethods) { text += $"STATIC_"; } text += m.Name; // Parameters text += $"("; if (m.Parameters.Count > 0) { var paramList = m.Parameters .Where(p => p.ParamType != Package.Method.Parameter.Type.Return) .OrderBy(p => p.ParamType) .Select(p => (p.PassByReference ? $"const " : "") + p.CppType + (p.PassByReference ? $"& " : p.ParamType == Package.Method.Parameter.Type.Out ? $"* " : $" ") + p.Name).ToList(); if (paramList.Count > 0) { text += paramList.Aggregate((cur, next) => cur + ", " + next); } } text += $")"; return(text); }
public string BuildMethodBody(Package.Class c, Package.Method m) { var text = new CorrmStringBuilder(); // Function Pointer text += $"{{{Utils.NLine}\tstatic auto fn"; if (Generator.ShouldUseStrings) { text += $" = UObject::FindObject<UFunction>("; if (Generator.ShouldXorStrings) { text += $"_xor_(\"{m.FullName}\")"; } else { text += $"\"{m.FullName}\""; } text += $");{Utils.NLine}{Utils.NLine}"; } else { text += $" = UObject::GetObjectCasted<UFunction>({m.Index});{Utils.NLine}{Utils.NLine}"; } // Parameters if (Generator.ShouldGenerateFunctionParametersFile()) { text += $"\t{c.NameCpp}_{m.Name}_Params params;{Utils.NLine}"; } else { text += $"\tstruct{Utils.NLine}\t{{{Utils.NLine}"; foreach (var param in m.Parameters) { text += $"\t\t{param.CppType,-30} {param.Name};{Utils.NLine}"; } text += $"\t}} params;{Utils.NLine}"; } var retn = m.Parameters.Where(item => item.ParamType == Package.Method.Parameter.Type.Default).ToList(); if (retn.Any()) { foreach (var param in retn) { text += $"\tparams.{param.Name} = {param.Name};{Utils.NLine}"; } } text += $"{Utils.NLine}"; //Function Call text += $"\tauto flags = fn->FunctionFlags;{Utils.NLine}"; if (m.IsNative) { text += $"\tfn->FunctionFlags |= 0x{UEFunctionFlags.Native:X};{Utils.NLine}"; } text += $"{Utils.NLine}"; if (m.IsStatic && !Generator.ShouldConvertStaticMethods) { text += $"\tstatic auto defaultObj = StaticClass()->CreateDefaultObject();{Utils.NLine}"; text += $"\tdefaultObj->ProcessEvent(fn, ¶ms);{Utils.NLine}{Utils.NLine}"; } else { text += $"\tUObject::ProcessEvent(fn, ¶ms);{Utils.NLine}{Utils.NLine}"; } text += $"\tfn->FunctionFlags = flags;{Utils.NLine}"; //Out Parameters var rOut = m.Parameters.Where(item => item.ParamType == Package.Method.Parameter.Type.Out).ToList(); if (rOut.Any()) { text += $"{Utils.NLine}"; foreach (var param in rOut) { text += $"\tif ({param.Name} != nullptr){Utils.NLine}" + $"\t\t*{param.Name} = params.{param.Name};{Utils.NLine}"; } } text += $"{Utils.NLine}"; //Return Value var ret = m.Parameters.Where(item => item.ParamType == Package.Method.Parameter.Type.Return).ToList(); if (ret.Any()) { text += $"{Utils.NLine}\treturn params.{ret.First().Name};{Utils.NLine}"; } text += $"}}{Utils.NLine}"; return(text); }