Skip to content

Commit

Permalink
Deps: Update SdkGenny
Browse files Browse the repository at this point in the history
  • Loading branch information
cursey committed Mar 23, 2023
1 parent 222442c commit 9c97777
Show file tree
Hide file tree
Showing 18 changed files with 75 additions and 74 deletions.
10 changes: 5 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,21 @@ endif()

include(FetchContent)

message(STATUS "Fetching sdkgenny (ee6d202ed31bd040bd6d484df6ef90ad3c4d3536)...")
message(STATUS "Fetching sdkgenny (5a6768a13d7d929cc7495d95d5f604593efcfd50)...")
FetchContent_Declare(sdkgenny
GIT_REPOSITORY
"https://github.com/cursey/sdkgenny.git"
GIT_TAG
ee6d202ed31bd040bd6d484df6ef90ad3c4d3536
5a6768a13d7d929cc7495d95d5f604593efcfd50
)
FetchContent_MakeAvailable(sdkgenny)

message(STATUS "Fetching luagenny (2e275aec7dfa9483507bb6f768e8479860064d8b)...")
message(STATUS "Fetching luagenny (5832d4c57b8a8d195667b2844100cf80feece81b)...")
FetchContent_Declare(luagenny
GIT_REPOSITORY
"https://github.com/praydog/luagenny.git"
"https://github.com/cursey/luagenny.git"
GIT_TAG
2e275aec7dfa9483507bb6f768e8479860064d8b
5832d4c57b8a8d195667b2844100cf80feece81b
)
FetchContent_MakeAvailable(luagenny)

Expand Down
4 changes: 2 additions & 2 deletions cmake.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ packages = [
]

[fetch-content]
sdkgenny = { git = "https://github.com/cursey/sdkgenny.git", tag = "ee6d202ed31bd040bd6d484df6ef90ad3c4d3536" }
luagenny = { git = "https://github.com/praydog/luagenny.git", tag = "2e275aec7dfa9483507bb6f768e8479860064d8b" }
sdkgenny = { git = "https://github.com/cursey/sdkgenny.git", tag = "5a6768a13d7d929cc7495d95d5f604593efcfd50" }
luagenny = { git = "https://github.com/cursey/luagenny.git", tag = "5832d4c57b8a8d195667b2844100cf80feece81b" }

[find-package]
imgui = {}
Expand Down
4 changes: 2 additions & 2 deletions src/MemoryUi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
#include "MemoryUi.hpp"

