Skip to content

Commit eb1366e

Browse files
Lord-McSweeneyLord-McSweeney
Lord-McSweeney
authored andcommitted
chore: Resolve review comments and appease clippy
1 parent cb65dbd commit eb1366e

File tree

7 files changed

+19
-14
lines changed

7 files changed

+19
-14
lines changed

core/src/avm1/globals/color.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ fn set_transform<'gc>(
166166
out: &mut Fixed8,
167167
) -> Result<(), Error<'gc>> {
168168
// The parameters are set only if the property exists on the object itself (prototype excluded).
169-
if transform.has_own_property(activation, property.into()) {
169+
if transform.has_own_property(activation, property) {
170170
let n = transform
171171
.get(property, activation)?
172172
.coerce_to_f64(activation)?;
@@ -184,7 +184,7 @@ fn set_transform<'gc>(
184184
out: &mut i16,
185185
) -> Result<(), Error<'gc>> {
186186
// The parameters are set only if the property exists on the object itself (prototype excluded).
187-
if transform.has_own_property(activation, property.into()) {
187+
if transform.has_own_property(activation, property) {
188188
*out = transform
189189
.get(property, activation)?
190190
.coerce_to_i16(activation)?;

core/src/avm1/object/array_object.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ impl<'gc> ArrayObject<'gc> {
6363
Self::builder_with_proto(&activation.context.strings, proto)
6464
}
6565

66-
pub fn builder_with_proto<'a>(
66+
pub fn builder_with_proto(
6767
context: &StringContext<'gc>,
6868
proto: Object<'gc>,
6969
) -> ArrayBuilder<'gc> {

core/src/avm1/runtime.rs

+2
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,8 @@ pub fn root_error_handler<'gc>(activation: &mut Activation<'_, 'gc>, error: Erro
590590
if let Ok(message) = value.coerce_to_string(activation) {
591591
activation.context.avm_trace(&message.to_utf8_lossy());
592592
} else {
593+
// The only Value variant that can throw an error when being stringified
594+
// is Object, so just print "[type Object]".
593595
activation.context.avm_trace("[type Object]");
594596
}
595597
// Continue execution without halting.

core/src/backend/audio.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ use crate::{
44
buffer::Substream,
55
context::UpdateContext,
66
display_object::{self, DisplayObject, MovieClip, TDisplayObject},
7+
string::AvmString,
78
};
89
use downcast_rs::Downcast;
910
use gc_arena::Collect;
10-
use ruffle_macros::istr;
1111
use slotmap::{new_key_type, Key, SlotMap};
1212

1313
#[cfg(feature = "audio")]
@@ -380,14 +380,13 @@ impl<'gc> AudioManager<'gc> {
380380

381381
/// Update state of active sounds. Should be called once per frame.
382382
pub fn update_sounds(context: &mut UpdateContext<'gc>) {
383+
let mc = context.gc();
384+
383385
// We can't use 'context' to construct an event inside the
384386
// 'retain()' closure, so we queue the events up here, and fire
385387
// them after running 'retain()'
386388
let mut event_targets = Vec::new();
387389

388-
// We need to declare this up here to avoid borrow-checker issues
389-
let on_sound_complete_string = istr!(context, "onSoundComplete");
390-
391390
// Update the position of sounds, and remove any completed sounds.
392391
context.audio_manager.sounds.retain(|sound| {
393392
if let Some(pos) = context.audio.get_sound_position(sound.instance) {
@@ -413,11 +412,13 @@ impl<'gc> AudioManager<'gc> {
413412

414413
// Fire soundComplete event.
415414
if let Some(root) = context.stage.root_clip() {
415+
let method_name = AvmString::new_utf8(mc, "onSoundComplete");
416+
416417
context.action_queue.queue_action(
417418
root,
418419
crate::context::ActionType::Method {
419420
object,
420-
name: on_sound_complete_string,
421+
name: method_name,
421422
args: vec![],
422423
},
423424
false,

core/src/display_object/interactive.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ use crate::display_object::{
1717
DisplayObject, DisplayObjectBase, TDisplayObject, TDisplayObjectContainer,
1818
};
1919
use crate::events::{ClipEvent, ClipEventResult, MouseButton};
20+
use crate::string::AvmString;
2021
use bitflags::bitflags;
2122
use gc_arena::{Collect, Mutation};
2223
use ruffle_macros::{enum_trait_object, istr};
@@ -607,11 +608,13 @@ pub trait TInteractiveObject<'gc>:
607608
let other = other
608609
.map(|d| d.as_displayobject().object())
609610
.unwrap_or(Avm1Value::Null);
611+
610612
let method_name = if focused {
611-
istr!(context, "onSetFocus")
613+
AvmString::new_utf8(context.gc(), "onSetFocus")
612614
} else {
613-
istr!(context, "onKillFocus")
615+
AvmString::new_utf8(context.gc(), "onKillFocus")
614616
};
617+
615618
Avm1::run_stack_frame_for_method(self_do, object, method_name, &[other], context);
616619
} else if let Avm2Value::Object(object) = self_do.object2() {
617620
let mut activation = Avm2Activation::from_nothing(context);

core/src/loader.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -2534,14 +2534,16 @@ impl<'gc> Loader<'gc> {
25342534
match vm_data {
25352535
MovieLoaderVMData::Avm1 { broadcaster } => {
25362536
if let Some(broadcaster) = broadcaster {
2537+
let error_message = AvmString::new_utf8(uc.gc(), "LoadNeverCompleted");
2538+
25372539
Avm1::run_stack_frame_for_method(
25382540
clip,
25392541
broadcaster,
25402542
istr!(uc, "broadcastMessage"),
25412543
&[
25422544
istr!(uc, "onLoadError").into(),
25432545
clip.object(),
2544-
istr!(uc, "LoadNeverCompleted").into(),
2546+
error_message.into(),
25452547
],
25462548
uc,
25472549
);

core/src/string/common.rs

-3
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,6 @@ define_common_strings! {
147147
str_littleEndian: b"littleEndian",
148148
str_ll: b"ll",
149149
str_loaded: b"loaded",
150-
str_LoadNeverCompleted: b"LoadNeverCompleted",
151150
str_localhost: b"localhost",
152151
str_localName: b"localName",
153152
str_loop: b"loop",
@@ -190,7 +189,6 @@ define_common_strings! {
190189
str_onHTTPStatus: b"onHTTPStatus",
191190
str_onKeyDown: b"onKeyDown",
192191
str_onKeyUp: b"onKeyUp",
193-
str_onKillFocus: b"onKillFocus",
194192
str_onLoad: b"onLoad",
195193
str_onLoadComplete: b"onLoadComplete",
196194
str_onLoadError: b"onLoadError",
@@ -207,7 +205,6 @@ define_common_strings! {
207205
str_onScroller: b"onScroller",
208206
str_onSelect: b"onSelect",
209207
str_onSetFocus: b"onSetFocus",
210-
str_onSoundComplete: b"onSoundComplete",
211208
str_onStatus: b"onStatus",
212209
str_onUnload: b"onUnload",
213210
str_onXML: b"onXML",

0 commit comments

Comments
 (0)