diff --git a/core/src/avm1/activation.rs b/core/src/avm1/activation.rs index 9d468509c..a6129fba3 100644 --- a/core/src/avm1/activation.rs +++ b/core/src/avm1/activation.rs @@ -2769,7 +2769,7 @@ impl<'a, 'gc, 'gc_context> Activation<'a, 'gc, 'gc_context> { if let Some(level) = self.context.levels.get(&level_id) { *level } else { - let mut level: DisplayObject<'_> = MovieClip::new( + let level: DisplayObject<'_> = MovieClip::new( SwfSlice::empty(self.base_clip().movie().unwrap()), self.context.gc_context, ) diff --git a/core/src/avm1/globals/movie_clip.rs b/core/src/avm1/globals/movie_clip.rs index daa485720..eeb434613 100644 --- a/core/src/avm1/globals/movie_clip.rs +++ b/core/src/avm1/globals/movie_clip.rs @@ -487,7 +487,7 @@ fn clear<'gc>( } fn attach_movie<'gc>( - mut movie_clip: MovieClip<'gc>, + movie_clip: MovieClip<'gc>, activation: &mut Activation<'_, 'gc, '_>, args: &[Value<'gc>], ) -> Result, Error<'gc>> { @@ -512,7 +512,7 @@ fn attach_movie<'gc>( return Ok(Value::Undefined); } - if let Ok(mut new_clip) = activation + if let Ok(new_clip) = activation .context .library .library_for_movie(movie_clip.movie().unwrap()) @@ -543,7 +543,7 @@ fn attach_movie<'gc>( } fn create_empty_movie_clip<'gc>( - mut movie_clip: MovieClip<'gc>, + movie_clip: MovieClip<'gc>, activation: &mut Activation<'_, 'gc, '_>, args: &[Value<'gc>], ) -> Result, Error<'gc>> { @@ -568,7 +568,7 @@ fn create_empty_movie_clip<'gc>( .movie() .or_else(|| activation.base_clip().movie()) .unwrap(); - let mut new_clip = MovieClip::new(SwfSlice::empty(swf_movie), activation.context.gc_context); + let new_clip = MovieClip::new(SwfSlice::empty(swf_movie), activation.context.gc_context); // Set name and attach to parent. new_clip.set_name(activation.context.gc_context, &new_instance_name); @@ -585,7 +585,7 @@ fn create_empty_movie_clip<'gc>( } fn create_text_field<'gc>( - mut movie_clip: MovieClip<'gc>, + movie_clip: MovieClip<'gc>, activation: &mut Activation<'_, 'gc, '_>, args: &[Value<'gc>], ) -> Result, Error<'gc>> { @@ -617,7 +617,7 @@ fn create_text_field<'gc>( .unwrap_or(Value::Undefined) .coerce_to_f64(activation)?; - let mut text_field: DisplayObject<'gc> = + let text_field: DisplayObject<'gc> = EditText::new(&mut activation.context, movie, x, y, width, height).into(); text_field.set_name( activation.context.gc_context, @@ -675,7 +675,7 @@ pub fn duplicate_movie_clip_with_bias<'gc>( let init_object = args.get(2); // Can't duplicate the root! - let mut parent = if let Some(parent) = movie_clip.parent().and_then(|o| o.as_movie_clip()) { + let parent = if let Some(parent) = movie_clip.parent().and_then(|o| o.as_movie_clip()) { parent } else { return Ok(Value::Undefined); @@ -687,7 +687,7 @@ pub fn duplicate_movie_clip_with_bias<'gc>( return Ok(Value::Undefined); } - if let Ok(mut new_clip) = activation + if let Ok(new_clip) = activation .context .library .library_for_movie(movie_clip.movie().unwrap()) diff --git a/core/src/avm1/object/script_object.rs b/core/src/avm1/object/script_object.rs index 26b65285f..62a4cd05d 100644 --- a/core/src/avm1/object/script_object.rs +++ b/core/src/avm1/object/script_object.rs @@ -874,7 +874,7 @@ mod tests { let mut avm1 = Avm1::new(gc_context, swf_version); let mut avm2 = Avm2::new(gc_context); let swf = Arc::new(SwfMovie::empty(swf_version)); - let mut root: DisplayObject<'_> = + let root: DisplayObject<'_> = MovieClip::new(SwfSlice::empty(swf.clone()), gc_context).into(); root.set_depth(gc_context, 0); let mut levels = BTreeMap::new(); diff --git a/core/src/avm1/test_utils.rs b/core/src/avm1/test_utils.rs index 765ee1e62..d24fe82f8 100644 --- a/core/src/avm1/test_utils.rs +++ b/core/src/avm1/test_utils.rs @@ -36,7 +36,7 @@ where let mut avm1 = Avm1::new(gc_context, swf_version); let mut avm2 = Avm2::new(gc_context); let swf = Arc::new(SwfMovie::empty(swf_version)); - let mut root: DisplayObject<'gc> = + let root: DisplayObject<'gc> = MovieClip::new(SwfSlice::empty(swf.clone()), gc_context).into(); root.set_depth(gc_context, 0); let mut levels = BTreeMap::new(); diff --git a/core/src/display_object.rs b/core/src/display_object.rs index f8ae31660..a7f4566d3 100644 --- a/core/src/display_object.rs +++ b/core/src/display_object.rs @@ -732,14 +732,14 @@ pub trait TDisplayObject<'gc>: /// Events execute inside-out; the deepest child will react first, followed by its parent, and /// so forth. fn handle_clip_event( - &mut self, + &self, _context: &mut UpdateContext<'_, 'gc, '_>, _event: ClipEvent, ) -> ClipEventResult { ClipEventResult::NotHandled } - fn run_frame(&mut self, _context: &mut UpdateContext<'_, 'gc, '_>) {} + fn run_frame(&self, _context: &mut UpdateContext<'_, 'gc, '_>) {} fn render(&self, _context: &mut RenderContext<'_, 'gc>) {} fn unload(&self, context: &mut UpdateContext<'_, 'gc, '_>) { @@ -872,7 +872,7 @@ pub trait TDisplayObject<'gc>: } fn post_instantiation( - &mut self, + &self, context: &mut UpdateContext<'_, 'gc, '_>, _display_object: DisplayObject<'gc>, _init_object: Option>, diff --git a/core/src/display_object/bitmap.rs b/core/src/display_object/bitmap.rs index 0303393f1..85a15ac5b 100644 --- a/core/src/display_object/bitmap.rs +++ b/core/src/display_object/bitmap.rs @@ -80,7 +80,7 @@ impl<'gc> TDisplayObject<'gc> for Bitmap<'gc> { } } - fn run_frame(&mut self, _context: &mut UpdateContext) { + fn run_frame(&self, _context: &mut UpdateContext) { // Noop } diff --git a/core/src/display_object/button.rs b/core/src/display_object/button.rs index 50473c60b..11482efc0 100644 --- a/core/src/display_object/button.rs +++ b/core/src/display_object/button.rs @@ -115,7 +115,7 @@ impl<'gc> Button<'gc> { /// This function instantiates children and thus must not be called whilst /// the caller is holding a write lock on the button data. fn set_state( - &mut self, + &self, self_display_object: DisplayObject<'gc>, context: &mut crate::context::UpdateContext<'_, 'gc, '_>, state: ButtonState, @@ -153,7 +153,7 @@ impl<'gc> Button<'gc> { drop(write); - for (mut child, depth) in new_children { + for (child, depth) in new_children { // Initialize child. child.post_instantiation(context, child, None, Instantiator::Movie, false); child.run_frame(context); @@ -174,7 +174,7 @@ impl<'gc> TDisplayObject<'gc> for Button<'gc> { } fn post_instantiation( - &mut self, + &self, context: &mut UpdateContext<'_, 'gc, '_>, display_object: DisplayObject<'gc>, _init_object: Option>, @@ -200,7 +200,7 @@ impl<'gc> TDisplayObject<'gc> for Button<'gc> { } } - fn run_frame(&mut self, context: &mut UpdateContext<'_, 'gc, '_>) { + fn run_frame(&self, context: &mut UpdateContext<'_, 'gc, '_>) { let self_display_object = (*self).into(); let initialized = self.0.read().initialized; @@ -240,7 +240,7 @@ impl<'gc> TDisplayObject<'gc> for Button<'gc> { drop(read); - for (mut child, depth) in new_children { + for (child, depth) in new_children { child.post_instantiation(context, child, None, Instantiator::Movie, false); self.0 .write(context.gc_context) @@ -249,7 +249,7 @@ impl<'gc> TDisplayObject<'gc> for Button<'gc> { } } - for mut child in self.iter_execution_list() { + for child in self.iter_execution_list() { child.run_frame(context); } } @@ -322,12 +322,12 @@ impl<'gc> TDisplayObject<'gc> for Button<'gc> { /// Events execute inside-out; the deepest child will react first, followed by its parent, and /// so forth. fn handle_clip_event( - &mut self, + &self, context: &mut UpdateContext<'_, 'gc, '_>, event: ClipEvent, ) -> ClipEventResult { if event.propagates() { - for mut child in self.iter_execution_list() { + for child in self.iter_execution_list() { if child.handle_clip_event(context, event) == ClipEventResult::Handled { return ClipEventResult::Handled; } diff --git a/core/src/display_object/container.rs b/core/src/display_object/container.rs index 2b6ffbb3d..fe96f4aea 100644 --- a/core/src/display_object/container.rs +++ b/core/src/display_object/container.rs @@ -90,7 +90,7 @@ pub trait TDisplayObjectContainer<'gc>: /// being placed by script. If such a child was removed from said lists, it /// will be returned here. Otherwise, this method returns `None`. fn replace_at_depth( - &mut self, + self, context: &mut UpdateContext<'_, 'gc, '_>, child: DisplayObject<'gc>, depth: Depth, @@ -214,14 +214,14 @@ macro_rules! impl_display_object_container { } fn replace_at_depth( - &mut self, + self, context: &mut UpdateContext<'_, 'gc, '_>, child: DisplayObject<'gc>, depth: Depth, ) -> Option> { child.set_place_frame(context.gc_context, 0); child.set_depth(context.gc_context, depth); - child.set_parent(context.gc_context, Some((*self).into())); + child.set_parent(context.gc_context, Some(self.into())); let mut write = self.0.write(context.gc_context); diff --git a/core/src/display_object/edit_text.rs b/core/src/display_object/edit_text.rs index 6cb6e4e2c..8d789aa90 100644 --- a/core/src/display_object/edit_text.rs +++ b/core/src/display_object/edit_text.rs @@ -1093,7 +1093,7 @@ impl<'gc> TDisplayObject<'gc> for EditText<'gc> { Some(self.0.read().static_data.swf.clone()) } - fn run_frame(&mut self, _context: &mut UpdateContext) { + fn run_frame(&self, _context: &mut UpdateContext) { // Noop } @@ -1102,7 +1102,7 @@ impl<'gc> TDisplayObject<'gc> for EditText<'gc> { } fn post_instantiation( - &mut self, + &self, context: &mut UpdateContext<'_, 'gc, '_>, display_object: DisplayObject<'gc>, _init_object: Option>, @@ -1387,7 +1387,7 @@ impl<'gc> TDisplayObject<'gc> for EditText<'gc> { } fn handle_clip_event( - &mut self, + &self, context: &mut UpdateContext<'_, 'gc, '_>, event: ClipEvent, ) -> ClipEventResult { diff --git a/core/src/display_object/graphic.rs b/core/src/display_object/graphic.rs index ea3d9aafc..e1a5b0381 100644 --- a/core/src/display_object/graphic.rs +++ b/core/src/display_object/graphic.rs @@ -55,7 +55,7 @@ impl<'gc> TDisplayObject<'gc> for Graphic<'gc> { bounds } - fn run_frame(&mut self, _context: &mut UpdateContext) { + fn run_frame(&self, _context: &mut UpdateContext) { // Noop } diff --git a/core/src/display_object/morph_shape.rs b/core/src/display_object/morph_shape.rs index c437a066f..7105f617d 100644 --- a/core/src/display_object/morph_shape.rs +++ b/core/src/display_object/morph_shape.rs @@ -52,7 +52,7 @@ impl<'gc> TDisplayObject<'gc> for MorphShape<'gc> { Some(*self) } - fn run_frame(&mut self, _context: &mut UpdateContext) { + fn run_frame(&self, _context: &mut UpdateContext) { // Noop } diff --git a/core/src/display_object/movie_clip.rs b/core/src/display_object/movie_clip.rs index 46373481d..c22aaad61 100644 --- a/core/src/display_object/movie_clip.rs +++ b/core/src/display_object/movie_clip.rs @@ -1104,7 +1104,7 @@ impl<'gc> MovieClip<'gc> { /// Instantiate a given child object on the timeline at a given depth. #[allow(clippy::too_many_arguments)] fn instantiate_child( - mut self, + self, self_display_object: DisplayObject<'gc>, context: &mut UpdateContext<'_, 'gc, '_>, id: CharacterId, @@ -1112,7 +1112,7 @@ impl<'gc> MovieClip<'gc> { place_object: &swf::PlaceObject, copy_previous_properties: bool, ) -> Option> { - if let Ok(mut child) = context + if let Ok(child) = context .library .library_for_movie_mut(self.movie().unwrap()) //TODO .instantiate_by_id(id, context.gc_context) @@ -1381,7 +1381,7 @@ impl<'gc> MovieClip<'gc> { } fn construct_as_avm1_object( - mut self, + self, context: &mut UpdateContext<'_, 'gc, '_>, display_object: DisplayObject<'gc>, init_object: Option>, @@ -1657,9 +1657,9 @@ impl<'gc> TDisplayObject<'gc> for MovieClip<'gc> { self.0.read().movie().version() } - fn run_frame(&mut self, context: &mut UpdateContext<'_, 'gc, '_>) { + fn run_frame(&self, context: &mut UpdateContext<'_, 'gc, '_>) { // Children must run first. - for mut child in self.iter_execution_list() { + for child in self.iter_execution_list() { child.run_frame(context); } @@ -1770,12 +1770,12 @@ impl<'gc> TDisplayObject<'gc> for MovieClip<'gc> { } fn handle_clip_event( - &mut self, + &self, context: &mut UpdateContext<'_, 'gc, '_>, event: ClipEvent, ) -> ClipEventResult { if event.propagates() { - for mut child in self.iter_execution_list() { + for child in self.iter_execution_list() { if child.handle_clip_event(context, event) == ClipEventResult::Handled { return ClipEventResult::Handled; } @@ -1794,7 +1794,7 @@ impl<'gc> TDisplayObject<'gc> for MovieClip<'gc> { } fn post_instantiation( - &mut self, + &self, context: &mut UpdateContext<'_, 'gc, '_>, display_object: DisplayObject<'gc>, init_object: Option>, diff --git a/core/src/display_object/text.rs b/core/src/display_object/text.rs index db53af0ed..9834caa08 100644 --- a/core/src/display_object/text.rs +++ b/core/src/display_object/text.rs @@ -53,7 +53,7 @@ impl<'gc> TDisplayObject<'gc> for Text<'gc> { Some(self.0.read().static_data.swf.clone()) } - fn run_frame(&mut self, _context: &mut UpdateContext) { + fn run_frame(&self, _context: &mut UpdateContext) { // Noop } diff --git a/core/src/player.rs b/core/src/player.rs index b6ee8bc37..3fa16f6e9 100644 --- a/core/src/player.rs +++ b/core/src/player.rs @@ -290,7 +290,7 @@ impl Player { player.mutate_with_update_context(|context| { // Instantiate an empty root before the main movie loads. - let mut fake_root = MovieClip::from_movie(context.gc_context, fake_movie); + let fake_root = MovieClip::from_movie(context.gc_context, fake_movie); fake_root.post_instantiation( context, fake_root.into(), @@ -358,7 +358,7 @@ impl Player { .library_for_movie_mut(context.swf.clone()) .set_avm2_domain(domain); - let mut root: DisplayObject = + let root: DisplayObject = MovieClip::from_movie(context.gc_context, context.swf.clone()).into(); root.set_depth(context.gc_context, 0); @@ -608,7 +608,7 @@ impl Player { if button_event.is_some() { self.mutate_with_update_context(|context| { let levels: Vec> = context.levels.values().copied().collect(); - for mut level in levels { + for level in levels { if let Some(button_event) = button_event { let state = level.handle_clip_event(context, button_event); if state == ClipEventResult::Handled { @@ -658,7 +658,7 @@ impl Player { // Fire clip event on all clips. if let Some(clip_event) = clip_event { let levels: Vec> = context.levels.values().copied().collect(); - for mut level in levels { + for level in levels { level.handle_clip_event(context, clip_event); } } @@ -689,7 +689,7 @@ impl Player { PlayerEvent::MouseDown { .. } => { is_mouse_down = true; needs_render = true; - if let Some(mut node) = context.mouse_hovered_object { + if let Some(node) = context.mouse_hovered_object { node.handle_clip_event(context, ClipEvent::Press); } } @@ -697,7 +697,7 @@ impl Player { PlayerEvent::MouseUp { .. } => { is_mouse_down = false; needs_render = true; - if let Some(mut node) = context.mouse_hovered_object { + if let Some(node) = context.mouse_hovered_object { node.handle_clip_event(context, ClipEvent::Release); } } @@ -766,7 +766,7 @@ impl Player { if cur_hovered.map(|d| d.as_ptr()) != new_hovered.map(|d| d.as_ptr()) { // RollOut of previous node. - if let Some(mut node) = cur_hovered { + if let Some(node) = cur_hovered { if !node.removed() { node.handle_clip_event(context, ClipEvent::RollOut); } @@ -774,7 +774,7 @@ impl Player { // RollOver on new node.I still new_cursor = MouseCursor::Arrow; - if let Some(mut node) = new_hovered { + if let Some(node) = new_hovered { new_cursor = node.mouse_cursor(); node.handle_clip_event(context, ClipEvent::RollOver); } @@ -828,7 +828,7 @@ impl Player { // want to run frames on let levels: Vec<_> = update_context.levels.values().copied().collect(); - for mut level in levels { + for level in levels { level.run_frame(update_context); } });