chore: cargo fmt
This commit is contained in:
parent
1c3e4406b3
commit
b6eba80ebd
|
@ -82,8 +82,8 @@ pub fn create<'gc>(gc_context: MutationContext<'gc, '_>) -> GcCell<'gc, Object<'
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::avm1::Error;
|
|
||||||
use crate::avm1::activation::Activation;
|
use crate::avm1::activation::Activation;
|
||||||
|
use crate::avm1::Error;
|
||||||
use crate::backend::audio::NullAudioBackend;
|
use crate::backend::audio::NullAudioBackend;
|
||||||
use crate::backend::navigator::NullNavigatorBackend;
|
use crate::backend::navigator::NullNavigatorBackend;
|
||||||
use crate::display_object::DisplayObject;
|
use crate::display_object::DisplayObject;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::avm1::{ActionContext, Avm1, Value};
|
use crate::avm1::function::{Avm1Function, Avm1Function2, Executable, NativeFunction};
|
||||||
use crate::avm1::function::{Executable, NativeFunction, Avm1Function, Avm1Function2};
|
|
||||||
use crate::avm1::scope::Scope;
|
use crate::avm1::scope::Scope;
|
||||||
|
use crate::avm1::{ActionContext, Avm1, Value};
|
||||||
use crate::display_object::DisplayNode;
|
use crate::display_object::DisplayNode;
|
||||||
use crate::tag_utils::SwfSlice;
|
use crate::tag_utils::SwfSlice;
|
||||||
use core::fmt;
|
use core::fmt;
|
||||||
|
@ -135,7 +135,7 @@ impl<'gc> Object<'gc> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Constructs an object with no values, not even builtins.
|
/// Constructs an object with no values, not even builtins.
|
||||||
///
|
///
|
||||||
/// Intended for constructing scope chains, since they exclusively use the
|
/// Intended for constructing scope chains, since they exclusively use the
|
||||||
/// object values, but can't just have a hashmap because of `with` and
|
/// object values, but can't just have a hashmap because of `with` and
|
||||||
/// friends.
|
/// friends.
|
||||||
|
@ -157,12 +157,24 @@ impl<'gc> Object<'gc> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn action_function(swf_version: u8, actions: SwfSlice, name: &str, params: &[&str], scope: GcCell<'gc, Scope<'gc>>) -> Self {
|
pub fn action_function(
|
||||||
|
swf_version: u8,
|
||||||
|
actions: SwfSlice,
|
||||||
|
name: &str,
|
||||||
|
params: &[&str],
|
||||||
|
scope: GcCell<'gc, Scope<'gc>>,
|
||||||
|
) -> Self {
|
||||||
Self {
|
Self {
|
||||||
type_of: TYPE_OF_FUNCTION,
|
type_of: TYPE_OF_FUNCTION,
|
||||||
function: Some(Executable::Action(Avm1Function::new(swf_version, actions, name, params, scope))),
|
function: Some(Executable::Action(Avm1Function::new(
|
||||||
|
swf_version,
|
||||||
|
actions,
|
||||||
|
name,
|
||||||
|
params,
|
||||||
|
scope,
|
||||||
|
))),
|
||||||
display_node: None,
|
display_node: None,
|
||||||
values: HashMap::new()
|
values: HashMap::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,7 +183,7 @@ impl<'gc> Object<'gc> {
|
||||||
type_of: TYPE_OF_FUNCTION,
|
type_of: TYPE_OF_FUNCTION,
|
||||||
function: Some(Executable::Action2(func)),
|
function: Some(Executable::Action2(func)),
|
||||||
display_node: None,
|
display_node: None,
|
||||||
values: HashMap::new()
|
values: HashMap::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -244,7 +256,10 @@ impl<'gc> Object<'gc> {
|
||||||
) {
|
) {
|
||||||
self.force_set(
|
self.force_set(
|
||||||
name,
|
name,
|
||||||
Value::Object(GcCell::allocate(gc_context, Object::native_function(function))),
|
Value::Object(GcCell::allocate(
|
||||||
|
gc_context,
|
||||||
|
Object::native_function(function),
|
||||||
|
)),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -283,10 +298,10 @@ impl<'gc> Object<'gc> {
|
||||||
self.values.contains_key(name)
|
self.values.contains_key(name)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn iter_values(&self) -> impl Iterator<Item=(&String, &Value<'gc>)> {
|
pub fn iter_values(&self) -> impl Iterator<Item = (&String, &Value<'gc>)> {
|
||||||
self.values.iter().filter_map(|(k, p)| match p {
|
self.values.iter().filter_map(|(k, p)| match p {
|
||||||
Property::Virtual {..} => None,
|
Property::Virtual { .. } => None,
|
||||||
Property::Stored { value, .. } => Some((k, value))
|
Property::Stored { value, .. } => Some((k, value)),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -325,11 +340,11 @@ impl<'gc> Object<'gc> {
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
|
use crate::avm1::activation::Activation;
|
||||||
use crate::backend::audio::NullAudioBackend;
|
use crate::backend::audio::NullAudioBackend;
|
||||||
use crate::backend::navigator::NullNavigatorBackend;
|
use crate::backend::navigator::NullNavigatorBackend;
|
||||||
use crate::display_object::DisplayObject;
|
use crate::display_object::DisplayObject;
|
||||||
use crate::movie_clip::MovieClip;
|
use crate::movie_clip::MovieClip;
|
||||||
use crate::avm1::activation::Activation;
|
|
||||||
use gc_arena::rootless_arena;
|
use gc_arena::rootless_arena;
|
||||||
use rand::{rngs::SmallRng, SeedableRng};
|
use rand::{rngs::SmallRng, SeedableRng};
|
||||||
|
|
||||||
|
|
|
@ -515,7 +515,11 @@ impl<Audio: AudioBackend, Renderer: RenderBackend, Navigator: NavigatorBackend>
|
||||||
action_context.start_clip = active_clip;
|
action_context.start_clip = active_clip;
|
||||||
action_context.active_clip = active_clip;
|
action_context.active_clip = active_clip;
|
||||||
action_context.target_clip = Some(active_clip);
|
action_context.target_clip = Some(active_clip);
|
||||||
update_context.avm.insert_stack_frame_for_action(update_context.swf_version, action, &mut action_context);
|
update_context.avm.insert_stack_frame_for_action(
|
||||||
|
update_context.swf_version,
|
||||||
|
action,
|
||||||
|
&mut action_context,
|
||||||
|
);
|
||||||
let _ = update_context.avm.run_stack_till_empty(&mut action_context);
|
let _ = update_context.avm.run_stack_till_empty(&mut action_context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ impl AsRef<[u8]> for SwfSlice {
|
||||||
|
|
||||||
impl SwfSlice {
|
impl SwfSlice {
|
||||||
/// Construct a new SwfSlice from a regular slice.
|
/// Construct a new SwfSlice from a regular slice.
|
||||||
///
|
///
|
||||||
/// This function returns None if the given slice is not a subslice of the
|
/// This function returns None if the given slice is not a subslice of the
|
||||||
/// current slice.
|
/// current slice.
|
||||||
pub fn to_subslice(&self, slice: &[u8]) -> Option<SwfSlice> {
|
pub fn to_subslice(&self, slice: &[u8]) -> Option<SwfSlice> {
|
||||||
|
@ -30,7 +30,7 @@ impl SwfSlice {
|
||||||
Some(SwfSlice {
|
Some(SwfSlice {
|
||||||
data: self.data.clone(),
|
data: self.data.clone(),
|
||||||
start: slice_pval - self_pval,
|
start: slice_pval - self_pval,
|
||||||
end: (slice_pval - self_pval) + slice.len()
|
end: (slice_pval - self_pval) + slice.len(),
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
|
|
Loading…
Reference in New Issue