mirror of
https://github.com/godotengine/godot.git
synced 2025-10-20 08:23:29 +00:00
Style: Enforce braces around if blocks and loops
Using clang-tidy's `readability-braces-around-statements`. https://clang.llvm.org/extra/clang-tidy/checks/readability-braces-around-statements.html
This commit is contained in:
parent
07bc4e2f96
commit
0ee0fa42e6
683 changed files with 22803 additions and 12225 deletions
|
@ -133,8 +133,9 @@ VisualScriptNode::TypeGuess VisualScriptNode::guess_output_type(TypeGuess *p_inp
|
|||
}
|
||||
|
||||
Ref<VisualScript> VisualScriptNode::get_visual_script() const {
|
||||
if (scripts_used.size())
|
||||
if (scripts_used.size()) {
|
||||
return Ref<VisualScript>(scripts_used.front()->get());
|
||||
}
|
||||
|
||||
return Ref<VisualScript>();
|
||||
}
|
||||
|
@ -194,8 +195,9 @@ void VisualScript::remove_function(const StringName &p_name) {
|
|||
void VisualScript::rename_function(const StringName &p_name, const StringName &p_new_name) {
|
||||
ERR_FAIL_COND(instances.size());
|
||||
ERR_FAIL_COND(!functions.has(p_name));
|
||||
if (p_new_name == p_name)
|
||||
if (p_new_name == p_name) {
|
||||
return;
|
||||
}
|
||||
|
||||
ERR_FAIL_COND(!String(p_new_name).is_valid_identifier());
|
||||
|
||||
|
@ -506,8 +508,9 @@ bool VisualScript::is_input_value_port_connected(const StringName &p_func, int p
|
|||
const Function &func = functions[p_func];
|
||||
|
||||
for (const Set<DataConnection>::Element *E = func.data_connections.front(); E; E = E->next()) {
|
||||
if (E->get().to_node == p_node && E->get().to_port == p_port)
|
||||
if (E->get().to_node == p_node && E->get().to_port == p_port) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -620,16 +623,21 @@ bool VisualScript::get_variable_export(const StringName &p_name) const {
|
|||
|
||||
void VisualScript::_set_variable_info(const StringName &p_name, const Dictionary &p_info) {
|
||||
PropertyInfo pinfo;
|
||||
if (p_info.has("type"))
|
||||
if (p_info.has("type")) {
|
||||
pinfo.type = Variant::Type(int(p_info["type"]));
|
||||
if (p_info.has("name"))
|
||||
}
|
||||
if (p_info.has("name")) {
|
||||
pinfo.name = p_info["name"];
|
||||
if (p_info.has("hint"))
|
||||
}
|
||||
if (p_info.has("hint")) {
|
||||
pinfo.hint = PropertyHint(int(p_info["hint"]));
|
||||
if (p_info.has("hint_string"))
|
||||
}
|
||||
if (p_info.has("hint_string")) {
|
||||
pinfo.hint_string = p_info["hint_string"];
|
||||
if (p_info.has("usage"))
|
||||
}
|
||||
if (p_info.has("usage")) {
|
||||
pinfo.usage = p_info["usage"];
|
||||
}
|
||||
|
||||
set_variable_info(p_name, pinfo);
|
||||
}
|
||||
|
@ -662,8 +670,9 @@ void VisualScript::set_instance_base_type(const StringName &p_type) {
|
|||
void VisualScript::rename_variable(const StringName &p_name, const StringName &p_new_name) {
|
||||
ERR_FAIL_COND(instances.size());
|
||||
ERR_FAIL_COND(!variables.has(p_name));
|
||||
if (p_new_name == p_name)
|
||||
if (p_new_name == p_name) {
|
||||
return;
|
||||
}
|
||||
|
||||
ERR_FAIL_COND(!String(p_new_name).is_valid_identifier());
|
||||
|
||||
|
@ -682,13 +691,15 @@ void VisualScript::rename_variable(const StringName &p_name, const StringName &p
|
|||
for (List<int>::Element *E = ids.front(); E; E = E->next()) {
|
||||
Ref<VisualScriptVariableGet> nodeget = get_node(F->get(), E->get());
|
||||
if (nodeget.is_valid()) {
|
||||
if (nodeget->get_variable() == p_name)
|
||||
if (nodeget->get_variable() == p_name) {
|
||||
nodeget->set_variable(p_new_name);
|
||||
}
|
||||
} else {
|
||||
Ref<VisualScriptVariableSet> nodeset = get_node(F->get(), E->get());
|
||||
if (nodeset.is_valid()) {
|
||||
if (nodeset->get_variable() == p_name)
|
||||
if (nodeset->get_variable() == p_name) {
|
||||
nodeset->set_variable(p_new_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -713,10 +724,11 @@ void VisualScript::custom_signal_add_argument(const StringName &p_func, Variant:
|
|||
Argument arg;
|
||||
arg.type = p_type;
|
||||
arg.name = p_name;
|
||||
if (p_index < 0)
|
||||
if (p_index < 0) {
|
||||
custom_signals[p_func].push_back(arg);
|
||||
else
|
||||
} else {
|
||||
custom_signals[p_func].insert(0, arg);
|
||||
}
|
||||
}
|
||||
|
||||
void VisualScript::custom_signal_set_argument_type(const StringName &p_func, int p_argidx, Variant::Type p_type) {
|
||||
|
@ -775,8 +787,9 @@ void VisualScript::remove_custom_signal(const StringName &p_name) {
|
|||
void VisualScript::rename_custom_signal(const StringName &p_name, const StringName &p_new_name) {
|
||||
ERR_FAIL_COND(instances.size());
|
||||
ERR_FAIL_COND(!custom_signals.has(p_name));
|
||||
if (p_new_name == p_name)
|
||||
if (p_new_name == p_name) {
|
||||
return;
|
||||
}
|
||||
|
||||
ERR_FAIL_COND(!String(p_new_name).is_valid_identifier());
|
||||
|
||||
|
@ -799,8 +812,9 @@ void VisualScript::get_custom_signal_list(List<StringName> *r_custom_signals) co
|
|||
int VisualScript::get_available_id() const {
|
||||
int max_id = 0;
|
||||
for (Map<StringName, Function>::Element *E = functions.front(); E; E = E->next()) {
|
||||
if (E->get().nodes.empty())
|
||||
if (E->get().nodes.empty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
int last_id = E->get().nodes.back()->key();
|
||||
max_id = MAX(max_id, last_id + 1);
|
||||
|
@ -829,14 +843,16 @@ void VisualScript::_placeholder_erased(PlaceHolderScriptInstance *p_placeholder)
|
|||
}
|
||||
|
||||
void VisualScript::_update_placeholders() {
|
||||
if (placeholders.size() == 0)
|
||||
if (placeholders.size() == 0) {
|
||||
return; //no bother if no placeholders
|
||||
}
|
||||
List<PropertyInfo> pinfo;
|
||||
Map<StringName, Variant> values;
|
||||
|
||||
for (Map<StringName, Variable>::Element *E = variables.front(); E; E = E->next()) {
|
||||
if (!E->get()._export)
|
||||
if (!E->get()._export) {
|
||||
continue;
|
||||
}
|
||||
|
||||
PropertyInfo p = E->get().info;
|
||||
p.name = String(E->key());
|
||||
|
@ -862,8 +878,9 @@ ScriptInstance *VisualScript::instance_create(Object *p_this) {
|
|||
Map<StringName, Variant> values;
|
||||
|
||||
for (Map<StringName, Variable>::Element *E = variables.front(); E; E = E->next()) {
|
||||
if (!E->get()._export)
|
||||
if (!E->get()._export) {
|
||||
continue;
|
||||
}
|
||||
|
||||
PropertyInfo p = E->get().info;
|
||||
p.name = String(E->key());
|
||||
|
@ -940,8 +957,9 @@ void VisualScript::get_script_signal_list(List<MethodInfo> *r_signals) const {
|
|||
}
|
||||
|
||||
bool VisualScript::get_property_default_value(const StringName &p_property, Variant &r_value) const {
|
||||
if (!variables.has(p_property))
|
||||
if (!variables.has(p_property)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
r_value = variables[p_property].default_value;
|
||||
return true;
|
||||
|
@ -973,8 +991,9 @@ bool VisualScript::has_method(const StringName &p_method) const {
|
|||
|
||||
MethodInfo VisualScript::get_method_info(const StringName &p_method) const {
|
||||
const Map<StringName, Function>::Element *E = functions.find(p_method);
|
||||
if (!E)
|
||||
if (!E) {
|
||||
return MethodInfo();
|
||||
}
|
||||
|
||||
MethodInfo mi;
|
||||
mi.name = E->key();
|
||||
|
@ -1014,8 +1033,9 @@ int VisualScript::get_member_line(const StringName &p_member) const {
|
|||
#ifdef TOOLS_ENABLED
|
||||
if (has_function(p_member)) {
|
||||
for (Map<int, Function::NodeData>::Element *E = functions[p_member].nodes.front(); E; E = E->next()) {
|
||||
if (Object::cast_to<VisualScriptFunction>(E->get().node.ptr()))
|
||||
if (Object::cast_to<VisualScriptFunction>(E->get().node.ptr())) {
|
||||
return E->key();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -1092,8 +1112,9 @@ MultiplayerAPI::RPCMode VisualScript::get_rset_mode(const StringName &p_variable
|
|||
|
||||
void VisualScript::_set_data(const Dictionary &p_data) {
|
||||
Dictionary d = p_data;
|
||||
if (d.has("base_type"))
|
||||
if (d.has("base_type")) {
|
||||
base_type = d["base_type"];
|
||||
}
|
||||
|
||||
variables.clear();
|
||||
Array vars = d["variables"];
|
||||
|
@ -1184,10 +1205,11 @@ void VisualScript::_set_data(const Dictionary &p_data) {
|
|||
}
|
||||
}
|
||||
|
||||
if (d.has("is_tool_script"))
|
||||
if (d.has("is_tool_script")) {
|
||||
is_tool_script = d["is_tool_script"];
|
||||
else
|
||||
} else {
|
||||
is_tool_script = false;
|
||||
}
|
||||
|
||||
// Takes all the rpc methods
|
||||
rpc_functions.clear();
|
||||
|
@ -1390,8 +1412,9 @@ VisualScript::~VisualScript() {
|
|||
|
||||
bool VisualScriptInstance::set(const StringName &p_name, const Variant &p_value) {
|
||||
Map<StringName, Variant>::Element *E = variables.find(p_name);
|
||||
if (!E)
|
||||
if (!E) {
|
||||
return false;
|
||||
}
|
||||
|
||||
E->get() = p_value;
|
||||
|
||||
|
@ -1400,8 +1423,9 @@ bool VisualScriptInstance::set(const StringName &p_name, const Variant &p_value)
|
|||
|
||||
bool VisualScriptInstance::get(const StringName &p_name, Variant &r_ret) const {
|
||||
const Map<StringName, Variant>::Element *E = variables.find(p_name);
|
||||
if (!E)
|
||||
if (!E) {
|
||||
return false;
|
||||
}
|
||||
|
||||
r_ret = E->get();
|
||||
return true;
|
||||
|
@ -1409,8 +1433,9 @@ bool VisualScriptInstance::get(const StringName &p_name, Variant &r_ret) const {
|
|||
|
||||
void VisualScriptInstance::get_property_list(List<PropertyInfo> *p_properties) const {
|
||||
for (const Map<StringName, VisualScript::Variable>::Element *E = script->variables.front(); E; E = E->next()) {
|
||||
if (!E->get()._export)
|
||||
if (!E->get()._export) {
|
||||
continue;
|
||||
}
|
||||
PropertyInfo p = E->get().info;
|
||||
p.name = String(E->key());
|
||||
p.usage |= PROPERTY_USAGE_SCRIPT_VARIABLE;
|
||||
|
@ -1421,13 +1446,15 @@ void VisualScriptInstance::get_property_list(List<PropertyInfo> *p_properties) c
|
|||
Variant::Type VisualScriptInstance::get_property_type(const StringName &p_name, bool *r_is_valid) const {
|
||||
const Map<StringName, VisualScript::Variable>::Element *E = script->variables.find(p_name);
|
||||
if (!E) {
|
||||
if (r_is_valid)
|
||||
if (r_is_valid) {
|
||||
*r_is_valid = false;
|
||||
}
|
||||
ERR_FAIL_V(Variant::NIL);
|
||||
}
|
||||
|
||||
if (r_is_valid)
|
||||
if (r_is_valid) {
|
||||
*r_is_valid = true;
|
||||
}
|
||||
|
||||
return E->get().info.type;
|
||||
}
|
||||
|
@ -1462,8 +1489,9 @@ void VisualScriptInstance::get_method_list(List<MethodInfo> *p_list) const {
|
|||
}
|
||||
|
||||
bool VisualScriptInstance::has_method(const StringName &p_method) const {
|
||||
if (p_method == script->get_default_func())
|
||||
if (p_method == script->get_default_func()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return script->functions.has(p_method);
|
||||
}
|
||||
|
@ -1474,8 +1502,9 @@ bool VisualScriptInstance::has_method(const StringName &p_method) const {
|
|||
void VisualScriptInstance::_dependency_step(VisualScriptNodeInstance *node, int p_pass, int *pass_stack, const Variant **input_args, Variant **output_args, Variant *variant_stack, Callable::CallError &r_error, String &error_str, VisualScriptNodeInstance **r_error_node) {
|
||||
ERR_FAIL_COND(node->pass_idx == -1);
|
||||
|
||||
if (pass_stack[node->pass_idx] == p_pass)
|
||||
if (pass_stack[node->pass_idx] == p_pass) {
|
||||
return;
|
||||
}
|
||||
|
||||
pass_stack[node->pass_idx] = p_pass;
|
||||
|
||||
|
@ -1485,8 +1514,9 @@ void VisualScriptInstance::_dependency_step(VisualScriptNodeInstance *node, int
|
|||
|
||||
for (int i = 0; i < dc; i++) {
|
||||
_dependency_step(deps[i], p_pass, pass_stack, input_args, output_args, variant_stack, r_error, error_str, r_error_node);
|
||||
if (r_error.error != Callable::CallError::CALL_OK)
|
||||
if (r_error.error != Callable::CallError::CALL_OK) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1599,8 +1629,9 @@ Variant VisualScriptInstance::_call_internal(const StringName &p_method, void *p
|
|||
}
|
||||
}
|
||||
|
||||
if (error)
|
||||
if (error) {
|
||||
break;
|
||||
}
|
||||
|
||||
//setup output pointers
|
||||
|
||||
|
@ -1684,14 +1715,17 @@ Variant VisualScriptInstance::_call_internal(const StringName &p_method, void *p
|
|||
bool do_break = false;
|
||||
|
||||
if (EngineDebugger::get_script_debugger()->get_lines_left() > 0) {
|
||||
if (EngineDebugger::get_script_debugger()->get_depth() <= 0)
|
||||
if (EngineDebugger::get_script_debugger()->get_depth() <= 0) {
|
||||
EngineDebugger::get_script_debugger()->set_lines_left(EngineDebugger::get_script_debugger()->get_lines_left() - 1);
|
||||
if (EngineDebugger::get_script_debugger()->get_lines_left() <= 0)
|
||||
}
|
||||
if (EngineDebugger::get_script_debugger()->get_lines_left() <= 0) {
|
||||
do_break = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (EngineDebugger::get_script_debugger()->is_breakpoint(current_node_id, source))
|
||||
if (EngineDebugger::get_script_debugger()->is_breakpoint(current_node_id, source)) {
|
||||
do_break = true;
|
||||
}
|
||||
|
||||
if (do_break) {
|
||||
VisualScriptLanguage::singleton->debug_break("Breakpoint", true);
|
||||
|
@ -1988,17 +2022,20 @@ String VisualScriptInstance::to_string(bool *r_valid) {
|
|||
Variant ret = call(CoreStringNames::get_singleton()->_to_string, nullptr, 0, ce);
|
||||
if (ce.error == Callable::CallError::CALL_OK) {
|
||||
if (ret.get_type() != Variant::STRING) {
|
||||
if (r_valid)
|
||||
if (r_valid) {
|
||||
*r_valid = false;
|
||||
}
|
||||
ERR_FAIL_V_MSG(String(), "Wrong type for " + CoreStringNames::get_singleton()->_to_string + ", must be a String.");
|
||||
}
|
||||
if (r_valid)
|
||||
if (r_valid) {
|
||||
*r_valid = true;
|
||||
}
|
||||
return ret.operator String();
|
||||
}
|
||||
}
|
||||
if (r_valid)
|
||||
if (r_valid) {
|
||||
*r_valid = false;
|
||||
}
|
||||
return String();
|
||||
}
|
||||
|
||||
|
@ -2057,16 +2094,21 @@ void VisualScriptInstance::create(const Ref<VisualScript> &p_script, Object *p_o
|
|||
if (Object::cast_to<Node>(p_owner)) {
|
||||
//turn on these if they exist and base is a node
|
||||
Node *node = Object::cast_to<Node>(p_owner);
|
||||
if (p_script->functions.has("_process"))
|
||||
if (p_script->functions.has("_process")) {
|
||||
node->set_process(true);
|
||||
if (p_script->functions.has("_physics_process"))
|
||||
}
|
||||
if (p_script->functions.has("_physics_process")) {
|
||||
node->set_physics_process(true);
|
||||
if (p_script->functions.has("_input"))
|
||||
}
|
||||
if (p_script->functions.has("_input")) {
|
||||
node->set_process_input(true);
|
||||
if (p_script->functions.has("_unhandled_input"))
|
||||
}
|
||||
if (p_script->functions.has("_unhandled_input")) {
|
||||
node->set_process_unhandled_input(true);
|
||||
if (p_script->functions.has("_unhandled_key_input"))
|
||||
}
|
||||
if (p_script->functions.has("_unhandled_key_input")) {
|
||||
node->set_process_unhandled_key_input(true);
|
||||
}
|
||||
}
|
||||
|
||||
for (const Map<StringName, VisualScript::Variable>::Element *E = script->variables.front(); E; E = E->next()) {
|
||||
|
@ -2156,10 +2198,11 @@ void VisualScriptInstance::create(const Ref<VisualScript> &p_script, Object *p_o
|
|||
|
||||
StringName var_name;
|
||||
|
||||
if (Object::cast_to<VisualScriptLocalVar>(*node))
|
||||
if (Object::cast_to<VisualScriptLocalVar>(*node)) {
|
||||
var_name = String(Object::cast_to<VisualScriptLocalVar>(*node)->get_var_name()).strip_edges();
|
||||
else
|
||||
} else {
|
||||
var_name = String(Object::cast_to<VisualScriptLocalVarSet>(*node)->get_var_name()).strip_edges();
|
||||
}
|
||||
|
||||
if (!local_var_indices.has(var_name)) {
|
||||
local_var_indices[var_name] = function.max_stack;
|
||||
|
@ -2491,15 +2534,17 @@ String VisualScriptLanguage::debug_get_error() const {
|
|||
}
|
||||
|
||||
int VisualScriptLanguage::debug_get_stack_level_count() const {
|
||||
if (_debug_parse_err_node >= 0)
|
||||
if (_debug_parse_err_node >= 0) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return _debug_call_stack_pos;
|
||||
}
|
||||
|
||||
int VisualScriptLanguage::debug_get_stack_level_line(int p_level) const {
|
||||
if (_debug_parse_err_node >= 0)
|
||||
if (_debug_parse_err_node >= 0) {
|
||||
return _debug_parse_err_node;
|
||||
}
|
||||
|
||||
ERR_FAIL_INDEX_V(p_level, _debug_call_stack_pos, -1);
|
||||
|
||||
|
@ -2509,8 +2554,9 @@ int VisualScriptLanguage::debug_get_stack_level_line(int p_level) const {
|
|||
}
|
||||
|
||||
String VisualScriptLanguage::debug_get_stack_level_function(int p_level) const {
|
||||
if (_debug_parse_err_node >= 0)
|
||||
if (_debug_parse_err_node >= 0) {
|
||||
return "";
|
||||
}
|
||||
|
||||
ERR_FAIL_INDEX_V(p_level, _debug_call_stack_pos, "");
|
||||
int l = _debug_call_stack_pos - p_level - 1;
|
||||
|
@ -2518,8 +2564,9 @@ String VisualScriptLanguage::debug_get_stack_level_function(int p_level) const {
|
|||
}
|
||||
|
||||
String VisualScriptLanguage::debug_get_stack_level_source(int p_level) const {
|
||||
if (_debug_parse_err_node >= 0)
|
||||
if (_debug_parse_err_node >= 0) {
|
||||
return _debug_parse_err_file;
|
||||
}
|
||||
|
||||
ERR_FAIL_INDEX_V(p_level, _debug_call_stack_pos, "");
|
||||
int l = _debug_call_stack_pos - p_level - 1;
|
||||
|
@ -2527,8 +2574,9 @@ String VisualScriptLanguage::debug_get_stack_level_source(int p_level) const {
|
|||
}
|
||||
|
||||
void VisualScriptLanguage::debug_get_stack_level_locals(int p_level, List<String> *p_locals, List<Variant> *p_values, int p_max_subitems, int p_max_depth) {
|
||||
if (_debug_parse_err_node >= 0)
|
||||
if (_debug_parse_err_node >= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
ERR_FAIL_INDEX(p_level, _debug_call_stack_pos);
|
||||
|
||||
|
@ -2601,15 +2649,17 @@ void VisualScriptLanguage::debug_get_stack_level_locals(int p_level, List<String
|
|||
}
|
||||
|
||||
void VisualScriptLanguage::debug_get_stack_level_members(int p_level, List<String> *p_members, List<Variant> *p_values, int p_max_subitems, int p_max_depth) {
|
||||
if (_debug_parse_err_node >= 0)
|
||||
if (_debug_parse_err_node >= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
ERR_FAIL_INDEX(p_level, _debug_call_stack_pos);
|
||||
int l = _debug_call_stack_pos - p_level - 1;
|
||||
|
||||
Ref<VisualScript> vs = _call_stack[l].instance->get_script();
|
||||
if (vs.is_null())
|
||||
if (vs.is_null()) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<StringName> vars;
|
||||
vs->get_variable_list(&vars);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue