You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-08 12:40:44 +00:00
Style: Enforce separation line between function definitions
I couldn't find a tool that enforces it, so I went the manual route: ``` find -name "thirdparty" -prune \ -o -name "*.cpp" -o -name "*.h" -o -name "*.m" -o -name "*.mm" \ -o -name "*.glsl" > files perl -0777 -pi -e 's/\n}\n([^#])/\n}\n\n\1/g' $(cat files) misc/scripts/fix_style.sh -c ``` This adds a newline after all `}` on the first column, unless they are followed by `#` (typically `#endif`). This leads to having lots of places with two lines between function/class definitions, but clang-format then fixes it as we enforce max one line of separation. This doesn't fix potential occurrences of function definitions which are indented (e.g. for a helper class defined in a .cpp), but it's better than nothing. Also can't be made to run easily on CI/hooks so we'll have to be careful with new code. Part of #33027.
This commit is contained in:
@@ -160,11 +160,13 @@ MethodInfo::MethodInfo(const String &p_name) :
|
||||
name(p_name),
|
||||
flags(METHOD_FLAG_NORMAL) {
|
||||
}
|
||||
|
||||
MethodInfo::MethodInfo(const String &p_name, const PropertyInfo &p_param1) :
|
||||
name(p_name),
|
||||
flags(METHOD_FLAG_NORMAL) {
|
||||
arguments.push_back(p_param1);
|
||||
}
|
||||
|
||||
MethodInfo::MethodInfo(const String &p_name, const PropertyInfo &p_param1, const PropertyInfo &p_param2) :
|
||||
name(p_name),
|
||||
flags(METHOD_FLAG_NORMAL) {
|
||||
@@ -209,12 +211,14 @@ MethodInfo::MethodInfo(Variant::Type ret, const String &p_name) :
|
||||
flags(METHOD_FLAG_NORMAL) {
|
||||
return_val.type = ret;
|
||||
}
|
||||
|
||||
MethodInfo::MethodInfo(Variant::Type ret, const String &p_name, const PropertyInfo &p_param1) :
|
||||
name(p_name),
|
||||
flags(METHOD_FLAG_NORMAL) {
|
||||
return_val.type = ret;
|
||||
arguments.push_back(p_param1);
|
||||
}
|
||||
|
||||
MethodInfo::MethodInfo(Variant::Type ret, const String &p_name, const PropertyInfo &p_param1, const PropertyInfo &p_param2) :
|
||||
name(p_name),
|
||||
flags(METHOD_FLAG_NORMAL) {
|
||||
@@ -320,6 +324,7 @@ bool Object::Connection::operator<(const Connection &p_conn) const {
|
||||
return signal < p_conn.signal;
|
||||
}
|
||||
}
|
||||
|
||||
Object::Connection::Connection(const Variant &p_variant) {
|
||||
Dictionary d = p_variant;
|
||||
if (d.has("signal"))
|
||||
@@ -349,6 +354,7 @@ void Object::_postinitialize() {
|
||||
|
||||
void Object::get_valid_parents_static(List<String> *p_parents) {
|
||||
}
|
||||
|
||||
void Object::_get_valid_parents_static(List<String> *p_parents) {
|
||||
}
|
||||
|
||||
@@ -739,6 +745,7 @@ Variant Object::getvar(const Variant &p_key, bool *r_valid) const {
|
||||
*r_valid = false;
|
||||
return Variant();
|
||||
}
|
||||
|
||||
void Object::setvar(const Variant &p_key, const Variant &p_value, bool *r_valid) {
|
||||
if (r_valid)
|
||||
*r_valid = false;
|
||||
@@ -997,6 +1004,7 @@ Vector<String> Object::_get_meta_list_bind() const {
|
||||
|
||||
return _metaret;
|
||||
}
|
||||
|
||||
void Object::get_meta_list(List<String> *p_list) const {
|
||||
List<Variant> keys;
|
||||
metadata.get_key_list(&keys);
|
||||
@@ -1318,6 +1326,7 @@ void Object::get_signals_connected_to_this(List<Connection> *p_connections) cons
|
||||
Error Object::connect_compat(const StringName &p_signal, Object *p_to_object, const StringName &p_to_method, const Vector<Variant> &p_binds, uint32_t p_flags) {
|
||||
return connect(p_signal, Callable(p_to_object, p_to_method), p_binds, p_flags);
|
||||
}
|
||||
|
||||
Error Object::connect(const StringName &p_signal, const Callable &p_callable, const Vector<Variant> &p_binds, uint32_t p_flags) {
|
||||
ERR_FAIL_COND_V(p_callable.is_null(), ERR_INVALID_PARAMETER);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user