Style: Remove redundant DEBUG_METHODS_ENABLED

• Replaced with functionally identical and far more ubiquitous `DEBUG_ENABLED`
This commit is contained in:
Thaddeus Crews 2025-05-15 13:09:41 -05:00
parent 5e27318b6c
commit d237e31a89
No known key found for this signature in database
GPG key ID: 8C6E5FEB5FC03CCC
25 changed files with 328 additions and 337 deletions

View file

@ -69,11 +69,11 @@ static MethodInfo info_from_utility_func(const StringName &p_function) {
} else {
for (int i = 0; i < Variant::get_utility_function_argument_count(p_function); i++) {
PropertyInfo pi;
#ifdef DEBUG_METHODS_ENABLED
#ifdef DEBUG_ENABLED
pi.name = Variant::get_utility_function_argument_name(p_function, i);
#else
pi.name = "arg" + itos(i + 1);
#endif
#endif // DEBUG_ENABLED
pi.type = Variant::get_utility_function_argument_type(p_function, i);
info.arguments.push_back(pi);
}
@ -452,7 +452,7 @@ Error GDScriptAnalyzer::resolve_class_inheritance(GDScriptParser::ClassNode *p_c
if (!parser->_is_tool && ext_parser->get_parser()->_is_tool) {
parser->push_warning(p_class, GDScriptWarning::MISSING_TOOL);
}
#endif
#endif // DEBUG_ENABLED
base = ext_parser->get_parser()->head->get_datatype();
} else {
@ -486,7 +486,7 @@ Error GDScriptAnalyzer::resolve_class_inheritance(GDScriptParser::ClassNode *p_c
if (!parser->_is_tool && base_parser->get_parser()->_is_tool) {
parser->push_warning(p_class, GDScriptWarning::MISSING_TOOL);
}
#endif
#endif // DEBUG_ENABLED
base = base_parser->get_parser()->head->get_datatype();
}
@ -513,7 +513,7 @@ Error GDScriptAnalyzer::resolve_class_inheritance(GDScriptParser::ClassNode *p_c
if (!parser->_is_tool && info_parser->get_parser()->_is_tool) {
parser->push_warning(p_class, GDScriptWarning::MISSING_TOOL);
}
#endif
#endif // DEBUG_ENABLED
base = info_parser->get_parser()->head->get_datatype();
} else if (class_exists(name)) {
@ -1039,7 +1039,7 @@ void GDScriptAnalyzer::resolve_class_member(GDScriptParser::ClassNode *p_class,
}
}
}
#endif
#endif // DEBUG_ENABLED
switch (member.type) {
case GDScriptParser::ClassNode::Member::VARIABLE: {
bool previous_static_context = static_context;
@ -1102,7 +1102,7 @@ void GDScriptAnalyzer::resolve_class_member(GDScriptParser::ClassNode *p_class,
}
}
}
#endif
#endif // DEBUG_ENABLED
} break;
case GDScriptParser::ClassNode::Member::CONSTANT: {
check_class_member_name_conflict(p_class, member.constant->identifier->name, member.constant);
@ -1132,7 +1132,7 @@ void GDScriptAnalyzer::resolve_class_member(GDScriptParser::ClassNode *p_class,
if (param->datatype_specifier == nullptr) {
parser->push_warning(param, GDScriptWarning::UNTYPED_DECLARATION, "Parameter", param->identifier->name);
}
#endif
#endif // DEBUG_ENABLED
mi.arguments.push_back(param_type.to_property_info(param->identifier->name));
// Signals do not support parameter default values.
}
@ -1185,7 +1185,7 @@ void GDScriptAnalyzer::resolve_class_member(GDScriptParser::ClassNode *p_class,
if (member.m_enum->identifier->name == StringName()) {
is_shadowing(element.identifier, "enum member", false);
}
#endif
#endif // DEBUG_ENABLED
}
current_enum = prev_enum;
@ -1273,7 +1273,7 @@ void GDScriptAnalyzer::resolve_class_interface(GDScriptParser::ClassNode *p_clas
if (!p_class->resolved_interface) {
#ifdef DEBUG_ENABLED
bool has_static_data = p_class->has_static_data;
#endif
#endif // DEBUG_ENABLED
if (!parser->has_class(p_class)) {
if (parser_ref.is_null()) {
@ -1322,7 +1322,7 @@ void GDScriptAnalyzer::resolve_class_interface(GDScriptParser::ClassNode *p_clas
has_static_data = member.m_class->has_static_data;
}
}
#endif
#endif // DEBUG_ENABLED
}
#ifdef DEBUG_ENABLED
@ -1336,7 +1336,7 @@ void GDScriptAnalyzer::resolve_class_interface(GDScriptParser::ClassNode *p_clas
}
parser->push_warning(static_unload ? static_unload : p_class, GDScriptWarning::REDUNDANT_STATIC_UNLOAD);
}
#endif
#endif // DEBUG_ENABLED
}
}
@ -1443,7 +1443,7 @@ void GDScriptAnalyzer::resolve_class_body(GDScriptParser::ClassNode *p_class, co
if (member.variable->usages == 0 && String(member.variable->identifier->name).begins_with("_")) {
parser->push_warning(member.variable->identifier, GDScriptWarning::UNUSED_PRIVATE_CLASS_VARIABLE, member.variable->identifier->name);
}
#endif
#endif // DEBUG_ENABLED
if (member.variable->property == GDScriptParser::VariableNode::PROP_SETGET) {
GDScriptParser::FunctionNode *getter_function = nullptr;
@ -1477,7 +1477,7 @@ void GDScriptAnalyzer::resolve_class_body(GDScriptParser::ClassNode *p_class, co
if (member.variable->datatype.builtin_type == Variant::INT && return_datatype.builtin_type == Variant::FLOAT) {
parser->push_warning(member.variable, GDScriptWarning::NARROWING_CONVERSION);
}
#endif
#endif // DEBUG_ENABLED
}
}
}
@ -1503,7 +1503,7 @@ void GDScriptAnalyzer::resolve_class_body(GDScriptParser::ClassNode *p_class, co
if (member.variable->datatype.builtin_type == Variant::FLOAT && setter_function->parameters[0]->datatype.builtin_type == Variant::INT) {
parser->push_warning(member.variable, GDScriptWarning::NARROWING_CONVERSION);
}
#endif
#endif // DEBUG_ENABLED
}
}
@ -1518,7 +1518,7 @@ void GDScriptAnalyzer::resolve_class_body(GDScriptParser::ClassNode *p_class, co
if (member.signal->usages == 0) {
parser->push_warning(member.signal->identifier, GDScriptWarning::UNUSED_SIGNAL, member.signal->identifier->name);
}
#endif
#endif // DEBUG_ENABLED
}
}
@ -1662,7 +1662,7 @@ void GDScriptAnalyzer::resolve_annotation(GDScriptParser::AnnotationNode *p_anno
if (argument_info.type == Variant::INT && value.get_type() == Variant::FLOAT) {
parser->push_warning(argument, GDScriptWarning::NARROWING_CONVERSION);
}
#endif
#endif // DEBUG_ENABLED
if (!Variant::can_convert_strict(value.get_type(), argument_info.type)) {
push_error(vformat(R"(Invalid argument for annotation "%s": argument %d should be "%s" but is "%s".)", p_annotation->name, i + 1, Variant::get_type_name(argument_info.type), argument->get_datatype().to_string()), argument);
@ -1735,7 +1735,7 @@ void GDScriptAnalyzer::resolve_function_signature(GDScriptParser::FunctionNode *
if (function_name == StringName()) {
function_visible_name = p_is_lambda ? "<anonymous lambda>" : "<unknown function>";
}
#endif
#endif // DEBUG_ENABLED
for (int i = 0; i < p_function->parameters.size(); i++) {
resolve_parameter(p_function->parameters[i]);
@ -1879,7 +1879,7 @@ void GDScriptAnalyzer::resolve_function_signature(GDScriptParser::FunctionNode *
if (native_base != StringName()) {
parser->push_warning(p_function, GDScriptWarning::NATIVE_METHOD_OVERRIDE, function_name, native_base);
}
#endif
#endif // DEBUG_ENABLED
}
#endif // TOOLS_ENABLED
}
@ -1888,7 +1888,7 @@ void GDScriptAnalyzer::resolve_function_signature(GDScriptParser::FunctionNode *
if (p_function->return_type == nullptr) {
parser->push_warning(p_function, GDScriptWarning::UNTYPED_DECLARATION, "Function", function_visible_name);
}
#endif
#endif // DEBUG_ENABLED
method_info.default_arguments.append_array(p_function->default_arg_values);
method_info.return_val = p_function->get_datatype().to_property_info("");
@ -1984,7 +1984,7 @@ void GDScriptAnalyzer::resolve_assignable(GDScriptParser::AssignableNode *p_assi
parser->push_warning(p_assignable->identifier, GDScriptWarning::CONFUSABLE_LOCAL_DECLARATION, local.get_name(), p_assignable->identifier->name);
}
}
#endif
#endif // DEBUG_ENABLED
GDScriptParser::DataType specified_type;
bool has_specified_type = p_assignable->datatype_specifier != nullptr;
@ -2034,7 +2034,7 @@ void GDScriptAnalyzer::resolve_assignable(GDScriptParser::AssignableNode *p_assi
if (initializer_type.is_hard_type() && initializer_type.is_variant()) {
parser->push_warning(p_assignable, GDScriptWarning::INFERENCE_ON_VARIANT, p_kind);
}
#endif
#endif // DEBUG_ENABLED
} else {
if (!initializer_type.is_set()) {
push_error(vformat(R"(Could not resolve type for %s "%s".)", p_kind, p_assignable->identifier->name), p_assignable->initializer);
@ -2072,7 +2072,7 @@ void GDScriptAnalyzer::resolve_assignable(GDScriptParser::AssignableNode *p_assi
#ifdef DEBUG_ENABLED
} else if (specified_type.builtin_type == Variant::INT && initializer_type.builtin_type == Variant::FLOAT) {
parser->push_warning(p_assignable->initializer, GDScriptWarning::NARROWING_CONVERSION);
#endif
#endif // DEBUG_ENABLED
}
}
}
@ -2104,7 +2104,7 @@ void GDScriptAnalyzer::resolve_assignable(GDScriptParser::AssignableNode *p_assi
parser->push_warning(p_assignable, GDScriptWarning::ENUM_VARIABLE_WITHOUT_DEFAULT, p_assignable->identifier->name);
}
}
#endif
#endif // DEBUG_ENABLED
type.is_constant = is_constant;
type.is_read_only = false;
@ -2122,7 +2122,7 @@ void GDScriptAnalyzer::resolve_variable(GDScriptParser::VariableNode *p_variable
}
}
is_shadowing(p_variable->identifier, kind, p_is_local);
#endif
#endif // DEBUG_ENABLED
}
void GDScriptAnalyzer::resolve_constant(GDScriptParser::ConstantNode *p_constant, bool p_is_local) {
@ -2136,7 +2136,7 @@ void GDScriptAnalyzer::resolve_constant(GDScriptParser::ConstantNode *p_constant
}
}
is_shadowing(p_constant->identifier, kind, p_is_local);
#endif
#endif // DEBUG_ENABLED
}
void GDScriptAnalyzer::resolve_parameter(GDScriptParser::ParameterNode *p_parameter) {
@ -2326,7 +2326,7 @@ void GDScriptAnalyzer::resolve_for(GDScriptParser::ForNode *p_for) {
} else {
parser->push_warning(p_for->variable, GDScriptWarning::UNTYPED_DECLARATION, R"("for" iterator variable)", p_for->variable->name);
}
#endif
#endif // DEBUG_ENABLED
}
}
@ -2336,7 +2336,7 @@ void GDScriptAnalyzer::resolve_for(GDScriptParser::ForNode *p_for) {
if (p_for->variable) {
is_shadowing(p_for->variable, R"("for" iterator variable)", true);
}
#endif
#endif // DEBUG_ENABLED
}
void GDScriptAnalyzer::resolve_while(GDScriptParser::WhileNode *p_while) {
@ -2365,7 +2365,7 @@ void GDScriptAnalyzer::resolve_assert(GDScriptParser::AssertNode *p_assert) {
parser->push_warning(p_assert->condition, GDScriptWarning::ASSERT_ALWAYS_FALSE);
}
}
#endif
#endif // DEBUG_ENABLED
}
void GDScriptAnalyzer::resolve_match(GDScriptParser::MatchNode *p_match) {
@ -2444,7 +2444,7 @@ void GDScriptAnalyzer::resolve_match_pattern(GDScriptParser::PatternNode *p_matc
if (p_match_pattern->bind->usages == 0 && !String(p_match_pattern->bind->name).begins_with("_")) {
parser->push_warning(p_match_pattern->bind, GDScriptWarning::UNUSED_VARIABLE, p_match_pattern->bind->name);
}
#endif
#endif // DEBUG_ENABLED
break;
case GDScriptParser::PatternNode::PT_ARRAY:
for (int i = 0; i < p_match_pattern->array.size(); i++) {
@ -2504,7 +2504,7 @@ void GDScriptAnalyzer::resolve_return(GDScriptParser::ReturnNode *p_return) {
String called_function_name = static_cast<GDScriptParser::CallNode *>(p_return->return_value)->function_name.operator String();
#ifdef DEBUG_ENABLED
parser->push_warning(p_return, GDScriptWarning::UNSAFE_VOID_RETURN, function_name, called_function_name);
#endif
#endif // DEBUG_ENABLED
mark_node_unsafe(p_return);
} else if (!is_call) {
push_error("A void function cannot return a value.", p_return);
@ -2547,7 +2547,7 @@ void GDScriptAnalyzer::resolve_return(GDScriptParser::ReturnNode *p_return) {
#ifdef DEBUG_ENABLED
} else if (expected_type.builtin_type == Variant::INT && result.builtin_type == Variant::FLOAT) {
parser->push_warning(p_return, GDScriptWarning::NARROWING_CONVERSION);
#endif
#endif // DEBUG_ENABLED
}
}
@ -2681,7 +2681,7 @@ static bool enum_has_value(const GDScriptParser::DataType p_type, int64_t p_valu
}
return false;
}
#endif
#endif // DEBUG_ENABLED
void GDScriptAnalyzer::update_const_expression_builtin_type(GDScriptParser::ExpressionNode *p_expression, const GDScriptParser::DataType &p_type, const char *p_usage, bool p_is_cast) {
if (p_expression->get_datatype() == p_type) {
@ -2708,7 +2708,7 @@ void GDScriptAnalyzer::update_const_expression_builtin_type(GDScriptParser::Expr
if (p_type.kind == GDScriptParser::DataType::ENUM && value_type.builtin_type == Variant::INT && !enum_has_value(p_type, p_expression->reduced_value)) {
parser->push_warning(p_expression, GDScriptWarning::INT_AS_ENUM_WITHOUT_MATCH, p_usage, p_expression->reduced_value.stringify(), p_type.to_string());
}
#endif
#endif // DEBUG_ENABLED
if (value_type.builtin_type == p_type.builtin_type) {
p_expression->set_datatype(p_type);
@ -2728,7 +2728,7 @@ void GDScriptAnalyzer::update_const_expression_builtin_type(GDScriptParser::Expr
if (p_type.builtin_type == Variant::INT && value_type.builtin_type == Variant::FLOAT) {
parser->push_warning(p_expression, GDScriptWarning::NARROWING_CONVERSION);
}
#endif
#endif // DEBUG_ENABLED
p_expression->reduced_value = converted_to;
p_expression->set_datatype(p_type);
@ -2825,7 +2825,7 @@ void GDScriptAnalyzer::reduce_assignment(GDScriptParser::AssignmentNode *p_assig
id->variable_source->assignments++;
}
}
#endif
#endif // DEBUG_ENABLED
reduce_expression(p_assignment->assignee);
@ -2865,7 +2865,7 @@ void GDScriptAnalyzer::reduce_assignment(GDScriptParser::AssignmentNode *p_assig
}
}
}
#endif
#endif // DEBUG_ENABLED
if (p_assignment->assigned_value == nullptr || p_assignment->assignee == nullptr) {
return;
@ -3014,7 +3014,7 @@ void GDScriptAnalyzer::reduce_assignment(GDScriptParser::AssignmentNode *p_assig
parser->push_warning(p_assignment, GDScriptWarning::UNASSIGNED_VARIABLE_OP_ASSIGN, id->name, Variant::get_operator_name(p_assignment->variant_op));
}
}
#endif
#endif // DEBUG_ENABLED
}
void GDScriptAnalyzer::reduce_await(GDScriptParser::AwaitNode *p_await) {
@ -3048,7 +3048,7 @@ void GDScriptAnalyzer::reduce_await(GDScriptParser::AwaitNode *p_await) {
if (!to_await_type.is_coroutine && !to_await_type.is_variant() && to_await_type.builtin_type != Variant::SIGNAL) {
parser->push_warning(p_await, GDScriptWarning::REDUNDANT_AWAIT);
}
#endif
#endif // DEBUG_ENABLED
}
void GDScriptAnalyzer::reduce_binary_op(GDScriptParser::BinaryOpNode *p_binary_op) {
@ -3072,7 +3072,7 @@ void GDScriptAnalyzer::reduce_binary_op(GDScriptParser::BinaryOpNode *p_binary_o
if (p_binary_op->variant_op == Variant::OP_DIVIDE && left_type.builtin_type == Variant::INT && right_type.builtin_type == Variant::INT) {
parser->push_warning(p_binary_op, GDScriptWarning::INTEGER_DIVISION);
}
#endif
#endif // DEBUG_ENABLED
if (p_binary_op->left_operand->is_constant && p_binary_op->right_operand->is_constant) {
p_binary_op->is_constant = true;
@ -3313,7 +3313,7 @@ void GDScriptAnalyzer::reduce_call(GDScriptParser::CallNode *p_call, bool p_is_a
expected_types += "\", or \"" + types[types.size() - 1];
}
parser->push_warning(p_call->arguments[0], GDScriptWarning::UNSAFE_CALL_ARGUMENT, "1", "constructor", function_name, expected_types, "Variant");
#endif
#endif // DEBUG_ENABLED
p_call->set_datatype(call_type);
return;
}
@ -3344,7 +3344,7 @@ void GDScriptAnalyzer::reduce_call(GDScriptParser::CallNode *p_call, bool p_is_a
if (par_type.builtin_type == Variant::INT && arg_type.builtin_type == Variant::FLOAT && builtin_type != Variant::INT) {
parser->push_warning(p_call, GDScriptWarning::NARROWING_CONVERSION, function_name);
}
#endif
#endif // DEBUG_ENABLED
}
}
@ -3362,7 +3362,7 @@ void GDScriptAnalyzer::reduce_call(GDScriptParser::CallNode *p_call, bool p_is_a
parser->push_warning(p_call->arguments[i], GDScriptWarning::UNSAFE_CALL_ARGUMENT, itos(i + 1), "constructor", function_name, par_type.to_string(), arg_type.to_string_strict());
}
}
#endif
#endif // DEBUG_ENABLED
}
match = true;
call_type = type_from_property(info.return_val);
@ -3400,7 +3400,7 @@ void GDScriptAnalyzer::reduce_call(GDScriptParser::CallNode *p_call, bool p_is_a
}
}
}
#endif
#endif // DEBUG_ENABLED
p_call->set_datatype(call_type);
return;
@ -3698,7 +3698,7 @@ void GDScriptAnalyzer::reduce_call(GDScriptParser::CallNode *p_call, bool p_is_a
} else if (!is_self && !(base_type.is_hard_type() && base_type.kind == GDScriptParser::DataType::BUILTIN)) {
parser->push_warning(p_call, GDScriptWarning::UNSAFE_METHOD_ACCESS, p_call->function_name, base_type.to_string());
mark_node_unsafe(p_call);
#endif
#endif // DEBUG_ENABLED
}
}
}
@ -3762,7 +3762,7 @@ void GDScriptAnalyzer::reduce_cast(GDScriptParser::CastNode *p_cast) {
mark_node_unsafe(p_cast);
#ifdef DEBUG_ENABLED
parser->push_warning(p_cast, GDScriptWarning::UNSAFE_CAST, cast_type.to_string());
#endif
#endif // DEBUG_ENABLED
} else {
bool valid = false;
if (op_type.builtin_type == Variant::INT && cast_type.kind == GDScriptParser::DataType::ENUM) {
@ -4387,7 +4387,7 @@ void GDScriptAnalyzer::reduce_identifier(GDScriptParser::IdentifierNode *p_ident
if (p_identifier->variable_source && p_identifier->variable_source->assignments == 0 && !(p_identifier->get_datatype().is_hard_type() && p_identifier->get_datatype().kind == GDScriptParser::DataType::BUILTIN)) {
parser->push_warning(p_identifier, GDScriptWarning::UNASSIGNED_VARIABLE, p_identifier->name);
}
#endif
#endif // DEBUG_ENABLED
break;
case GDScriptParser::IdentifierNode::LOCAL_ITERATOR:
p_identifier->set_datatype(p_identifier->bind_source->get_datatype());
@ -4409,7 +4409,7 @@ void GDScriptAnalyzer::reduce_identifier(GDScriptParser::IdentifierNode *p_ident
if (!found_source && p_identifier->suite != nullptr && p_identifier->suite->has_local(p_identifier->name)) {
parser->push_warning(p_identifier, GDScriptWarning::CONFUSABLE_LOCAL_USAGE, p_identifier->name);
}
#endif
#endif // DEBUG_ENABLED
// Not a local, so check members.
@ -4831,7 +4831,7 @@ void GDScriptAnalyzer::reduce_subscript(GDScriptParser::SubscriptNode *p_subscri
if (valid) {
parser->push_warning(p_subscript, GDScriptWarning::UNSAFE_PROPERTY_ACCESS, p_subscript->attribute->name, base_type.to_string());
}
#endif
#endif // DEBUG_ENABLED
result_type.kind = GDScriptParser::DataType::VARIANT;
mark_node_unsafe(p_subscript);
}
@ -5127,7 +5127,7 @@ void GDScriptAnalyzer::reduce_ternary_op(GDScriptParser::TernaryOpNode *p_ternar
result.kind = GDScriptParser::DataType::VARIANT;
#ifdef DEBUG_ENABLED
parser->push_warning(p_ternary_op, GDScriptWarning::INCOMPATIBLE_TERNARY);
#endif
#endif // DEBUG_ENABLED
}
}
}
@ -5855,7 +5855,7 @@ bool GDScriptAnalyzer::get_function_signature(GDScriptParser::Node *p_source, bo
if (native_method && r_native_class) {
*r_native_class = native_method->get_instance_class();
}
#endif
#endif // DEBUG_ENABLED
return valid;
}
@ -5911,7 +5911,7 @@ void GDScriptAnalyzer::validate_call_arg(const List<GDScriptParser::DataType> &p
mark_node_unsafe(p_call->arguments[i]);
parser->push_warning(p_call->arguments[i], GDScriptWarning::UNSAFE_CALL_ARGUMENT, itos(i + 1), "function", p_call->function_name, par_type.to_string(), arg_type.to_string_strict());
}
#endif
#endif // DEBUG_ENABLED
} else if (par_type.is_hard_type() && !is_type_compatible(par_type, arg_type, true)) {
if (!is_type_compatible(arg_type, par_type)) {
push_error(vformat(R"*(Invalid argument for "%s()" function: argument %d should be "%s" but is "%s".)*",
@ -5922,12 +5922,12 @@ void GDScriptAnalyzer::validate_call_arg(const List<GDScriptParser::DataType> &p
// Supertypes are acceptable for dynamic compliance, but it's unsafe.
mark_node_unsafe(p_call);
parser->push_warning(p_call->arguments[i], GDScriptWarning::UNSAFE_CALL_ARGUMENT, itos(i + 1), "function", p_call->function_name, par_type.to_string(), arg_type.to_string_strict());
#endif
#endif // DEBUG_ENABLED
}
#ifdef DEBUG_ENABLED
} else if (par_type.kind == GDScriptParser::DataType::BUILTIN && par_type.builtin_type == Variant::INT && arg_type.kind == GDScriptParser::DataType::BUILTIN && arg_type.builtin_type == Variant::FLOAT) {
parser->push_warning(p_call->arguments[i], GDScriptWarning::NARROWING_CONVERSION, p_call->function_name);
#endif
#endif // DEBUG_ENABLED
}
}
}
@ -6088,7 +6088,7 @@ bool GDScriptAnalyzer::is_type_compatible(const GDScriptParser::DataType &p_targ
}
}
}
#endif
#endif // DEBUG_ENABLED
return check_type_compatibility(p_target, p_source, p_allow_implicit_conversion, p_source_node);
}
@ -6260,7 +6260,7 @@ void GDScriptAnalyzer::mark_node_unsafe(const GDScriptParser::Node *p_node) {
for (int i = p_node->start_line; i <= p_node->end_line; i++) {
parser->unsafe_lines.insert(i);
}
#endif
#endif // DEBUG_ENABLED
}
void GDScriptAnalyzer::downgrade_node_type_source(GDScriptParser::Node *p_node) {
@ -6376,7 +6376,7 @@ Error GDScriptAnalyzer::resolve_body() {
#ifdef DEBUG_ENABLED
// Apply here, after all `@warning_ignore`s have been resolved and applied.
parser->apply_pending_warnings();
#endif
#endif // DEBUG_ENABLED
return parser->errors.is_empty() ? OK : ERR_PARSE_ERROR;
}

View file

@ -30,7 +30,7 @@
#include "class_db_api_json.h"
#ifdef DEBUG_METHODS_ENABLED
#ifdef DEBUG_ENABLED
#include "core/config/project_settings.h"
#include "core/io/file_access.h"
@ -232,4 +232,4 @@ void class_db_api_to_json(const String &p_output_file, ClassDB::APIType p_api) {
print_line(String() + "ClassDB API JSON written to: " + ProjectSettings::get_singleton()->globalize_path(p_output_file));
}
#endif // DEBUG_METHODS_ENABLED
#endif // DEBUG_ENABLED

View file

@ -30,14 +30,10 @@
#pragma once
// 'core/object/method_bind.h' defines DEBUG_METHODS_ENABLED, but it looks like we
// cannot include it here. That's why we include it through 'core/object/class_db.h'.
#ifdef DEBUG_ENABLED
#include "core/object/class_db.h"
#ifdef DEBUG_METHODS_ENABLED
#include "core/string/ustring.h"
void class_db_api_to_json(const String &p_output_file, ClassDB::APIType p_api);
#endif // DEBUG_METHODS_ENABLED
#endif // DEBUG_ENABLED

View file

@ -39,9 +39,9 @@
#include "utils/path_utils.h"
#include "utils/string_utils.h"
#ifdef DEBUG_METHODS_ENABLED
#ifdef DEBUG_ENABLED
#include "class_db_api_json.h"
#endif
#endif // DEBUG_ENABLED
#ifdef TOOLS_ENABLED
#include "editor/editor_internal_calls.h"
@ -104,14 +104,14 @@ void CSharpLanguage::init() {
return;
}
#endif
#ifdef DEBUG_METHODS_ENABLED
#ifdef DEBUG_ENABLED
if (OS::get_singleton()->get_cmdline_args().find("--class-db-json")) {
class_db_api_to_json("user://class_db_api.json", ClassDB::API_CORE);
#ifdef TOOLS_ENABLED
class_db_api_to_json("user://class_db_api_editor.json", ClassDB::API_EDITOR);
#endif
}
#endif
#endif // DEBUG_ENABLED
GLOBAL_DEF("dotnet/project/assembly_name", "");
#ifdef TOOLS_ENABLED
@ -179,7 +179,7 @@ void CSharpLanguage::finalize() {
ERR_PRINT("Leaked unsafe reference to deleted object: " + itos(id));
}
}
#endif
#endif // DEBUG_ENABLED
memdelete(managed_callable_middleman);
@ -518,7 +518,7 @@ void CSharpLanguage::post_unsafe_reference(Object *p_obj) {
MutexLock lock(unsafe_object_references_lock);
ObjectID id = p_obj->get_instance_id();
unsafe_object_references[id]++;
#endif
#endif // DEBUG_ENABLED
}
void CSharpLanguage::pre_unsafe_unreference(Object *p_obj) {
@ -530,7 +530,7 @@ void CSharpLanguage::pre_unsafe_unreference(Object *p_obj) {
if (--elem->value == 0) {
unsafe_object_references.remove(elem);
}
#endif
#endif // DEBUG_ENABLED
}
void CSharpLanguage::frame() {
@ -932,7 +932,7 @@ void CSharpLanguage::reload_assemblies(bool p_soft_reload) {
#ifdef DEBUG_ENABLED
// If we reached here, the instantiated script must be a placeholder.
CRASH_COND(!obj->get_script_instance()->is_placeholder());
#endif
#endif // DEBUG_ENABLED
}
}
@ -1117,7 +1117,7 @@ bool CSharpLanguage::setup_csharp_script_binding(CSharpScriptBinding &r_script_b
CSharpInstance *csharp_instance = CAST_CSHARP_INSTANCE(p_object->get_script_instance());
CRASH_COND(csharp_instance != nullptr && !csharp_instance->is_destructing_script_instance());
}
#endif
#endif // DEBUG_ENABLED
StringName type_name = p_object->get_class_name();
@ -1140,7 +1140,7 @@ bool CSharpLanguage::setup_csharp_script_binding(CSharpScriptBinding &r_script_b
#ifdef DEBUG_ENABLED
CRASH_COND(!r_script_binding.gchandle.is_released());
#endif
#endif // DEBUG_ENABLED
GCHandleIntPtr strong_gchandle =
GDMonoCache::managed_callbacks.ScriptManagerBridge_CreateManagedForGodotObjectBinding(
@ -1194,8 +1194,8 @@ void CSharpLanguage::_instance_binding_free_callback(void *, void *, void *p_bin
if (GDMono::get_singleton() == nullptr) {
#ifdef DEBUG_ENABLED
CRASH_COND(csharp_lang && !csharp_lang->script_bindings.is_empty());
#endif
// Mono runtime finalized, all the gchandle bindings were already released
#endif // DEBUG_ENABLED
// Mono runtime finalized, all the gchandle bindings were already released
return;
}
@ -1238,7 +1238,7 @@ GDExtensionBool CSharpLanguage::_instance_binding_reference_callback(void *p_tok
#ifdef DEBUG_ENABLED
CRASH_COND(!rc_owner);
#endif
#endif // DEBUG_ENABLED
MonoGCHandleData &gchandle = script_binding.gchandle;
@ -1331,7 +1331,7 @@ void *CSharpLanguage::get_instance_binding_with_setup(Object *p_object) {
void *CSharpLanguage::get_existing_instance_binding(Object *p_object) {
#ifdef DEBUG_ENABLED
CRASH_COND(p_object->has_instance_binding(p_object));
#endif
#endif // DEBUG_ENABLED
return get_instance_binding(p_object);
}
@ -1686,7 +1686,7 @@ bool CSharpInstance::_reference_owner_unsafe() {
CRASH_COND(!base_ref_counted);
CRASH_COND(owner == nullptr);
CRASH_COND(unsafe_referenced); // already referenced
#endif
#endif // DEBUG_ENABLED
// Unsafe refcount increment. The managed instance also counts as a reference.
// This way if the unmanaged world has no references to our owner
@ -1706,7 +1706,7 @@ bool CSharpInstance::_unreference_owner_unsafe() {
#ifdef DEBUG_ENABLED
CRASH_COND(!base_ref_counted);
CRASH_COND(owner == nullptr);
#endif
#endif // DEBUG_ENABLED
if (!unsafe_referenced) {
return false; // Already unreferenced
@ -1754,7 +1754,7 @@ void CSharpInstance::mono_object_disposed(GCHandleIntPtr p_gchandle_to_free) {
#ifdef DEBUG_ENABLED
CRASH_COND(base_ref_counted);
CRASH_COND(gchandle.is_released());
#endif
#endif // DEBUG_ENABLED
CSharpLanguage::get_singleton()->release_script_gchandle_thread_safe(p_gchandle_to_free, gchandle);
}
@ -1762,7 +1762,7 @@ void CSharpInstance::mono_object_disposed_baseref(GCHandleIntPtr p_gchandle_to_f
#ifdef DEBUG_ENABLED
CRASH_COND(!base_ref_counted);
CRASH_COND(gchandle.is_released());
#endif
#endif // DEBUG_ENABLED
// Must make sure event signals are not left dangling
disconnect_event_signals();
@ -1824,7 +1824,7 @@ void CSharpInstance::refcount_incremented() {
#ifdef DEBUG_ENABLED
CRASH_COND(!base_ref_counted);
CRASH_COND(owner == nullptr);
#endif
#endif // DEBUG_ENABLED
RefCounted *rc_owner = Object::cast_to<RefCounted>(owner);
@ -1855,7 +1855,7 @@ bool CSharpInstance::refcount_decremented() {
#ifdef DEBUG_ENABLED
CRASH_COND(!base_ref_counted);
CRASH_COND(owner == nullptr);
#endif
#endif // DEBUG_ENABLED
RefCounted *rc_owner = Object::cast_to<RefCounted>(owner);
@ -2011,7 +2011,7 @@ CSharpInstance::~CSharpInstance() {
#ifdef DEBUG_ENABLED
// The "instance binding" holds a reference so the refcount should be at least 2 before `scope_keep_owner_alive` goes out of scope
CRASH_COND(rc_owner->get_reference_count() <= 1);
#endif
#endif // DEBUG_ENABLED
}
if (script.is_valid() && owner) {
@ -2024,7 +2024,7 @@ CSharpInstance::~CSharpInstance() {
script->instances.remove(match);
#else
script->instances.erase(owner);
#endif
#endif // DEBUG_ENABLED
}
}
@ -2076,7 +2076,7 @@ void GD_CLR_STDCALL CSharpScript::_add_property_info_list_callback(CSharpScript
#if defined(TOOLS_ENABLED) || defined(DEBUG_ENABLED)
p_script->exported_members_names.insert(name);
#endif
#endif // DEBUG_ENABLED
}
}
}
@ -2433,7 +2433,7 @@ Variant CSharpScript::_new(const Variant **p_args, int p_argcount, Callable::Cal
ScriptInstance *CSharpScript::instance_create(Object *p_this) {
#ifdef DEBUG_ENABLED
CRASH_COND(!valid);
#endif
#endif // DEBUG_ENABLED
StringName native_name;
GDMonoCache::managed_callbacks.ScriptManagerBridge_GetScriptNativeName(this, &native_name);
@ -2588,7 +2588,7 @@ Error CSharpScript::reload(bool p_keep_state) {
if (valid) {
#ifdef DEBUG_ENABLED
print_verbose("Found class for script " + get_path());
#endif
#endif // DEBUG_ENABLED
update_script_class_info(this);
@ -2770,7 +2770,7 @@ CSharpScript::CSharpScript() {
MutexLock lock(CSharpLanguage::get_singleton()->script_instances_mutex);
CSharpLanguage::get_singleton()->script_list.add(&script_list);
}
#endif
#endif // DEBUG_ENABLED
}
CSharpScript::~CSharpScript() {
@ -2779,7 +2779,7 @@ CSharpScript::~CSharpScript() {
MutexLock lock(CSharpLanguage::get_singleton()->script_instances_mutex);
CSharpLanguage::get_singleton()->script_list.remove(&script_list);
}
#endif
#endif // DEBUG_ENABLED
if (GDMonoCache::godot_api_cache_updated) {
GDMonoCache::managed_callbacks.ScriptManagerBridge_RemoveScriptBridge(this);
@ -2787,13 +2787,13 @@ CSharpScript::~CSharpScript() {
}
void CSharpScript::get_members(HashSet<StringName> *p_members) {
#if defined(TOOLS_ENABLED) || defined(DEBUG_ENABLED)
#ifdef DEBUG_ENABLED
if (p_members) {
for (const StringName &member_name : exported_members_names) {
p_members->insert(member_name);
}
}
#endif
#endif // DEBUG_ENABLED
}
/*************** RESOURCE ***************/
@ -2821,10 +2821,10 @@ Ref<Resource> ResourceFormatLoaderCSharpScript::load(const String &p_path, const
scr.instantiate();
}
#if defined(DEBUG_ENABLED) || defined(TOOLS_ENABLED)
#ifdef DEBUG_ENABLED
Error err = scr->load_source_code(real_path);
ERR_FAIL_COND_V_MSG(err != OK, Ref<Resource>(), "Cannot load C# script file '" + real_path + "'.");
#endif
#endif // DEBUG_ENABLED
// Only one instance of a C# script is allowed to exist.
ERR_FAIL_COND_V_MSG(!scr->get_path().is_empty() && scr->get_path() != p_original_path, Ref<Resource>(),

View file

@ -30,7 +30,7 @@
#include "bindings_generator.h"
#ifdef DEBUG_METHODS_ENABLED
#ifdef DEBUG_ENABLED
#include "../godotsharp_defs.h"
#include "../utils/naming_utils.h"
@ -5300,4 +5300,4 @@ void BindingsGenerator::handle_cmdline_args(const List<String> &p_cmdline_args)
}
}
#endif
#endif // DEBUG_ENABLED

View file

@ -30,14 +30,13 @@
#pragma once
#include "core/typedefs.h" // DEBUG_METHODS_ENABLED
#ifdef DEBUG_METHODS_ENABLED
#ifdef DEBUG_ENABLED
#include "core/doc_data.h"
#include "core/object/class_db.h"
#include "core/string/string_builder.h"
#include "core/string/ustring.h"
#include "core/typedefs.h"
#include "editor/doc_tools.h"
#include "editor/editor_help.h"
@ -873,4 +872,4 @@ public:
}
};
#endif
#endif // DEBUG_ENABLED

View file

@ -585,7 +585,7 @@ static bool _on_core_api_assembly_loaded() {
debug = true;
#else
debug = false;
#endif
#endif // DEBUG_ENABLED
GDMonoCache::managed_callbacks.GD_OnCoreApiAssemblyLoaded(debug);
@ -690,13 +690,13 @@ void GDMono::_try_load_project_assembly() {
#endif
void GDMono::_init_godot_api_hashes() {
#ifdef DEBUG_METHODS_ENABLED
#ifdef DEBUG_ENABLED
get_api_core_hash();
#ifdef TOOLS_ENABLED
get_api_editor_hash();
#endif // TOOLS_ENABLED
#endif // DEBUG_METHODS_ENABLED
#endif // DEBUG_ENABLED
}
#ifdef TOOLS_ENABLED

View file

@ -76,9 +76,9 @@ class GDMono {
void _try_load_project_assembly();
#endif
#ifdef DEBUG_METHODS_ENABLED
#ifdef DEBUG_ENABLED
uint64_t api_core_hash = 0;
#endif
#endif // DEBUG_ENABLED
#ifdef TOOLS_ENABLED
uint64_t api_editor_hash = 0;
#endif
@ -92,7 +92,7 @@ protected:
static GDMono *singleton;
public:
#ifdef DEBUG_METHODS_ENABLED
#ifdef DEBUG_ENABLED
uint64_t get_api_core_hash() {
if (api_core_hash == 0) {
api_core_hash = ClassDB::get_api_hash(ClassDB::API_CORE);
@ -107,7 +107,7 @@ public:
return api_editor_hash;
}
#endif // TOOLS_ENABLED
#endif // DEBUG_METHODS_ENABLED
#endif // DEBUG_ENABLED
_FORCE_INLINE_ static String get_expected_api_build_config() {
#ifdef TOOLS_ENABLED
@ -117,7 +117,7 @@ public:
return "Debug";
#else
return "Release";
#endif
#endif // DEBUG_ENABLED
#endif
}