chore: Remove unnecessary type annotations
This commit is contained in:
parent
3dc5b34706
commit
20d6fcc128
|
@ -17,24 +17,14 @@ use std::hash::{Hash, Hasher};
|
||||||
pub enum EventPhase {
|
pub enum EventPhase {
|
||||||
/// The event has yet to be fired on the target and is descending the
|
/// The event has yet to be fired on the target and is descending the
|
||||||
/// ancestors of the event target.
|
/// ancestors of the event target.
|
||||||
Capturing,
|
Capturing = 1,
|
||||||
|
|
||||||
/// The event is currently firing on the target.
|
/// The event is currently firing on the target.
|
||||||
AtTarget,
|
AtTarget = 2,
|
||||||
|
|
||||||
/// The event has already fired on the target and is ascending the
|
/// The event has already fired on the target and is ascending the
|
||||||
/// ancestors of the event target.
|
/// ancestors of the event target.
|
||||||
Bubbling,
|
Bubbling = 3,
|
||||||
}
|
|
||||||
|
|
||||||
impl From<EventPhase> for u32 {
|
|
||||||
fn from(event: EventPhase) -> u32 {
|
|
||||||
match event {
|
|
||||||
EventPhase::Capturing => 1,
|
|
||||||
EventPhase::AtTarget => 2,
|
|
||||||
EventPhase::Bubbling => 3,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// How this event is allowed to propagate.
|
/// How this event is allowed to propagate.
|
||||||
|
|
|
@ -130,7 +130,7 @@ pub fn event_phase<'gc>(
|
||||||
_args: &[Value<'gc>],
|
_args: &[Value<'gc>],
|
||||||
) -> Result<Value<'gc>, Error> {
|
) -> Result<Value<'gc>, Error> {
|
||||||
if let Some(evt) = this.unwrap().as_event() {
|
if let Some(evt) = this.unwrap().as_event() {
|
||||||
let event_phase: u32 = evt.phase().into();
|
let event_phase = evt.phase() as u32;
|
||||||
return Ok(event_phase.into());
|
return Ok(event_phase.into());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -102,7 +102,7 @@ impl<'gc> TObject<'gc> for EventObject<'gc> {
|
||||||
let event_type = read.event.event_type();
|
let event_type = read.event.event_type();
|
||||||
let bubbles = read.event.is_bubbling();
|
let bubbles = read.event.is_bubbling();
|
||||||
let cancelable = read.event.is_cancelable();
|
let cancelable = read.event.is_cancelable();
|
||||||
let phase: u32 = read.event.phase().into();
|
let phase = read.event.phase() as u32;
|
||||||
|
|
||||||
Ok(AvmString::new(
|
Ok(AvmString::new(
|
||||||
mc,
|
mc,
|
||||||
|
|
|
@ -134,7 +134,7 @@ impl<R: Read> AdpcmDecoder<R> {
|
||||||
|
|
||||||
self.sample_num = (self.sample_num + 1) % 4095;
|
self.sample_num = (self.sample_num + 1) % 4095;
|
||||||
|
|
||||||
let data: i32 = self.inner.read::<u32>(self.bits_per_sample as u32)? as i32;
|
let data = self.inner.read::<u32>(self.bits_per_sample as u32)? as i32;
|
||||||
self.left_step = Self::STEP_TABLE[self.left_step_index as usize];
|
self.left_step = Self::STEP_TABLE[self.left_step_index as usize];
|
||||||
|
|
||||||
// (data + 0.5) * step / 2^(bits_per_sample - 2)
|
// (data + 0.5) * step / 2^(bits_per_sample - 2)
|
||||||
|
|
|
@ -132,7 +132,7 @@ impl WebGlRenderBackend {
|
||||||
|
|
||||||
// Ensure that we don't exceed the max MSAA of this device.
|
// Ensure that we don't exceed the max MSAA of this device.
|
||||||
if let Ok(max_samples) = gl2.get_parameter(Gl2::MAX_SAMPLES) {
|
if let Ok(max_samples) = gl2.get_parameter(Gl2::MAX_SAMPLES) {
|
||||||
let max_samples: u32 = max_samples.as_f64().unwrap_or(0.0) as u32;
|
let max_samples = max_samples.as_f64().unwrap_or(0.0) as u32;
|
||||||
if max_samples > 0 && max_samples < msaa_sample_count {
|
if max_samples > 0 && max_samples < msaa_sample_count {
|
||||||
log::info!("Device only supports {}xMSAA", max_samples);
|
log::info!("Device only supports {}xMSAA", max_samples);
|
||||||
msaa_sample_count = max_samples;
|
msaa_sample_count = max_samples;
|
||||||
|
|
|
@ -92,6 +92,7 @@ impl<'a> Reader<'a> {
|
||||||
| (i32::from(self.read_u8()? as i8) << 8)
|
| (i32::from(self.read_u8()? as i8) << 8)
|
||||||
| (i32::from(self.read_u8()? as i8) << 16))
|
| (i32::from(self.read_u8()? as i8) << 16))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn read_i32(&mut self) -> Result<i32> {
|
fn read_i32(&mut self) -> Result<i32> {
|
||||||
self.read_encoded_i32()
|
self.read_encoded_i32()
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,21 +67,21 @@ pub trait ReadSwfExt<'a> {
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn read_fixed8(&mut self) -> Result<f32> {
|
fn read_fixed8(&mut self) -> Result<f32> {
|
||||||
ReadSwfExt::read_i16(self).map(|n| f32::from(n) / 256f32)
|
Ok((self.read_i16()? as f32) / 256.0)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn read_fixed16(&mut self) -> Result<f64> {
|
fn read_fixed16(&mut self) -> Result<f64> {
|
||||||
ReadSwfExt::read_i32(self).map(|n| f64::from(n) / 65536f64)
|
Ok((self.read_i32()? as f64) / 65536.0)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn read_encoded_u32(&mut self) -> Result<u32> {
|
fn read_encoded_u32(&mut self) -> Result<u32> {
|
||||||
let mut val = 0u32;
|
let mut val: u32 = 0;
|
||||||
for i in 0..5 {
|
for i in (0..35).step_by(7) {
|
||||||
let byte = ReadSwfExt::read_u8(self)?;
|
let byte = self.read_u8()? as u32;
|
||||||
val |= u32::from(byte & 0b01111111) << (i * 7);
|
val |= (byte & 0b0111_1111) << i;
|
||||||
if byte & 0b10000000 == 0 {
|
if byte & 0b1000_0000 == 0 {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -90,23 +90,21 @@ pub trait ReadSwfExt<'a> {
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn read_encoded_i32(&mut self) -> Result<i32> {
|
fn read_encoded_i32(&mut self) -> Result<i32> {
|
||||||
let mut n: i32 = 0;
|
let mut val: i32 = 0;
|
||||||
let mut i = 0;
|
for i in (0..35).step_by(7) {
|
||||||
for _ in 0..5 {
|
let byte = self.read_u8()? as i32;
|
||||||
let byte: i32 = self.read_u8()?.into();
|
val |= (byte & 0b0111_1111) << i;
|
||||||
n |= (byte & 0b0111_1111) << i;
|
|
||||||
i += 7;
|
|
||||||
|
|
||||||
if byte & 0b1000_0000 == 0 {
|
if byte & 0b1000_0000 == 0 {
|
||||||
|
let i = i + 7;
|
||||||
if i < 32 {
|
if i < 32 {
|
||||||
n <<= 32 - i;
|
// Perform sign-extension to allow negative values.
|
||||||
n >>= 32 - i;
|
val <<= 32 - i;
|
||||||
|
val >>= 32 - i;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(n)
|
Ok(val)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
|
|
@ -560,7 +560,7 @@ impl<'a> Reader<'a> {
|
||||||
|
|
||||||
pub fn read_rectangle(&mut self) -> Result<Rectangle> {
|
pub fn read_rectangle(&mut self) -> Result<Rectangle> {
|
||||||
let mut bits = self.bits();
|
let mut bits = self.bits();
|
||||||
let num_bits: u32 = bits.read_ubits(5)?;
|
let num_bits = bits.read_ubits(5)?;
|
||||||
Ok(Rectangle {
|
Ok(Rectangle {
|
||||||
x_min: bits.read_sbits_twips(num_bits)?,
|
x_min: bits.read_sbits_twips(num_bits)?,
|
||||||
x_max: bits.read_sbits_twips(num_bits)?,
|
x_max: bits.read_sbits_twips(num_bits)?,
|
||||||
|
|
|
@ -2594,7 +2594,7 @@ impl<W: Write> Writer<W> {
|
||||||
|
|
||||||
fn write_tag_code_and_length(&mut self, tag_code: u16, length: u32) -> Result<()> {
|
fn write_tag_code_and_length(&mut self, tag_code: u16, length: u32) -> Result<()> {
|
||||||
// TODO: Test for tag code/length overflow.
|
// TODO: Test for tag code/length overflow.
|
||||||
let mut tag_code_and_length: u16 = tag_code << 6;
|
let mut tag_code_and_length = tag_code << 6;
|
||||||
if length < 0b111111 {
|
if length < 0b111111 {
|
||||||
tag_code_and_length |= length as u16;
|
tag_code_and_length |= length as u16;
|
||||||
self.write_u16(tag_code_and_length)?;
|
self.write_u16(tag_code_and_length)?;
|
||||||
|
|
Loading…
Reference in New Issue