Skip to content

Commit

Permalink
Merge pull request #525 from vnen/update-clang-format
Browse files Browse the repository at this point in the history
Update clang-format to version 11
  • Loading branch information
akien-mga authored Mar 1, 2021
2 parents cee79bb + cba90d6 commit 55c0a2e
Show file tree
Hide file tree
Showing 26 changed files with 62 additions and 288 deletions.
10 changes: 6 additions & 4 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ AlignAfterOpenBracket: DontAlign
AlignTrailingComments: false
AllowAllParametersOfDeclarationOnNextLine: false
# AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: true
# AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Inline
AllowShortIfStatementsOnASingleLine: true
# AllowShortIfStatementsOnASingleLine: false
# AllowShortLoopsOnASingleLine: false
# AlwaysBreakAfterDefinitionReturnType: None
# AlwaysBreakAfterReturnType: None
Expand Down Expand Up @@ -76,7 +76,7 @@ IndentWidth: 4
# IndentWrappedFunctionNames: false
# JavaScriptQuotes: Leave
# JavaScriptWrapImports: true
# KeepEmptyLinesAtTheStartOfBlocks: true
KeepEmptyLinesAtTheStartOfBlocks: false
# MacroBlockBegin: ''
# MacroBlockEnd: ''
# MaxEmptyLinesToKeep: 1
Expand Down Expand Up @@ -112,15 +112,17 @@ UseTab: Always
---
### C++ specific config ###
Language: Cpp
Standard: Cpp03
Standard: Cpp11
---
### ObjC specific config ###
Language: ObjC
Standard: Cpp11
ObjCBlockIndentWidth: 4
# ObjCSpaceAfterProperty: false
# ObjCSpaceBeforeProtocolList: true
---
### Java specific config ###
Language: Java
# BreakAfterJavaFieldAnnotations: false
JavaImportGroups: ['org.godotengine', 'android', 'androidx', 'com.android', 'com.google', 'java', 'javax']
...
16 changes: 12 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -147,14 +147,22 @@ jobs:
static-checks:
name: Static Checks (clang-format)
runs-on: ubuntu-16.04
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v2.3.4

uses: actions/checkout@v2

