Skip to content

Commit ab75552

Browse files
committed
Unify code formatting across files
1 parent a9b0ea2 commit ab75552

6 files changed

Lines changed: 127 additions & 90 deletions

File tree

.clang-format

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# WIP, some stuff is still formatted in an undesired way.
2+
---
3+
BasedOnStyle: LLVM
4+
5+
IndentWidth: 4
6+
IndentCaseLabels: true
7+
IndentAccessModifiers: false
8+
AccessModifierOffset: -4
9+
10+
SpaceBeforeCpp11BracedList: false
11+
Cpp11BracedListStyle: false
12+
SpacesBeforeTrailingComments: 2
13+
FixNamespaceComments: false
14+
15+
EmptyLineBeforeAccessModifier: Always
16+
WrapNamespaceBodyWithEmptyLines: Always
17+
MaxEmptyLinesToKeep: 3
18+
SeparateDefinitionBlocks: Leave # Should be at least one, but there is no option for that
19+
20+
PackConstructorInitializers: Never
21+
BreakConstructorInitializers: AfterColon
22+
BreakBeforeBraces: Custom
23+
BraceWrapping:
24+
AfterControlStatement: Always
25+
AfterCaseLabel: true
26+
AfterClass: true
27+
AfterEnum: true
28+
AfterFunction: true
29+
AfterNamespace: false
30+
AfterExternBlock: false
31+
AfterStruct: true
32+
AfterUnion: true
33+
BeforeCatch: true
34+
BeforeElse: true
35+
BeforeLambdaBody: false
36+
BeforeWhile: true
37+
SplitEmptyFunction: false
38+
SplitEmptyRecord: false
39+
SplitEmptyNamespace: false
40+
ColumnLimit: 0
41+
42+
QualifierAlignment: Left
43+
ReferenceAlignment: Left
44+
PointerAlignment: Left
45+
AlignArrayOfStructures: None
46+
AlignTrailingComments:
47+
Kind: Leave
48+
---

src/NativeRopeServer.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,7 @@ using namespace godot;
1515
NativeRopeServer* NativeRopeServer::_singleton = nullptr;
1616

1717

18-
NativeRopeServer::NativeRopeServer() :
19-
_tree(nullptr),
20-
_last_time(0.0),
21-
_update_in_editor(false),
22-
_is_running(false)
18+
NativeRopeServer::NativeRopeServer()
2319
{
2420
_singleton = this;
2521
}

src/NativeRopeServer.hpp

Lines changed: 29 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,45 @@
1-
#ifndef NATIVE_ROPE_SERVER_HPP
2-
#define NATIVE_ROPE_SERVER_HPP
1+
#pragma once
32

3+
#include <godot_cpp/classes/curve.hpp>
44
#include <godot_cpp/classes/node2d.hpp>
55
#include <godot_cpp/classes/scene_tree.hpp>
66
#include <godot_cpp/templates/vector.hpp>
7-
#include <godot_cpp/classes/curve.hpp>
87

