Merge pull request #66435 from akien-mga/style-header-guards-cleanup

Cleanup header guards for consistency
This commit is contained in:
Rémi Verschelde 2022-09-26 15:48:56 +02:00
commit 926c1127e9
30 changed files with 106 additions and 70 deletions

View File

@ -28,6 +28,9 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifndef CONVEX_HULL_H
#define CONVEX_HULL_H
/*
Copyright (c) 2011 Ole Kniemeyer, MAXON, www.maxon.net
This software is provided 'as-is', without any express or implied warranty.
@ -40,9 +43,6 @@ subject to the following restrictions:
3. This notice may not be removed or altered from any source distribution.
*/
#ifndef CONVEX_HULL_H
#define CONVEX_HULL_H
#include "core/math/geometry_3d.h"
#include "core/math/vector3.h"
#include "core/templates/local_vector.h"

View File

@ -28,11 +28,11 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
// Note: _GODOT suffix added to avoid conflict with ICU header with the same guard.
#ifndef USTRING_GODOT_H
#define USTRING_GODOT_H
// Note: _GODOT suffix added to header guard to avoid conflict with ICU header.
#include "core/string/char_utils.h"
#include "core/templates/cowdata.h"
#include "core/templates/vector.h"

View File

@ -28,7 +28,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#pragma once
#ifndef POOLED_LIST_H
#define POOLED_LIST_H
// Simple template to provide a pool with O(1) allocate and free.
// The freelist could alternatively be a linked list placed within the unused elements
@ -206,3 +207,5 @@ private:
LocalVector<U, U> _active_map;
LocalVector<U, U> _active_list;
};
#endif // POOLED_LIST_H

View File

@ -28,11 +28,11 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "scene/gui/tree.h"
#ifndef EDITOR_DEBUGGER_TREE_H
#define EDITOR_DEBUGGER_TREE_H
#include "scene/gui/tree.h"
class SceneDebuggerTree;
class EditorFileDialog;

View File

@ -5,11 +5,15 @@ if [ ! -f "version.py" ]; then
echo "Some of the paths checks may not work as intended from a different folder."
fi
files_invalid_guard=""
for file in $(find -name "thirdparty" -prune -o -name "*.h" -print); do
# Skip *.gen.h and *-so_wrap.h, they're generated.
if [[ "$file" == *".gen.h" || "$file" == *"-so_wrap.h" ]]; then continue; fi
# Has important define before normal header guards.
if [[ "$file" == *"thread.h" || "$file" == *"platform_config.h" ]]; then continue; fi
# Obj-C files don't use header guards.
if grep -q "#import " "$file"; then continue; fi
bname=$(basename $file .h)
@ -43,8 +47,21 @@ for file in $(find -name "thirdparty" -prune -o -name "*.h" -print); do
sed -i $file -e "$ s/#endif.*/\n#endif \/\/ $guard/"
# Removes redundant \n added before, if they weren't needed.
sed -i $file -e "/^$/N;/^\n$/D"
# Check that first ifndef (should be header guard) is at the expected position.
# If not it can mean we have some code before the guard that should be after.
# "31" is the expected line with the copyright header.
first_ifndef=$(grep -n -m 1 "ifndef" $file | sed 's/\([0-9]*\).*/\1/')
if [[ "$first_ifndef" != "31" ]]; then
files_invalid_guard+="$file\n"
fi
done
if [[ ! -z "$files_invalid_guard" ]]; then
echo -e "The following files were found to have potentially invalid header guard:\n"
echo -e "$files_invalid_guard"
fi
diff=$(git diff --color)
# If no diff has been generated all is OK, clean up, and exit.

View File

@ -28,7 +28,12 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifndef GLTF_REGISTER_TYPES_H
#define GLTF_REGISTER_TYPES_H
#include "modules/register_module_types.h"
void initialize_gltf_module(ModuleInitializationLevel p_level);
void uninitialize_gltf_module(ModuleInitializationLevel p_level);
#endif // GLTF_REGISTER_TYPES_H

View File

@ -28,13 +28,13 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "core/string/ustring.h"
#ifndef MONO_MACOS_UTILS_H
#define MONO_MACOS_UTILS_H
#ifdef MACOS_ENABLED
#include "core/string/ustring.h"
bool macos_is_app_bundle_installed(const String &p_bundle_id);
#endif

View File