- name: Make apt sources.list use the default Ubuntu repositories
run: |
sudo rm -f /etc/apt/sources.list.d/*
sudo cp -f misc/ci/sources.list /etc/apt/sources.list
sudo apt-get update
- name: Install dependencies
run: |
sudo apt-get install clang-format-8
sudo apt-get install -qq dos2unix recode clang-format-11
sudo update-alternatives --remove-all clang-format
sudo update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-11 100
- name: Style checks via clang-format
run: |
Expand Down
2 changes: 0 additions & 2 deletions include/core/AABB.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,10 @@ class AABB {

real_t get_area() const; /// get area
inline bool has_no_area() const {

return (size.x <= CMP_EPSILON || size.y <= CMP_EPSILON || size.z <= CMP_EPSILON);
}

inline bool has_no_surface() const {

return (size.x <= CMP_EPSILON && size.y <= CMP_EPSILON && size.z <= CMP_EPSILON);
}

Expand Down
2 changes: 0 additions & 2 deletions include/core/CameraMatrix.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ using namespace godot;
} // namespace

struct CameraMatrix {

enum Planes {
PLANE_NEAR,
PLANE_FAR,
Expand Down Expand Up @@ -84,7 +83,6 @@ struct CameraMatrix {
};

Vector3 CameraMatrix::xform(const Vector3 &p_vec3) const {

Vector3 ret;
ret.x = matrix[0][0] * p_vec3.x + matrix[1][0] * p_vec3.y + matrix[2][0] * p_vec3.z + matrix[3][0];
ret.y = matrix[0][1] * p_vec3.x + matrix[1][1] * p_vec3.y + matrix[2][1] * p_vec3.z + matrix[3][1];
Expand Down
2 changes: 0 additions & 2 deletions include/core/Color.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,10 @@
namespace godot {

struct Color {

private:
// static float _parse_col(const String& p_str, int p_ofs);
public:
union {

struct {
float r;
float g;
Expand Down
4 changes: 0 additions & 4 deletions include/core/Godot.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,6 @@ void register_method(const char *name, M method_ptr, godot_method_rpc_mode rpc_t
template <class D, class B, class R, class... As>
void register_method_explicit(const char *name, R (B::*method_ptr)(As...),
godot_method_rpc_mode rpc_type = GODOT_METHOD_RPC_MODE_DISABLED) {

static_assert(std::is_base_of<B, D>::value, "Explicit class must derive from method class");
register_method(name, static_cast<R (D::*)(As...)>(method_ptr), rpc_type);
}
Expand Down Expand Up @@ -394,7 +393,6 @@ void register_property(const char *name, P(T::*var), P default_value,
godot_method_rpc_mode rpc_mode = GODOT_METHOD_RPC_MODE_DISABLED,
godot_property_usage_flags usage = GODOT_PROPERTY_USAGE_DEFAULT,
godot_property_hint hint = GODOT_PROPERTY_HINT_NONE, String hint_string = "") {

static_assert(T::___CLASS_IS_SCRIPT, "This function must only be used on custom classes");

Variant def_val = default_value;
Expand Down Expand Up @@ -451,7 +449,6 @@ void register_property(const char *name, void (T::*setter)(P), P (T::*getter)(),
godot_method_rpc_mode rpc_mode = GODOT_METHOD_RPC_MODE_DISABLED,
godot_property_usage_flags usage = GODOT_PROPERTY_USAGE_DEFAULT,
godot_property_hint hint = GODOT_PROPERTY_HINT_NONE, String hint_string = "") {

static_assert(T::___CLASS_IS_SCRIPT, "This function must only be used on custom classes");

Variant def_val = default_value;
Expand Down Expand Up @@ -495,7 +492,6 @@ void register_property(const char *name, void (T::*setter)(P), P (T::*getter)()
godot_method_rpc_mode rpc_mode = GODOT_METHOD_RPC_MODE_DISABLED,
godot_property_usage_flags usage = GODOT_PROPERTY_USAGE_DEFAULT,
godot_property_hint hint = GODOT_PROPERTY_HINT_NONE, String hint_string = "") {

register_property(name, setter, (P(T::*)())getter, default_value, rpc_mode, usage, hint, hint_string);
}

Expand Down
1 change: 0 additions & 1 deletion include/core/GodotGlobal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ extern "C" const godot_gdnative_ext_net_3_2_api_struct *net_3_2_api;
extern "C" const void *gdnlib;

class Godot {

public:
static void print(const String &message);
static void print_warning(const String &description, const String &function, const String &file, int line);
Expand Down
1 change: 0 additions & 1 deletion include/core/Math.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,6 @@ inline double stepify(double p_value, double p_step) {
}

inline unsigned int next_power_of_2(unsigned int x) {

if (x == 0)
return 0;

Expand Down
1 change: 0 additions & 1 deletion include/core/PoolArrays.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ class PoolByteArray {

public:
class Read {

friend class PoolByteArray;
godot_pool_byte_array_read_access *_read_access;

Expand Down
5 changes: 0 additions & 5 deletions include/core/Rect2.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ typedef Vector2 Point2;
struct Transform2D;

struct Rect2 {

Point2 position;
Size2 size;

Expand Down Expand Up @@ -48,14 +47,12 @@ struct Rect2 {
bool intersects_segment(const Point2 &p_from, const Point2 &p_to, Point2 *r_position = nullptr, Point2 *r_normal = nullptr) const;

inline bool encloses(const Rect2 &p_rect) const {

return (p_rect.position.x >= position.x) && (p_rect.position.y >= position.y) &&
((p_rect.position.x + p_rect.size.x) < (position.x + size.x)) &&
((p_rect.position.y + p_rect.size.y) < (position.y + size.y));
}

inline bool has_no_area() const {

return (size.x <= 0 || size.y <= 0);
}
Rect2 clip(const Rect2 &p_rect) const;
Expand All @@ -82,7 +79,6 @@ struct Rect2 {
inline bool operator!=(const Rect2 &p_rect) const { return position != p_rect.position || size != p_rect.size; }

inline Rect2 grow(real_t p_by) const {

Rect2 g = *this;
g.position.x -= p_by;
g.position.y -= p_by;
Expand All @@ -92,7 +88,6 @@ struct Rect2 {
}

inline Rect2 expand(const Vector2 &p_vector) const {

Rect2 r = *this;
r.expand_to(p_vector);
return r;
Expand Down
18 changes: 0 additions & 18 deletions include/core/Ref.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ class Ref {
T *reference = nullptr;

void ref(const Ref &p_from) {

if (p_from.reference == reference)
return;

Expand All @@ -31,7 +30,6 @@ class Ref {
}

void ref_pointer(T *p_ref) {

ERR_FAIL_COND(p_ref == nullptr);

if (p_ref->init_ref())
Expand All @@ -40,44 +38,35 @@ class Ref {

public:
inline bool operator<(const Ref<T> &p_r) const {

return reference < p_r.reference;
}
inline bool operator==(const Ref<T> &p_r) const {

return reference == p_r.reference;
}
inline bool operator!=(const Ref<T> &p_r) const {

return reference != p_r.reference;
}

inline T *operator->() {

return reference;
}

inline T *operator*() {

return reference;
}

inline const T *operator->() const {

return reference;
}

inline const T *ptr() const {

return reference;
}
inline T *ptr() {

return reference;
}

inline const T *operator*() const {

return reference;
}

Expand All @@ -88,7 +77,6 @@ class Ref {
}

void operator=(const Ref &p_from) {

ref(p_from);
}

Expand Down Expand Up @@ -118,7 +106,6 @@ class Ref {
}

Ref(const Ref &p_from) {

reference = nullptr;
ref(p_from);
}
Expand All @@ -138,15 +125,13 @@ class Ref {
}

Ref(T *p_reference) {

if (p_reference)
ref_pointer(p_reference);
else
reference = nullptr;
}

Ref(const Variant &p_variant) {

reference = nullptr;
Object *refb = T::___get_from_variant(p_variant);
if (refb == nullptr) {
Expand All @@ -168,7 +153,6 @@ class Ref {
// mutexes will avoid more crashes?

if (reference && reference->unreference()) {

//memdelete(reference);
reference->free();
}
Expand All @@ -181,12 +165,10 @@ class Ref {
}

Ref() {

reference = nullptr;
}

~Ref() {

unref();
}

Expand Down
1 change: 0 additions & 1 deletion include/core/String.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ class PoolStringArray;
class String;

class CharString {

friend class String;

godot_char_string _char_string;
Expand Down
2 changes: 0 additions & 2 deletions include/core/Vector3.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ namespace godot {
class Basis;

struct Vector3 {

enum Axis {
AXIS_X,
AXIS_Y,
Expand Down Expand Up @@ -305,7 +304,6 @@ inline Vector3 operator*(real_t p_scalar, const Vector3 &p_vec) {
}

inline Vector3 vec3_cross(const Vector3 &p_a, const Vector3 &p_b) {

return p_a.cross(p_b);
}

Expand Down
4 changes: 4 additions & 0 deletions misc/ci/sources.list
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
deb http://archive.ubuntu.com/ubuntu/ focal main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ focal-updates main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ focal-security main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse
Loading

0 comments on commit 55c0a2e

Please sign in to comment.