Skip to content

Commit

Permalink
Merge pull request godotengine#29027 from akien-mga/clang-format-8.0
Browse files Browse the repository at this point in the history
Travis: Update clang-format to version 8.0
  • Loading branch information
akien-mga authored May 20, 2019
2 parents 6110bde + b00d7bf commit 9643b2b
Show file tree
Hide file tree
Showing 11 changed files with 46 additions and 60 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ matrix:
addons:
apt:
sources:
- llvm-toolchain-xenial-6.0
- llvm-toolchain-xenial-8
packages:
- clang-format-6.0
- clang-format-8

- env: PLATFORM=x11 TOOLS=yes TARGET=debug CACHE_NAME=${PLATFORM}-tools-mono-gcc-8 MATRIX_EVAL="CC=gcc-8 && CXX=g++-8" EXTRA_ARGS="module_mono_enabled=yes mono_glue=no warnings=extra werror=yes"
os: linux
Expand Down
3 changes: 1 addition & 2 deletions core/io/resource_importer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,8 +301,7 @@ String ResourceFormatImporter::get_import_group_file(const String &p_path) const
bool valid = true;
PathAndType pat;
_get_path_and_type(p_path, pat, &valid);
return valid?pat.group_file:String();

return valid ? pat.group_file : String();
}

bool ResourceFormatImporter::is_import_valid(const String &p_path) const {
Expand Down
2 changes: 1 addition & 1 deletion core/io/resource_importer.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ class ResourceImporter : public Reference {

virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = NULL, Variant *r_metadata = NULL) = 0;

virtual Error import_group_file(const String& p_group_file,const Map<String,Map<StringName, Variant> >&p_source_file_options, const Map<String,String>& p_base_paths) { return ERR_UNAVAILABLE; }
virtual Error import_group_file(const String &p_group_file, const Map<String, Map<StringName, Variant> > &p_source_file_options, const Map<String, String> &p_base_paths) { return ERR_UNAVAILABLE; }
virtual bool are_import_settings_valid(const String &p_path) const { return true; }
virtual String get_import_settings_string() const { return String(); }
};
Expand Down
6 changes: 3 additions & 3 deletions editor/editor_folding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ void EditorFolding::load_resource_folding(RES p_resource, const String &p_path)
_set_unfolds(p_resource.ptr(), unfolds);
}