@ -1,5 +1,5 @@
/*************************************************************************/
/* lightmap_raycaster.cpp */
/* lightmap_raycaster_embree.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@ -30,7 +30,7 @@
#ifdef TOOLS_ENABLED
#include "lightmap_raycaster.h"
#include "lightmap_raycaster_embree.h"
#ifdef __SSE2__
#include <pmmintrin.h>
@ -193,4 +193,4 @@ LightmapRaycasterEmbree::~LightmapRaycasterEmbree() {
}
}
#endif
#endif // TOOLS_ENABLED

View File

@ -1,5 +1,5 @@
/*************************************************************************/
/* lightmap_raycaster.h */
/* lightmap_raycaster_embree.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@ -28,6 +28,9 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifndef LIGHTMAP_RAYCASTER_EMBREE_H
#define LIGHTMAP_RAYCASTER_EMBREE_H
#ifdef TOOLS_ENABLED
#include "core/io/image.h"
@ -74,4 +77,6 @@ public:
~LightmapRaycasterEmbree();
};
#endif // LIGHTMAP_RAYCASTER_H
#endif // TOOLS_ENABLED
#endif // LIGHTMAP_RAYCASTER_EMBREE_H

View File

@ -30,9 +30,9 @@
#include "register_types.h"
#include "lightmap_raycaster.h"
#include "lightmap_raycaster_embree.h"
#include "raycast_occlusion_cull.h"
#include "static_raycaster.h"
#include "static_raycaster_embree.h"
RaycastOcclusionCull *raycast_occlusion_cull = nullptr;

View File

@ -28,7 +28,12 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifndef RAYCAST_REGISTER_TYPES_H
#define RAYCAST_REGISTER_TYPES_H
#include "modules/register_module_types.h"
void initialize_raycast_module(ModuleInitializationLevel p_level);
void uninitialize_raycast_module(ModuleInitializationLevel p_level);
#endif // RAYCAST_REGISTER_TYPES_H

View File

@ -1,5 +1,5 @@
/*************************************************************************/
/* static_raycaster.cpp */
/* static_raycaster_embree.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@ -30,7 +30,7 @@
#ifdef TOOLS_ENABLED
#include "static_raycaster.h"
#include "static_raycaster_embree.h"
#ifdef __SSE2__
#include <pmmintrin.h>
@ -134,4 +134,4 @@ StaticRaycasterEmbree::~StaticRaycasterEmbree() {
}
}
#endif
#endif // TOOLS_ENABLED

View File

@ -1,5 +1,5 @@
/*************************************************************************/
/* static_raycaster.h */
/* static_raycaster_embree.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@ -28,6 +28,9 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifndef STATIC_RAYCASTER_EMBREE_H
#define STATIC_RAYCASTER_EMBREE_H
#ifdef TOOLS_ENABLED
#include "core/math/static_raycaster.h"
@ -61,4 +64,6 @@ public:
~StaticRaycasterEmbree();
};
#endif // STATIC_RAYCASTER_H
#endif // TOOLS_ENABLED
#endif // STATIC_RAYCASTER_EMBREE_H

View File

@ -28,9 +28,6 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
// note, swapped java and godot around in the file name so all the java
// wrappers are together
#ifndef JAVA_GODOT_IO_WRAPPER_H
#define JAVA_GODOT_IO_WRAPPER_H

View File

@ -28,9 +28,6 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
// note, swapped java and godot around in the file name so all the java
// wrappers are together
#ifndef JAVA_GODOT_WRAPPER_H
#define JAVA_GODOT_WRAPPER_H

View File

@ -28,11 +28,11 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifdef IOS_ENABLED
#ifndef OS_IOS_H
#define OS_IOS_H
#ifdef IOS_ENABLED
#include "drivers/coreaudio/audio_driver_coreaudio.h"
#include "drivers/unix/os_unix.h"
#include "ios.h"
@ -124,6 +124,6 @@ public:
void on_focus_in();
};
#endif // OS_IOS_H
#endif // IOS_ENABLED
#endif // OS_IOS_H

View File

@ -28,11 +28,13 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifdef X11_ENABLED
#if defined(GLES3_ENABLED)
#ifndef DETECT_PRIME_X11_H
#define DETECT_PRIME_X11_H
#if defined(X11_ENABLED) && defined(GLES3_ENABLED)
int detect_prime();
#endif
#endif // X11_ENABLED && GLES3_ENABLED
#endif // DETECT_PRIME_X11_H

View File

@ -28,6 +28,9 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifndef MACOS_CODESIGN_H
#define MACOS_CODESIGN_H
// macOS code signature creation utility.
//
// Current implementation has the following limitation:
@ -38,9 +41,6 @@
// - Requirements code generator is not implemented (only hard-coded requirements for the ad-hoc signing is supported).
// - RFC5652/CMS blob generation is not implemented, supports ad-hoc signing only.
#ifndef MACOS_CODESIGN_H
#define MACOS_CODESIGN_H
#include "core/crypto/crypto_core.h"
#include "core/io/dir_access.h"
#include "core/io/file_access.h"

View File

@ -28,11 +28,11 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
// Universal / Universal 2 fat binary file creator and extractor.
#ifndef MACOS_LIPO_H
#define MACOS_LIPO_H
// Universal / Universal 2 fat binary file creator and extractor.
#include "core/io/file_access.h"
#include "core/object/ref_counted.h"
#include "modules/modules_enabled.gen.h" // For regex.

View File

@ -28,11 +28,11 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
// Mach-O binary object file format parser and editor.
#ifndef MACOS_MACHO_H
#define MACOS_MACHO_H
// Mach-O binary object file format parser and editor.
#include "core/crypto/crypto.h"
#include "core/crypto/crypto_core.h"
#include "core/io/file_access.h"

View File

@ -28,11 +28,11 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
// Property list file format (application/x-plist) parser, property list ASN-1 serialization.
#ifndef MACOS_PLIST_H
#define MACOS_PLIST_H
// Property list file format (application/x-plist) parser, property list ASN-1 serialization.
#include "core/crypto/crypto_core.h"
#include "core/io/file_access.h"
#include "modules/modules_enabled.gen.h" // For regex.

View File

@ -28,6 +28,9 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifndef EASING_EQUATIONS_H
#define EASING_EQUATIONS_H
/*
* Derived from Robert Penner's easing equations: http://robertpenner.com/easing/
*
@ -52,9 +55,6 @@
* SOFTWARE.
*/
#ifndef EASING_EQUATIONS_H
#define EASING_EQUATIONS_H
namespace linear {
static real_t in(real_t t, real_t b, real_t c, real_t d) {
return c * t / d + b;

View File

@ -28,12 +28,12 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "core/templates/rid.h"
#include "scene/resources/material.h"
#ifndef PARTICLE_PROCESS_MATERIAL_H
#define PARTICLE_PROCESS_MATERIAL_H
#include "core/templates/rid.h"
#include "scene/resources/material.h"
/*
TODO:
-Path following

View File

@ -28,12 +28,12 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "core/templates/rid.h"
#include "scene/resources/material.h"
#ifndef SKY_MATERIAL_H
#define SKY_MATERIAL_H
#include "core/templates/rid.h"
#include "scene/resources/material.h"
class ProceduralSkyMaterial : public Material {
GDCLASS(ProceduralSkyMaterial, Material);

View File

@ -28,6 +28,9 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifndef GODOT_CONE_TWIST_JOINT_3D_H
#define GODOT_CONE_TWIST_JOINT_3D_H
/*
Adapted to Godot from the Bullet library.
*/
@ -49,9 +52,6 @@ subject to the following restrictions:
Written by: Marcus Hennix
*/
#ifndef GODOT_CONE_TWIST_JOINT_3D_H
#define GODOT_CONE_TWIST_JOINT_3D_H
#include "servers/physics_3d/godot_joint_3d.h"
#include "servers/physics_3d/joints/godot_jacobian_entry_3d.h"

View File

@ -28,13 +28,13 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifndef GODOT_GENERIC_6DOF_JOINT_3D_H
#define GODOT_GENERIC_6DOF_JOINT_3D_H
/*
Adapted to Godot from the Bullet library.
*/
#ifndef GODOT_GENERIC_6DOF_JOINT_3D_H
#define GODOT_GENERIC_6DOF_JOINT_3D_H
#include "servers/physics_3d/godot_joint_3d.h"
#include "servers/physics_3d/joints/godot_jacobian_entry_3d.h"

View File

@ -28,13 +28,13 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifndef GODOT_HINGE_JOINT_3D_H
#define GODOT_HINGE_JOINT_3D_H
/*
Adapted to Godot from the Bullet library.
*/
#ifndef GODOT_HINGE_JOINT_3D_H
#define GODOT_HINGE_JOINT_3D_H
#include "servers/physics_3d/godot_joint_3d.h"
#include "servers/physics_3d/joints/godot_jacobian_entry_3d.h"

View File

@ -28,13 +28,13 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifndef GODOT_JACOBIAN_ENTRY_3D_H
#define GODOT_JACOBIAN_ENTRY_3D_H
/*
Adapted to Godot from the Bullet library.
*/
#ifndef GODOT_JACOBIAN_ENTRY_3D_H
#define GODOT_JACOBIAN_ENTRY_3D_H
/*
Bullet Continuous Collision Detection and Physics Library
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/

View File

@ -28,13 +28,13 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifndef GODOT_PIN_JOINT_3D_H
#define GODOT_PIN_JOINT_3D_H
/*
Adapted to Godot from the Bullet library.
*/
#ifndef GODOT_PIN_JOINT_3D_H
#define GODOT_PIN_JOINT_3D_H
#include "servers/physics_3d/godot_joint_3d.h"
#include "servers/physics_3d/joints/godot_jacobian_entry_3d.h"

View File

@ -28,13 +28,13 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifndef GODOT_SLIDER_JOINT_3D_H
#define GODOT_SLIDER_JOINT_3D_H
/*
Adapted to Godot from the Bullet library.
*/
#ifndef GODOT_SLIDER_JOINT_3D_H
#define GODOT_SLIDER_JOINT_3D_H
#include "servers/physics_3d/godot_joint_3d.h"
#include "servers/physics_3d/joints/godot_jacobian_entry_3d.h"