clang-format: Enable BreakBeforeTernaryOperators

clang-format keeps breaking the way it handles break *after* ternary operators,
so I give up and go with the only style they seem to actually test.
This commit is contained in:
Rémi Verschelde 2021-10-28 14:35:34 +02:00
parent 1b65550ec7
commit 87c80f529f
No known key found for this signature in database
GPG key ID: C3336907360768E1
13 changed files with 54 additions and 64 deletions

View file

@ -56,7 +56,7 @@ AllowShortFunctionsOnASingleLine: Inline
# BreakBeforeBraces: Attach
# BreakBeforeInheritanceComma: false
# BreakInheritanceList: BeforeColon
BreakBeforeTernaryOperators: false
# BreakBeforeTernaryOperators: true
# BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: AfterColon
# BreakStringLiterals: true

View file

@ -781,9 +781,9 @@ Quat Basis::get_quat() const {
temp[1] = ((m.elements[0][2] - m.elements[2][0]) * s);
temp[2] = ((m.elements[1][0] - m.elements[0][1]) * s);
} else {
int i = m.elements[0][0] < m.elements[1][1] ?
(m.elements[1][1] < m.elements[2][2] ? 2 : 1) :
(m.elements[0][0] < m.elements[2][2] ? 2 : 0);
int i = m.elements[0][0] < m.elements[1][1]
? (m.elements[1][1] < m.elements[2][2] ? 2 : 1)
: (m.elements[0][0] < m.elements[2][2] ? 2 : 0);
int j = (i + 1) % 3;
int k = (i + 2) % 3;

View file

@ -264,8 +264,7 @@ public:
}
int32_t get_sign() const {
return ((int64_t)high < 0) ? -1 : (high || low) ? 1 :
0;
return ((int64_t)high < 0) ? -1 : ((high || low) ? 1 : 0);
}
bool operator<(const Int128 &b) const {
@ -791,8 +790,7 @@ int32_t ConvexHullInternal::Rational128::compare(const Rational128 &b) const {
int32_t ConvexHullInternal::Rational128::compare(int64_t b) const {
if (is_int_64) {
int64_t a = sign * (int64_t)numerator.low;
return (a > b) ? 1 : (a < b) ? -1 :
0;
return (a > b) ? 1 : ((a < b) ? -1 : 0);
}
if (b > 0) {
if (sign <= 0) {
@ -1444,8 +1442,7 @@ void ConvexHullInternal::merge(IntermediateHull &p_h0, IntermediateHull &p_h1) {
c1->edges = e;
return;
} else {
int32_t cmp = !min0 ? 1 : !min1 ? -1 :
min_cot0.compare(min_cot1);
int32_t cmp = !min0 ? 1 : (!min1 ? -1 : min_cot0.compare(min_cot1));
#ifdef DEBUG_CONVEX_HULL
printf(" -> Result %d\n", cmp);
#endif

View file

@ -838,9 +838,9 @@ void RasterizerCanvasBaseGLES2::canvas_light_shadow_buffer_update(RID p_buffer,
if (transformed_cull_cache != VS::CANVAS_OCCLUDER_POLYGON_CULL_DISABLED &&
(p_light_xform.basis_determinant() * instance->xform_cache.basis_determinant()) < 0) {
transformed_cull_cache = transformed_cull_cache == VS::CANVAS_OCCLUDER_POLYGON_CULL_CLOCKWISE ?
VS::CANVAS_OCCLUDER_POLYGON_CULL_COUNTER_CLOCKWISE :
VS::CANVAS_OCCLUDER_POLYGON_CULL_CLOCKWISE;
transformed_cull_cache = (transformed_cull_cache == VS::CANVAS_OCCLUDER_POLYGON_CULL_CLOCKWISE)
? VS::CANVAS_OCCLUDER_POLYGON_CULL_COUNTER_CLOCKWISE
: VS::CANVAS_OCCLUDER_POLYGON_CULL_CLOCKWISE;
}
if (cull != transformed_cull_cache) {

View file

@ -897,9 +897,9 @@ void RasterizerCanvasBaseGLES3::canvas_light_shadow_buffer_update(RID p_buffer,
if (transformed_cull_cache != VS::CANVAS_OCCLUDER_POLYGON_CULL_DISABLED &&
(p_light_xform.basis_determinant() * instance->xform_cache.basis_determinant()) < 0) {
transformed_cull_cache = transformed_cull_cache == VS::CANVAS_OCCLUDER_POLYGON_CULL_CLOCKWISE ?
VS::CANVAS_OCCLUDER_POLYGON_CULL_COUNTER_CLOCKWISE :
VS::CANVAS_OCCLUDER_POLYGON_CULL_CLOCKWISE;
transformed_cull_cache = (transformed_cull_cache == VS::CANVAS_OCCLUDER_POLYGON_CULL_CLOCKWISE)
? VS::CANVAS_OCCLUDER_POLYGON_CULL_COUNTER_CLOCKWISE
: VS::CANVAS_OCCLUDER_POLYGON_CULL_CLOCKWISE;
}
if (cull != transformed_cull_cache) {

View file

@ -4817,9 +4817,9 @@ void EditorNode::_scene_tab_closed(int p_tab, int option) {
return;
}
bool unsaved = (p_tab == editor_data.get_edited_scene()) ?
saved_version != editor_data.get_undo_redo().get_version() :
editor_data.get_scene_version(p_tab) != 0;
bool unsaved = (p_tab == editor_data.get_edited_scene())
? saved_version != editor_data.get_undo_redo().get_version()
: editor_data.get_scene_version(p_tab) != 0;
if (unsaved) {
save_confirmation->get_ok()->set_text(TTR("Save & Close"));
save_confirmation->set_text(vformat(TTR("Save changes to '%s' before closing?"), scene->get_filename() != "" ? scene->get_filename() : "unsaved scene"));

View file

@ -3175,16 +3175,16 @@ void CanvasItemEditor::_draw_ruler_tool() {
const Vector2 end_to_begin = (end - begin);
float arc_1_start_angle = end_to_begin.x < 0 ?
(end_to_begin.y < 0 ? 3.0 * Math_PI / 2.0 - vertical_angle_rad : Math_PI / 2.0) :
(end_to_begin.y < 0 ? 3.0 * Math_PI / 2.0 : Math_PI / 2.0 - vertical_angle_rad);
float arc_1_start_angle = end_to_begin.x < 0
? (end_to_begin.y < 0 ? 3.0 * Math_PI / 2.0 - vertical_angle_rad : Math_PI / 2.0)
: (end_to_begin.y < 0 ? 3.0 * Math_PI / 2.0 : Math_PI / 2.0 - vertical_angle_rad);
float arc_1_end_angle = arc_1_start_angle + vertical_angle_rad;
// Constrain arc to triangle height & max size
float arc_1_radius = MIN(MIN(arc_radius_max_length_percent * ruler_length, ABS(end_to_begin.y)), arc_max_radius);
float arc_2_start_angle = end_to_begin.x < 0 ?
(end_to_begin.y < 0 ? 0.0 : -horizontal_angle_rad) :
(end_to_begin.y < 0 ? Math_PI - horizontal_angle_rad : Math_PI);
float arc_2_start_angle = end_to_begin.x < 0
? (end_to_begin.y < 0 ? 0.0 : -horizontal_angle_rad)
: (end_to_begin.y < 0 ? Math_PI - horizontal_angle_rad : Math_PI);
float arc_2_end_angle = arc_2_start_angle + horizontal_angle_rad;
// Constrain arc to triangle width & max size
float arc_2_radius = MIN(MIN(arc_radius_max_length_percent * ruler_length, ABS(end_to_begin.x)), arc_max_radius);

View file

@ -352,9 +352,9 @@ void CurveEditor::open_context_menu(Vector2 pos) {
_context_menu->add_check_item(TTR("Linear"), CONTEXT_LINEAR);
bool is_linear = _selected_tangent == TANGENT_LEFT ?
_curve_ref->get_point_left_mode(_selected_point) == Curve::TANGENT_LINEAR :
_curve_ref->get_point_right_mode(_selected_point) == Curve::TANGENT_LINEAR;
bool is_linear = _selected_tangent == TANGENT_LEFT
? _curve_ref->get_point_left_mode(_selected_point) == Curve::TANGENT_LINEAR
: _curve_ref->get_point_right_mode(_selected_point) == Curve::TANGENT_LINEAR;
_context_menu->set_item_checked(_context_menu->get_item_index(CONTEXT_LINEAR), is_linear);

View file

@ -3294,10 +3294,10 @@ Error CSharpScript::load_source_code(const String &p_path) {
Error ferr = read_all_file_utf8(p_path, source);
ERR_FAIL_COND_V_MSG(ferr != OK, ferr,
ferr == ERR_INVALID_DATA ?
"Script '" + p_path + "' contains invalid unicode (UTF-8), so it was not loaded."
" Please ensure that scripts are saved in valid UTF-8 unicode." :
"Failed to read file: '" + p_path + "'.");
ferr == ERR_INVALID_DATA
? "Script '" + p_path + "' contains invalid unicode (UTF-8), so it was not loaded."
" Please ensure that scripts are saved in valid UTF-8 unicode."
: "Failed to read file: '" + p_path + "'.");
#ifdef TOOLS_ENABLED
source_changed_cache = true;

View file

@ -354,8 +354,7 @@ String BindingsGenerator::bbcode_to_xml(const String &p_bbcode, const TypeInterf
xml_output.append(link_target);
xml_output.append("</c>");
} else if (link_tag == "enum") {
StringName search_cname = !target_itype ? target_cname :
StringName(target_itype->name + "." + (String)target_cname);
StringName search_cname = !target_itype ? target_cname : StringName(target_itype->name + "." + (String)target_cname);
const Map<StringName, TypeInterface>::Element *enum_match = enum_types.find(search_cname);

View file

@ -716,10 +716,10 @@ Error ScriptClassParser::parse_file(const String &p_filepath) {
Error ferr = read_all_file_utf8(p_filepath, source);
ERR_FAIL_COND_V_MSG(ferr != OK, ferr,
ferr == ERR_INVALID_DATA ?
"File '" + p_filepath + "' contains invalid unicode (UTF-8), so it was not loaded."
" Please ensure that scripts are saved in valid UTF-8 unicode." :
"Failed to read file: '" + p_filepath + "'.");
ferr == ERR_INVALID_DATA
? "File '" + p_filepath + "' contains invalid unicode (UTF-8), so it was not loaded."
" Please ensure that scripts are saved in valid UTF-8 unicode."
: "Failed to read file: '" + p_filepath + "'.");
run_dummy_preprocessor(source, p_filepath);

View file

@ -584,9 +584,9 @@ bool GDMono::load_assembly_from(const String &p_name, const String &p_path, GDMo
ApiAssemblyInfo::Version ApiAssemblyInfo::Version::get_from_loaded_assembly(GDMonoAssembly *p_api_assembly, ApiAssemblyInfo::Type p_api_type) {
ApiAssemblyInfo::Version api_assembly_version;
const char *nativecalls_name = p_api_type == ApiAssemblyInfo::API_CORE ?
BINDINGS_CLASS_NATIVECALLS :
BINDINGS_CLASS_NATIVECALLS_EDITOR;
const char *nativecalls_name = p_api_type == ApiAssemblyInfo::API_CORE
? BINDINGS_CLASS_NATIVECALLS
: BINDINGS_CLASS_NATIVECALLS_EDITOR;
GDMonoClass *nativecalls_klass = p_api_assembly->get_class(BINDINGS_NAMESPACE, nativecalls_name);
@ -628,7 +628,9 @@ bool GDMono::copy_prebuilt_api_assembly(ApiAssemblyInfo::Type p_api_type, const
String src_dir = GodotSharpDirs::get_data_editor_prebuilt_api_dir().plus_file(p_config);
String dst_dir = GodotSharpDirs::get_res_assemblies_base_dir().plus_file(p_config);
String assembly_name = p_api_type == ApiAssemblyInfo::API_CORE ? CORE_API_ASSEMBLY_NAME : EDITOR_API_ASSEMBLY_NAME;
String assembly_name = p_api_type == ApiAssemblyInfo::API_CORE
? CORE_API_ASSEMBLY_NAME
: EDITOR_API_ASSEMBLY_NAME;
// Create destination directory if needed
if (!DirAccess::exists(dst_dir)) {
@ -739,12 +741,8 @@ bool GDMono::_temp_domain_load_are_assemblies_out_of_sync(const String &p_config
String GDMono::update_api_assemblies_from_prebuilt(const String &p_config, const bool *p_core_api_out_of_sync, const bool *p_editor_api_out_of_sync) {
#define FAIL_REASON(m_out_of_sync, m_prebuilt_exists) \
( \
(m_out_of_sync ? \
String("The assembly is invalidated ") : \
String("The assembly was not found ")) + \
(m_prebuilt_exists ? \
String("and the prebuilt assemblies are missing.") : \
String("and we failed to copy the prebuilt assemblies.")))
(m_out_of_sync ? String("The assembly is invalidated ") : String("The assembly was not found ")) + \
(m_prebuilt_exists ? String("and the prebuilt assemblies are missing.") : String("and we failed to copy the prebuilt assemblies.")))
String dst_assemblies_dir = GodotSharpDirs::get_res_assemblies_base_dir().plus_file(p_config);
@ -800,9 +798,7 @@ bool GDMono::_load_core_api_assembly(LoadedApiAssembly &r_loaded_api_assembly, c
// For the editor and the editor player we want to load it from a specific path to make sure we can keep it up to date
// If running the project manager, load it from the prebuilt API directory
String assembly_dir = !Main::is_project_manager() ?
GodotSharpDirs::get_res_assemblies_base_dir().plus_file(p_config) :
GodotSharpDirs::get_data_editor_prebuilt_api_dir().plus_file(p_config);
String assembly_dir = !Main::is_project_manager() ? GodotSharpDirs::get_res_assemblies_base_dir().plus_file(p_config) : GodotSharpDirs::get_data_editor_prebuilt_api_dir().plus_file(p_config);
String assembly_path = assembly_dir.plus_file(CORE_API_ASSEMBLY_NAME ".dll");
@ -832,9 +828,7 @@ bool GDMono::_load_editor_api_assembly(LoadedApiAssembly &r_loaded_api_assembly,
// For the editor and the editor player we want to load it from a specific path to make sure we can keep it up to date
// If running the project manager, load it from the prebuilt API directory
String assembly_dir = !Main::is_project_manager() ?
GodotSharpDirs::get_res_assemblies_base_dir().plus_file(p_config) :
GodotSharpDirs::get_data_editor_prebuilt_api_dir().plus_file(p_config);
String assembly_dir = !Main::is_project_manager() ? GodotSharpDirs::get_res_assemblies_base_dir().plus_file(p_config) : GodotSharpDirs::get_data_editor_prebuilt_api_dir().plus_file(p_config);
String assembly_path = assembly_dir.plus_file(EDITOR_API_ASSEMBLY_NAME ".dll");

View file

@ -156,16 +156,16 @@ public class GodotView extends GLSurfaceView {
*/
if (GLUtils.use_32) {
setEGLConfigChooser(translucent ?
new RegularFallbackConfigChooser(8, 8, 8, 8, 24, stencil,
new RegularConfigChooser(8, 8, 8, 8, 16, stencil)) :
new RegularFallbackConfigChooser(8, 8, 8, 8, 24, stencil,
setEGLConfigChooser(translucent
? new RegularFallbackConfigChooser(8, 8, 8, 8, 24, stencil,
new RegularConfigChooser(8, 8, 8, 8, 16, stencil))
: new RegularFallbackConfigChooser(8, 8, 8, 8, 24, stencil,
new RegularConfigChooser(5, 6, 5, 0, 16, stencil)));
} else {
setEGLConfigChooser(translucent ?
new RegularConfigChooser(8, 8, 8, 8, 16, stencil) :
new RegularConfigChooser(5, 6, 5, 0, 16, stencil));
setEGLConfigChooser(translucent
? new RegularConfigChooser(8, 8, 8, 8, 16, stencil)
: new RegularConfigChooser(5, 6, 5, 0, 16, stencil));
}
break;
}