9-
namespace godot
8+
namespace godot {
9+
10+
class NativeRopeServer : public Object // NOLINT(cppcoreguidelines-special-member-functions)
1011
{
11-
class NativeRopeServer : public Object // NOLINT(cppcoreguidelines-special-member-functions)
12-
{
13-
GDCLASS(NativeRopeServer, Object) // NOLINT
12+
GDCLASS(NativeRopeServer, Object) // NOLINT
1413

15-
public:
16-
NativeRopeServer();
17-
~NativeRopeServer() override;
14+
public:
15+
NativeRopeServer();
16+
~NativeRopeServer() override;
1817

19-
static NativeRopeServer* get_singleton();
18+
static NativeRopeServer* get_singleton();
2019

21-
void register_rope(Node2D* rope);
22-
void unregister_rope(Node2D* rope);
20+
void register_rope(Node2D* rope);
21+
void unregister_rope(Node2D* rope);
2322

24-
void set_update_in_editor(bool value);
25-
bool get_update_in_editor() const;
23+
void set_update_in_editor(bool value);
24+
bool get_update_in_editor() const;
2625

27-
int64_t get_num_ropes() const;
28-
float get_computation_time() const;
26+
int64_t get_num_ropes() const;
27+
float get_computation_time() const;
2928

30-
protected:
31-
static void _bind_methods();
29+
protected:
30+
static void _bind_methods();
3231

33-
private:
34-
void _start_stop_process();
35-
void _on_physics_frame();
32+
private:
33+
void _start_stop_process();
34+
void _on_physics_frame();
3635

37-
private:
38-
static NativeRopeServer* _singleton;
39-
SceneTree* _tree;
40-
Vector<Node2D*> _ropes;
41-
float _last_time;
42-
bool _update_in_editor;
43-
bool _is_running;
44-
};
36+
private:
37+
static NativeRopeServer* _singleton;
38+
SceneTree* _tree = nullptr;
39+
Vector<Node2D*> _ropes;
40+
float _last_time = 0.0;
41+
bool _update_in_editor = false;
42+
bool _is_running = false;
43+
};
4544

4645
}
47-
48-
#endif

src/RopeWindParameters.hpp

Lines changed: 28 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,37 @@
1-
#ifndef NATIVE_ROPE_WIND_PARAMETERS_HPP
2-
#define NATIVE_ROPE_WIND_PARAMETERS_HPP
1+
#pragma once
32

43
#include <godot_cpp/classes/fast_noise_lite.hpp>
54
#include <godot_cpp/classes/resource.hpp>
65

7-
namespace godot
6+
namespace godot {
7+
8+
class RopeWindParameters : public Resource // NOLINT(cppcoreguidelines-special-member-functions)
89
{
9-
class RopeWindParameters : public Resource // NOLINT(cppcoreguidelines-special-member-functions)
10-
{
11-
GDCLASS(RopeWindParameters, Resource) // NOLINT
10+
GDCLASS(RopeWindParameters, Resource) // NOLINT
1211

13-
public:
14-
void set_direction(float angle);
15-
float get_direction() const;
16-
Vector2 get_direction_vector() const;
17-
void set_wind_strength(float strength);
18-
float get_wind_strength() const;
19-
void set_oscillation_strength(float strength);
20-
float get_oscillation_strength() const;
21-
void set_noise(Ref<FastNoiseLite> noise);
22-
Ref<FastNoiseLite> get_noise() const;
23-
void set_enable_wind(bool wind_enabled);
24-
bool get_enable_wind() const;
12+
public:
13+
void set_direction(float angle);
14+
float get_direction() const;
15+
Vector2 get_direction_vector() const;
16+
void set_wind_strength(float strength);
17+
float get_wind_strength() const;
18+
void set_oscillation_strength(float strength);
19+
float get_oscillation_strength() const;
20+
void set_noise(Ref<FastNoiseLite> noise);
21+
Ref<FastNoiseLite> get_noise() const;
22+
void set_enable_wind(bool wind_enabled);
23+
bool get_enable_wind() const;
2524

26-
protected:
27-
static void _bind_methods();
25+
protected:
26+
static void _bind_methods();
2827

29-
private:
30-
Vector2 _wind_direction = {1.0f, 0.0f};
31-
float _angle = 0.0f;
32-
float _wind_strength = 0.0f;
33-
float _oscillation_strength = 0.0f;
34-
Ref<FastNoiseLite> _noise = nullptr;
35-
bool _enable_wind = true;
36-
};
37-
}
28+
private:
29+
Vector2 _wind_direction = { 1.0f, 0.0f };
30+
float _angle = 0.0f;
31+
float _wind_strength = 0.0f;
32+
float _oscillation_strength = 0.0f;
33+
Ref<FastNoiseLite> _noise = nullptr;
34+
bool _enable_wind = true;
35+
};
3836

