fix build warnings

This commit is contained in:
water
2023-11-02 18:17:09 -04:00
parent 385b8e6e6a
commit 02e6e3c99d
7 changed files with 47 additions and 25 deletions
+8 -8
View File
@@ -86,7 +86,7 @@ void apply_formatting_config(
// circumstance, we do NOT do this sort of thing when formatting normal forms (cond/case pairs
// are another similar situation)
if (curr_node.formatting_config.has_constant_pairs) {
for (int i = 0; i < curr_node.refs.size(); i++) {
for (int i = 0; i < (int)curr_node.refs.size(); i++) {
auto& child_ref = curr_node.refs.at(i);
const auto type = child_ref.metadata.node_type;
if (constant_types.find(type) == constant_types.end() &&
@@ -107,7 +107,7 @@ void apply_formatting_config(
curr_node.formatting_config.indentation_width = hang_indentation_width(curr_node);
}
// iterate through the refs
for (int i = 0; i < curr_node.refs.size(); i++) {
for (int i = 0; i < (int)curr_node.refs.size(); i++) {
auto& ref = curr_node.refs.at(i);
if (!ref.token) {
// If the child has a pre-defined configuration at that index, we pass it along
@@ -211,7 +211,7 @@ std::vector<std::string> apply_formatting(const FormatterTreeNode& curr_node,
//
// This means we may combine elements onto the same line in this step.
std::vector<std::string> form_lines = {};
for (int i = 0; i < curr_node.refs.size(); i++) {
for (int i = 0; i < (int)curr_node.refs.size(); i++) {
const auto& ref = curr_node.refs.at(i);
// Add new line entry
if (ref.token) {
@@ -227,7 +227,7 @@ std::vector<std::string> apply_formatting(const FormatterTreeNode& curr_node,
// If it's not a token, we have to recursively build up the form
// TODO - add the cursor_pos here
const auto& lines = apply_formatting(ref, {}, cursor_pos);
for (int i = 0; i < lines.size(); i++) {
for (int i = 0; i < (int)lines.size(); i++) {
const auto& line = lines.at(i);
form_lines.push_back(fmt::format(
"{}{}", str_util::repeat(ref.formatting_config.parent_mutable_extra_indent, " "),
@@ -235,12 +235,12 @@ std::vector<std::string> apply_formatting(const FormatterTreeNode& curr_node,
}
}
// If we are hanging forms, combine the first two forms onto the same line
if (i == curr_node.refs.size() - 1 && form_lines.size() > 1 &&
if (i == (int)curr_node.refs.size() - 1 && form_lines.size() > 1 &&
(curr_node.formatting_config.hang_forms ||
curr_node.formatting_config.combine_first_two_lines)) {
form_lines.at(0) += fmt::format(" {}", form_lines.at(1));
form_lines.erase(form_lines.begin() + 1);
} else if ((i + 1) < curr_node.refs.size()) {
} else if ((i + 1) < (int)curr_node.refs.size()) {
const auto& next_ref = curr_node.refs.at(i + 1);
// combine the next inline comment or constant pair
if ((next_ref.metadata.node_type == "comment" && next_ref.metadata.is_inline) ||
@@ -267,7 +267,7 @@ std::vector<std::string> apply_formatting(const FormatterTreeNode& curr_node,
// Consolidate any lines if the configuration requires it
if (curr_node.formatting_config.inline_until_index != -1) {
std::vector<std::string> new_form_lines = {};
for (int i = 0; i < form_lines.size(); i++) {
for (int i = 0; i < (int)form_lines.size(); i++) {
if (i < curr_node.formatting_config.inline_until_index) {
if (new_form_lines.empty()) {
new_form_lines.push_back(form_lines.at(i));
@@ -296,7 +296,7 @@ std::vector<std::string> apply_formatting(const FormatterTreeNode& curr_node,
if (inline_form) {
form_lines = {fmt::format("{}", fmt::join(form_lines, " "))};
} else {
for (int i = 0; i < form_lines.size(); i++) {
for (int i = 0; i < (int)form_lines.size(); i++) {
if (i > 0) {
auto& line = form_lines.at(i);
line = fmt::format("{}{}",
+1 -1
View File
@@ -39,7 +39,7 @@ bool should_insert_blank_line(const FormatterTreeNode& containing_node,
return false;
}
// If the next form is a comment and is inline, don't insert a comment
if ((index + 1) < containing_node.refs.size() &&
if ((index + 1) < (int)containing_node.refs.size() &&
containing_node.refs.at(index + 1).metadata.is_comment &&
containing_node.refs.at(index + 1).metadata.is_inline) {
return false;
+2 -2
View File
@@ -22,13 +22,13 @@ FormFormattingConfig new_binding_rule() {
auto binding_list_config = std::make_shared<FormFormattingConfig>();
binding_list_config->hang_forms = false;
binding_list_config->indentation_width = 1;
binding_list_config->indentation_width_for_index = [](FormFormattingConfig cfg, int index) {
binding_list_config->indentation_width_for_index = [](FormFormattingConfig /*cfg*/, int index) {
if (index == 0) {
return 0;
}
return 4;
};
binding_list_config->should_prevent_inlining = [](FormFormattingConfig config, int num_refs) {
binding_list_config->should_prevent_inlining = [](FormFormattingConfig /*config*/, int num_refs) {
// Only prevent inlining a binding list, if there are more than 1 bindings
if (num_refs > 1) {
return true;
+2 -2
View File
@@ -17,14 +17,14 @@ struct FormFormattingConfig {
2; // 2 for a flow // TODO - also remove this, prefer storing the first node's width in the
// metadata on the first pass, that's basically all this does
std::function<int(FormFormattingConfig, int)> indentation_width_for_index =
[](FormFormattingConfig config, int index) { return config.indentation_width; };
[](FormFormattingConfig config, int /*index*/) { return config.indentation_width; };
bool combine_first_two_lines =
false; // NOTE - basically hang, but will probably stick around after hang is gone
int inline_until_index = -1;
bool has_constant_pairs = false;
bool prevent_inlining = false;
std::function<bool(FormFormattingConfig, int num_refs)> should_prevent_inlining =
[](FormFormattingConfig config, int num_refs) { return config.prevent_inlining; };
[](FormFormattingConfig config, int /*num_refs*/) { return config.prevent_inlining; };
int parent_mutable_extra_indent = 0;
std::unordered_map<int, std::shared_ptr<FormFormattingConfig>> index_configs = {};
};
+30 -8
View File
@@ -544,8 +544,15 @@ MethodInfo TypeSystem::override_method(Type* type,
throw_typesystem_error("Trying to override a method that has no parent declaration");
}
// use the existing ID.
return type->add_method({existing_info.id, existing_info.name, existing_info.type,
type->get_name(), existing_info.no_virtual, false, true, docstring});
return type->add_method({existing_info.id,
existing_info.name,
existing_info.type,
type->get_name(),
existing_info.no_virtual,
false,
true,
docstring,
{}});
}
MethodInfo TypeSystem::declare_method(const std::string& type_name,
@@ -596,8 +603,15 @@ MethodInfo TypeSystem::declare_method(Type* type,
}
// use the existing ID.
return type->add_method(
{existing_info.id, method_name, ts, type->get_name(), no_virtual, true, false, docstring});
return type->add_method({existing_info.id,
method_name,
ts,
type->get_name(),
no_virtual,
true,
false,
docstring,
{}});
} else {
if (got_existing) {
// make sure we aren't changing anything.
@@ -627,8 +641,15 @@ MethodInfo TypeSystem::declare_method(Type* type,
return existing_info;
} else {
// add a new method!
return type->add_method({get_next_method_id(type), method_name, ts, type->get_name(),
no_virtual, false, false, docstring});
return type->add_method({get_next_method_id(type),
method_name,
ts,
type->get_name(),
no_virtual,
false,
false,
docstring,
{}});
}
}
}
@@ -736,7 +757,8 @@ MethodInfo TypeSystem::add_new_method(Type* type,
return existing;
} else {
return type->add_new_method({0, "new", ts, type->get_name(), false, false, false, docstring});
return type->add_new_method(
{0, "new", ts, type->get_name(), false, false, false, docstring, {}});
}
}
@@ -2089,7 +2111,7 @@ std::optional<std::string> find_best_field_in_structure(const TypeSystem& ts,
if (end_field == -1) {
end_field = st->fields().size();
}
for (size_t i = start_field; i < end_field; ++i) {
for (size_t i = start_field; i < (size_t)end_field; ++i) {
const auto& field = st->fields().at(i);
auto type = ts.lookup_type(field.type());
if (field.is_dynamic() || field.offset() > offset || field.user_placed() != want_fixed) {
+1 -1
View File
@@ -457,7 +457,7 @@ void declare_method(Type* type,
void declare_state_methods(Type* type,
TypeSystem* type_system,
const goos::Object& def,
StructureDefResult& struct_def) {
StructureDefResult& /*struct_def*/) {
for_each_in_list(def, [&](const goos::Object& _obj) {
auto obj = &_obj;
// either state-name or (state-name args...) or (state-name "docstring" args...)
+3 -3
View File
@@ -972,7 +972,7 @@ void pc_get_external_speedrun_time(u32 speedrun_id_ptr,
auto speedrun_id = std::string(Ptr<String>(speedrun_id_ptr).c()->data());
if (external_speedrun_time_cache.find(speedrun_id) != external_speedrun_time_cache.end()) {
const auto& runs = external_speedrun_time_cache.at(speedrun_id);
if (index < runs.size()) {
if (index < (int)runs.size()) {
const auto& run_info = external_speedrun_time_cache.at(speedrun_id).at(index);
std::string converted =
get_font_bank(GameTextVersion::JAK2)->convert_utf8_to_game(run_info.first);
@@ -991,7 +991,7 @@ void pc_get_external_race_time(u32 race_id_ptr, s32 index, u32 name_dest_ptr, u3
auto race_id = std::string(Ptr<String>(race_id_ptr).c()->data());
if (external_race_time_cache.find(race_id) != external_race_time_cache.end()) {
const auto& runs = external_race_time_cache.at(race_id);
if (index < runs.size()) {
if (index < (int)runs.size()) {
const auto& run_info = external_race_time_cache.at(race_id).at(index);
std::string converted =
get_font_bank(GameTextVersion::JAK2)->convert_utf8_to_game(run_info.first);
@@ -1013,7 +1013,7 @@ void pc_get_external_highscore(u32 highscore_id_ptr,
auto highscore_id = std::string(Ptr<String>(highscore_id_ptr).c()->data());
if (external_highscores_cache.find(highscore_id) != external_highscores_cache.end()) {
const auto& runs = external_highscores_cache.at(highscore_id);
if (index < runs.size()) {
if (index < (int)runs.size()) {
const auto& run_info = external_highscores_cache.at(highscore_id).at(index);
std::string converted =
get_font_bank(GameTextVersion::JAK2)->convert_utf8_to_game(run_info.first);