Fixed toml::parse_error construction and config fields not getting populated in RSPRecomp

This commit is contained in:
Mr-Wiseguy 2024-05-16 17:55:56 -04:00
parent 7d0490f43f
commit e8a0e8147e
2 changed files with 21 additions and 12 deletions

View file

@ -639,18 +639,27 @@ bool read_config(const std::filesystem::path& config_path, RSPRecompilerConfig&
std::filesystem::path basedir = std::filesystem::path{ config_path }.parent_path();
std::optional<uint32_t> text_offset = config_data["text_offset"].value<uint32_t>();
if (!text_offset.has_value()) {
throw toml::parse_error("Missing text_offset in config file", {});
if (text_offset.has_value()) {
ret.text_offset = text_offset.value();
}
else {
throw toml::parse_error("Missing text_offset in config file", config_data.source());
}
std::optional<uint32_t> text_size = config_data["text_size"].value<uint32_t>();
if (!text_size.has_value()) {
throw toml::parse_error("Missing text_size in config file", {});
if (text_size.has_value()) {
ret.text_size = text_size.value();
}
else {
throw toml::parse_error("Missing text_size in config file", config_data.source());
}
std::optional<uint32_t> text_address = config_data["text_address"].value<uint32_t>();
if (!text_address.has_value()) {
throw toml::parse_error("Missing text_address in config file", {});
if (text_address.has_value()) {
ret.text_address = text_address.value();
}
else {
throw toml::parse_error("Missing text_address in config file", config_data.source());
}
std::optional<std::string> rom_file_path = config_data["rom_file_path"].value<std::string>();
@ -658,7 +667,7 @@ bool read_config(const std::filesystem::path& config_path, RSPRecompilerConfig&
ret.rom_file_path = concat_if_not_empty(basedir, rom_file_path.value());
}
else {
throw toml::parse_error("Missing rom_file_path in config file", {});
throw toml::parse_error("Missing rom_file_path in config file", config_data.source());
}
std::optional<std::string> output_file_path = config_data["output_file_path"].value<std::string>();
@ -666,7 +675,7 @@ bool read_config(const std::filesystem::path& config_path, RSPRecompilerConfig&
ret.output_file_path = concat_if_not_empty(basedir, output_file_path.value());
}
else {
throw toml::parse_error("Missing output_file_path in config file", {});
throw toml::parse_error("Missing output_file_path in config file", config_data.source());
}
std::optional<std::string> output_function_name = config_data["output_function_name"].value<std::string>();
@ -674,7 +683,7 @@ bool read_config(const std::filesystem::path& config_path, RSPRecompilerConfig&
ret.output_function_name = output_function_name.value();
}
else {
throw toml::parse_error("Missing output_function_name in config file", {});
throw toml::parse_error("Missing output_function_name in config file", config_data.source());
}
// Extra indirect branch targets (optional)

View file

@ -19,11 +19,11 @@ std::vector<RecompPort::ManualFunction> get_manual_funcs(const toml::array* manu
if (func_name.has_value() && section_name.has_value() && vram_in.has_value() && size.has_value()) {
ret.emplace_back(func_name.value(), section_name.value(), vram_in.value(), size.value());
} else {
throw toml::parse_error("Missing required value in manual_funcs array", {});
throw toml::parse_error("Missing required value in manual_funcs array", el.source());
}
}
else {
throw toml::parse_error("Missing required value in manual_funcs array", {});
throw toml::parse_error("Missing required value in manual_funcs array", el.source());
}
});
@ -279,7 +279,7 @@ RecompPort::Config::Config(const char* path) {
output_func_path = concat_if_not_empty(basedir, output_func_path_opt.value());
}
else {
throw toml::parse_error("Missing output_func_path in config file", {});
throw toml::parse_error("Missing output_func_path in config file", input_data.node()->source());
}
std::optional<std::string> relocatable_sections_path_opt = input_data["relocatable_sections_path"].value<std::string>();