Skip to content

Commit

Permalink
Formatting fixes, add .clang-format
Browse files Browse the repository at this point in the history
  • Loading branch information
localcc committed Sep 26, 2023
1 parent 6c920bb commit 0a984b0
Show file tree
Hide file tree
Showing 23 changed files with 708 additions and 540 deletions.
19 changes: 19 additions & 0 deletions UVTD/.clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Format Style Options - Created with Clang Power Tools
---
AllowAllArgumentsOnNextLine: false
AllowShortBlocksOnASingleLine: Empty
AllowShortLambdasOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: WithoutElse
AlwaysBreakTemplateDeclarations: Yes
BasedOnStyle: Microsoft
BinPackArguments: false
BinPackParameters: false
ColumnLimit: 160
ContinuationIndentWidth: 8
NamespaceIndentation: All
ObjCBreakBeforeNestedBlockParam: false
PenaltyBreakBeforeFirstCallParameter: 120
PenaltyExcessCharacter: 5
PointerAlignment: Left
Standard: Latest
...
8 changes: 4 additions & 4 deletions UVTD/include/UVTD/ExceptionHandling.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@

#include <stdexcept>

#include <Helpers/String.hpp>
#include <DynamicOutput/DynamicOutput.hpp>
#include <Helpers/String.hpp>

namespace RC
{
// Will try some code and properly propagate any exceptions
// This is a simple helper function to avoid having 15 extra lines of code everywhere
template<typename CodeToTry>
template <typename CodeToTry>
auto constexpr TRY(CodeToTry code_to_try) -> void
{
try
Expand All @@ -29,6 +29,6 @@ namespace RC
}
}
}
}
} // namespace RC

#endif //UNREALVTABLEDUMPER_EXCEPTIONHANDLING_HPP
#endif // UNREALVTABLEDUMPER_EXCEPTIONHANDLING_HPP
263 changes: 128 additions & 135 deletions UVTD/include/UVTD/Helpers.hpp

Large diffs are not rendered by default.

32 changes: 18 additions & 14 deletions UVTD/include/UVTD/MemberVarsDumper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,43 +3,47 @@

#include <unordered_map>

#include <File/File.hpp>
#include <UVTD/Symbols.hpp>
#include <UVTD/TypeContainer.hpp>
#include <File/File.hpp>

namespace RC::UVTD
{
class MemberVarsDumper
{
private:
private:
Symbols symbols;
TypeContainer type_container;

public:
public:
MemberVarsDumper() = delete;
explicit MemberVarsDumper(Symbols symbols) : symbols(std::move(symbols))
{


}

private:
auto process_class(const PDB::TPIStream& tpi_stream, const PDB::CodeView::TPI::Record* class_record, const File::StringType& class_name, const SymbolNameInfo& name_info) -> void;
private:
auto process_class(const PDB::TPIStream& tpi_stream,
const PDB::CodeView::TPI::Record* class_record,
const File::StringType& class_name,
const SymbolNameInfo& name_info) -> void;
auto process_member(const PDB::TPIStream& tpi_stream, const PDB::CodeView::TPI::FieldList* field_record, Class& class_entry) -> void;

private:
private:
auto dump_member_variable_layouts(std::unordered_map<File::StringType, SymbolNameInfo>& names) -> void;

public:
public:
auto generate_code() -> void;
auto generate_files() -> void;

public:
auto get_type_container() const -> const TypeContainer& { return type_container; }

public:
public:
auto get_type_container() const -> const TypeContainer&
{
return type_container;
}

public:
static auto output_cleanup() -> void;
};
}
} // namespace RC::UVTD

#endif
11 changes: 5 additions & 6 deletions UVTD/include/UVTD/MemberVarsWrapperGenerator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,22 @@ namespace RC::UVTD
{
class MemberVarsWrapperGenerator
{
private:
private:
TypeContainer type_container;

public:
public:
MemberVarsWrapperGenerator() = delete;

explicit MemberVarsWrapperGenerator(TypeContainer container) : type_container(std::move(container))
{

}

public:
public:
auto generate_files() -> void;

public:
public:
static auto output_cleanup() -> void;
};
}
} // namespace RC::UVTD

