Skip to content

Commit

Permalink
Little cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
EliotVU committed Jul 12, 2022
1 parent fc8ce45 commit 8bf4cf8
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 21 deletions.
2 changes: 1 addition & 1 deletion src/Core/Classes/UEnumDecompiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public override string Decompile()
UnrealConfig.PrintEndBracket() + ";";
}

protected override string FormatHeader()
protected virtual string FormatHeader()
{
return $"enum {Name}{DecompileMeta()}";
}
Expand Down
17 changes: 11 additions & 6 deletions src/Core/Classes/UMetaData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,13 @@ public override string ToString()

#region Serialized Members

// ReSharper disable once MemberCanBePrivate.Global
public UArray<UFieldData> MetaObjects;
private UArray<UFieldData> _Fields;

public UArray<UFieldData> Fields
{
get => _Fields;
set => _Fields = value;
}

#endregion

Expand All @@ -81,8 +86,8 @@ public override string ToString()
protected override void Deserialize()
{
base.Deserialize();
_Buffer.ReadArray(out MetaObjects);
Record(nameof(MetaObjects), MetaObjects);
_Buffer.ReadArray(out _Fields);
Record(nameof(_Fields), _Fields);
}

#endregion
Expand All @@ -103,12 +108,12 @@ public override string Decompile()
{
// UE3 Debug
BeginDeserializing();
if (MetaObjects == null)
if (_Fields == null)
{
return "";
}

return string.Join("\r\n", MetaObjects.ConvertAll(data => data + data.Decompile()));
return string.Join("\r\n", _Fields.ConvertAll(data => data + data.Decompile()));
}

#endregion
Expand Down
18 changes: 10 additions & 8 deletions src/Core/Classes/UObjectDecompiler.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace UELib.Core
using System.Diagnostics;

namespace UELib.Core
{
public partial class UObject : IUnrealDecompilable
{
Expand All @@ -12,8 +14,14 @@ public virtual string Decompile()
BeginDeserializing();
}

if (ImportTable != null)
{
return $"// Cannot decompile import {Name}";
}

Debug.Assert(Class != null);
string output = $"begin object name={Name} class={Class.Name}" +
$"\r\n";
"\r\n";
UDecompilingState.AddTabs(1);
try
{
Expand All @@ -29,12 +37,6 @@ public virtual string Decompile()
$"// Reference: {Class.Name}'{GetOuterGroup()}'";
}

protected virtual string FormatHeader()
{
// Note:Dangerous recursive call!
return Decompile();
}

protected string DecompileProperties()
{
if (Properties == null || Properties.Count == 0)
Expand Down
2 changes: 1 addition & 1 deletion src/Core/Classes/UStructDecompiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public override string Decompile()
return content + UnrealConfig.PrintEndBracket() + ";";
}

protected override string FormatHeader()
protected virtual string FormatHeader()
{
var output = $"struct {FormatFlags()}{Name}{(Super != null ? $" {FormatExtends()} {Super.Name}" : string.Empty)}";
string metaData = DecompileMeta();
Expand Down
5 changes: 0 additions & 5 deletions src/Core/Classes/UTextBufferDecompiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,5 @@ public override string Decompile()

return output;
}

protected override string FormatHeader()
{
return "// Postprocessed copy of the source code.";
}
}
}

0 comments on commit 8bf4cf8

Please sign in to comment.