MemoryUi::MemoryUi(
Config& cfg, genny::Sdk& sdk, genny::Struct* struct_, Process& process, node::Property& inherited_props)
Config& cfg, sdkgenny::Sdk& sdk, sdkgenny::Struct* struct_, Process& process, node::Property& inherited_props)
: m_cfg{cfg}, m_sdk{sdk}, m_struct{struct_}, m_process{process}, m_props{inherited_props} {
if (m_struct == nullptr) {
return;
}

m_proxy_variable = std::make_unique<genny::Variable>("root");
m_proxy_variable = std::make_unique<sdkgenny::Variable>("root");
m_proxy_variable->type(m_struct->ptr());

auto root = std::make_unique<node::Pointer>(m_cfg, m_process, m_proxy_variable.get(), m_props);
Expand Down
11 changes: 6 additions & 5 deletions src/MemoryUi.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <unordered_map>
#include <vector>

#include <Genny.hpp>
#include <sdkgenny.hpp>

#include "Config.hpp"
#include "Process.hpp"
Expand All @@ -14,19 +14,20 @@

class MemoryUi {
public:
MemoryUi(Config& cfg, genny::Sdk& sdk, genny::Struct* struct_, Process& process, node::Property& inherited_props);
MemoryUi(
Config& cfg, sdkgenny::Sdk& sdk, sdkgenny::Struct* struct_, Process& process, node::Property& inherited_props);

void display(uintptr_t address);

auto&& props() { return m_props; }

private:
Config& m_cfg;
genny::Sdk& m_sdk;
genny::Struct* m_struct{};
sdkgenny::Sdk& m_sdk;
sdkgenny::Struct* m_struct{};
Process& m_process;

std::unique_ptr<genny::Variable> m_proxy_variable{};
std::unique_ptr<sdkgenny::Variable> m_proxy_variable{};
std::unique_ptr<node::Base> m_root{};

node::Property m_props;
Expand Down
2 changes: 1 addition & 1 deletion src/Process.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class Process {
virtual uint32_t process_id() { return 0; }

// NOTE: Return true by default so you can view structures without being attached.
virtual bool ok() { return true; }
virtual bool ok() { return true; }

// RTTI
virtual std::optional<std::string> get_typename(uintptr_t ptr) { return std::nullopt; }
Expand Down
30 changes: 15 additions & 15 deletions src/ReGenny.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
#include <imgui_internal.h>
#include <imgui_stdlib.h>
#include <nfd.h>
#include <sdkgenny_parser.hpp>
#include <spdlog/spdlog.h>

#include "AboutUi.hpp"
#include "GennyParser.hpp"
#include "Utility.hpp"
#include "arch/Arch.hpp"
#include "node/Undefined.hpp"
Expand Down Expand Up @@ -663,7 +663,7 @@ void ReGenny::action_detach() {
spdlog::info("Detaching...");
m_process = std::make_unique<Process>();
m_mem_ui = std::make_unique<MemoryUi>(
m_cfg, *m_sdk, dynamic_cast<genny::Struct*>(m_type), *m_process, m_project.props[m_project.type_chosen]);
m_cfg, *m_sdk, dynamic_cast<sdkgenny::Struct*>(m_type), *m_process, m_project.props[m_project.type_chosen]);
m_ui.processes.clear();
set_window_title();
}
Expand Down Expand Up @@ -938,12 +938,12 @@ void ReGenny::set_type() {
return;
}

genny::Object* parent = m_sdk->global_ns();
sdkgenny::Object* parent = m_sdk->global_ns();
std::string type_name = m_project.type_chosen;
size_t pos{};

while ((pos = type_name.find('.')) != std::string::npos) {
parent = parent->find<genny::Object>(type_name.substr(0, pos));
parent = parent->find<sdkgenny::Object>(type_name.substr(0, pos));

if (parent == nullptr) {
return;
Expand All @@ -952,7 +952,7 @@ void ReGenny::set_type() {
type_name.erase(0, pos + 1);
}

m_type = parent->find<genny::Struct>(type_name);
m_type = parent->find<sdkgenny::Struct>(type_name);

if (m_type == nullptr) {
return;
Expand All @@ -967,7 +967,7 @@ void ReGenny::set_type() {
set_address();

m_mem_ui = std::make_unique<MemoryUi>(
m_cfg, *m_sdk, dynamic_cast<genny::Struct*>(m_type), *m_process, m_project.props[m_project.type_chosen]);
m_cfg, *m_sdk, dynamic_cast<sdkgenny::Struct*>(m_type), *m_process, m_project.props[m_project.type_chosen]);
}

void ReGenny::reset_lua_state() {
Expand Down Expand Up @@ -1006,11 +1006,11 @@ void ReGenny::reset_lua_state() {
return sol::make_object(s, sol::nil);
}

if (rg->type() == nullptr || !rg->type()->is_a<genny::Struct>()) {
if (rg->type() == nullptr || !rg->type()->is_a<sdkgenny::Struct>()) {
return sol::make_object(s, sol::nil);
}

return sol::make_object(s, create_overlay(rg->address(), dynamic_cast<genny::Struct*>(rg->type())));
return sol::make_object(s, create_overlay(rg->address(), dynamic_cast<sdkgenny::Struct*>(rg->type())));
},
"sdk", [](sol::this_state s, ReGenny* rg) {
if (rg->sdk() == nullptr) {
Expand Down Expand Up @@ -1283,17 +1283,17 @@ void ReGenny::reset_lua_state() {
}

void ReGenny::parse_file() try {
auto sdk = std::make_unique<genny::Sdk>();
auto sdk = std::make_unique<sdkgenny::Sdk>();

sdk->import(m_open_filepath);

genny::parser::State s{};
sdkgenny::parser::State s{};
s.filepath = m_open_filepath;
s.parents.push_back(sdk->global_ns());

tao::pegtl::file_input in{m_open_filepath};

if (tao::pegtl::parse<genny::parser::Grammar, genny::parser::Action>(in, s)) {
if (tao::pegtl::parse<sdkgenny::parser::Grammar, sdkgenny::parser::Action>(in, s)) {
// We just parsed, so record the max last write time for any of the imported files.
// This prevents reloading on opening a file for the first time since launch.
for (auto&& import : sdk->imports()) {
Expand All @@ -1310,14 +1310,14 @@ void ReGenny::parse_file() try {
// Build the list of selectable types for the type selector.
m_ui.type_names.clear();

std::unordered_set<genny::Struct*> structs{};
m_sdk->global_ns()->get_all_in_children<genny::Struct>(structs);
std::unordered_set<sdkgenny::Struct*> structs{};
m_sdk->global_ns()->get_all_in_children<sdkgenny::Struct>(structs);

for (auto&& struct_ : structs) {
std::vector<std::string> parent_names{};

for (auto p = struct_->owner<genny::Object>(); p != nullptr && !p->is_a<genny::Sdk>();
p = p->owner<genny::Object>()) {
for (auto p = struct_->owner<sdkgenny::Object>(); p != nullptr && !p->is_a<sdkgenny::Sdk>();
p = p->owner<sdkgenny::Object>()) {
if (auto& name = p->name(); !name.empty()) {
parent_names.emplace_back(name);
}
Expand Down
6 changes: 3 additions & 3 deletions src/ReGenny.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
#include <string>
#include <unordered_map>

#include <Genny.hpp>
#include <SDL.h>
#include <sdkgenny.hpp>
#include <sol/sol.hpp>

#include "Config.hpp"
Expand Down Expand Up @@ -48,8 +48,8 @@ class ReGenny {

std::unique_ptr<Helpers> m_helpers{};
std::unique_ptr<Process> m_process{};
std::unique_ptr<genny::Sdk> m_sdk{};
genny::Type* m_type{};
std::unique_ptr<sdkgenny::Sdk> m_sdk{};
sdkgenny::Type* m_type{};
uintptr_t m_address{};
bool m_is_address_valid{};
ParsedAddress m_parsed_address{};
Expand Down
12 changes: 6 additions & 6 deletions src/node/Array.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ void Array::display_str(std::string& s, const std::string& str) {
s += "\" ";
}

Array::Array(Config& cfg, Process& process, genny::Variable* var, Property& props)
: Variable{cfg, process, var, props}, m_arr{dynamic_cast<genny::Array*>(var->type())} {
Array::Array(Config& cfg, Process& process, sdkgenny::Variable* var, Property& props)
: Variable{cfg, process, var, props}, m_arr{dynamic_cast<sdkgenny::Array*>(var->type())} {
assert(m_arr != nullptr);

m_props["__collapsed"].set_default(true);
Expand Down Expand Up @@ -159,21 +159,21 @@ void Array::create_nodes() {
auto end = start + num_elements;

for (auto i = start; i < end; ++i) {
auto proxy_variable = std::make_unique<genny::Variable>(fmt::format("{}[{}]", m_var->name(), i));
auto proxy_variable = std::make_unique<sdkgenny::Variable>(fmt::format("{}[{}]", m_var->name(), i));
auto&& proxy_props = m_props[proxy_variable->name()];

proxy_variable->type(m_arr->of());
proxy_variable->offset(m_var->offset() + i * m_arr->size());

std::unique_ptr<Variable> node{};

if (proxy_variable->type()->is_a<genny::Array>()) {
if (proxy_variable->type()->is_a<sdkgenny::Array>()) {
node = std::make_unique<Array>(m_cfg, m_process, proxy_variable.get(), proxy_props);
} else if (proxy_variable->type()->is_a<genny::Struct>()) {
} else if (proxy_variable->type()->is_a<sdkgenny::Struct>()) {
auto struct_ = std::make_unique<Struct>(m_cfg, m_process, proxy_variable.get(), proxy_props);
struct_->is_collapsed(false);
node = std::move(struct_);
} else if (proxy_variable->type()->is_a<genny::Pointer>()) {
} else if (proxy_variable->type()->is_a<sdkgenny::Pointer>()) {
node = std::make_unique<Pointer>(m_cfg, m_process, proxy_variable.get(), proxy_props);
} else {
node = std::make_unique<Variable>(m_cfg, m_process, proxy_variable.get(), proxy_props);
Expand Down
6 changes: 3 additions & 3 deletions src/node/Array.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace node {
class Array : public Variable {
public:
Array(Config& cfg, Process& process, genny::Variable* var, Property& props);
Array(Config& cfg, Process& process, sdkgenny::Variable* var, Property& props);

void display(uintptr_t address, uintptr_t offset, std::byte* mem) override;
void update(uintptr_t address, uintptr_t offset, std::byte* mem) override;
Expand All @@ -29,9 +29,9 @@ class Array : public Variable {
auto& num_elements_displayed() { return m_props["__count"].as_int(); }

protected:
genny::Array* m_arr{};
sdkgenny::Array* m_arr{};
std::vector<std::unique_ptr<Variable>> m_elements{};
std::vector<std::unique_ptr<genny::Variable>> m_proxy_variables{};
std::vector<std::unique_ptr<sdkgenny::Variable>> m_proxy_variables{};

std::string m_value_str{};

Expand Down
6 changes: 3 additions & 3 deletions src/node/Bitfield.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ template <typename T> void display_as(std::string& s, size_t num_bits, uintptr_t
}

template <typename T>
void display_enum(std::string& s, size_t num_bits, uintptr_t offset, std::byte* mem, genny::Enum* enum_) {
void display_enum(std::string& s, size_t num_bits, uintptr_t offset, std::byte* mem, sdkgenny::Enum* enum_) {
T mask{};
auto data = *(T*)mem;
auto start = offset;
Expand Down Expand Up @@ -68,7 +68,7 @@ void display_enum(std::string& s, size_t num_bits, uintptr_t offset, std::byte*
}
}

Bitfield::Bitfield(Config& cfg, Process& process, genny::Variable* var, Property& props)
Bitfield::Bitfield(Config& cfg, Process& process, sdkgenny::Variable* var, Property& props)
: Variable{cfg, process, var, props} {
assert(var->is_bitfield());
}
Expand Down Expand Up @@ -135,7 +135,7 @@ void Bitfield::update(uintptr_t address, uintptr_t offset, std::byte* mem) {
}
}

if (auto enum_ = dynamic_cast<genny::Enum*>(m_var->type())) {
if (auto enum_ = dynamic_cast<sdkgenny::Enum*>(m_var->type())) {
switch (m_var->type()->size()) {
case 1:
display_enum<uint8_t>(m_display_str, m_var->bit_size(), m_var->bit_offset(), mem, enum_);
Expand Down
2 changes: 1 addition & 1 deletion src/node/Bitfield.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
namespace node {
class Bitfield : public Variable {
public:
Bitfield(Config& cfg, Process& process, genny::Variable* var, Property& props);
Bitfield(Config& cfg, Process& process, sdkgenny::Variable* var, Property& props);

void display(uintptr_t address, uintptr_t offset, std::byte* mem) override;
void update(uintptr_t address, uintptr_t offset, std::byte* mem) override;
Expand Down
12 changes: 6 additions & 6 deletions src/node/Pointer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ void Pointer::display_str(std::string& s, const std::string& str) {
s += "\" ";
}

Pointer::Pointer(Config& cfg, Process& process, genny::Variable* var, Property& props)
Pointer::Pointer(Config& cfg, Process& process, sdkgenny::Variable* var, Property& props)
: Variable{cfg, process, var, props} {
m_ptr = dynamic_cast<genny::Pointer*>(m_var->type());
m_ptr = dynamic_cast<sdkgenny::Pointer*>(m_var->type());
assert(m_ptr != nullptr);

m_props["__collapsed"].set_default(true);
Expand Down Expand Up @@ -105,18 +105,18 @@ void Pointer::display(uintptr_t address, uintptr_t offset, std::byte* mem) {
auto&& props = m_props[var_name];

if (is_array()) {
m_proxy_var = std::make_unique<genny::Variable>(var_name);
m_proxy_var = std::make_unique<sdkgenny::Variable>(var_name);
m_proxy_var->type(m_ptr->to()->array_(array_count()));
m_ptr_node = std::make_unique<Array>(m_cfg, m_process, m_proxy_var.get(), props);
} else {
m_proxy_var = std::make_unique<genny::Variable>(var_name);
m_proxy_var = std::make_unique<sdkgenny::Variable>(var_name);
m_proxy_var->type(m_ptr->to());

if (m_ptr->to()->is_a<genny::Struct>()) {
if (m_ptr->to()->is_a<sdkgenny::Struct>()) {
auto struct_ = std::make_unique<Struct>(m_cfg, m_process, m_proxy_var.get(), props);
struct_->display_self(false)->is_collapsed(false);
m_ptr_node = std::move(struct_);
} else if (m_ptr->to()->is_a<genny::Pointer>()) {
} else if (m_ptr->to()->is_a<sdkgenny::Pointer>()) {
m_ptr_node = std::make_unique<Pointer>(m_cfg, m_process, m_proxy_var.get(), props);
} else {
m_ptr_node = std::make_unique<Variable>(m_cfg, m_process, m_proxy_var.get(), props);
Expand Down
6 changes: 3 additions & 3 deletions src/node/Pointer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
namespace node {
class Pointer : public Variable {
public:
Pointer(Config& cfg, Process& process, genny::Variable* var, Property& props);
Pointer(Config& cfg, Process& process, sdkgenny::Variable* var, Property& props);

void display(uintptr_t address, uintptr_t offset, std::byte* mem) override;
void update(uintptr_t address, uintptr_t offset, std::byte* mem) override;
Expand All @@ -32,13 +32,13 @@ class Pointer : public Variable {
auto& array_count() { return m_props["__count"].as_int(); }

protected:
genny::Pointer* m_ptr{};
sdkgenny::Pointer* m_ptr{};
std::vector<std::byte> m_mem{};
std::chrono::steady_clock::time_point m_mem_refresh_time{};
uintptr_t m_address{};

std::unique_ptr<Base> m_ptr_node{};
std::unique_ptr<genny::Variable> m_proxy_var{};
std::unique_ptr<sdkgenny::Variable> m_proxy_var{};

std::string m_value_str{};
std::string m_address_str{};
Expand Down

0 comments on commit 9c97777

Please sign in to comment.