#endif
16 changes: 9 additions & 7 deletions UVTD/include/UVTD/SolBindingsGenerator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,32 @@

#include <unordered_map>

#include <File/File.hpp>
#include <UVTD/Symbols.hpp>
#include <UVTD/TypeContainer.hpp>
#include <File/File.hpp>

namespace RC::UVTD
{
class SolBindingsGenerator
{
private:
private:
Symbols symbols;
TypeContainer type_container;

public:
public:
SolBindingsGenerator() = delete;

explicit SolBindingsGenerator(Symbols symbols) : symbols(std::move(symbols)) {}
explicit SolBindingsGenerator(Symbols symbols) : symbols(std::move(symbols))
{
}

public:
public:
auto generate_code() -> void;
auto generate_files() -> void;

public:
public:
static auto output_cleanup() -> void;
};
}
} // namespace RC::UVTD

#endif
55 changes: 32 additions & 23 deletions UVTD/include/UVTD/Symbols.hpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#ifndef UNREALVTABLEDUMPER_SYMBOLS_HPP
#define UNREALVTABLEDUMPER_SYMBOLS_HPP

#include <unordered_map>
#include <format>
#include <map>
#include <unordered_map>
#include <vector>
#include <format>

#include <File/File.hpp>

#include <PDB_RawFile.h>
#include <PDB_DBIStream.h>
#include <PDB_RawFile.h>
#include <PDB_TPIStream.h>

namespace RC::UVTD
Expand All @@ -21,17 +21,24 @@ namespace RC::UVTD
bool should_dump_sol_bindings{};
};

enum class ValidForVTable { Yes, No };
enum class ValidForMemberVars { Yes, No };
enum class ValidForVTable
{
Yes,
No
};
enum class ValidForMemberVars
{
Yes,
No
};

struct SymbolNameInfo
{
ValidForVTable valid_for_vtable{};
ValidForMemberVars valid_for_member_vars{};

explicit SymbolNameInfo(ValidForVTable valid_for_vtable, ValidForMemberVars valid_for_member_vars) :
valid_for_vtable(valid_for_vtable),
valid_for_member_vars(valid_for_member_vars)
explicit SymbolNameInfo(ValidForVTable valid_for_vtable, ValidForMemberVars valid_for_member_vars)
: valid_for_vtable(valid_for_vtable), valid_for_member_vars(valid_for_member_vars)
{
}
};
Expand Down Expand Up @@ -90,12 +97,13 @@ namespace RC::UVTD
// Key: Variable name
std::map<File::StringType, MemberVariable> variables;
uint32_t last_virtual_offset{};
ValidForVTable valid_for_vtable{ ValidForVTable::No };
ValidForMemberVars valid_for_member_vars{ ValidForMemberVars::No };
ValidForVTable valid_for_vtable{ValidForVTable::No};
ValidForMemberVars valid_for_member_vars{ValidForMemberVars::No};
};

