diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2020-05-14 14:29:06 +0200 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2020-05-14 16:54:55 +0200 |
commit | 07bc4e2f96f8f47991339654ff4ab16acc19d44f (patch) | |
tree | 43cdc7cfe8239c23065616a931de3769d2db1e86 /main | |
parent | 0be6d925dc3c6413bce7a3ccb49631b8e4a6e67a (diff) |
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.
Diffstat (limited to 'main')
-rw-r--r-- | main/tests/test_gdscript.cpp | 2 | ||||
-rw-r--r-- | main/tests/test_gui.cpp | 1 | ||||
-rw-r--r-- | main/tests/test_math.cpp | 1 | ||||
-rw-r--r-- | main/tests/test_oa_hash_map.cpp | 1 | ||||
-rw-r--r-- | main/tests/test_ordered_hash_map.cpp | 1 | ||||
-rw-r--r-- | main/tests/test_physics_2d.cpp | 1 | ||||
-rw-r--r-- | main/tests/test_physics_3d.cpp | 1 | ||||
-rw-r--r-- | main/tests/test_render.cpp | 1 | ||||
-rw-r--r-- | main/tests/test_shader_lang.cpp | 1 | ||||
-rw-r--r-- | main/tests/test_string.cpp | 1 |
10 files changed, 11 insertions, 0 deletions
diff --git a/main/tests/test_gdscript.cpp b/main/tests/test_gdscript.cpp index d95be7b218..ea6fcee1c0 100644 --- a/main/tests/test_gdscript.cpp +++ b/main/tests/test_gdscript.cpp @@ -991,6 +991,7 @@ MainLoop *test(TestType p_type) { return nullptr; } + } // namespace TestGDScript #else @@ -1001,6 +1002,7 @@ MainLoop *test(TestType p_type) { ERR_PRINT("The GDScript module is disabled, therefore GDScript tests cannot be used."); return nullptr; } + } // namespace TestGDScript #endif diff --git a/main/tests/test_gui.cpp b/main/tests/test_gui.cpp index 14bc13ff61..d46a13d2c0 100644 --- a/main/tests/test_gui.cpp +++ b/main/tests/test_gui.cpp @@ -265,6 +265,7 @@ public: MainLoop *test() { return memnew(TestMainLoop); } + } // namespace TestGUI #endif diff --git a/main/tests/test_math.cpp b/main/tests/test_math.cpp index 33589e37af..14ae81ad26 100644 --- a/main/tests/test_math.cpp +++ b/main/tests/test_math.cpp @@ -695,4 +695,5 @@ MainLoop *test() { return nullptr; } + } // namespace TestMath diff --git a/main/tests/test_oa_hash_map.cpp b/main/tests/test_oa_hash_map.cpp index b14fda15c4..27792c48e6 100644 --- a/main/tests/test_oa_hash_map.cpp +++ b/main/tests/test_oa_hash_map.cpp @@ -152,4 +152,5 @@ MainLoop *test() { return nullptr; } + } // namespace TestOAHashMap diff --git a/main/tests/test_ordered_hash_map.cpp b/main/tests/test_ordered_hash_map.cpp index 12d9e7906c..aba222fbba 100644 --- a/main/tests/test_ordered_hash_map.cpp +++ b/main/tests/test_ordered_hash_map.cpp @@ -169,4 +169,5 @@ MainLoop *test() { return nullptr; } + } // namespace TestOrderedHashMap diff --git a/main/tests/test_physics_2d.cpp b/main/tests/test_physics_2d.cpp index 7bb6dfedc9..9b37033354 100644 --- a/main/tests/test_physics_2d.cpp +++ b/main/tests/test_physics_2d.cpp @@ -402,4 +402,5 @@ namespace TestPhysics2D { MainLoop *test() { return memnew(TestPhysics2DMainLoop); } + } // namespace TestPhysics2D diff --git a/main/tests/test_physics_3d.cpp b/main/tests/test_physics_3d.cpp index 0552db86a2..fe54ece98e 100644 --- a/main/tests/test_physics_3d.cpp +++ b/main/tests/test_physics_3d.cpp @@ -409,4 +409,5 @@ namespace TestPhysics3D { MainLoop *test() { return memnew(TestPhysics3DMainLoop); } + } // namespace TestPhysics3D diff --git a/main/tests/test_render.cpp b/main/tests/test_render.cpp index b512a17e55..adae0283e5 100644 --- a/main/tests/test_render.cpp +++ b/main/tests/test_render.cpp @@ -235,4 +235,5 @@ public: MainLoop *test() { return memnew(TestMainLoop); } + } // namespace TestRender diff --git a/main/tests/test_shader_lang.cpp b/main/tests/test_shader_lang.cpp index 42d4841ecf..707a25699f 100644 --- a/main/tests/test_shader_lang.cpp +++ b/main/tests/test_shader_lang.cpp @@ -353,4 +353,5 @@ MainLoop *test() { return nullptr; } + } // namespace TestShaderLang diff --git a/main/tests/test_string.cpp b/main/tests/test_string.cpp index aa59b74371..ca66ef1cf7 100644 --- a/main/tests/test_string.cpp +++ b/main/tests/test_string.cpp @@ -1169,4 +1169,5 @@ MainLoop *test() { return nullptr; } + } // namespace TestString |