private void AppendSetter(CSharpTextBuilder builder, string propertyName, UField setter, List <string> namespaces) { builder.AppendLine("set"); builder.OpenBrace(); UFunction function = setter as UFunction; if (function != null) { AppendFunctionBody(builder, function, false, true, false, namespaces); } else { if (Settings.CheckObjectDestroyed) { builder.AppendLine(Names.UObject_CheckDestroyed + "();"); } if (Settings.GenerateIsValidSafeguards) { builder.AppendLine("if (!" + propertyName + Settings.VarNames.IsValid + ")"); builder.OpenBrace(); builder.AppendLine(Names.NativeReflection_LogInvalidPropertyAccessed + "(\"" + setter.GetPathName() + "\");"); builder.AppendLine("return;"); builder.CloseBrace(); } AppendPropertyToNative(builder, setter as UProperty, propertyName, Names.UObject_Address, "this", "value", false, namespaces); } builder.CloseBrace(); }
private void AppendDocComment(CSharpTextBuilder builder, UField field, bool isBlueprintType) { if (field == null || Settings.SkipDocumentation || string.IsNullOrEmpty(field.GetMetaData("Tooltip"))) { return; } string tooltip = null; if (isBlueprintType) { // Blueprint metadata seems to have an internal representation which doesn't update the main metadata until reload. // TODO: Find the correct metadata for functions/variables for blueprint. // - Functions: Get function graph, call FBlueprintEditorUtils::GetGraphFunctionMetaData(graph), Metadata->ToolTip // - Variables: Call FBlueprintEditorUtils::GetBlueprintVariableMetaData? tooltip = field.GetToolTip(); } else { tooltip = field.GetToolTip(); } if (!string.IsNullOrEmpty(tooltip)) { AppendDocComment(builder, tooltip, true); } }
public void Reset() { unrealStruct = targetStruct; field = GetField(unrealStruct); interfaceIndex = -1; first = true; }
public string ResolveNameConflict(UField field, string name) { UFunction function = field as UFunction; if (function != null) { // Functions are a special case and must use the base-most function for name resolving. // See above for more info on this. UFunction originalFunction; UClass originalOwner = codeGenerator.GetOriginalFunctionOwner(function, out originalFunction); if (originalOwner != Class) { StructInfo originalOwnerStructInfo = codeGenerator.GetStructInfo(originalOwner); return(originalOwnerStructInfo.ResolveNameConflict(originalFunction, name)); } } string resolvedName; if (conflictInfo.ResolvedName.TryGetValue(field, out resolvedName)) { return(resolvedName); } return(name); }
private void AppendAttribute(CSharpTextBuilder builder, UField field, UnrealModuleInfo module, StructInfo structInfo) { AppendAttribute(builder, field, module); //if (field.IsA<UScriptStruct>() && structInfo.StructAsClass) //{ // builder.AppendLine("[" + Names.UStructAsClassAttributeShort + "]"); //} }
/// <summary> /// Helper function to print metadata for a given UField /// </summary> private void PrintMetaData(UField field) { Dictionary <FName, string> metaDataValues = UMetaData.GetMapForObject(field); foreach (KeyValuePair <FName, string> metaDataValue in metaDataValues) { FMessage.Log(string.Format("{0}={1}", metaDataValue.Key.PlainName, metaDataValue.Value)); } }
public void AddField(UField field, CollapsedMember collapsedMember) { Fields[field] = collapsedMember; if (collapsedMember != null) { List <UField> fields; if (!FieldsByCollapsedMember.TryGetValue(collapsedMember, out fields)) { FieldsByCollapsedMember.Add(collapsedMember, fields = new List <UField>()); } fields.Add(field); } }
private void UpdateAvailableTypesProp(UProperty property) { UField field1 = null; UField field2 = null; GetStructEnumOrFuncFromProp(property, out field1, out field2); if (field1 != null) { UpdateAvailableTypes(field1); } if (field2 != null) { UpdateAvailableTypes(field2); } }
public static void SetMetaData <TEnum, T>(this UField field, TEnum key, T value) where TEnum : struct { string valueStr = null; UClass unrealClass = value as UClass; if (unrealClass != null) { valueStr = unrealClass.GetPathName(); } else { valueStr = value.ToString(); } field.SetMetaData(UMeta.GetKey(key), valueStr); }
public TFieldIterator(UStruct unrealStruct, EFieldIteratorType iteratorType, bool includeSuper = true, bool includeDeprecated = true, bool includeInterface = false) { typeClass = UClass.GetClass <T>(); targetStruct = unrealStruct; this.iteratorType = iteratorType; this.unrealStruct = unrealStruct; field = GetField(unrealStruct); interfaceIndex = -1; this.includeSuper = includeSuper; this.includeDeprecated = includeDeprecated; this.includeInterface = includeInterface && unrealStruct as UClass != null; first = true; }
private string ResolveNameConflict(UField field, string name) { UStruct unrealStruct = field.GetOwnerStruct(); if ((field as UFunction) != null) { // GetOwnerStruct will return itself if it is a UStruct (which is true for UFunction) unrealStruct = field.GetOwnerClass(); } if (unrealStruct != null) { StructInfo structInfo = GetStructInfo(unrealStruct); if (structInfo != null) { return(structInfo.ResolveNameConflict(field, name)); } } return(name); }
private void NameConflictResolved(UField field, string resolvedName) { int conflictIndex = -1; string baseResolvedName = null; while (conflictInfo.MembersByName.ContainsKey(resolvedName) || conflictInfo.BaseMembersByName.ContainsKey(resolvedName)) { // The resolved name has as a conflict (double conflict) - rename until no more conflicts if (conflictIndex == -1) { conflictIndex = 1; baseResolvedName = resolvedName; } resolvedName = baseResolvedName + "_" + conflictIndex; conflictIndex++; } conflictInfo.AddResolvedMember(field, resolvedName); conflictInfo.ResolvedName[field] = resolvedName; }
private void AddMember(UField field, string name, bool isResolvedName) { CollapsedMember collapsedMember = null; UProperty property = field as UProperty; if (property != null) { structInfo.collapsedMembersByProperty.TryGetValue(property, out collapsedMember); } UFunction function = field as UFunction; if (function != null) { structInfo.collapsedMembersByFunction.TryGetValue(function, out collapsedMember); } if (collapsedMember != null) { if (isResolvedName) { collapsedMember.ResolvedName = name; } else { name = collapsedMember.Name; } } NameConflictFieldInfo fieldInfo; if (!MembersByName.TryGetValue(name, out fieldInfo)) { MembersByName.Add(name, fieldInfo = new NameConflictFieldInfo(name)); } fieldInfo.AddField(field, collapsedMember); }
private string GetModuleName(UField field, out UnrealModuleType moduleType, out UnrealModuleType moduleAssetType) { moduleType = UnrealModuleType.Unknown; moduleAssetType = UnrealModuleType.Unknown; UPackage package = field.GetOutermost(); if (package != null) { CachedNamespace cachedNamespace; if (!namespaceCache.TryGetValue(package, out cachedNamespace)) { GetModuleNamespace(field); namespaceCache.TryGetValue(package, out cachedNamespace); } if (cachedNamespace != null) { moduleType = cachedNamespace.ModuleType; moduleAssetType = cachedNamespace.ModuleAssetType; return(cachedNamespace.ModuleName); } } return(null); }
private string GetModuleNamespace(UField field, out UnrealModuleType moduleAssetType, bool allowFoldersAsNamespace = true) { moduleAssetType = UnrealModuleType.Unknown; UPackage package = field.GetOutermost(); if (package != null) { CachedNamespace cachedNamespace; if (namespaceCache.TryGetValue(package, out cachedNamespace)) { moduleAssetType = cachedNamespace.ModuleAssetType; return(cachedNamespace.Namespace); } UnrealModuleType moduleType = UnrealModuleType.Unknown; moduleAssetType = UnrealModuleType.Unknown; string packageFilename = package.FileName.ToString(); if (string.IsNullOrEmpty(packageFilename.ToString()) || packageFilename == FName.None.ToString()) { packageFilename = field.GetPathName(); } string moduleName = FPackageName.GetShortName(package.GetName()); if (packageFilename.StartsWith("/Script")) { if (!modulesByName.TryGetValue(new FName(moduleName), out moduleType)) { moduleType = UnrealModuleType.Unknown; FMessage.Log(ELogVerbosity.Error, string.Format("Failed to find module for module '{0}'", moduleName)); } } else if (packageFilename.StartsWith("/Game/")) { moduleType = UnrealModuleType.Game; moduleAssetType = UnrealModuleType.Game; moduleName = FPaths.GetBaseFilename(FPaths.ProjectFilePath);// {Module} same as {Game} } else if (packageFilename.StartsWith("/Engine/")) { moduleType = UnrealModuleType.Game; moduleAssetType = UnrealModuleType.Engine; moduleName = Settings.Namespaces.Default; } else { string rootName = null; if (packageFilename.Length > 1 && packageFilename[0] == '/') { int slashIndex = packageFilename.IndexOf('/', 1); if (slashIndex >= 0) { rootName = packageFilename.Substring(1, slashIndex - 1); moduleName = rootName;// Update ModuleName for {Module} if (!modulesByName.TryGetValue(new FName(rootName), out moduleAssetType)) { moduleAssetType = UnrealModuleType.Unknown; } } } if (moduleAssetType == UnrealModuleType.Unknown) { FMessage.Log(ELogVerbosity.Error, string.Format("Unknown module asset type root:'{0}' path:'{1}' name:'{2}' path2:'{3}'", rootName, packageFilename, field.GetName(), field.GetPathName())); } moduleType = UnrealModuleType.Game; } if (moduleType != UnrealModuleType.Unknown) { string namespaceName = GetModuleNamespace(moduleType, moduleName, moduleAssetType, allowFoldersAsNamespace, packageFilename); namespaceCache[package] = new CachedNamespace(namespaceName, moduleName, moduleType, moduleAssetType); return(namespaceName); } else { FMessage.Log(ELogVerbosity.Error, string.Format("Unknown module type {0} {1}", packageFilename, moduleName)); } } return(null); }
private void UpdateAvailableTypes(UField field) { if (field == null) { return; } System.Diagnostics.Debug.Assert(!field.IsA <UProperty>(), "Shouldn't have UProperty here"); if (field.IsA <UStruct>() || field.IsA <UEnum>()) { bool isNewElement = availableTypes.Add(field); if (!isNewElement) { return; } } if (Settings.ExportMode != CodeGeneratorSettings.CodeExportMode.Referenced) { return; } // Get all of the references from this struct UStruct unrealStruct = field as UStruct; if (unrealStruct != null) { bool isBlueprintType = unrealStruct.IsA <UUserDefinedStruct>() || unrealStruct.IsA <UBlueprintGeneratedClass>(); // Get struct references from parent class chain UStruct parentStruct = unrealStruct.GetSuperStruct(); while (parentStruct != null) { UpdateAvailableTypes(parentStruct); parentStruct = parentStruct.GetSuperStruct(); } // Get references from interfaces UClass unrealClass = field as UClass; if (unrealClass != null) { foreach (FImplementedInterface implementedInterface in unrealClass.Interfaces) { UpdateAvailableTypes(implementedInterface.InterfaceClass); } } // Get struct references from members foreach (UProperty property in unrealStruct.GetFields <UProperty>(false)) { if (CanExportProperty(property, unrealStruct, isBlueprintType)) { UpdateAvailableTypesProp(property); } } // Get struct references from function params (and return type) foreach (UFunction unrealFunction in unrealStruct.GetFields <UFunction>(false)) { if (CanExportFunction(unrealFunction, isBlueprintType)) { foreach (UProperty parameter in unrealFunction.GetFields <UProperty>()) { UpdateAvailableTypesProp(parameter); } } } } // This should be for global functions only (delegates) UFunction function = field as UFunction; if (function != null) { if (CanExportFunction(function, false)) { UStruct functionOwner = function.GetOuter() as UStruct; if (functionOwner != null) { UpdateAvailableTypes(functionOwner); } foreach (UProperty parameter in function.GetFields <UProperty>()) { UpdateAvailableTypesProp(parameter); } } } }
private string GetModuleNamespace(UField field) { UnrealModuleType moduleAssetType; return(GetModuleNamespace(field, out moduleAssetType)); }
public bool MoveNext() { if (first) { first = false; } else { field = field.Next; } UField currentField = field; UStruct currentStruct = unrealStruct; while (currentStruct != null) { while (currentField != null) { UClass fieldClass = currentField.GetClass(); if (fieldClass.HasAllCastFlags(typeClass.ClassCastFlags) && (includeDeprecated || !fieldClass.HasAllCastFlags(EClassCastFlags.UProperty) || !(currentField as UProperty).HasAllPropertyFlags(EPropertyFlags.Deprecated))) { unrealStruct = currentStruct; field = currentField; return(true); } currentField = currentField.Next; } if (includeInterface) { // We shouldn't be able to get here for non-classes UClass currentClass = currentStruct as UClass; ++interfaceIndex; FImplementedInterface[] interfaces = currentClass.Interfaces; if (interfaces != null && interfaceIndex < interfaces.Length) { UClass interfaceClass = interfaces[interfaceIndex].InterfaceClass; currentField = GetField(interfaceClass); continue; } } if (includeSuper) { currentStruct = currentStruct.GetInheritanceSuper(); if (currentStruct != null) { currentField = GetField(currentStruct); interfaceIndex = -1; continue; } } break; } unrealStruct = currentStruct; field = currentField; return(field != null); }
private bool IsAvailableType(UField field) { return(Settings.ExportMode == CodeGeneratorSettings.CodeExportMode.All || availableTypes.Contains(field)); }
private void AppendAttribute(CSharpTextBuilder builder, UField field, UnrealModuleInfo module, bool isCollapsedMember) { UnrealModuleType moduleType; UnrealModuleType moduleAssetType; string moduleName = GetModuleName(field, out moduleType, out moduleAssetType); if (string.IsNullOrEmpty(moduleName)) { moduleName = module.Name; } List <string> attributes = new List <string>(); // TODO: Combine all of this into EPropertyType (add some TypeCode into UField?) bool isInterface = false; UEnum unrealEnum = field as UEnum; UClass unrealClass = field as UClass; UScriptStruct unrealStruct = field as UScriptStruct; UFunction unrealFunction = field as UFunction; if (unrealFunction != null) { if (unrealFunction.HasAnyFunctionFlags(EFunctionFlags.Delegate)) { attributes.Add("UDelegate"); } else { string additionalFunctionInfo = string.Empty; // TODO: Only get the script name for virtual functions / interface functions as we currently only need // this for finding the base function for hooking things up to the native base types. string scriptFunctionName; if (unrealFunction.GetScriptName(out scriptFunctionName)) { additionalFunctionInfo += ", OriginalName=\"" + unrealFunction.GetName() + "\""; } if (isCollapsedMember) { // The Flags here might not contain too useful information if there is both a get/set function. // Maybe include a second flags var? attributes.Add("UFunctionAsProp(Flags=0x" + ((uint)unrealFunction.FunctionFlags).ToString("X8") + additionalFunctionInfo + ")"); } else { attributes.Add("UFunction(Flags=0x" + ((uint)unrealFunction.FunctionFlags).ToString("X8") + additionalFunctionInfo + ")"); } } } UProperty unrealProperty = field as UProperty; if (unrealProperty != null) { attributes.Add("UProperty(Flags=(PropFlags)0x" + ((ulong)unrealProperty.PropertyFlags).ToString("X16") + ")"); } if (unrealStruct != null) { attributes.Add("UStruct(Flags=0x" + ((uint)unrealStruct.StructFlags).ToString("X8") + ")"); } else if (unrealClass != null) { // Abstract isn't really required but might help with code browsing to know what is abstract // and what isn't. Therefore put it at the start of the attributes list. if (unrealClass.HasAnyClassFlags(EClassFlags.Abstract)) { attributes.Add("Abstract"); } isInterface = unrealClass.IsChildOf <UInterface>(); if (isInterface) { attributes.Add("UInterface(Flags=0x" + ((uint)unrealClass.ClassFlags).ToString("X8") + ")"); } else { attributes.Add("UClass(Flags=(ClassFlags)0x" + ((uint)unrealClass.ClassFlags).ToString("X8") + ")"); } } if (unrealEnum != null) { attributes.Add("UEnum"); } if (unrealEnum != null || unrealClass != null || unrealStruct != null) { bool blueprintType = false; bool blueprintable = false; if (unrealEnum != null) { blueprintType = field.GetBoolMetaData(MDClass.BlueprintType); } else { GetBlueprintability(field as UStruct, out blueprintType, out blueprintable); } if (blueprintType) { attributes.Add(UMeta.GetKey(MDClass.BlueprintType)); } if (unrealClass != null && blueprintable) { attributes.Add(UMeta.GetKey(MDClass.Blueprintable)); } attributes.Add("UMetaPath(\"" + field.GetPathName() + "\"" + (isInterface ? ", InterfaceImpl=typeof(" + GetTypeName(unrealClass, null) + "Impl" + ")" : string.Empty) + ")"); } else { attributes.Add("UMetaPath(\"" + field.GetPathName() + "\")"); } if (attributes.Count > 0) { builder.AppendLine("[" + string.Join(", ", attributes) + "]"); } }
private void ProcessCommon(EExprToken opcode) { switch (opcode) { case EExprToken.EX_PrimitiveCast: { // A type conversion. byte conversionType = ReadByte(); output.AppendLine(FmtOpcodeIndent(opcode) + "PrimitiveCast of type " + conversionType); AddIndent(); output.AppendLine(indents + " Argument:"); ProcessCastByte(conversionType); //@TODO: //Ar.Logf(TEXT("%s Expression:"), *Indents); //SerializeExpr( ScriptIndex ); break; } case EExprToken.EX_SetSet: { output.AppendLine(FmtOpcodeIndent(opcode) + "set set"); SerializeExpr(); ReadInt32(); while (SerializeExpr() != EExprToken.EX_EndSet) { // Set contents } break; } case EExprToken.EX_EndSet: { output.AppendLine(FmtOpcodeIndent(opcode) + "EX_EndSet"); break; } case EExprToken.EX_SetConst: { UProperty innerProp = ReadPointer <UProperty>(); int num = ReadInt32(); output.AppendLine(FmtOpcodeIndent(opcode) + "set set const - elements number: " + num + ", inner property: " + UObject.GetNameSafe(innerProp)); while (SerializeExpr() != EExprToken.EX_EndSetConst) { // Set contents } break; } case EExprToken.EX_EndSetConst: { output.AppendLine(FmtOpcodeIndent(opcode) + "EX_EndSetConst"); break; } case EExprToken.EX_SetMap: { output.AppendLine(FmtOpcodeIndent(opcode) + "set map"); SerializeExpr(); ReadInt32(); while (SerializeExpr() != EExprToken.EX_EndMap) { // Map contents } break; } case EExprToken.EX_EndMap: { output.AppendLine(FmtOpcodeIndent(opcode) + "EX_EndMap"); break; } case EExprToken.EX_MapConst: { UProperty keyProp = ReadPointer <UProperty>(); UProperty valProp = ReadPointer <UProperty>(); int num = ReadInt32(); output.AppendLine(FmtOpcodeIndent(opcode) + "set map const - elements number: " + num + ", key property: " + UObject.GetNameSafe(keyProp) + ", val property: " + UObject.GetNameSafe(valProp)); while (SerializeExpr() != EExprToken.EX_EndMapConst) { // Map contents } break; } case EExprToken.EX_ObjToInterfaceCast: { // A conversion from an object variable to a native interface variable. // We use a different bytecode to avoid the branching each time we process a cast token // the interface class to convert to UClass interfaceClass = ReadPointer <UClass>(); output.AppendLine(FmtOpcodeIndent(opcode) + "ObjToInterfaceCast to " + interfaceClass.GetName()); SerializeExpr(); break; } case EExprToken.EX_CrossInterfaceCast: { // A conversion from one interface variable to a different interface variable. // We use a different bytecode to avoid the branching each time we process a cast token // the interface class to convert to UClass interfaceClass = ReadPointer <UClass>(); output.AppendLine(FmtOpcodeIndent(opcode) + "InterfaceToInterfaceCast to " + interfaceClass.GetName()); SerializeExpr(); break; } case EExprToken.EX_InterfaceToObjCast: { // A conversion from an interface variable to a object variable. // We use a different bytecode to avoid the branching each time we process a cast token // the interface class to convert to UClass objectClass = ReadPointer <UClass>(); output.AppendLine(FmtOpcodeIndent(opcode) + "InterfaceToObjCast to " + objectClass.GetName()); SerializeExpr(); break; } case EExprToken.EX_Let: { output.AppendLine(FmtOpcodeIndent(opcode) + "Let (Variable = Expression)"); AddIndent(); ReadPointer <UProperty>(); // Variable expr. output.AppendLine(indents + " Variable:"); SerializeExpr(); // Assignment expr. output.AppendLine(indents + " Expression:"); SerializeExpr(); DropIndent(); break; } case EExprToken.EX_LetObj: case EExprToken.EX_LetWeakObjPtr: { if (opcode == EExprToken.EX_LetObj) { output.AppendLine(FmtOpcodeIndent(opcode) + "Let Obj (Variable = Expression)"); } else { output.AppendLine(FmtOpcodeIndent(opcode) + "Let WeakObjPtr (Variable = Expression)"); } AddIndent(); // Variable expr. output.AppendLine(indents + " Variable:"); SerializeExpr(); // Assignment expr. output.AppendLine(indents + " Expression:"); SerializeExpr(); DropIndent(); break; } case EExprToken.EX_LetBool: { output.AppendLine(FmtOpcodeIndent(opcode) + "LetBool (Variable = Expression)"); AddIndent(); // Variable expr. output.AppendLine(indents + " Variable:"); SerializeExpr(); // Assignment expr. output.AppendLine(indents + " Expression:"); SerializeExpr(); DropIndent(); break; } case EExprToken.EX_LetValueOnPersistentFrame: { output.AppendLine(FmtOpcodeIndent(opcode) + "LetValueOnPersistentFrame"); AddIndent(); UProperty prop = ReadPointer <UProperty>(); output.AppendLine(indents + " Destination variable: " + UObject.GetNameSafe(prop) + ", offset: " + (prop != null ? prop.GetOffset_ForDebug() : 0)); output.AppendLine(indents + " Expression:"); SerializeExpr(); DropIndent(); break; } case EExprToken.EX_StructMemberContext: { output.AppendLine(FmtOpcodeIndent(opcode) + "Struct member context"); AddIndent(); UProperty prop = ReadPointer <UProperty>(); // although that isn't a UFunction, we are not going to indirect the props of a struct, so this should be fine output.AppendLine(indents + " Expression within struct " + prop.GetName() + ", offset " + prop.GetOffset_ForDebug()); output.AppendLine(indents + " Expression to struct:"); SerializeExpr(); DropIndent(); break; } case EExprToken.EX_LetDelegate: { output.AppendLine(FmtOpcodeIndent(opcode) + "LetDelegate (Variable = Expression)"); AddIndent(); // Variable expr. output.AppendLine(indents + " Variable:"); SerializeExpr(); // Assignment expr. output.AppendLine(indents + " Expression:"); SerializeExpr(); DropIndent(); break; } case EExprToken.EX_LetMulticastDelegate: { output.AppendLine(FmtOpcodeIndent(opcode) + "LetMulticastDelegate (Variable = Expression)"); AddIndent(); // Variable expr. output.AppendLine(indents + " Variable:"); SerializeExpr(); // Assignment expr. output.AppendLine(indents + " Expression:"); SerializeExpr(); DropIndent(); break; } case EExprToken.EX_ComputedJump: { output.AppendLine(FmtOpcodeIndent(opcode) + "Computed Jump, offset specified by expression:"); AddIndent(); SerializeExpr(); DropIndent(); break; } case EExprToken.EX_Jump: { uint skipCount = ReadSkipCount(); output.AppendLine(FmtOpcodeIndent(opcode) + "Jump to offset " + FmtSkipCount(skipCount)); break; } case EExprToken.EX_LocalVariable: { UProperty property = ReadPointer <UProperty>(); output.AppendLine(FmtOpcodeIndent(opcode) + "Local variable named " + FmtObjNameOrNull(property)); break; } case EExprToken.EX_DefaultVariable: { UProperty property = ReadPointer <UProperty>(); output.AppendLine(FmtOpcodeIndent(opcode) + "Default variable named " + FmtObjNameOrNull(property)); break; } case EExprToken.EX_InstanceVariable: { UProperty property = ReadPointer <UProperty>(); output.AppendLine(FmtOpcodeIndent(opcode) + "Instance variable named " + FmtObjNameOrNull(property)); break; } case EExprToken.EX_LocalOutVariable: { UProperty property = ReadPointer <UProperty>(); output.AppendLine(FmtOpcodeIndent(opcode) + "Local out variable named " + FmtObjNameOrNull(property)); break; } case EExprToken.EX_InterfaceContext: { output.AppendLine(FmtOpcodeIndent(opcode) + "EX_InterfaceContext:"); SerializeExpr(); break; } case EExprToken.EX_DeprecatedOp4A: { output.AppendLine(FmtOpcodeIndent(opcode) + "This opcode has been removed and does nothing."); break; } case EExprToken.EX_Nothing: case EExprToken.EX_EndOfScript: case EExprToken.EX_EndFunctionParms: case EExprToken.EX_EndStructConst: case EExprToken.EX_EndArray: case EExprToken.EX_EndArrayConst: case EExprToken.EX_IntZero: case EExprToken.EX_IntOne: case EExprToken.EX_True: case EExprToken.EX_False: case EExprToken.EX_NoObject: case EExprToken.EX_NoInterface: case EExprToken.EX_Self: case EExprToken.EX_EndParmValue: { output.AppendLine(FmtOpcodeIndent(opcode) + opcode.ToString()); break; } case EExprToken.EX_Return: { output.AppendLine(FmtOpcodeIndent(opcode) + opcode.ToString()); SerializeExpr(); // Return expression. break; } case EExprToken.EX_CallMath: { UStruct stackNode = ReadPointer <UStruct>(); output.AppendLine(FmtOpcodeIndent(opcode) + "Call Math (stack node " + UObject.GetNameSafe(stackNode != null ? stackNode.GetOuter() : null) + "::" + UObject.GetNameSafe(stackNode) + ")"); while (SerializeExpr() != EExprToken.EX_EndFunctionParms) { // Params } break; } case EExprToken.EX_FinalFunction: { UStruct stackNode = ReadPointer <UStruct>(); output.AppendLine(FmtOpcodeIndent(opcode) + "Final Function (stack node " + FmtObjOuterNameOrNull(stackNode) + "::" + FmtObjNameOrNull(stackNode) + ")"); while (SerializeExpr() != EExprToken.EX_EndFunctionParms) { // Params } break; } case EExprToken.EX_CallMulticastDelegate: { UStruct stackNode = ReadPointer <UStruct>(); output.AppendLine(FmtOpcodeIndent(opcode) + "CallMulticastDelegate (signature " + FmtObjOuterNameOrNull(stackNode) + "::" + FmtObjNameOrNull(stackNode) + ") delegate:"); SerializeExpr(); output.AppendLine(FmtOpcodeIndent(opcode) + "Params:"); while (SerializeExpr() != EExprToken.EX_EndFunctionParms) { // Params } break; } case EExprToken.EX_VirtualFunction: { string functionName = ReadName(); output.AppendLine(FmtOpcodeIndent(opcode) + "Virtual Function named " + functionName); while (SerializeExpr() != EExprToken.EX_EndFunctionParms) { } break; } case EExprToken.EX_ClassContext: case EExprToken.EX_Context: case EExprToken.EX_Context_FailSilent: { output.AppendLine(FmtOpcodeIndent(opcode) + (opcode == EExprToken.EX_ClassContext ? "Class Context" : "Context")); AddIndent(); // Object expression. output.AppendLine(indents + " ObjectExpression:"); SerializeExpr(); if (opcode == EExprToken.EX_Context_FailSilent) { output.AppendLine(indents + " Can fail silently on access none "); } // Code offset for NULL expressions. uint skipCount = ReadSkipCount(); output.AppendLine(indents + " Skip Bytes: " + FmtSkipCount(skipCount)); // Property corresponding to the r-value data, in case the l-value needs to be mem-zero'd UField field = ReadPointer <UField>(); output.AppendLine(indents + " R-Value Property: " + FmtObjNameOrNull(field)); // Context expression. output.AppendLine(indents + " ContextExpression:"); SerializeExpr(); DropIndent(); break; } case EExprToken.EX_IntConst: { int constValue = ReadInt32(); output.AppendLine(FmtOpcodeIndent(opcode) + "literal int32 " + constValue); break; } case EExprToken.EX_SkipOffsetConst: { uint constValue = ReadSkipCount(); output.AppendLine(FmtOpcodeIndent(opcode) + "literal CodeSkipSizeType " + FmtSkipCount(constValue)); break; } case EExprToken.EX_FloatConst: { float constValue = ReadFloat(); output.AppendLine(FmtOpcodeIndent(opcode) + "literal float " + constValue); break; } case EExprToken.EX_StringConst: { string constValue = ReadString8(); output.AppendLine(FmtOpcodeIndent(opcode) + "literal ansi string \"" + constValue + "\""); break; } case EExprToken.EX_UnicodeStringConst: { string constValue = ReadString16(); output.AppendLine(FmtOpcodeIndent(opcode) + "literal unicode string \"" + constValue + "\""); break; } case EExprToken.EX_TextConst: { // What kind of text are we dealing with? EBlueprintTextLiteralType textLiteralType = (EBlueprintTextLiteralType)script[scriptIndex++]; switch (textLiteralType) { case EBlueprintTextLiteralType.Empty: { output.AppendLine(FmtOpcodeIndent(opcode) + "literal text - empty"); break; } case EBlueprintTextLiteralType.LocalizedText: { string sourceString = ReadString(); string keyString = ReadString(); string namespaceString = ReadString(); output.AppendLine(FmtOpcodeIndent(opcode) + "literal text - localized text { namespace: \"" + namespaceString + "\", key: \"" + keyString + "\", source: \"" + sourceString + "\" }"); break; } case EBlueprintTextLiteralType.InvariantText: { string sourceString = ReadString(); output.AppendLine(FmtOpcodeIndent(opcode) + "literal text - invariant text: \"" + sourceString + "\""); break; } case EBlueprintTextLiteralType.LiteralString: { string sourceString = ReadString(); output.AppendLine(FmtOpcodeIndent(opcode) + "literal text - literal string: \"" + sourceString + "\""); break; } case EBlueprintTextLiteralType.StringTableEntry: { ReadPointer <UObject>(); // String Table asset (if any) string tableIdString = ReadString(); string keyString = ReadString(); output.AppendLine(FmtOpcodeIndent(opcode) + "literal text - string table entry { tableid: \"" + tableIdString + "\", key: \"" + keyString + "\" }"); break; } default: throw new Exception("Unknown EBlueprintTextLiteralType! Please update ProcessCommon() to handle this type of text."); } break; } case EExprToken.EX_ObjectConst: { UObject pointer = ReadPointer <UObject>(); output.AppendLine(FmtOpcodeIndent(opcode) + "EX_ObjectConst (" + FmtPtr(pointer) + ":" + pointer.GetFullName()); break; } case EExprToken.EX_SoftObjectConst: { output.AppendLine(FmtOpcodeIndent(opcode) + "EX_SoftObjectConst"); SerializeExpr(); break; } case EExprToken.EX_NameConst: { string constValue = ReadName(); output.AppendLine(FmtOpcodeIndent(opcode) + "literal name " + constValue); break; } case EExprToken.EX_RotationConst: { float pitch = ReadFloat(); float yaw = ReadFloat(); float roll = ReadFloat(); output.AppendLine(FmtOpcodeIndent(opcode) + "literal rotation (" + pitch + "," + yaw + "," + roll + ")"); break; } case EExprToken.EX_VectorConst: { float x = ReadFloat(); float y = ReadFloat(); float z = ReadFloat(); output.AppendLine(FmtOpcodeIndent(opcode) + "literal vector (" + x + "," + y + "," + z + ")"); break; } case EExprToken.EX_TransformConst: { float rotX = ReadFloat(); float rotY = ReadFloat(); float rotZ = ReadFloat(); float rotW = ReadFloat(); float transX = ReadFloat(); float transY = ReadFloat(); float transZ = ReadFloat(); float scaleX = ReadFloat(); float scaleY = ReadFloat(); float scaleZ = ReadFloat(); output.AppendLine(FmtOpcodeIndent(opcode) + "literal transform " + "R(" + rotX + "," + rotY + "," + rotZ + "," + rotW + "," + ") " + "T(" + transX + "," + transY + "," + transZ + ") " + "T(" + scaleX + "," + scaleY + "," + scaleZ + ")"); break; } case EExprToken.EX_StructConst: { UScriptStruct unrealStruct = ReadPointer <UScriptStruct>(); int serializedSize = ReadInt32(); output.AppendLine(FmtOpcodeIndent(opcode) + "literal struct " + unrealStruct.GetName() + " (serialized size: " + serializedSize + ")"); break; } case EExprToken.EX_SetArray: { output.AppendLine(FmtOpcodeIndent(opcode) + "set array"); SerializeExpr(); while (SerializeExpr() != EExprToken.EX_EndArray) { // Array contents } break; } case EExprToken.EX_ArrayConst: { UProperty innerProp = ReadPointer <UProperty>(); int num = ReadInt32(); output.AppendLine(FmtOpcodeIndent(opcode) + "set array const - elements number: " + num + ", inner property: " + UObject.GetNameSafe(innerProp)); break; } case EExprToken.EX_ByteConst: { byte constValue = ReadByte(); output.AppendLine(FmtOpcodeIndent(opcode) + "literal byte " + constValue); break; } case EExprToken.EX_IntConstByte: { int constValue = ReadByte(); output.AppendLine(FmtOpcodeIndent(opcode) + "literal int " + constValue); break; } case EExprToken.EX_MetaCast: { UClass unrealClass = ReadPointer <UClass>(); output.AppendLine(FmtOpcodeIndent(opcode) + "MetaCast to " + unrealClass.GetName() + " of expr:"); SerializeExpr(); break; } case EExprToken.EX_DynamicCast: { UClass unrealClass = ReadPointer <UClass>(); output.AppendLine(FmtOpcodeIndent(opcode) + "DynamicCast to " + unrealClass.GetName() + " of expr:"); SerializeExpr(); break; } case EExprToken.EX_JumpIfNot: { // Code offset. uint skipCount = ReadSkipCount(); output.AppendLine(FmtOpcodeIndent(opcode) + "Jump to offset " + FmtSkipCount(skipCount) + " if not expr:"); // Boolean expr. SerializeExpr(); break; } case EExprToken.EX_Assert: { ushort lineNumber = ReadUInt16(); byte inDebugMode = ReadByte(); output.AppendLine(FmtOpcodeIndent(opcode) + "assert at line " + lineNumber + ", in debug mode = " + inDebugMode + " with expr:"); SerializeExpr(); // Assert expr. break; } case EExprToken.EX_Skip: { uint w = ReadSkipCount(); output.AppendLine(FmtOpcodeIndent(opcode) + "possibly skip " + FmtSkipCount(w) + " bytes of expr:"); // Expression to possibly skip. SerializeExpr(); break; } case EExprToken.EX_InstanceDelegate: { // the name of the function assigned to the delegate. string funcName = ReadName(); output.AppendLine(FmtOpcodeIndent(opcode) + "instance delegate function named " + funcName); break; } case EExprToken.EX_AddMulticastDelegate: { output.AppendLine(FmtOpcodeIndent(opcode) + "Add MC delegate"); SerializeExpr(); SerializeExpr(); break; } case EExprToken.EX_RemoveMulticastDelegate: { output.AppendLine(FmtOpcodeIndent(opcode) + "Remove MC delegate"); SerializeExpr(); SerializeExpr(); break; } case EExprToken.EX_ClearMulticastDelegate: { output.AppendLine(FmtOpcodeIndent(opcode) + "Clear MC delegate"); SerializeExpr(); break; } case EExprToken.EX_BindDelegate: { // the name of the function assigned to the delegate. string funcName = ReadName(); output.AppendLine(FmtOpcodeIndent(opcode) + "BindDelegate '" + funcName + "'"); output.AppendLine(indents + " Delegate:"); SerializeExpr(); output.AppendLine(indents + " Object:"); SerializeExpr(); break; } case EExprToken.EX_PushExecutionFlow: { uint skipCount = ReadSkipCount(); output.AppendLine(FmtOpcodeIndent(opcode) + "FlowStack.Push(" + FmtSkipCount(skipCount) + ");"); break; } case EExprToken.EX_PopExecutionFlow: { output.AppendLine(FmtOpcodeIndent(opcode) + "if (FlowStack.Num()) { jump to statement at FlowStack.Pop(); } else { ERROR!!! }"); break; } case EExprToken.EX_PopExecutionFlowIfNot: { output.AppendLine(FmtOpcodeIndent(opcode) + "if (!condition) { if (FlowStack.Num()) { jump to statement at FlowStack.Pop(); } else { ERROR!!! } }"); // Boolean expr. SerializeExpr(); break; } case EExprToken.EX_Breakpoint: { output.AppendLine(FmtOpcodeIndent(opcode) + "<<< BREAKPOINT >>>"); break; } case EExprToken.EX_WireTracepoint: { output.AppendLine(FmtOpcodeIndent(opcode) + ".. wire debug site .."); break; } case EExprToken.EX_InstrumentationEvent: { EScriptInstrumentation eventType = (EScriptInstrumentation)ReadByte(); switch (eventType) { case EScriptInstrumentation.InlineEvent: output.AppendLine(FmtOpcodeIndent(opcode) + ".. instrumented inline event .."); break; case EScriptInstrumentation.Stop: output.AppendLine(FmtOpcodeIndent(opcode) + ".. instrumented event stop .."); break; case EScriptInstrumentation.PureNodeEntry: output.AppendLine(FmtOpcodeIndent(opcode) + ".. instrumented pure node entry site .."); break; case EScriptInstrumentation.NodeDebugSite: output.AppendLine(FmtOpcodeIndent(opcode) + ".. instrumented debug site .."); break; case EScriptInstrumentation.NodeEntry: output.AppendLine(FmtOpcodeIndent(opcode) + ".. instrumented wire entry site .."); break; case EScriptInstrumentation.NodeExit: output.AppendLine(FmtOpcodeIndent(opcode) + ".. instrumented wire exit site .."); break; case EScriptInstrumentation.PushState: output.AppendLine(FmtOpcodeIndent(opcode) + ".. push execution state .."); break; case EScriptInstrumentation.RestoreState: output.AppendLine(FmtOpcodeIndent(opcode) + ".. restore execution state .."); break; case EScriptInstrumentation.ResetState: output.AppendLine(FmtOpcodeIndent(opcode) + ".. reset execution state .."); break; case EScriptInstrumentation.SuspendState: output.AppendLine(FmtOpcodeIndent(opcode) + ".. suspend execution state .."); break; case EScriptInstrumentation.PopState: output.AppendLine(FmtOpcodeIndent(opcode) + ".. pop execution state .."); break; case EScriptInstrumentation.TunnelEndOfThread: output.AppendLine(FmtOpcodeIndent(opcode) + ".. tunnel end of thread .."); break; } break; } case EExprToken.EX_Tracepoint: { output.AppendLine(FmtOpcodeIndent(opcode) + ".. debug site .."); break; } case EExprToken.EX_SwitchValue: { ushort numCases = ReadUInt16(); uint afterSkip = ReadSkipCount(); output.AppendLine(FmtOpcodeIndent(opcode) + "Switch Value " + numCases + " cases, end in " + FmtSkipCount(afterSkip)); AddIndent(); output.AppendLine(indents + " Index:"); SerializeExpr(); for (ushort caseIndex = 0; caseIndex < numCases; ++caseIndex) { output.AppendLine(indents + " [" + caseIndex + "] Case Index (label: " + FmtScriptIndex(scriptIndex) + ")"); SerializeExpr(); // case index value term uint offsetToNextCase = ReadSkipCount(); output.AppendLine(indents + " [" + caseIndex + "] Offset to the next case: " + FmtSkipCount(offsetToNextCase)); output.AppendLine(indents + " [" + caseIndex + "] Case Result:"); SerializeExpr(); // case term } output.AppendLine(indents + " Default result (label: " + FmtScriptIndex(scriptIndex) + ")"); SerializeExpr(); output.AppendLine(indents + " (label: " + FmtScriptIndex(scriptIndex) + ")"); DropIndent(); break; } case EExprToken.EX_ArrayGetByRef: { output.AppendLine(FmtOpcodeIndent(opcode) + "Array Get-by-Ref Index"); AddIndent(); SerializeExpr(); SerializeExpr(); DropIndent(); break; } default: { string error = "Unknown bytecode 0x" + ((byte)opcode).ToString("X2") + "; ignoring it"; output.AppendLine(FmtOpcodeIndent(opcode) + "!!!" + error); FMessage.Log(ELogVerbosity.Warning, error); } break; } }
private void AppendAttribute(CSharpTextBuilder builder, UField field, UnrealModuleInfo module, bool isCollapsedMember) { UnrealModuleType moduleType; UnrealModuleType moduleAssetType; string moduleName = GetModuleName(field, out moduleType, out moduleAssetType); if (string.IsNullOrEmpty(moduleName)) { moduleName = module.Name; } List <string> attributes = new List <string>(); // TODO: Combine all of this into EPropertyType (add some TypeCode into UField?) bool isInterface = false; UEnum unrealEnum = field as UEnum; UClass unrealClass = field as UClass; UScriptStruct unrealStruct = field as UScriptStruct; UFunction unrealFunction = field as UFunction; if (unrealFunction != null) { if (unrealFunction.HasAnyFunctionFlags(EFunctionFlags.Delegate)) { attributes.Add("UDelegate"); } else { if (isCollapsedMember) { // The Flags here might not contain too useful information if there is both a get/set function. // Maybe include a second flags var? attributes.Add("UFunctionAsProp(Flags=0x" + ((uint)unrealFunction.FunctionFlags).ToString("X8") + ")"); } else { attributes.Add("UFunction(Flags=0x" + ((uint)unrealFunction.FunctionFlags).ToString("X8") + ")"); } } } UProperty unrealProperty = field as UProperty; if (unrealProperty != null) { attributes.Add("UProperty(Flags=(PropFlags)0x" + ((ulong)unrealProperty.PropertyFlags).ToString("X16") + ")"); } if (unrealStruct != null) { attributes.Add("UStruct(Flags=0x" + ((uint)unrealStruct.StructFlags).ToString("X8") + ")"); } else if (unrealClass != null) { // Abstract isn't really required but might help with code browsing to know what is abstract // and what isn't. Therefore put it at the start of the attributes list. if (unrealClass.HasAnyClassFlags(EClassFlags.Abstract)) { attributes.Add("Abstract"); } isInterface = unrealClass.IsChildOf <UInterface>(); if (isInterface) { attributes.Add("UInterface(Flags=0x" + ((uint)unrealClass.ClassFlags).ToString("X8") + ")"); } else { // Should we skip "inherit" config name? string configNameStr = string.Empty; if (unrealClass.ClassConfigName != FName.None && !unrealClass.ClassConfigName.ToString().Equals("inherit", StringComparison.InvariantCultureIgnoreCase)) { configNameStr = ", Config=\"" + unrealClass.ClassConfigName + "\""; } attributes.Add("UClass(Flags=(ClassFlags)0x" + ((uint)unrealClass.ClassFlags).ToString("X8") + configNameStr + ")"); } } if (unrealEnum != null) { attributes.Add("UEnum"); } if (unrealEnum != null || unrealClass != null || unrealStruct != null) { bool blueprintType = false; bool blueprintable = false; if (unrealEnum != null) { blueprintType = field.GetBoolMetaData(MDClass.BlueprintType); } else { GetBlueprintability(field as UStruct, out blueprintType, out blueprintable); } if (blueprintType) { attributes.Add(UMeta.GetKey(MDClass.BlueprintType)); } if (unrealClass != null && blueprintable) { attributes.Add(UMeta.GetKey(MDClass.Blueprintable)); } if (isInterface) { } attributes.Add("UMetaPath(\"" + field.GetPathName() + "\", \"" + moduleName + "\", UnrealModuleType." + GetUnrealModuleTypeString(moduleType, moduleAssetType) + (isInterface ? ", InterfaceImpl=typeof(" + GetTypeName(unrealClass, null) + "Impl" + ")" : string.Empty) + ")"); } else { attributes.Add("UMetaPath(\"" + field.GetPathName() + "\")"); } if (attributes.Count > 0) { builder.AppendLine("[" + string.Join(", ", attributes) + "]"); } }
private void AppendAttribute(CSharpTextBuilder builder, UField field, UnrealModuleInfo module) { AppendAttribute(builder, field, module, false); }
private void ResolveNameConflicts() { List <NameConflictInfo> baseConflictInfos = new List <NameConflictInfo>(); UStruct parentStruct = Struct.GetSuperStruct(); if (parentStruct != null) { StructInfo parentInfo = codeGenerator.GetStructInfo(parentStruct); if (parentInfo != null && parentInfo.conflictInfo != null) { baseConflictInfos.Add(parentInfo.conflictInfo); } } if (Class != null) { foreach (FImplementedInterface implementedInterface in Class.Interfaces) { UClass interfaceClass = implementedInterface.InterfaceClass; if (interfaceClass != null) { StructInfo interfaceInfo = codeGenerator.GetStructInfo(interfaceClass); if (interfaceInfo != null && interfaceInfo.conflictInfo != null) { baseConflictInfos.Add(interfaceInfo.conflictInfo); } } } } conflictInfo = new NameConflictInfo(this); foreach (KeyValuePair <UProperty, string> property in exportableProperties) { conflictInfo.AddMember(property.Key, codeGenerator.GetMemberName(property.Key, false, property.Value)); } foreach (UFunction function in exportableFunctions) { // Functions are a special case. They can be redefined in the hierarchy but for name resolving // we want them to have the same name throughout. Therefore only resolve the base-most function // name (even if redefined later in the hierarchy). Then when we do a name conflict lookup find that // base-most function and use that name for all of the functions in the hierarchy with that name. // - This is lookup is done in ResolveNameConflict(). if (codeGenerator.GetOriginalFunctionOwner(function) == Class) { conflictInfo.AddMember(function, codeGenerator.GetFunctionName(function, false)); } } foreach (NameConflictInfo baseConflictInfo in baseConflictInfos) { foreach (KeyValuePair <string, NameConflictFieldInfo> baseMembersByName in baseConflictInfo.MembersByName) { NameConflictFieldInfo baseMembers; if (!conflictInfo.BaseMembersByName.TryGetValue(baseMembersByName.Key, out baseMembers)) { conflictInfo.BaseMembersByName.Add(baseMembersByName.Key, baseMembers = new NameConflictFieldInfo(baseMembersByName.Key)); } foreach (KeyValuePair <UField, CollapsedMember> baseMember in baseMembersByName.Value.Fields) { baseMembers.AddField(baseMember.Key, baseMember.Value); } } foreach (KeyValuePair <string, NameConflictFieldInfo> baseBaseMembersByName in baseConflictInfo.BaseMembersByName) { NameConflictFieldInfo baseBaseMembers; if (!conflictInfo.BaseMembersByName.TryGetValue(baseBaseMembersByName.Key, out baseBaseMembers)) { conflictInfo.BaseMembersByName.Add(baseBaseMembersByName.Key, baseBaseMembers = new NameConflictFieldInfo(baseBaseMembersByName.Key)); } foreach (KeyValuePair <UField, CollapsedMember> baseBaseMember in baseBaseMembersByName.Value.Fields) { baseBaseMembers.AddField(baseBaseMember.Key, baseBaseMember.Value); } } } var tempMembersByName = new Dictionary <string, NameConflictFieldInfo>(conflictInfo.MembersByName); foreach (KeyValuePair <string, NameConflictFieldInfo> membersByName in tempMembersByName) { // What about overridden functions? where do they appear? if (membersByName.Value.HasConflict() || conflictInfo.BaseMembersByName.ContainsKey(membersByName.Key)) { foreach (KeyValuePair <UField, CollapsedMember> field in membersByName.Value.Fields) { if (field.Value == null) { string hashedName = membersByName.Key + "_" + field.Key.GetPathName().GetHashCode().ToString("X8"); NameConflictResolved(field.Key, hashedName); } } foreach (KeyValuePair <CollapsedMember, List <UField> > collapsedMember in membersByName.Value.FieldsByCollapsedMember) { UField field = null; if (collapsedMember.Key.Getter != null) { field = collapsedMember.Key.Getter; } else if (collapsedMember.Key.Setter != null) { field = collapsedMember.Key.Setter; } else if (collapsedMember.Key.BackingProperty != null) { field = collapsedMember.Key.BackingProperty; } string hashedName = membersByName.Key + "_" + field.GetPathName().GetHashCode().ToString("X8"); if (collapsedMember.Key.Getter != null) { NameConflictResolved(collapsedMember.Key.Getter, hashedName); } if (collapsedMember.Key.Setter != null) { NameConflictResolved(collapsedMember.Key.Setter, hashedName); } if (collapsedMember.Key.BackingProperty != null) { NameConflictResolved(collapsedMember.Key.BackingProperty, hashedName); } } // All fields with this name should have been renamed. Remove the old name. conflictInfo.MembersByName.Remove(membersByName.Key); } } }
public static UClass GetClassMetaData <TEnum>(this UField field, TEnum key) where TEnum : struct { return(field.GetClassMetaData(UMeta.GetKey(key))); }
private void GenerateCodeForProperty(UnrealModuleInfo module, CSharpTextBuilder builder, CSharpTextBuilder offsetsBuilder, CollapsedMember collapsedMember, bool isBlueprintType, List <string> namespaces) { StringBuilder modifiers = new StringBuilder(); if (collapsedMember.BackingProperty != null) { UProperty property = collapsedMember.BackingProperty; if (property.HasAnyPropertyFlags(EPropertyFlags.DisableEditOnInstance) && !property.GetBoolMetaData(MDProp.AllowPrivateAccess)) { modifiers.Append("private"); } else if (property.HasAnyPropertyFlags(EPropertyFlags.NativeAccessSpecifierProtected | EPropertyFlags.Protected)) { modifiers.Append("protected"); } else { modifiers.Append("public"); } } else { UFunction function = collapsedMember.Getter != null ? collapsedMember.Getter : collapsedMember.Setter; if (function.HasAnyFunctionFlags(EFunctionFlags.Protected)) { modifiers.Append("protected"); } else { modifiers.Append("public"); } } if (modifiers.Length > 0) { modifiers.Append(" "); } // Note: Potential issues with different categories/docs/attribute on BackingProperty/Getter/Setter UField field = collapsedMember.BackingProperty; if (field == null) { field = collapsedMember.Getter; if (field == null) { field = collapsedMember.Setter; } } // Use either the backing property or the getter function for the documentation UField fieldForDocumentation = collapsedMember.BackingProperty != null ? (UField)collapsedMember.BackingProperty : collapsedMember.Getter; string name = collapsedMember.ResolvedName != null ? collapsedMember.ResolvedName : collapsedMember.Name; string propertyName = GetName(field, name, Settings.MemberCasing, false, true); AppendGetterSetterOffsets(builder, offsetsBuilder, propertyName, collapsedMember.Getter == null || collapsedMember.Setter == null ? collapsedMember.BackingProperty : null, namespaces, collapsedMember.Getter, collapsedMember.Setter); AppendDocComment(builder, fieldForDocumentation, isBlueprintType); AppendAttribute(builder, field, module, true); builder.AppendLine(modifiers + GetTypeName(collapsedMember.Property, namespaces) + " " + propertyName); builder.OpenBrace(); if (collapsedMember.Getter != null) { AppendGetter(builder, propertyName, collapsedMember.Getter, namespaces); } else if (collapsedMember.BackingProperty != null) { AppendGetter(builder, propertyName, collapsedMember.BackingProperty, namespaces); } if (collapsedMember.Setter != null) { AppendSetter(builder, propertyName, collapsedMember.Setter, namespaces); } else if (collapsedMember.BackingProperty != null) { AppendSetter(builder, propertyName, collapsedMember.BackingProperty, namespaces); } builder.CloseBrace(); builder.AppendLine(); }
public void AddResolvedMember(UField field, string name) { AddMember(field, name, true); }
public void AddMember(UField field, string name) { AddMember(field, name, false); }
public bool IsCollapsed(UField field) { CollapsedMember collapsed; return(Fields.TryGetValue(field, out collapsed) && collapsed != null); }
public static float GetFloatMetaData <TEnum>(this UField field, TEnum key) where TEnum : struct { return(field.GetFloatMetaData(UMeta.GetKey(key))); }