void EditorFolding::_fill_folds(const Node *p_root, const Node *p_node, Array &p_folds, Array &resource_folds, Array& nodes_folded,Set<RES> &resources) {
void EditorFolding::_fill_folds(const Node *p_root, const Node *p_node, Array &p_folds, Array &resource_folds, Array &nodes_folded, Set<RES> &resources) {
if (p_root != p_node) {
if (!p_node->get_owner()) {
return; //not owned, bye
Expand Down Expand Up @@ -130,7 +130,7 @@ void EditorFolding::_fill_folds(const Node *p_root, const Node *p_node, Array &p
}

for (int i = 0; i < p_node->get_child_count(); i++) {
_fill_folds(p_root, p_node->get_child(i), p_folds, resource_folds, nodes_folded,resources);
_fill_folds(p_root, p_node->get_child(i), p_folds, resource_folds, nodes_folded, resources);
}
}
void EditorFolding::save_scene_folding(const Node *p_scene, const String &p_path) {
Expand Down Expand Up @@ -205,7 +205,7 @@ void EditorFolding::load_scene_folding(Node *p_scene, const String &p_path) {
_set_unfolds(res.ptr(), unfolds2);
}

for(int i=0;i<nodes_folded.size();i++) {
for (int i = 0; i < nodes_folded.size(); i++) {
NodePath fold_path = nodes_folded[i];
if (p_scene->has_node(fold_path)) {
Node *node = p_scene->get_node(fold_path);
Expand Down
2 changes: 1 addition & 1 deletion misc/travis/clang-format.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh

CLANG_FORMAT=clang-format-6.0
CLANG_FORMAT=clang-format-8

if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
# Check the whole commit range against $TRAVIS_BRANCH, the base merge branch
Expand Down
30 changes: 13 additions & 17 deletions scene/audio/audio_stream_player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@

#include "core/engine.h"


void AudioStreamPlayer::_mix_to_bus(const AudioFrame *p_frames,int p_amount) {
void AudioStreamPlayer::_mix_to_bus(const AudioFrame *p_frames, int p_amount) {

int bus_index = AudioServer::get_singleton()->thread_find_bus_index(bus);

Expand Down Expand Up @@ -66,10 +65,8 @@ void AudioStreamPlayer::_mix_to_bus(const AudioFrame *p_frames,int p_amount) {
}
}


void AudioStreamPlayer::_mix_internal(bool p_fadeout) {


//get data
AudioFrame *buffer = mix_buffer.ptrw();
int buffer_size = mix_buffer.size();
Expand All @@ -94,15 +91,14 @@ void AudioStreamPlayer::_mix_internal(bool p_fadeout) {
//set volume for next mix
mix_volume_db = target_volume;

_mix_to_bus(buffer,buffer_size);

_mix_to_bus(buffer, buffer_size);
}

void AudioStreamPlayer::_mix_audio() {

if (use_fadeout) {
_mix_to_bus(fadeout_buffer.ptr(),fadeout_buffer.size());
use_fadeout=false;
_mix_to_bus(fadeout_buffer.ptr(), fadeout_buffer.size());
use_fadeout = false;
}

if (!stream_playback.is_valid() || !active ||
Expand All @@ -121,7 +117,7 @@ void AudioStreamPlayer::_mix_audio() {
if (setstop) {
_mix_internal(true);
stream_playback->stop();
setstop=false;
setstop = false;
}

if (setseek >= 0.0 && !stop_has_priority) {
Expand Down Expand Up @@ -154,7 +150,7 @@ void AudioStreamPlayer::_notification(int p_what) {
if (p_what == NOTIFICATION_INTERNAL_PROCESS) {

if (!active || (setseek < 0 && !stream_playback->is_playing())) {
active = false;
active = false;
set_process_internal(false);
emit_signal("finished");
}
Expand Down Expand Up @@ -200,7 +196,7 @@ void AudioStreamPlayer::set_stream(Ref<AudioStream> p_stream) {
vol += vol_inc;
}

use_fadeout=true;
use_fadeout = true;
}

mix_buffer.resize(AudioServer::get_singleton()->thread_get_mix_buffer_size());
Expand Down Expand Up @@ -252,7 +248,7 @@ void AudioStreamPlayer::play(float p_from_pos) {
if (stream_playback.is_valid()) {
//mix_volume_db = volume_db; do not reset volume ramp here, can cause clicks
setseek = p_from_pos;
stop_has_priority=false;
stop_has_priority = false;
active = true;
set_process_internal(true);
}
Expand All @@ -268,8 +264,8 @@ void AudioStreamPlayer::seek(float p_seconds) {
void AudioStreamPlayer::stop() {

if (stream_playback.is_valid() && active) {
setstop=true;
stop_has_priority=true;
setstop = true;
stop_has_priority = true;
}
}

Expand Down Expand Up @@ -357,7 +353,7 @@ void AudioStreamPlayer::_validate_property(PropertyInfo &property) const {
if (property.name == "bus") {

String options;
for (int i = 0; i <AudioServer::get_singleton()->get_bus_count(); i++) {
for (int i = 0; i < AudioServer::get_singleton()->get_bus_count(); i++) {
if (i > 0)
options += ",";
String name = AudioServer::get_singleton()->get_bus_name(i);
Expand Down Expand Up @@ -442,8 +438,8 @@ AudioStreamPlayer::AudioStreamPlayer() {
stream_paused_fade = false;
mix_target = MIX_TARGET_STEREO;
fadeout_buffer.resize(512);
setstop=false;
use_fadeout=false;
setstop = false;
use_fadeout = false;

AudioServer::get_singleton()->connect("bus_layout_changed", this, "_bus_layout_changed");
}
Expand Down
1 change: 0 additions & 1 deletion scene/audio/audio_stream_player.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ class AudioStreamPlayer : public Node {

Ref<AudioStreamPlayback> get_stream_playback();


AudioStreamPlayer();
~AudioStreamPlayer();
};
Expand Down
40 changes: 19 additions & 21 deletions scene/resources/bit_map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -595,16 +595,16 @@ Array BitMap::_opaque_to_polygons_bind(const Rect2 &p_rect, float p_epsilon) con
return result_array;
}

void BitMap::resize(const Size2& p_new_size) {
void BitMap::resize(const Size2 &p_new_size) {

Ref<BitMap> new_bitmap;
new_bitmap.instance();
new_bitmap->create(p_new_size);
int lw = MIN(width,p_new_size.width);
int lh = MIN(height,p_new_size.height);
for(int x=0;x<lw;x++) {
for(int y=0;y<lh;y++) {
new_bitmap->set_bit(Vector2(x,y),get_bit(Vector2(x,y)));
int lw = MIN(width, p_new_size.width);
int lh = MIN(height, p_new_size.height);
for (int x = 0; x < lw; x++) {
for (int y = 0; y < lh; y++) {
new_bitmap->set_bit(Vector2(x, y), get_bit(Vector2(x, y)));
}
}

Expand All @@ -617,42 +617,40 @@ Ref<Image> BitMap::convert_to_image() const {

Ref<Image> image;
image.instance();
image->create(width,height,false,Image::FORMAT_L8);
image->create(width, height, false, Image::FORMAT_L8);
image->lock();
for(int i=0;i<width;i++) {
for(int j=0;j<height;j++) {
image->set_pixel( i,j,get_bit(Point2(i,j)) ? Color(1,1,1) : Color(0,0,0));
for (int i = 0; i < width; i++) {
for (int j = 0; j < height; j++) {
image->set_pixel(i, j, get_bit(Point2(i, j)) ? Color(1, 1, 1) : Color(0, 0, 0));
}
}

image->unlock();

return image;
}
void BitMap::blit(const Vector2& p_pos,const Ref<BitMap>& p_bitmap) {
void BitMap::blit(const Vector2 &p_pos, const Ref<BitMap> &p_bitmap) {

int x = p_pos.x;
int y = p_pos.y;
int w = p_bitmap->get_size().width;
int h = p_bitmap->get_size().height;

for(int i=0;i<w;i++) {
for (int j=0;j<h;j++) {
int px = x+i;
int py = y+j;
if (px<0 || px>=width)
for (int i = 0; i < w; i++) {
for (int j = 0; j < h; j++) {
int px = x + i;
int py = y + j;
if (px < 0 || px >= width)
continue;
if (py<0 || py>=height)
if (py < 0 || py >= height)
continue;
if (p_bitmap->get_bit(Vector2(i,j))) {
set_bit(Vector2(x,y),true);
if (p_bitmap->get_bit(Vector2(i, j))) {
set_bit(Vector2(x, y), true);
}
}
}

}


void BitMap::_bind_methods() {

ClassDB::bind_method(D_METHOD("create", "size"), &BitMap::create);
Expand Down
4 changes: 2 additions & 2 deletions scene/resources/bit_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ class BitMap : public Resource {
int get_true_bit_count() const;

Size2 get_size() const;
void resize(const Size2& p_new_size);
void resize(const Size2 &p_new_size);

void grow_mask(int p_pixels, const Rect2 &p_rect);

void blit(const Vector2& p_pos,const Ref<BitMap>& p_bitmap);
void blit(const Vector2 &p_pos, const Ref<BitMap> &p_bitmap);
Ref<Image> convert_to_image() const;

Vector<Vector<Vector2> > clip_opaque_to_polygons(const Rect2 &p_rect, float p_epsilon = 2.0) const;
Expand Down
11 changes: 3 additions & 8 deletions scene/resources/resource_format_text.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -447,9 +447,8 @@ Error ResourceInteractiveLoaderText::poll() {
resource_cache.push_back(res);
#ifdef TOOLS_ENABLED
//remember ID for saving
res->set_id_for_path(local_path,index);
res->set_id_for_path(local_path, index);
#endif

}

ExtResource er;
Expand Down Expand Up @@ -1545,9 +1544,6 @@ Error ResourceFormatSaverTextInstance::save(const String &p_path, const RES &p_r
}

{



}

#ifdef TOOLS_ENABLED
Expand All @@ -1569,15 +1565,15 @@ Error ResourceFormatSaverTextInstance::save(const String &p_path, const RES &p_r
}

int attempt = 1; //start from one, more readable format
while(cached_ids_found.has(attempt)) {
while (cached_ids_found.has(attempt)) {
attempt++;
}

cached_ids_found.insert(attempt);
E->get() = attempt;
//update also in resource
Ref<Resource> res = E->key();
res->set_id_for_path(local_path,attempt);
res->set_id_for_path(local_path, attempt);
}
#else
//make sure to start from one, as it makes format more readable
Expand All @@ -1598,7 +1594,6 @@ Error ResourceFormatSaverTextInstance::save(const String &p_path, const RES &p_r

sorted_er.sort();


for (int i = 0; i < sorted_er.size(); i++) {
String p = sorted_er[i].resource->get_path();

Expand Down
3 changes: 1 addition & 2 deletions scene/resources/resource_format_text.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,9 @@ class ResourceFormatSaverTextInstance {
struct ResourceSort {
RES resource;
int index;
bool operator<(const ResourceSort& p_right) const {
bool operator<(const ResourceSort &p_right) const {
return index < p_right.index;
}

};

void _find_resources(const Variant &p_variant, bool p_main = false);
Expand Down

0 comments on commit 9643b2b

Please sign in to comment.