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. --- modules/assimp/editor_scene_importer_assimp.cpp | 1 + modules/bullet/rigid_body_bullet.cpp | 1 + modules/bullet/slider_joint_bullet.cpp | 1 + modules/csg/csg_gizmos.cpp | 4 ++ modules/csg/csg_shape.cpp | 4 ++ modules/enet/networked_multiplayer_enet.cpp | 2 + modules/gdnative/gdnative/string.cpp | 1 + modules/gdnative/nativescript/nativescript.cpp | 25 ++++++++ modules/gdscript/gdscript.cpp | 9 +++ modules/gdscript/gdscript_compiler.cpp | 2 + modules/gdscript/gdscript_editor.cpp | 5 ++ modules/gdscript/gdscript_function.cpp | 2 + modules/gdscript/gdscript_parser.cpp | 1 + modules/gdscript/gdscript_tokenizer.cpp | 7 +++ modules/glslang/register_types.cpp | 1 + modules/gridmap/grid_map.cpp | 2 + modules/lightmapper_rd/lightmapper_rd.cpp | 7 +++ modules/lightmapper_rd/lm_common_inc.glsl | 7 +++ modules/lightmapper_rd/lm_compute.glsl | 2 + modules/lightmapper_rd/lm_raster.glsl | 1 + modules/mbedtls/stream_peer_mbedtls.cpp | 2 + modules/mono/mono_gd/gd_mono.cpp | 1 + modules/mono/mono_gd/gd_mono_utils.h | 1 + modules/mono/mono_gd/support/android_support.cpp | 0 modules/mono/mono_gd/support/ios_support.mm | 0 modules/mono/utils/mono_reg_utils.cpp | 1 + modules/mono/utils/string_utils.cpp | 1 + modules/pvr/texture_loader_pvr.cpp | 2 + modules/stb_vorbis/audio_stream_ogg_vorbis.cpp | 2 + .../stb_vorbis/resource_importer_ogg_vorbis.cpp | 2 + modules/svg/image_loader_svg.cpp | 1 + modules/visual_script/visual_script.cpp | 41 +++++++++++++ .../visual_script/visual_script_builtin_funcs.cpp | 2 + modules/visual_script/visual_script_editor.cpp | 1 + modules/visual_script/visual_script_expression.cpp | 5 ++ .../visual_script/visual_script_flow_control.cpp | 18 ++++++ modules/visual_script/visual_script_func_nodes.cpp | 15 +++++ modules/visual_script/visual_script_nodes.cpp | 67 ++++++++++++++++++++++ .../visual_script/visual_script_yield_nodes.cpp | 4 ++ modules/webm/video_stream_webm.cpp | 7 +++ modules/websocket/websocket_multiplayer_peer.cpp | 1 + 41 files changed, 259 insertions(+) mode change 100755 => 100644 modules/mono/mono_gd/support/android_support.cpp mode change 100755 => 100644 modules/mono/mono_gd/support/ios_support.mm (limited to 'modules') diff --git a/modules/assimp/editor_scene_importer_assimp.cpp b/modules/assimp/editor_scene_importer_assimp.cpp index a861b39537..7f0e27b0ee 100644 --- a/modules/assimp/editor_scene_importer_assimp.cpp +++ b/modules/assimp/editor_scene_importer_assimp.cpp @@ -817,6 +817,7 @@ void EditorSceneImporterAssimp::_import_animation(ImportState &state, int p_anim state.animation_player->add_animation(name, animation); } } + // // Mesh Generation from indices ? why do we need so much mesh code // [debt needs looked into] diff --git a/modules/bullet/rigid_body_bullet.cpp b/modules/bullet/rigid_body_bullet.cpp index 69a81f6f15..f263893287 100644 --- a/modules/bullet/rigid_body_bullet.cpp +++ b/modules/bullet/rigid_body_bullet.cpp @@ -555,6 +555,7 @@ void RigidBodyBullet::set_mode(PhysicsServer3D::BodyMode p_mode) { btBody->setAngularVelocity(btVector3(0, 0, 0)); btBody->setLinearVelocity(btVector3(0, 0, 0)); } + PhysicsServer3D::BodyMode RigidBodyBullet::get_mode() const { return mode; } diff --git a/modules/bullet/slider_joint_bullet.cpp b/modules/bullet/slider_joint_bullet.cpp index c248b78acf..6d5d95d07a 100644 --- a/modules/bullet/slider_joint_bullet.cpp +++ b/modules/bullet/slider_joint_bullet.cpp @@ -119,6 +119,7 @@ real_t SliderJointBullet::getLowerLinLimit() const { void SliderJointBullet::setLowerLinLimit(real_t lowerLimit) { sliderConstraint->setLowerLinLimit(lowerLimit); } + real_t SliderJointBullet::getUpperLinLimit() const { return sliderConstraint->getUpperLinLimit(); } diff --git a/modules/csg/csg_gizmos.cpp b/modules/csg/csg_gizmos.cpp index ad04d9941b..c9569a6d9c 100644 --- a/modules/csg/csg_gizmos.cpp +++ b/modules/csg/csg_gizmos.cpp @@ -70,6 +70,7 @@ String CSGShape3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, return ""; } + Variant CSGShape3DGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const { CSGShape3D *cs = Object::cast_to(p_gizmo->get_spatial_node()); @@ -102,6 +103,7 @@ Variant CSGShape3DGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int return Variant(); } + void CSGShape3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) { CSGShape3D *cs = Object::cast_to(p_gizmo->get_spatial_node()); @@ -200,6 +202,7 @@ void CSGShape3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Ca s->set_outer_radius(d); } } + void CSGShape3DGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) { CSGShape3D *cs = Object::cast_to(p_gizmo->get_spatial_node()); @@ -303,6 +306,7 @@ void CSGShape3DGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, ur->commit_action(); } } + bool CSGShape3DGizmoPlugin::has_gizmo(Node3D *p_spatial) { return Object::cast_to(p_spatial) || Object::cast_to(p_spatial) || Object::cast_to(p_spatial) || Object::cast_to(p_spatial) || Object::cast_to(p_spatial) || Object::cast_to(p_spatial); } diff --git a/modules/csg/csg_shape.cpp b/modules/csg/csg_shape.cpp index 8a0e1097c2..a5ebb1f437 100644 --- a/modules/csg/csg_shape.cpp +++ b/modules/csg/csg_shape.cpp @@ -443,6 +443,7 @@ void CSGShape3D::_update_shape() { set_base(root_mesh->get_rid()); } + AABB CSGShape3D::get_aabb() const { return node_aabb; } @@ -564,6 +565,7 @@ Array CSGShape3D::get_meshes() const { return Array(); } + void CSGShape3D::_bind_methods() { ClassDB::bind_method(D_METHOD("_update_shape"), &CSGShape3D::_update_shape); ClassDB::bind_method(D_METHOD("is_root_shape"), &CSGShape3D::is_root_shape); @@ -627,6 +629,7 @@ CSGShape3D::~CSGShape3D() { brush = nullptr; } } + ////////////////////////////////// CSGBrush *CSGCombiner3D::_build_brush() { @@ -2335,6 +2338,7 @@ void CSGPolygon3D::set_path_interval(float p_interval) { _make_dirty(); update_gizmo(); } + float CSGPolygon3D::get_path_interval() const { return path_interval; } diff --git a/modules/enet/networked_multiplayer_enet.cpp b/modules/enet/networked_multiplayer_enet.cpp index 0ff747c6d8..a53c2a2364 100644 --- a/modules/enet/networked_multiplayer_enet.cpp +++ b/modules/enet/networked_multiplayer_enet.cpp @@ -36,6 +36,7 @@ void NetworkedMultiplayerENet::set_transfer_mode(TransferMode p_mode) { transfer_mode = p_mode; } + NetworkedMultiplayerPeer::TransferMode NetworkedMultiplayerENet::get_transfer_mode() const { return transfer_mode; } @@ -113,6 +114,7 @@ Error NetworkedMultiplayerENet::create_server(int p_port, int p_max_clients, int connection_status = CONNECTION_CONNECTED; return OK; } + Error NetworkedMultiplayerENet::create_client(const String &p_address, int p_port, int p_in_bandwidth, int p_out_bandwidth, int p_client_port) { ERR_FAIL_COND_V_MSG(active, ERR_ALREADY_IN_USE, "The multiplayer instance is already active."); ERR_FAIL_COND_V_MSG(p_port < 0 || p_port > 65535, ERR_INVALID_PARAMETER, "The server port number must be set between 0 and 65535 (inclusive)."); diff --git a/modules/gdnative/gdnative/string.cpp b/modules/gdnative/gdnative/string.cpp index 4cb55900b0..a22af89edc 100644 --- a/modules/gdnative/gdnative/string.cpp +++ b/modules/gdnative/gdnative/string.cpp @@ -137,6 +137,7 @@ signed char GDAPI godot_string_nocasecmp_to(const godot_string *p_self, const go return self->nocasecmp_to(*str); } + signed char GDAPI godot_string_naturalnocasecmp_to(const godot_string *p_self, const godot_string *p_str) { const String *self = (const String *)p_self; const String *str = (const String *)p_str; diff --git a/modules/gdnative/nativescript/nativescript.cpp b/modules/gdnative/nativescript/nativescript.cpp index 70a651be1e..fe9496702a 100644 --- a/modules/gdnative/nativescript/nativescript.cpp +++ b/modules/gdnative/nativescript/nativescript.cpp @@ -817,6 +817,7 @@ bool NativeScriptInstance::set(const StringName &p_name, const Variant &p_value) } return false; } + bool NativeScriptInstance::get(const StringName &p_name, Variant &r_ret) const { NativeScriptDesc *script_data = GET_SCRIPT_DESC(); @@ -1267,22 +1268,29 @@ void NativeScriptLanguage::init() { EditorNode::add_init_callback(&_add_reload_node); #endif } + String NativeScriptLanguage::get_type() const { return "NativeScript"; } + String NativeScriptLanguage::get_extension() const { return "gdns"; } + Error NativeScriptLanguage::execute_file(const String &p_path) { return OK; // Qué? } + void NativeScriptLanguage::finish() { _unload_stuff(); } + void NativeScriptLanguage::get_reserved_words(List *p_words) const { } + void NativeScriptLanguage::get_comment_delimiters(List *p_delimiters) const { } + void NativeScriptLanguage::get_string_delimiters(List *p_delimiters) const { } @@ -1291,6 +1299,7 @@ Ref