Skip to content

Commit

Permalink
Style: clang-format: Disable AllowShortIfStatementsOnASingleLine
Browse files Browse the repository at this point in the history
Part of godotengine#33027, also discussed in godotengine#29848.

Enforcing the use of brackets even on single line statements would be
preferred, but `clang-format` doesn't have this functionality yet.
  • Loading branch information
akien-mga committed May 10, 2020
1 parent 03b13e0 commit e956e80
Show file tree
Hide file tree
Showing 130 changed files with 969 additions and 513 deletions.
2 changes: 1 addition & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ AllowAllParametersOfDeclarationOnNextLine: false
# AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: true
AllowShortFunctionsOnASingleLine: Inline
AllowShortIfStatementsOnASingleLine: true
# AllowShortIfStatementsOnASingleLine: false
# AllowShortLoopsOnASingleLine: false
# AlwaysBreakAfterDefinitionReturnType: None
# AlwaysBreakAfterReturnType: None
Expand Down
9 changes: 6 additions & 3 deletions core/class_db.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1456,16 +1456,19 @@ Variant ClassDB::class_get_default_property_value(const StringName &p_class, con
}

if (!default_values.has(p_class)) {
if (r_valid != nullptr) *r_valid = false;
if (r_valid != nullptr)
*r_valid = false;
return Variant();
}

if (!default_values[p_class].has(p_property)) {
if (r_valid != nullptr) *r_valid = false;
if (r_valid != nullptr)
*r_valid = false;
return Variant();
}

if (r_valid != nullptr) *r_valid = true;
if (r_valid != nullptr)
*r_valid = true;
return default_values[p_class][p_property];
}

Expand Down
3 changes: 2 additions & 1 deletion core/color.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,8 @@ bool Color::html_is_valid(const String &p_color) {
}

Color Color::named(const String &p_name) {
if (_named_colors.empty()) _populate_named_colors(); // from color_names.inc
if (_named_colors.empty())
_populate_named_colors(); // from color_names.inc
String name = p_name;
// Normalize name
name = name.replace(" ", "");
Expand Down
3 changes: 2 additions & 1 deletion core/color_names.inc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@

static Map<String, Color> _named_colors;
static void _populate_named_colors() {
if (!_named_colors.empty()) return;
if (!_named_colors.empty())
return;
_named_colors.insert("aliceblue", Color(0.94, 0.97, 1.00));
_named_colors.insert("antiquewhite", Color(0.98, 0.92, 0.84));
_named_colors.insert("aqua", Color(0.00, 1.00, 1.00));
Expand Down
24 changes: 16 additions & 8 deletions core/command_queue_mt.h
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,8 @@
cmd->method = p_method; \
SEMIC_SEP_LIST(CMD_ASSIGN_PARAM, N); \
unlock(); \
if (sync) sync->post(); \
if (sync) \
sync->post(); \
}

#define CMD_RET_TYPE(N) CommandRet##N<T, M, COMMA_SEP_LIST(TYPE_ARG, N) COMMA(N) R>
Expand All @@ -269,7 +270,8 @@
cmd->ret = r_ret; \
cmd->sync_sem = ss; \
unlock(); \
if (sync) sync->post(); \
if (sync) \
sync->post(); \
ss->sem.wait(); \
ss->in_use = false; \
}
Expand All @@ -286,7 +288,8 @@
SEMIC_SEP_LIST(CMD_ASSIGN_PARAM, N); \
cmd->sync_sem = ss; \
unlock(); \
if (sync) sync->post(); \
if (sync) \
sync->post(); \
ss->sem.wait(); \
ss->in_use = false; \
}
Expand Down Expand Up @@ -418,12 +421,14 @@ class CommandQueueMT {
}