class Symbols {
public:
class Symbols
{
public:
struct MemberVariable
{
File::StringType type;
Expand All @@ -107,8 +115,8 @@ namespace RC::UVTD
File::StringType name;
File::StringType name_clean;
std::map<File::StringType, MemberVariable> variables;
};
};

struct Class
{
File::StringType class_name;
Expand All @@ -117,11 +125,11 @@ namespace RC::UVTD
// Key: Variable name
std::map<File::StringType, MemberVariable> variables;
uint32_t last_virtual_offset;
ValidForVTable valid_for_vtable{ ValidForVTable::No };
ValidForMemberVars valid_for_member_vars{ ValidForMemberVars::No };
ValidForVTable valid_for_vtable{ValidForVTable::No};
ValidForMemberVars valid_for_member_vars{ValidForMemberVars::No};
};

public:
public:
std::filesystem::path pdb_file_path;
File::Handle pdb_file_handle;
std::span<uint8_t> pdb_file_map;
Expand All @@ -133,7 +141,7 @@ namespace RC::UVTD
std::unordered_map<File::StringType, EnumEntry> enum_entries;
std::unordered_map<File::StringType, Class> class_entries;

public:
public:
Symbols() = delete;

explicit Symbols(std::filesystem::path pdb_file_path);
Expand All @@ -142,13 +150,14 @@ namespace RC::UVTD

Symbols& operator=(const Symbols& other);

public:
public:
auto get_or_create_enum_entry(const File::StringType& symbol_name, const File::StringType& symbol_name_clean) -> EnumEntry&;
auto get_or_create_class_entry(const File::StringType& symbol_name, const File::StringType& symbol_name_clean, const SymbolNameInfo& name_info) -> Class&;

auto generate_method_signature(const PDB::TPIStream& tpi_stream, const PDB::CodeView::TPI::Record* function_record, File::StringType method_name) -> MethodSignature;
auto generate_method_signature(const PDB::TPIStream& tpi_stream, const PDB::CodeView::TPI::Record* function_record, File::StringType method_name)
-> MethodSignature;

public:
public:
auto static get_type_name(const PDB::TPIStream& tpi_stream, uint32_t record_index, bool check_valid = false) -> File::StringType;
auto static get_method_name(const PDB::CodeView::TPI::FieldList* method_record) -> File::StringType;
auto static get_leaf_name(const char* data, PDB::CodeView::TPI::TypeRecordKind kind) -> File::StringType;
Expand All @@ -157,9 +166,9 @@ namespace RC::UVTD

auto static is_virtual(PDB::CodeView::TPI::MemberAttributes attributes) -> bool;

private:
private:
auto setup_symbol_loader() -> void;
};
}
} // namespace RC::UVTD

#endif
4 changes: 2 additions & 2 deletions UVTD/include/UVTD/TemplateClassParser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ namespace RC::UVTD

class TemplateClassParser
{
public:
public:
static ParsedTemplateClass Parse(File::StringViewType input);
};
}
} // namespace RC::UVTD

#endif
17 changes: 10 additions & 7 deletions UVTD/include/UVTD/TypeContainer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,30 @@

#include <unordered_map>

#include <UVTD/Symbols.hpp>
#include <File/File.hpp>
#include <UVTD/Symbols.hpp>

namespace RC::UVTD
{
class TypeContainer
{
private:
private:
using ClassEntries = std::unordered_map<File::StringType, Class>;

ClassEntries class_entries;

public:
public:
auto join(const TypeContainer& other) -> void;

public:
constexpr auto get_class_entries() const -> const ClassEntries& { return class_entries; }
public:
constexpr auto get_class_entries() const -> const ClassEntries&
{
return class_entries;
}

public:
public:
auto get_or_create_class_entry(const File::StringType& symbol_name, const File::StringType& symbol_name_clean, const SymbolNameInfo& name_info) -> Class&;
};
}
} // namespace RC::UVTD

#endif
14 changes: 7 additions & 7 deletions UVTD/include/UVTD/UVTD.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@
#define RC_UVTD_HPP

#include <filesystem>
#include <unordered_set>
#include <set>
#include <map>
#include <set>
#include <unordered_set>
#include <utility>

#include <UVTD/Symbols.hpp>
#include <DynamicOutput/DynamicOutput.hpp>
#include <File/File.hpp>
#include <Input/Handler.hpp>
#include <Function/Function.hpp>
#include <DynamicOutput/DynamicOutput.hpp>
#include <Input/Handler.hpp>
#include <UVTD/Symbols.hpp>

namespace RC::UVTD
{
extern bool processing_events;
extern Input::Handler input_handler;

auto main(DumpSettings) -> void;
}
} // namespace RC::UVTD

#endif //RC_UVTD_HPP
#endif // RC_UVTD_HPP
Loading

0 comments on commit 0a984b0

Please sign in to comment.