39-
#endif
37+
}

src/gdlibrary.cpp

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,49 @@
11
#include "gdlibrary.hpp"
22
#include "NativeRopeServer.hpp"
33
#include "RopeWindParameters.hpp"
4-
54
#include <gdextension_interface.h>
5+
#include <godot_cpp/classes/engine.hpp>
66
#include <godot_cpp/core/defs.hpp>
77
#include <godot_cpp/godot.hpp>
8-
#include <godot_cpp/classes/engine.hpp>
98

109
using namespace godot;
1110

1211
static NativeRopeServer* rope_server = nullptr;
1312

14-
15-
void initialize_libropesim(ModuleInitializationLevel p_level) {
16-
if (p_level != MODULE_INITIALIZATION_LEVEL_SCENE) {
13+
void initialize_libropesim(ModuleInitializationLevel p_level)
14+
{
15+
if (p_level != MODULE_INITIALIZATION_LEVEL_SCENE)
1716
return;
18-
}
1917

2018
ClassDB::register_class<NativeRopeServer>();
2119
ClassDB::register_class<RopeWindParameters>();
22-
rope_server = memnew(NativeRopeServer); // NOLINT
20+
rope_server = memnew(NativeRopeServer); // NOLINT
2321
Engine::get_singleton()->register_singleton("NativeRopeServer", rope_server);
2422
}
2523

26-
void uninitialize_libropesim(ModuleInitializationLevel p_level) {
27-
if (p_level != MODULE_INITIALIZATION_LEVEL_SCENE) {
24+
void uninitialize_libropesim(ModuleInitializationLevel p_level)
25+
{
26+
if (p_level != MODULE_INITIALIZATION_LEVEL_SCENE)
2827
return;
29-
}
3028

3129
Engine::get_singleton()->unregister_singleton("NativeRopeServer");
3230
memdelete(rope_server);
3331
rope_server = nullptr;
3432
}
3533

3634
extern "C" {
37-
// Initialization.
38-
// NOLINTNEXTLINE(misc-misplaced-const)
39-
GDExtensionBool GDE_EXPORT libropesim_init(GDExtensionInterfaceGetProcAddress p_get_proc_address, const GDExtensionClassLibraryPtr p_library, GDExtensionInitialization *r_initialization) {
40-
const godot::GDExtensionBinding::InitObject init_obj(p_get_proc_address, p_library, r_initialization);
4135

42-
init_obj.register_initializer(initialize_libropesim);
43-
init_obj.register_terminator(uninitialize_libropesim);
44-
init_obj.set_minimum_library_initialization_level(MODULE_INITIALIZATION_LEVEL_SCENE);
36+
// Initialization
37+
// NOLINTNEXTLINE(misc-misplaced-const)
38+
GDExtensionBool GDE_EXPORT libropesim_init(GDExtensionInterfaceGetProcAddress p_get_proc_address, const GDExtensionClassLibraryPtr p_library, GDExtensionInitialization* r_initialization)
39+
{
40+
const godot::GDExtensionBinding::InitObject init_obj(p_get_proc_address, p_library, r_initialization);
41+
42+
init_obj.register_initializer(initialize_libropesim);
43+
init_obj.register_terminator(uninitialize_libropesim);
44+
init_obj.set_minimum_library_initialization_level(MODULE_INITIALIZATION_LEVEL_SCENE);
45+
46+
return init_obj.init();
47+
}
4548

46-
return init_obj.init();
47-
}
4849
}

src/gdlibrary.hpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1-
#ifndef GDLIBRARY_HPP
2-
#define GDLIBRARY_HPP
1+
#pragma once
32

43
#include <godot_cpp/core/class_db.hpp>
54

65
using namespace godot;
76

87
void initialize_libropesim(ModuleInitializationLevel p_level);
98
void uninitialize_libropesim(ModuleInitializationLevel p_level);
10-
11-
#endif

0 commit comments

Comments
 (0)