bool flush_one(bool p_lock = true) {
if (p_lock) lock();
if (p_lock)
lock();
tryagain:

// tried to read an empty queue
if (read_ptr == write_ptr) {
if (p_lock) unlock();
if (p_lock)
unlock();
return false;
}

Expand All @@ -442,15 +447,18 @@ class CommandQueueMT {

read_ptr += size;

if (p_lock) unlock();
if (p_lock)
unlock();
cmd->call();
if (p_lock) lock();
if (p_lock)
lock();

cmd->post();
cmd->~CommandBase();
*(uint32_t *)&command_mem[size_ptr] &= ~1;

if (p_lock) unlock();
if (p_lock)
unlock();
return true;
}

Expand Down
6 changes: 4 additions & 2 deletions core/image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3152,11 +3152,13 @@ void Image::bumpmap_to_normalmap(float bump_scale) {

for (int ty = 0; ty < height; ty++) {
int py = ty + 1;
if (py >= height) py -= height;
if (py >= height)
py -= height;

for (int tx = 0; tx < width; tx++) {
int px = tx + 1;
if (px >= width) px -= width;
if (px >= width)
px -= width;
float here = read_ptr[ty * width + tx];
float to_right = read_ptr[ty * width + px];
float above = read_ptr[py * width + tx];
Expand Down
3 changes: 2 additions & 1 deletion core/io/file_access_pack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,8 @@ Error DirAccessPack::change_dir(String p_dir) {

nd = nd.simplify_path();

if (nd == "") nd = ".";
if (nd == "")
nd = ".";

if (nd.begins_with("/")) {
nd = nd.replace_first("/", "");
Expand Down
12 changes: 8 additions & 4 deletions core/io/ip_address.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,20 @@ struct IP_Address {
public:
//operator Variant() const;
bool operator==(const IP_Address &p_ip) const {
if (p_ip.valid != valid) return false;
if (!valid) return false;
if (p_ip.valid != valid)
return false;
if (!valid)
return false;
for (int i = 0; i < 4; i++)
if (field32[i] != p_ip.field32[i])
return false;
return true;
}
bool operator!=(const IP_Address &p_ip) const {
if (p_ip.valid != valid) return true;
if (!valid) return true;
if (p_ip.valid != valid)
return true;
if (!valid)
return true;
for (int i = 0; i < 4; i++)
if (field32[i] != p_ip.field32[i])
return true;
Expand Down
3 changes: 2 additions & 1 deletion core/io/marshalls.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ static inline int encode_cstring(const char *p_string, uint8_t *p_data) {
len++;
};

if (p_data) *p_data = 0;
if (p_data)
*p_data = 0;
return len + 1;
}

Expand Down
8 changes: 5 additions & 3 deletions core/io/multiplayer_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@ void MultiplayerAPI::set_root_node(Node *p_node) {

void MultiplayerAPI::set_network_peer(const Ref<NetworkedMultiplayerPeer> &p_peer) {

if (p_peer == network_peer) return; // Nothing to do
if (p_peer == network_peer)
return; // Nothing to do

ERR_FAIL_COND_MSG(p_peer.is_valid() && p_peer->get_connection_status() == NetworkedMultiplayerPeer::CONNECTION_DISCONNECTED,
"Supplied NetworkedMultiplayerPeer must be connecting or connected.");
Expand Down Expand Up @@ -787,8 +788,9 @@ void MultiplayerAPI::_send_rpc(Node *p_from, int p_to, bool p_unreliable, bool p

int ofs = 0;

#define MAKE_ROOM(m_amount) \
if (packet_cache.size() < m_amount) packet_cache.resize(m_amount);
#define MAKE_ROOM(m_amount) \
if (packet_cache.size() < m_amount) \
packet_cache.resize(m_amount);

// Encode meta.
// The meta is composed by a single byte that contains (starting from the least segnificant bit):
Expand Down
6 changes: 4 additions & 2 deletions core/io/resource_loader.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,15 +160,17 @@ class ResourceLoader {
static bool get_timestamp_on_load() { return timestamp_on_load; }

static void notify_load_error(const String &p_err) {
if (err_notify) err_notify(err_notify_ud, p_err);
if (err_notify)
err_notify(err_notify_ud, p_err);
}
static void set_error_notify_func(void *p_ud, ResourceLoadErrorNotify p_err_notify) {
err_notify = p_err_notify;
err_notify_ud = p_ud;
}

static void notify_dependency_error(const String &p_path, const String &p_dependency, const String &p_type) {
if (dep_err_notify) dep_err_notify(dep_err_notify_ud, p_path, p_dependency, p_type);
if (dep_err_notify)
dep_err_notify(dep_err_notify_ud, p_path, p_dependency, p_type);
}
static void set_dependency_error_notify_func(void *p_ud, DependencyErrorNotify p_err_notify) {
dep_err_notify = p_err_notify;
Expand Down
3 changes: 2 additions & 1 deletion core/list.h
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,8 @@ class List {

Element *it = front();
while (it) {
if (it->value == p_val) return it;
if (it->value == p_val)
return it;
it = it->next();
};

Expand Down
24 changes: 16 additions & 8 deletions core/math/a_star.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,8 @@ void AStar::connect_points(int p_id, int p_with_id, bool bidirectional) {
}

Segment s(p_id, p_with_id);
if (bidirectional) s.direction = Segment::BIDIRECTIONAL;
if (bidirectional)
s.direction = Segment::BIDIRECTIONAL;

Set<Segment>::Element *element = segments.find(s);
if (element != nullptr) {
Expand Down Expand Up @@ -290,7 +291,8 @@ int AStar::get_closest_point(const Vector3 &p_point, bool p_include_disabled) co

for (OAHashMap<int, Point *>::Iterator it = points.iter(); it.valid; it = points.next_iter(it)) {

if (!p_include_disabled && !(*it.value)->enabled) continue; // Disabled points should not be considered.
if (!p_include_disabled && !(*it.value)->enabled)
continue; // Disabled points should not be considered.

real_t d = p_point.distance_squared_to((*it.value)->pos);
if (closest_id < 0 || d < closest_dist) {
Expand Down Expand Up @@ -340,7 +342,8 @@ bool AStar::_solve(Point *begin_point, Point *end_point) {

pass++;

if (!end_point->enabled) return false;
if (!end_point->enabled)
return false;

bool found_route = false;

Expand Down Expand Up @@ -451,7 +454,8 @@ Vector<Vector3> AStar::get_point_path(int p_from_id, int p_to_id) {
Point *end_point = b;

bool found_route = _solve(begin_point, end_point);
if (!found_route) return Vector<Vector3>();
if (!found_route)
return Vector<Vector3>();

Point *p = end_point;
int pc = 1; // Begin point
Expand Down Expand Up @@ -499,7 +503,8 @@ Vector<int> AStar::get_id_path(int p_from_id, int p_to_id) {
Point *end_point = b;

bool found_route = _solve(begin_point, end_point);
if (!found_route) return Vector<int>();
if (!found_route)
return Vector<int>();

Point *p = end_point;
int pc = 1; // Begin point
Expand Down Expand Up @@ -729,7 +734,8 @@ Vector<Vector2> AStar2D::get_point_path(int p_from_id, int p_to_id) {
AStar::Point *end_point = b;

bool found_route = _solve(begin_point, end_point);
if (!found_route) return Vector<Vector2>();
if (!found_route)
return Vector<Vector2>();

AStar::Point *p = end_point;
int pc = 1; // Begin point
Expand Down Expand Up @@ -777,7 +783,8 @@ Vector<int> AStar2D::get_id_path(int p_from_id, int p_to_id) {
AStar::Point *end_point = b;

bool found_route = _solve(begin_point, end_point);
if (!found_route) return Vector<int>();
if (!found_route)
return Vector<int>();

AStar::Point *p = end_point;
int pc = 1; // Begin point
Expand Down Expand Up @@ -809,7 +816,8 @@ bool AStar2D::_solve(AStar::Point *begin_point, AStar::Point *end_point) {

astar.pass++;

if (!end_point->enabled) return false;
if (!end_point->enabled)
return false;

bool found_route = false;

Expand Down
3 changes: 2 additions & 1 deletion core/math/basis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -783,7 +783,8 @@ void Basis::get_axis_angle(Vector3 &r_axis, real_t &r_angle) const {
real_t s = Math::sqrt((elements[1][2] - elements[2][1]) * (elements[1][2] - elements[2][1]) + (elements[2][0] - elements[0][2]) * (elements[2][0] - elements[0][2]) + (elements[0][1] - elements[1][0]) * (elements[0][1] - elements[1][0])); // s=|axis||sin(angle)|, used to normalise

angle = Math::acos((elements[0][0] + elements[1][1] + elements[2][2] - 1) / 2);
if (angle < 0) s = -s;
if (angle < 0)
s = -s;
x = (elements[2][1] - elements[1][2]) / s;
y = (elements[0][2] - elements[2][0]) / s;
z = (elements[1][0] - elements[0][1]) / s;
Expand Down
9 changes: 6 additions & 3 deletions core/math/camera_matrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -473,20 +473,23 @@ void CameraMatrix::invert() {

/** Divide column by minus pivot value **/
for (i = 0; i < 4; i++) {
if (i != k) matrix[i][k] /= (-pvt_val);
if (i != k)
matrix[i][k] /= (-pvt_val);
}

/** Reduce the matrix **/
for (i = 0; i < 4; i++) {
hold = matrix[i][k];
for (j = 0; j < 4; j++) {
if (i != k && j != k) matrix[i][j] += hold * matrix[k][j];
if (i != k && j != k)
matrix[i][j] += hold * matrix[k][j];
}
}

/** Divide row by pivot **/
for (j = 0; j < 4; j++) {
if (j != k) matrix[k][j] /= pvt_val;
if (j != k)
matrix[k][j] /= pvt_val;
}

/** Replace pivot by reciprocal (at last we can touch it). **/
Expand Down
Loading

0 comments on commit e956e80

Please sign in to comment.