mirror of
https://github.com/godotengine/godot.git
synced 2025-10-20 00:13:30 +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
|
@ -184,8 +184,9 @@ bool NativeScript::can_instance() const {
|
|||
Ref<Script> NativeScript::get_base_script() const {
|
||||
NativeScriptDesc *script_data = get_script_desc();
|
||||
|
||||
if (!script_data)
|
||||
if (!script_data) {
|
||||
return Ref<Script>();
|
||||
}
|
||||
|
||||
NativeScript *script = (NativeScript *)NSL->create_script();
|
||||
Ref<NativeScript> ns = Ref<NativeScript>(script);
|
||||
|
@ -199,8 +200,9 @@ Ref<Script> NativeScript::get_base_script() const {
|
|||
StringName NativeScript::get_instance_base_type() const {
|
||||
NativeScriptDesc *script_data = get_script_desc();
|
||||
|
||||
if (!script_data)
|
||||
if (!script_data) {
|
||||
return "";
|
||||
}
|
||||
|
||||
return script_data->base_native_type;
|
||||
}
|
||||
|
@ -272,8 +274,9 @@ bool NativeScript::has_method(const StringName &p_method) const {
|
|||
NativeScriptDesc *script_data = get_script_desc();
|
||||
|
||||
while (script_data) {
|
||||
if (script_data->methods.has(p_method))
|
||||
if (script_data->methods.has(p_method)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
script_data = script_data->base_data;
|
||||
}
|
||||
|
@ -283,14 +286,16 @@ bool NativeScript::has_method(const StringName &p_method) const {
|
|||
MethodInfo NativeScript::get_method_info(const StringName &p_method) const {
|
||||
NativeScriptDesc *script_data = get_script_desc();
|
||||
|
||||
if (!script_data)
|
||||
if (!script_data) {
|
||||
return MethodInfo();
|
||||
}
|
||||
|
||||
while (script_data) {
|
||||
Map<StringName, NativeScriptDesc::Method>::Element *M = script_data->methods.find(p_method);
|
||||
|
||||
if (M)
|
||||
if (M) {
|
||||
return M->get().info;
|
||||
}
|
||||
|
||||
script_data = script_data->base_data;
|
||||
}
|
||||
|
@ -304,8 +309,9 @@ bool NativeScript::is_valid() const {
|
|||
bool NativeScript::is_tool() const {
|
||||
NativeScriptDesc *script_data = get_script_desc();
|
||||
|
||||
if (script_data)
|
||||
if (script_data) {
|
||||
return script_data->is_tool;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -318,8 +324,9 @@ bool NativeScript::has_script_signal(const StringName &p_signal) const {
|
|||
NativeScriptDesc *script_data = get_script_desc();
|
||||
|
||||
while (script_data) {
|
||||
if (script_data->signals_.has(p_signal))
|
||||
if (script_data->signals_.has(p_signal)) {
|
||||
return true;
|
||||
}
|
||||
script_data = script_data->base_data;
|
||||
}
|
||||
return false;
|
||||
|
@ -328,8 +335,9 @@ bool NativeScript::has_script_signal(const StringName &p_signal) const {
|
|||
void NativeScript::get_script_signal_list(List<MethodInfo> *r_signals) const {
|
||||
NativeScriptDesc *script_data = get_script_desc();
|
||||
|
||||
if (!script_data)
|
||||
if (!script_data) {
|
||||
return;
|
||||
}
|
||||
|
||||
Set<MethodInfo> signals_;
|
||||
|
||||
|
@ -354,8 +362,9 @@ bool NativeScript::get_property_default_value(const StringName &p_property, Vari
|
|||
P = script_data->properties.find(p_property);
|
||||
script_data = script_data->base_data;
|
||||
}
|
||||
if (!P)
|
||||
if (!P) {
|
||||
return false;
|
||||
}
|
||||
|
||||
r_value = P.get().default_value;
|
||||
return true;
|
||||
|
@ -367,8 +376,9 @@ void NativeScript::update_exports() {
|
|||
void NativeScript::get_script_method_list(List<MethodInfo> *p_list) const {
|
||||
NativeScriptDesc *script_data = get_script_desc();
|
||||
|
||||
if (!script_data)
|
||||
if (!script_data) {
|
||||
return;
|
||||
}
|
||||
|
||||
Set<MethodInfo> methods;
|
||||
|
||||
|
@ -990,17 +1000,20 @@ String NativeScriptInstance::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();
|
||||
}
|
||||
|
||||
|
@ -1102,8 +1115,9 @@ void NativeScriptInstance::call_multilevel_reversed(const StringName &p_method,
|
|||
NativeScriptInstance::~NativeScriptInstance() {
|
||||
NativeScriptDesc *script_data = GET_SCRIPT_DESC();
|
||||
|
||||
if (!script_data)
|
||||
if (!script_data) {
|
||||
return;
|
||||
}
|
||||
|
||||
script_data->destroy_func.destroy_func((godot_object *)owner, script_data->destroy_func.method_data, userdata);
|
||||
|
||||
|
@ -1155,25 +1169,30 @@ void NativeScriptLanguage::_unload_stuff(bool p_reload) {
|
|||
for (Map<StringName, NativeScriptDesc>::Element *C = classes.front(); C; C = C->next()) {
|
||||
// free property stuff first
|
||||
for (OrderedHashMap<StringName, NativeScriptDesc::Property>::Element P = C->get().properties.front(); P; P = P.next()) {
|
||||
if (P.get().getter.free_func)
|
||||
if (P.get().getter.free_func) {
|
||||
P.get().getter.free_func(P.get().getter.method_data);
|
||||
}
|
||||
|
||||
if (P.get().setter.free_func)
|
||||
if (P.get().setter.free_func) {
|
||||
P.get().setter.free_func(P.get().setter.method_data);
|
||||
}
|
||||
}
|
||||
|
||||
// free method stuff
|
||||
for (Map<StringName, NativeScriptDesc::Method>::Element *M = C->get().methods.front(); M; M = M->next()) {
|
||||
if (M->get().method.free_func)
|
||||
if (M->get().method.free_func) {
|
||||
M->get().method.free_func(M->get().method.method_data);
|
||||
}
|
||||
}
|
||||
|
||||
// free constructor/destructor
|
||||
if (C->get().create_func.free_func)
|
||||
if (C->get().create_func.free_func) {
|
||||
C->get().create_func.free_func(C->get().create_func.method_data);
|
||||
}
|
||||
|
||||
if (C->get().destroy_func.free_func)
|
||||
if (C->get().destroy_func.free_func) {
|
||||
C->get().destroy_func.free_func(C->get().destroy_func.method_data);
|
||||
}
|
||||
}
|
||||
|
||||
erase_and_unload.insert(lib_path, gdn);
|
||||
|
@ -1407,8 +1426,9 @@ int NativeScriptLanguage::profiling_get_accumulated_data(ProfilingInfo *p_info_a
|
|||
int current = 0;
|
||||
|
||||
for (Map<StringName, ProfileData>::Element *d = profile_data.front(); d; d = d->next()) {
|
||||
if (current >= p_info_max)
|
||||
if (current >= p_info_max) {
|
||||
break;
|
||||
}
|
||||
|
||||
p_info_arr[current].call_count = d->get().call_count;
|
||||
p_info_arr[current].self_time = d->get().self_time;
|
||||
|
@ -1430,8 +1450,9 @@ int NativeScriptLanguage::profiling_get_frame_data(ProfilingInfo *p_info_arr, in
|
|||
int current = 0;
|
||||
|
||||
for (Map<StringName, ProfileData>::Element *d = profile_data.front(); d; d = d->next()) {
|
||||
if (current >= p_info_max)
|
||||
if (current >= p_info_max) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (d->get().last_frame_call_count) {
|
||||
p_info_arr[current].call_count = d->get().last_frame_call_count;
|
||||
|
@ -1508,14 +1529,16 @@ void NativeScriptLanguage::unregister_binding_functions(int p_idx) {
|
|||
for (Set<Vector<void *> *>::Element *E = binding_instances.front(); E; E = E->next()) {
|
||||
Vector<void *> &binding_data = *E->get();
|
||||
|
||||
if (p_idx < binding_data.size() && binding_data[p_idx] && binding_functions[p_idx].second.free_instance_binding_data)
|
||||
if (p_idx < binding_data.size() && binding_data[p_idx] && binding_functions[p_idx].second.free_instance_binding_data) {
|
||||
binding_functions[p_idx].second.free_instance_binding_data(binding_functions[p_idx].second.data, binding_data[p_idx]);
|
||||
}
|
||||
}
|
||||
|
||||
binding_functions.write[p_idx].first = false;
|
||||
|
||||
if (binding_functions[p_idx].second.free_func)
|
||||
if (binding_functions[p_idx].second.free_func) {
|
||||
binding_functions[p_idx].second.free_func(binding_functions[p_idx].second.data);
|
||||
}
|
||||
}
|
||||
|
||||
void *NativeScriptLanguage::get_instance_binding_data(int p_idx, Object *p_object) {
|
||||
|
@ -1525,8 +1548,9 @@ void *NativeScriptLanguage::get_instance_binding_data(int p_idx, Object *p_objec
|
|||
|
||||
Vector<void *> *binding_data = (Vector<void *> *)p_object->get_script_instance_binding(lang_idx);
|
||||
|
||||
if (!binding_data)
|
||||
if (!binding_data) {
|
||||
return nullptr; // should never happen.
|
||||
}
|
||||
|
||||
if (binding_data->size() <= p_idx) {
|
||||
// okay, add new elements here.
|
||||
|
@ -1564,14 +1588,16 @@ void *NativeScriptLanguage::alloc_instance_binding_data(Object *p_object) {
|
|||
}
|
||||
|
||||
void NativeScriptLanguage::free_instance_binding_data(void *p_data) {
|
||||
if (!p_data)
|
||||
if (!p_data) {
|
||||
return;
|
||||
}
|
||||
|
||||
Vector<void *> &binding_data = *(Vector<void *> *)p_data;
|
||||
|
||||
for (int i = 0; i < binding_data.size(); i++) {
|
||||
if (!binding_data[i])
|
||||
if (!binding_data[i]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (binding_functions[i].first && binding_functions[i].second.free_instance_binding_data) {
|
||||
binding_functions[i].second.free_instance_binding_data(binding_functions[i].second.data, binding_data[i]);
|
||||
|
@ -1586,17 +1612,20 @@ void NativeScriptLanguage::free_instance_binding_data(void *p_data) {
|
|||
void NativeScriptLanguage::refcount_incremented_instance_binding(Object *p_object) {
|
||||
void *data = p_object->get_script_instance_binding(lang_idx);
|
||||
|
||||
if (!data)
|
||||
if (!data) {
|
||||
return;
|
||||
}
|
||||
|
||||
Vector<void *> &binding_data = *(Vector<void *> *)data;
|
||||
|
||||
for (int i = 0; i < binding_data.size(); i++) {
|
||||
if (!binding_data[i])
|
||||
if (!binding_data[i]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!binding_functions[i].first)
|
||||
if (!binding_functions[i].first) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (binding_functions[i].second.refcount_incremented_instance_binding) {
|
||||
binding_functions[i].second.refcount_incremented_instance_binding(binding_data[i], p_object);
|
||||
|
@ -1607,19 +1636,22 @@ void NativeScriptLanguage::refcount_incremented_instance_binding(Object *p_objec
|
|||
bool NativeScriptLanguage::refcount_decremented_instance_binding(Object *p_object) {
|
||||
void *data = p_object->get_script_instance_binding(lang_idx);
|
||||
|
||||
if (!data)
|
||||
if (!data) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Vector<void *> &binding_data = *(Vector<void *> *)data;
|
||||
|
||||
bool can_die = true;
|
||||
|
||||
for (int i = 0; i < binding_data.size(); i++) {
|
||||
if (!binding_data[i])
|
||||
if (!binding_data[i]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!binding_functions[i].first)
|
||||
if (!binding_functions[i].first) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (binding_functions[i].second.refcount_decremented_instance_binding) {
|
||||
can_die = can_die && binding_functions[i].second.refcount_decremented_instance_binding(binding_data[i], p_object);
|
||||
|
@ -1640,13 +1672,15 @@ void NativeScriptLanguage::set_global_type_tag(int p_idx, StringName p_class_nam
|
|||
}
|
||||
|
||||
const void *NativeScriptLanguage::get_global_type_tag(int p_idx, StringName p_class_name) const {
|
||||
if (!global_type_tags.has(p_idx))
|
||||
if (!global_type_tags.has(p_idx)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const HashMap<StringName, const void *> &tags = global_type_tags[p_idx];
|
||||
|
||||
if (!tags.has(p_class_name))
|
||||
if (!tags.has(p_class_name)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const void *tag = tags.get(p_class_name);
|
||||
|
||||
|
@ -1682,8 +1716,9 @@ void NativeScriptLanguage::init_library(const Ref<GDNativeLibrary> &lib) {
|
|||
|
||||
library_classes.insert(lib_path, Map<StringName, NativeScriptDesc>());
|
||||
|
||||
if (!library_script_users.has(lib_path))
|
||||
if (!library_script_users.has(lib_path)) {
|
||||
library_script_users.insert(lib_path, Set<NativeScript *>());
|
||||
}
|
||||
|
||||
void *proc_ptr;
|
||||
|
||||
|
@ -1792,16 +1827,20 @@ String NativeScriptLanguage::get_global_class_name(const String &p_path, String
|
|||
if (!p_path.empty()) {
|
||||
Ref<NativeScript> script = ResourceLoader::load(p_path, "NativeScript");
|
||||
if (script.is_valid()) {
|
||||
if (r_base_type)
|
||||
if (r_base_type) {
|
||||
*r_base_type = script->get_instance_base_type();
|
||||
if (r_icon_path)
|
||||
}
|
||||
if (r_icon_path) {
|
||||
*r_icon_path = script->get_script_class_icon_path();
|
||||
}
|
||||
return script->get_script_class_name();
|
||||
}
|
||||
if (r_base_type)
|
||||
if (r_base_type) {
|
||||
*r_base_type = String();
|
||||
if (r_icon_path)
|
||||
}
|
||||
if (r_icon_path) {
|
||||
*r_icon_path = String();
|
||||
}
|
||||
}
|
||||
return String();
|
||||
}
|
||||
|
@ -1815,8 +1854,9 @@ void NativeReloadNode::_notification(int p_what) {
|
|||
|
||||
switch (p_what) {
|
||||
case NOTIFICATION_WM_FOCUS_OUT: {
|
||||
if (unloaded)
|
||||
if (unloaded) {
|
||||
break;
|
||||
}
|
||||
MutexLock lock(NSL->mutex);
|
||||
NSL->_unload_stuff(true);
|
||||
|
||||
|
@ -1848,8 +1888,9 @@ void NativeReloadNode::_notification(int p_what) {
|
|||
} break;
|
||||
|
||||
case NOTIFICATION_WM_FOCUS_IN: {
|
||||
if (!unloaded)
|
||||
if (!unloaded) {
|
||||
break;
|
||||
}
|
||||
MutexLock lock(NSL->mutex);
|
||||
|
||||
Set<StringName> libs_to_remove;
|
||||
|
@ -1891,8 +1932,9 @@ void NativeReloadNode::_notification(int p_what) {
|
|||
for (Set<NativeScript *>::Element *S = U->get().front(); S; S = S->next()) {
|
||||
NativeScript *script = S->get();
|
||||
|
||||
if (script->placeholders.size() == 0)
|
||||
if (script->placeholders.size() == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (Set<PlaceHolderScriptInstance *>::Element *P = script->placeholders.front(); P; P = P->next()) {
|
||||
script->_update_placeholder(P->get());
|
||||
|
@ -1928,8 +1970,9 @@ bool ResourceFormatLoaderNativeScript::handles_type(const String &p_type) const
|
|||
|
||||
String ResourceFormatLoaderNativeScript::get_resource_type(const String &p_path) const {
|
||||
String el = p_path.get_extension().to_lower();
|
||||
if (el == "gdns")
|
||||
if (el == "gdns") {
|
||||
return "NativeScript";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue