From 07bc4e2f96f8f47991339654ff4ab16acc19d44f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Thu, 14 May 2020 14:29:06 +0200 Subject: 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. --- core/object.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'core/object.cpp') diff --git a/core/object.cpp b/core/object.cpp index 50bf7d4d28..64b519f1b9 100644 --- a/core/object.cpp +++ b/core/object.cpp @@ -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 *p_parents) { } + void Object::_get_valid_parents_static(List *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 Object::_get_meta_list_bind() const { return _metaret; } + void Object::get_meta_list(List *p_list) const { List keys; metadata.get_key_list(&keys); @@ -1318,6 +1326,7 @@ void Object::get_signals_connected_to_this(List *p_connections) cons Error Object::connect_compat(const StringName &p_signal, Object *p_to_object, const StringName &p_to_method, const Vector &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 &p_binds, uint32_t p_flags) { ERR_FAIL_COND_V(p_callable.is_null(), ERR_INVALID_PARAMETER); -- cgit v1.2.3