diff --git a/core/src/avm1/globals/bevel_filter.rs b/core/src/avm1/globals/bevel_filter.rs index 6d9f01d91..5e1424ce1 100644 --- a/core/src/avm1/globals/bevel_filter.rs +++ b/core/src/avm1/globals/bevel_filter.rs @@ -60,10 +60,7 @@ pub fn set_distance<'gc>( this: Object<'gc>, args: &[Value<'gc>], ) -> Result, Error<'gc>> { - let distance = args - .get(0) - .unwrap_or(&4.0.into()) - .coerce_to_f64(activation)?; + let distance = args.get(0).unwrap_or(&4.into()).coerce_to_f64(activation)?; if let Some(filter) = this.as_bevel_filter_object() { filter.set_distance(activation.context.gc_context, distance); diff --git a/core/src/avm1/globals/convolution_filter.rs b/core/src/avm1/globals/convolution_filter.rs index b67ea7f8d..f6646937c 100644 --- a/core/src/avm1/globals/convolution_filter.rs +++ b/core/src/avm1/globals/convolution_filter.rs @@ -56,7 +56,7 @@ pub fn set_alpha<'gc>( ) -> Result, Error<'gc>> { let alpha = args .get(0) - .unwrap_or(&0.0.into()) + .unwrap_or(&0.into()) .coerce_to_f64(activation) .map(|x| x.max(0.0).min(1.0))?; @@ -84,10 +84,7 @@ pub fn set_bias<'gc>( this: Object<'gc>, args: &[Value<'gc>], ) -> Result, Error<'gc>> { - let bias = args - .get(0) - .unwrap_or(&0.0.into()) - .coerce_to_f64(activation)?; + let bias = args.get(0).unwrap_or(&0.into()).coerce_to_f64(activation)?; if let Some(filter) = this.as_convolution_filter_object() { filter.set_bias(activation.context.gc_context, bias); @@ -171,10 +168,7 @@ pub fn set_divisor<'gc>( this: Object<'gc>, args: &[Value<'gc>], ) -> Result, Error<'gc>> { - let divisor = args - .get(0) - .unwrap_or(&1.0.into()) - .coerce_to_f64(activation)?; + let divisor = args.get(0).unwrap_or(&1.into()).coerce_to_f64(activation)?; if let Some(filter) = this.as_convolution_filter_object() { filter.set_divisor(activation.context.gc_context, divisor); @@ -250,7 +244,7 @@ pub fn set_matrix_x<'gc>( ) -> Result, Error<'gc>> { let matrix_x = args .get(0) - .unwrap_or(&0.0.into()) + .unwrap_or(&0.into()) .coerce_to_i32(activation) .map(|x| x.max(0).min(15))? as u8; @@ -280,7 +274,7 @@ pub fn set_matrix_y<'gc>( ) -> Result, Error<'gc>> { let matrix_y = args .get(0) - .unwrap_or(&0.0.into()) + .unwrap_or(&0.into()) .coerce_to_i32(activation) .map(|x| x.max(0).min(15))? as u8; diff --git a/core/src/avm1/globals/displacement_map_filter.rs b/core/src/avm1/globals/displacement_map_filter.rs index 50a67c7ee..2d83c7610 100644 --- a/core/src/avm1/globals/displacement_map_filter.rs +++ b/core/src/avm1/globals/displacement_map_filter.rs @@ -56,7 +56,7 @@ pub fn set_alpha<'gc>( ) -> Result, Error<'gc>> { let alpha = args .get(0) - .unwrap_or(&0.0.into()) + .unwrap_or(&0.into()) .coerce_to_f64(activation) .map(|x| x.max(0.0).min(1.0))?; @@ -113,10 +113,7 @@ pub fn set_component_x<'gc>( this: Object<'gc>, args: &[Value<'gc>], ) -> Result, Error<'gc>> { - let component = args - .get(0) - .unwrap_or(&0.0.into()) - .coerce_to_i32(activation)?; + let component = args.get(0).unwrap_or(&0.into()).coerce_to_i32(activation)?; if let Some(object) = this.as_displacement_map_filter_object() { object.set_component_x(activation.context.gc_context, component); @@ -142,10 +139,7 @@ pub fn set_component_y<'gc>( this: Object<'gc>, args: &[Value<'gc>], ) -> Result, Error<'gc>> { - let component = args - .get(0) - .unwrap_or(&0.0.into()) - .coerce_to_i32(activation)?; + let component = args.get(0).unwrap_or(&0.into()).coerce_to_i32(activation)?; if let Some(object) = this.as_displacement_map_filter_object() { object.set_component_y(activation.context.gc_context, component); @@ -271,10 +265,7 @@ pub fn set_scale_x<'gc>( this: Object<'gc>, args: &[Value<'gc>], ) -> Result, Error<'gc>> { - let scale = args - .get(0) - .unwrap_or(&0.0.into()) - .coerce_to_f64(activation)?; + let scale = args.get(0).unwrap_or(&0.into()).coerce_to_f64(activation)?; if let Some(object) = this.as_displacement_map_filter_object() { object.set_scale_x(activation.context.gc_context, scale); @@ -300,10 +291,7 @@ pub fn set_scale_y<'gc>( this: Object<'gc>, args: &[Value<'gc>], ) -> Result, Error<'gc>> { - let scale = args - .get(0) - .unwrap_or(&0.0.into()) - .coerce_to_f64(activation)?; + let scale = args.get(0).unwrap_or(&0.into()).coerce_to_f64(activation)?; if let Some(object) = this.as_displacement_map_filter_object() { object.set_scale_y(activation.context.gc_context, scale); diff --git a/core/src/avm1/globals/drop_shadow_filter.rs b/core/src/avm1/globals/drop_shadow_filter.rs index 4fabfcc1b..2d3f7fbba 100644 --- a/core/src/avm1/globals/drop_shadow_filter.rs +++ b/core/src/avm1/globals/drop_shadow_filter.rs @@ -60,7 +60,7 @@ pub fn set_alpha<'gc>( ) -> Result, Error<'gc>> { let alpha = args .get(0) - .unwrap_or(&1.0.into()) + .unwrap_or(&1.into()) .coerce_to_f64(activation) .map(|x| x.max(0.0).min(1.0))?; @@ -88,10 +88,7 @@ pub fn set_distance<'gc>( this: Object<'gc>, args: &[Value<'gc>], ) -> Result, Error<'gc>> { - let distance = args - .get(0) - .unwrap_or(&4.0.into()) - .coerce_to_f64(activation)?; + let distance = args.get(0).unwrap_or(&4.into()).coerce_to_f64(activation)?; if let Some(object) = this.as_drop_shadow_filter_object() { object.set_distance(activation.context.gc_context, distance); @@ -154,7 +151,7 @@ pub fn set_blur_x<'gc>( ) -> Result, Error<'gc>> { let blur_x = args .get(0) - .unwrap_or(&4.0.into()) + .unwrap_or(&4.into()) .coerce_to_f64(activation) .map(|x| x.max(0.0).min(255.0))?; @@ -184,7 +181,7 @@ pub fn set_blur_y<'gc>( ) -> Result, Error<'gc>> { let blur_y = args .get(0) - .unwrap_or(&4.0.into()) + .unwrap_or(&4.into()) .coerce_to_f64(activation) .map(|x| x.max(0.0).min(255.0))?; @@ -330,7 +327,7 @@ pub fn set_quality<'gc>( ) -> Result, Error<'gc>> { let quality = args .get(0) - .unwrap_or(&1.0.into()) + .unwrap_or(&1.into()) .coerce_to_i32(activation) .map(|x| x.max(0).min(15))?; @@ -360,7 +357,7 @@ pub fn set_strength<'gc>( ) -> Result, Error<'gc>> { let strength = args .get(0) - .unwrap_or(&1.0.into()) + .unwrap_or(&1.into()) .coerce_to_f64(activation) .map(|x| x.max(0.0).min(255.0))?; diff --git a/core/src/avm1/globals/gradient_bevel_filter.rs b/core/src/avm1/globals/gradient_bevel_filter.rs index 8b135fe5b..c48e18185 100644 --- a/core/src/avm1/globals/gradient_bevel_filter.rs +++ b/core/src/avm1/globals/gradient_bevel_filter.rs @@ -59,10 +59,7 @@ pub fn set_distance<'gc>( this: Object<'gc>, args: &[Value<'gc>], ) -> Result, Error<'gc>> { - let distance = args - .get(0) - .unwrap_or(&4.0.into()) - .coerce_to_f64(activation)?; + let distance = args.get(0).unwrap_or(&4.into()).coerce_to_f64(activation)?; if let Some(object) = this.as_gradient_bevel_filter_object() { object.set_distance(activation.context.gc_context, distance); @@ -287,7 +284,7 @@ pub fn set_blur_x<'gc>( ) -> Result, Error<'gc>> { let blur_x = args .get(0) - .unwrap_or(&4.0.into()) + .unwrap_or(&4.into()) .coerce_to_f64(activation) .map(|x| x.max(0.0).min(255.0))?; @@ -317,7 +314,7 @@ pub fn set_blur_y<'gc>( ) -> Result, Error<'gc>> { let blur_y = args .get(0) - .unwrap_or(&4.0.into()) + .unwrap_or(&4.into()) .coerce_to_f64(activation) .map(|x| x.max(0.0).min(255.0))?; @@ -347,7 +344,7 @@ pub fn set_strength<'gc>( ) -> Result, Error<'gc>> { let strength = args .get(0) - .unwrap_or(&1.0.into()) + .unwrap_or(&1.into()) .coerce_to_f64(activation) .map(|x| x.max(0.0).min(255.0))?; @@ -377,7 +374,7 @@ pub fn set_quality<'gc>( ) -> Result, Error<'gc>> { let quality = args .get(0) - .unwrap_or(&1.0.into()) + .unwrap_or(&1.into()) .coerce_to_i32(activation) .map(|x| x.max(0).min(15))?; diff --git a/core/src/avm1/globals/gradient_glow_filter.rs b/core/src/avm1/globals/gradient_glow_filter.rs index 4acd57363..7ca296ee0 100644 --- a/core/src/avm1/globals/gradient_glow_filter.rs +++ b/core/src/avm1/globals/gradient_glow_filter.rs @@ -59,10 +59,7 @@ pub fn set_distance<'gc>( this: Object<'gc>, args: &[Value<'gc>], ) -> Result, Error<'gc>> { - let distance = args - .get(0) - .unwrap_or(&4.0.into()) - .coerce_to_f64(activation)?; + let distance = args.get(0).unwrap_or(&4.into()).coerce_to_f64(activation)?; if let Some(object) = this.as_gradient_glow_filter_object() { object.set_distance(activation.context.gc_context, distance); @@ -287,7 +284,7 @@ pub fn set_blur_x<'gc>( ) -> Result, Error<'gc>> { let blur_x = args .get(0) - .unwrap_or(&4.0.into()) + .unwrap_or(&4.into()) .coerce_to_f64(activation) .map(|x| x.max(0.0).min(255.0))?; @@ -317,7 +314,7 @@ pub fn set_blur_y<'gc>( ) -> Result, Error<'gc>> { let blur_y = args .get(0) - .unwrap_or(&4.0.into()) + .unwrap_or(&4.into()) .coerce_to_f64(activation) .map(|x| x.max(0.0).min(255.0))?; @@ -347,7 +344,7 @@ pub fn set_strength<'gc>( ) -> Result, Error<'gc>> { let strength = args .get(0) - .unwrap_or(&1.0.into()) + .unwrap_or(&1.into()) .coerce_to_f64(activation) .map(|x| x.max(0.0).min(255.0))?; @@ -377,7 +374,7 @@ pub fn set_quality<'gc>( ) -> Result, Error<'gc>> { let quality = args .get(0) - .unwrap_or(&1.0.into()) + .unwrap_or(&1.into()) .coerce_to_i32(activation) .map(|x| x.max(0).min(15))?; diff --git a/core/src/avm1/globals/math.rs b/core/src/avm1/globals/math.rs index 21fed9bc2..ba0f75cae 100644 --- a/core/src/avm1/globals/math.rs +++ b/core/src/avm1/globals/math.rs @@ -396,15 +396,15 @@ mod tests { assert_eq!(atan2(activation, math, &[]).unwrap(), f64::NAN.into()); assert_eq!( - atan2(activation, math, &[1.0.into(), Value::Null]).unwrap(), + atan2(activation, math, &[1.into(), Value::Null]).unwrap(), f64::NAN.into() ); assert_eq!( - atan2(activation, math, &[1.0.into(), Value::Undefined]).unwrap(), + atan2(activation, math, &[1.into(), Value::Undefined]).unwrap(), f64::NAN.into() ); assert_eq!( - atan2(activation, math, &[Value::Undefined, 1.0.into()]).unwrap(), + atan2(activation, math, &[Value::Undefined, 1.into()]).unwrap(), f64::NAN.into() ); Ok(()) @@ -421,11 +421,11 @@ mod tests { ); assert_eq!( - atan2(activation, math, &[10.0.into()]).unwrap(), + atan2(activation, math, &[10.into()]).unwrap(), std::f64::consts::FRAC_PI_2.into() ); assert_eq!( - atan2(activation, math, &[1.0.into(), 2.0.into()]).unwrap(), + atan2(activation, math, &[1.into(), 2.into()]).unwrap(), f64::atan2(1.0, 2.0).into() ); Ok(()) diff --git a/core/src/avm1/globals/selection.rs b/core/src/avm1/globals/selection.rs index f8c8c371b..ab53988b8 100644 --- a/core/src/avm1/globals/selection.rs +++ b/core/src/avm1/globals/selection.rs @@ -29,7 +29,7 @@ pub fn get_begin_index<'gc>( { Ok(selection.start().into()) } else { - Ok((-1.0).into()) + Ok((-1).into()) } } @@ -47,7 +47,7 @@ pub fn get_end_index<'gc>( { Ok(selection.end().into()) } else { - Ok((-1.0).into()) + Ok((-1).into()) } } @@ -65,7 +65,7 @@ pub fn get_caret_index<'gc>( { Ok(selection.to().into()) } else { - Ok((-1.0).into()) + Ok((-1).into()) } } diff --git a/core/src/avm1/tests.rs b/core/src/avm1/tests.rs index db6e05849..d7edfa7af 100644 --- a/core/src/avm1/tests.rs +++ b/core/src/avm1/tests.rs @@ -9,7 +9,7 @@ fn locals_into_form_values() { my_locals .set("value1", "string".into(), activation) .unwrap(); - my_locals.set("value2", 2.0.into(), activation).unwrap(); + my_locals.set("value2", 2.into(), activation).unwrap(); let my_local_values = activation.locals_into_form_values(); assert_eq!(my_local_values.len(), 2);