avm2: Add 'gc lifetime parameter to avm2::Error

This commit is contained in:
Aaron Hill 2022-09-13 16:04:04 -05:00
parent b1760063ec
commit 3e65a554fa
112 changed files with 1326 additions and 1239 deletions

View File

@ -67,7 +67,7 @@ const BROADCAST_WHITELIST: [&str; 3] = ["enterFrame", "exitFrame", "frameConstru
/// ///
/// As AVM2 is a far stricter VM than AVM1, this may eventually be replaced /// As AVM2 is a far stricter VM than AVM1, this may eventually be replaced
/// with a proper Avm2Error enum. /// with a proper Avm2Error enum.
pub type Error = Box<dyn std::error::Error>; pub type Error<'gc> = Box<dyn std::error::Error>;
/// The state of an AVM2 interpreter. /// The state of an AVM2 interpreter.
#[derive(Collect)] #[derive(Collect)]
@ -124,7 +124,7 @@ impl<'gc> Avm2<'gc> {
} }
} }
pub fn load_player_globals(context: &mut UpdateContext<'_, 'gc, '_>) -> Result<(), Error> { pub fn load_player_globals(context: &mut UpdateContext<'_, 'gc, '_>) -> Result<(), Error<'gc>> {
let globals = context.avm2.globals; let globals = context.avm2.globals;
let mut activation = Activation::from_nothing(context.reborrow()); let mut activation = Activation::from_nothing(context.reborrow());
globals::load_player_globals(&mut activation, globals) globals::load_player_globals(&mut activation, globals)
@ -141,7 +141,7 @@ impl<'gc> Avm2<'gc> {
pub fn run_script_initializer( pub fn run_script_initializer(
script: Script<'gc>, script: Script<'gc>,
context: &mut UpdateContext<'_, 'gc, '_>, context: &mut UpdateContext<'_, 'gc, '_>,
) -> Result<(), Error> { ) -> Result<(), Error<'gc>> {
let mut init_activation = Activation::from_script(context.reborrow(), script)?; let mut init_activation = Activation::from_script(context.reborrow(), script)?;
let (method, scope, _domain) = script.init(); let (method, scope, _domain) = script.init();
@ -185,7 +185,7 @@ impl<'gc> Avm2<'gc> {
context: &mut UpdateContext<'_, 'gc, '_>, context: &mut UpdateContext<'_, 'gc, '_>,
event: Object<'gc>, event: Object<'gc>,
target: Object<'gc>, target: Object<'gc>,
) -> Result<bool, Error> { ) -> Result<bool, Error<'gc>> {
use crate::avm2::events::dispatch_event; use crate::avm2::events::dispatch_event;
let mut activation = Activation::from_nothing(context.reborrow()); let mut activation = Activation::from_nothing(context.reborrow());
dispatch_event(&mut activation, target, event) dispatch_event(&mut activation, target, event)
@ -234,7 +234,7 @@ impl<'gc> Avm2<'gc> {
context: &mut UpdateContext<'_, 'gc, '_>, context: &mut UpdateContext<'_, 'gc, '_>,
event: Object<'gc>, event: Object<'gc>,
on_type: ClassObject<'gc>, on_type: ClassObject<'gc>,
) -> Result<(), Error> { ) -> Result<(), Error<'gc>> {
let base_event = event.as_event().unwrap(); // TODO: unwrap? let base_event = event.as_event().unwrap(); // TODO: unwrap?
let event_name = base_event.event_type(); let event_name = base_event.event_type();
drop(base_event); drop(base_event);
@ -278,7 +278,7 @@ impl<'gc> Avm2<'gc> {
reciever: Option<Object<'gc>>, reciever: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
context: &mut UpdateContext<'_, 'gc, '_>, context: &mut UpdateContext<'_, 'gc, '_>,
) -> Result<(), Error> { ) -> Result<(), Error<'gc>> {
let mut evt_activation = Activation::from_nothing(context.reborrow()); let mut evt_activation = Activation::from_nothing(context.reborrow());
callable.call(reciever, args, &mut evt_activation)?; callable.call(reciever, args, &mut evt_activation)?;
@ -290,7 +290,7 @@ impl<'gc> Avm2<'gc> {
context: &mut UpdateContext<'_, 'gc, '_>, context: &mut UpdateContext<'_, 'gc, '_>,
do_abc: DoAbc, do_abc: DoAbc,
domain: Domain<'gc>, domain: Domain<'gc>,
) -> Result<(), Error> { ) -> Result<(), Error<'gc>> {
let mut read = Reader::new(do_abc.data); let mut read = Reader::new(do_abc.data);
let abc_file = Rc::new(read.read()?); let abc_file = Rc::new(read.read()?);

File diff suppressed because it is too large Load Diff

View File

@ -91,7 +91,7 @@ pub fn recursive_serialize<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
obj: Object<'gc>, obj: Object<'gc>,
elements: &mut Vec<Element>, elements: &mut Vec<Element>,
) -> Result<(), Error> { ) -> Result<(), Error<'gc>> {
let mut last_index = obj.get_next_enumerant(0, activation)?; let mut last_index = obj.get_next_enumerant(0, activation)?;
while let Some(index) = last_index { while let Some(index) = last_index {
let name = obj let name = obj
@ -111,7 +111,7 @@ pub fn recursive_serialize<'gc>(
pub fn deserialize_value<'gc>( pub fn deserialize_value<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
val: &AmfValue, val: &AmfValue,
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Ok(match val { Ok(match val {
AmfValue::Null => Value::Null, AmfValue::Null => Value::Null,
AmfValue::Undefined => Value::Undefined, AmfValue::Undefined => Value::Undefined,
@ -215,7 +215,7 @@ pub fn deserialize_value<'gc>(
pub fn deserialize_lso<'gc>( pub fn deserialize_lso<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
lso: &Lso, lso: &Lso,
) -> Result<Object<'gc>, Error> { ) -> Result<Object<'gc>, Error<'gc>> {
let mut obj = activation let mut obj = activation
.avm2() .avm2()
.classes() .classes()

View File

@ -96,14 +96,14 @@ impl ByteArrayStorage {
/// Write bytes at the next position in the ByteArray, growing if needed. /// Write bytes at the next position in the ByteArray, growing if needed.
#[inline] #[inline]
pub fn write_bytes(&mut self, buf: &[u8]) -> Result<(), Error> { pub fn write_bytes<'gc>(&mut self, buf: &[u8]) -> Result<(), Error<'gc>> {
self.write_at(buf, self.position.get())?; self.write_at(buf, self.position.get())?;
self.position.set(self.position.get() + buf.len()); self.position.set(self.position.get() + buf.len());
Ok(()) Ok(())
} }
#[inline] #[inline]
pub fn write_bytes_within(&mut self, start: usize, amnt: usize) -> Result<(), Error> { pub fn write_bytes_within<'gc>(&mut self, start: usize, amnt: usize) -> Result<(), Error<'gc>> {
self.write_at_within(start, amnt, self.position.get())?; self.write_at_within(start, amnt, self.position.get())?;
self.position.set(self.position.get() + amnt); self.position.set(self.position.get() + amnt);
Ok(()) Ok(())
@ -111,7 +111,7 @@ impl ByteArrayStorage {
/// Reads any amount of bytes from the current position in the ByteArray /// Reads any amount of bytes from the current position in the ByteArray
#[inline] #[inline]
pub fn read_bytes(&self, amnt: usize) -> Result<&[u8], Error> { pub fn read_bytes<'gc>(&self, amnt: usize) -> Result<&[u8], Error<'gc>> {
let bytes = self.read_at(amnt, self.position.get())?; let bytes = self.read_at(amnt, self.position.get())?;
self.position.set(self.position.get() + amnt); self.position.set(self.position.get() + amnt);
Ok(bytes) Ok(bytes)
@ -119,7 +119,7 @@ impl ByteArrayStorage {
/// Reads any amount of bytes at any offset in the ByteArray /// Reads any amount of bytes at any offset in the ByteArray
#[inline] #[inline]
pub fn read_at(&self, amnt: usize, offset: usize) -> Result<&[u8], Error> { pub fn read_at<'gc>(&self, amnt: usize, offset: usize) -> Result<&[u8], Error<'gc>> {
self.bytes self.bytes
.get(offset..) .get(offset..)
.and_then(|bytes| bytes.get(..amnt)) .and_then(|bytes| bytes.get(..amnt))
@ -128,7 +128,7 @@ impl ByteArrayStorage {
/// Write bytes at any offset in the ByteArray /// Write bytes at any offset in the ByteArray
/// Will automatically grow the ByteArray to fit the new buffer /// Will automatically grow the ByteArray to fit the new buffer
pub fn write_at(&mut self, buf: &[u8], offset: usize) -> Result<(), Error> { pub fn write_at<'gc>(&mut self, buf: &[u8], offset: usize) -> Result<(), Error<'gc>> {
let new_len = offset let new_len = offset
.checked_add(buf.len()) .checked_add(buf.len())
.ok_or("RangeError: Cannot overflow usize")?; .ok_or("RangeError: Cannot overflow usize")?;
@ -144,7 +144,11 @@ impl ByteArrayStorage {
/// Write bytes at any offset in the ByteArray /// Write bytes at any offset in the ByteArray
/// Will return an error if the new buffer does not fit the ByteArray /// Will return an error if the new buffer does not fit the ByteArray
pub fn write_at_nongrowing(&mut self, buf: &[u8], offset: usize) -> Result<(), Error> { pub fn write_at_nongrowing<'gc>(
&mut self,
buf: &[u8],
offset: usize,
) -> Result<(), Error<'gc>> {
self.bytes self.bytes
.get_mut(offset..) .get_mut(offset..)
.and_then(|bytes| bytes.get_mut(..buf.len())) .and_then(|bytes| bytes.get_mut(..buf.len()))
@ -155,12 +159,12 @@ impl ByteArrayStorage {
/// Write bytes at any offset in the ByteArray from within the current ByteArray using a memmove. /// Write bytes at any offset in the ByteArray from within the current ByteArray using a memmove.
/// Will automatically grow the ByteArray to fit the new buffer /// Will automatically grow the ByteArray to fit the new buffer
pub fn write_at_within( pub fn write_at_within<'gc>(
&mut self, &mut self,
start: usize, start: usize,
amnt: usize, amnt: usize,
offset: usize, offset: usize,
) -> Result<(), Error> { ) -> Result<(), Error<'gc>> {
// First verify that reading from `start` to `amnt` is valid // First verify that reading from `start` to `amnt` is valid
let end = start let end = start
.checked_add(amnt) .checked_add(amnt)
@ -180,7 +184,10 @@ impl ByteArrayStorage {
} }
/// Compress the ByteArray into a temporary buffer /// Compress the ByteArray into a temporary buffer
pub fn compress(&mut self, algorithm: CompressionAlgorithm) -> Result<Vec<u8>, Error> { pub fn compress<'gc>(
&mut self,
algorithm: CompressionAlgorithm,
) -> Result<Vec<u8>, Error<'gc>> {
let mut buffer = Vec::new(); let mut buffer = Vec::new();
match algorithm { match algorithm {
CompressionAlgorithm::Zlib => { CompressionAlgorithm::Zlib => {
@ -202,7 +209,10 @@ impl ByteArrayStorage {
} }
/// Decompress the ByteArray into a temporary buffer /// Decompress the ByteArray into a temporary buffer
pub fn decompress(&mut self, algorithm: CompressionAlgorithm) -> Result<Vec<u8>, Error> { pub fn decompress<'gc>(
&mut self,
algorithm: CompressionAlgorithm,
) -> Result<Vec<u8>, Error<'gc>> {
let mut buffer = Vec::new(); let mut buffer = Vec::new();
match algorithm { match algorithm {
CompressionAlgorithm::Zlib => { CompressionAlgorithm::Zlib => {
@ -223,22 +233,22 @@ impl ByteArrayStorage {
Ok(buffer) Ok(buffer)
} }
pub fn read_utf(&self) -> Result<&[u8], Error> { pub fn read_utf<'gc>(&self) -> Result<&[u8], Error<'gc>> {
let len = self.read_unsigned_short()?; let len = self.read_unsigned_short()?;
let val = self.read_bytes(len.into())?; let val = self.read_bytes(len.into())?;
Ok(val) Ok(val)
} }
pub fn write_boolean(&mut self, val: bool) -> Result<(), Error> { pub fn write_boolean<'gc>(&mut self, val: bool) -> Result<(), Error<'gc>> {
self.write_bytes(&[val as u8; 1]) self.write_bytes(&[val as u8; 1])
} }
pub fn read_boolean(&self) -> Result<bool, Error> { pub fn read_boolean<'gc>(&self) -> Result<bool, Error<'gc>> {
Ok(self.read_bytes(1)? != [0]) Ok(self.read_bytes(1)? != [0])
} }
// Writes a UTF String into the buffer, with its length as a prefix // Writes a UTF String into the buffer, with its length as a prefix
pub fn write_utf(&mut self, utf_string: &str) -> Result<(), Error> { pub fn write_utf<'gc>(&mut self, utf_string: &str) -> Result<(), Error<'gc>> {
if let Ok(str_size) = u16::try_from(utf_string.len()) { if let Ok(str_size) = u16::try_from(utf_string.len()) {
self.write_unsigned_short(str_size)?; self.write_unsigned_short(str_size)?;
self.write_bytes(utf_string.as_bytes()) self.write_bytes(utf_string.as_bytes())
@ -393,7 +403,7 @@ macro_rules! impl_write{
=> =>
{ {
impl ByteArrayStorage { impl ByteArrayStorage {
$( pub fn $method_name (&mut self, val: $data_type) -> Result<(), Error> { $( pub fn $method_name<'gc> (&mut self, val: $data_type) -> Result<(), Error<'gc>> {
let val_bytes = match self.endian { let val_bytes = match self.endian {
Endian::Big => val.to_be_bytes(), Endian::Big => val.to_be_bytes(),
Endian::Little => val.to_le_bytes(), Endian::Little => val.to_le_bytes(),
@ -409,7 +419,7 @@ macro_rules! impl_read{
=> =>
{ {
impl ByteArrayStorage { impl ByteArrayStorage {
$( pub fn $method_name (&self) -> Result<$data_type, Error> { $( pub fn $method_name<'gc> (&self) -> Result<$data_type, Error<'gc>> {
Ok(match self.endian { Ok(match self.endian {
Endian::Big => <$data_type>::from_be_bytes(self.read_bytes($size)?.try_into().unwrap()), Endian::Big => <$data_type>::from_be_bytes(self.read_bytes($size)?.try_into().unwrap()),
Endian::Little => <$data_type>::from_le_bytes(self.read_bytes($size)?.try_into().unwrap()) Endian::Little => <$data_type>::from_le_bytes(self.read_bytes($size)?.try_into().unwrap())

View File

@ -77,7 +77,7 @@ macro_rules! define_indirect_properties {
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>] _args: &[Value<'gc>]
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
use crate::avm2::Multiname; use crate::avm2::Multiname;
use crate::avm2::globals::NS_RUFFLE_INTERNAL; use crate::avm2::globals::NS_RUFFLE_INTERNAL;
@ -121,7 +121,7 @@ pub(crate) use define_indirect_properties;
/// read for traits). /// read for traits).
/// * `activation` - The current AVM2 activation. /// * `activation` - The current AVM2 activation.
pub type AllocatorFn = pub type AllocatorFn =
for<'gc> fn(ClassObject<'gc>, &mut Activation<'_, 'gc, '_>) -> Result<Object<'gc>, Error>; for<'gc> fn(ClassObject<'gc>, &mut Activation<'_, 'gc, '_>) -> Result<Object<'gc>, Error<'gc>>;
#[derive(Clone, Collect)] #[derive(Clone, Collect)]
#[collect(require_static)] #[collect(require_static)]
@ -303,15 +303,15 @@ impl<'gc> Class<'gc> {
unit: TranslationUnit<'gc>, unit: TranslationUnit<'gc>,
class_index: u32, class_index: u32,
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
) -> Result<GcCell<'gc, Self>, Error> { ) -> Result<GcCell<'gc, Self>, Error<'gc>> {
let abc = unit.abc(); let abc = unit.abc();
let abc_class: Result<&AbcClass, Error> = abc let abc_class: Result<&AbcClass, Error<'gc>> = abc
.classes .classes
.get(class_index as usize) .get(class_index as usize)
.ok_or_else(|| "LoadError: Class index not valid".into()); .ok_or_else(|| "LoadError: Class index not valid".into());
let abc_class = abc_class?; let abc_class = abc_class?;
let abc_instance: Result<&AbcInstance, Error> = abc let abc_instance: Result<&AbcInstance, Error<'gc>> = abc
.instances .instances
.get(class_index as usize) .get(class_index as usize)
.ok_or_else(|| "LoadError: Instance index not valid".into()); .ok_or_else(|| "LoadError: Instance index not valid".into());
@ -406,7 +406,7 @@ impl<'gc> Class<'gc> {
unit: TranslationUnit<'gc>, unit: TranslationUnit<'gc>,
class_index: u32, class_index: u32,
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
) -> Result<(), Error> { ) -> Result<(), Error<'gc>> {
if self.traits_loaded { if self.traits_loaded {
return Ok(()); return Ok(());
} }
@ -414,13 +414,13 @@ impl<'gc> Class<'gc> {
self.traits_loaded = true; self.traits_loaded = true;
let abc = unit.abc(); let abc = unit.abc();
let abc_class: Result<&AbcClass, Error> = abc let abc_class: Result<&AbcClass, Error<'gc>> = abc
.classes .classes
.get(class_index as usize) .get(class_index as usize)
.ok_or_else(|| "LoadError: Class index not valid".into()); .ok_or_else(|| "LoadError: Class index not valid".into());
let abc_class = abc_class?; let abc_class = abc_class?;
let abc_instance: Result<&AbcInstance, Error> = abc let abc_instance: Result<&AbcInstance, Error<'gc>> = abc
.instances .instances
.get(class_index as usize) .get(class_index as usize)
.ok_or_else(|| "LoadError: Instance index not valid".into()); .ok_or_else(|| "LoadError: Instance index not valid".into());
@ -444,7 +444,7 @@ impl<'gc> Class<'gc> {
/// This should be called at class creation time once the superclass name /// This should be called at class creation time once the superclass name
/// has been resolved. It will return Ok for a valid class, and a /// has been resolved. It will return Ok for a valid class, and a
/// VerifyError for any invalid class. /// VerifyError for any invalid class.
pub fn validate_class(&self, superclass: Option<ClassObject<'gc>>) -> Result<(), Error> { pub fn validate_class(&self, superclass: Option<ClassObject<'gc>>) -> Result<(), Error<'gc>> {
// System classes do not throw verify errors. // System classes do not throw verify errors.
if self.is_system { if self.is_system {
return Ok(()); return Ok(());
@ -513,7 +513,7 @@ impl<'gc> Class<'gc> {
translation_unit: TranslationUnit<'gc>, translation_unit: TranslationUnit<'gc>,
method: &AbcMethod, method: &AbcMethod,
body: &AbcMethodBody, body: &AbcMethodBody,
) -> Result<GcCell<'gc, Self>, Error> { ) -> Result<GcCell<'gc, Self>, Error<'gc>> {
let name = let name =
translation_unit.pool_string(method.name.as_u30(), activation.context.gc_context)?; translation_unit.pool_string(method.name.as_u30(), activation.context.gc_context)?;
let mut traits = Vec::with_capacity(body.traits.len()); let mut traits = Vec::with_capacity(body.traits.len());

View File

@ -107,7 +107,7 @@ impl<'gc> Domain<'gc> {
pub fn get_defining_script( pub fn get_defining_script(
self, self,
multiname: &Multiname<'gc>, multiname: &Multiname<'gc>,
) -> Result<Option<(QName<'gc>, Script<'gc>)>, Error> { ) -> Result<Option<(QName<'gc>, Script<'gc>)>, Error<'gc>> {
let read = self.0.read(); let read = self.0.read();
if let Some(name) = multiname.local_name() { if let Some(name) = multiname.local_name() {
@ -129,7 +129,7 @@ impl<'gc> Domain<'gc> {
self, self,
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
name: QName<'gc>, name: QName<'gc>,
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
let (name, mut script) = self let (name, mut script) = self
.get_defining_script(&name.into())? .get_defining_script(&name.into())?
.ok_or_else(|| format!("MovieClip Symbol {} does not exist", name.local_name()))?; .ok_or_else(|| format!("MovieClip Symbol {} does not exist", name.local_name()))?;
@ -147,7 +147,7 @@ impl<'gc> Domain<'gc> {
name: QName<'gc>, name: QName<'gc>,
script: Script<'gc>, script: Script<'gc>,
mc: MutationContext<'gc, '_>, mc: MutationContext<'gc, '_>,
) -> Result<(), Error> { ) -> Result<(), Error<'gc>> {
if self.has_definition(name) { if self.has_definition(name) {
return Err(format!( return Err(format!(
"VerifyError: Attempted to redefine existing name {}", "VerifyError: Attempted to redefine existing name {}",
@ -185,7 +185,7 @@ impl<'gc> Domain<'gc> {
pub fn init_default_domain_memory( pub fn init_default_domain_memory(
self, self,
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
) -> Result<(), Error> { ) -> Result<(), Error<'gc>> {
let bytearray_class = activation.avm2().classes().bytearray; let bytearray_class = activation.avm2().classes().bytearray;
let domain_memory = bytearray_class.construct(activation, &[])?; let domain_memory = bytearray_class.construct(activation, &[])?;

View File

@ -372,7 +372,7 @@ pub fn dispatch_event_to_target<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
target: Object<'gc>, target: Object<'gc>,
event: Object<'gc>, event: Object<'gc>,
) -> Result<(), Error> { ) -> Result<(), Error<'gc>> {
avm_debug!( avm_debug!(
activation.context.avm2, activation.context.avm2,
"Event dispatch: {} to {:?}", "Event dispatch: {} to {:?}",
@ -435,7 +435,7 @@ pub fn dispatch_event<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Object<'gc>, this: Object<'gc>,
event: Object<'gc>, event: Object<'gc>,
) -> Result<bool, Error> { ) -> Result<bool, Error<'gc>> {
let target = this let target = this
.get_property( .get_property(
&Multiname::new(Namespace::private(NS_EVENT_DISPATCHER), "target"), &Multiname::new(Namespace::private(NS_EVENT_DISPATCHER), "target"),

View File

@ -108,7 +108,7 @@ impl<'gc> Executable<'gc> {
mut arguments: &[Value<'gc>], mut arguments: &[Value<'gc>],
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
callee: Object<'gc>, callee: Object<'gc>,
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
let ret = match self { let ret = match self {
Executable::Native(bm) => { Executable::Native(bm) => {
let method = bm.method.method; let method = bm.method.method;

View File

@ -186,7 +186,7 @@ fn function<'gc>(
name: &'static str, name: &'static str,
nf: NativeMethodImpl, nf: NativeMethodImpl,
script: Script<'gc>, script: Script<'gc>,
) -> Result<(), Error> { ) -> Result<(), Error<'gc>> {
let (_, mut global, mut domain) = script.init(); let (_, mut global, mut domain) = script.init();
let mc = activation.context.gc_context; let mc = activation.context.gc_context;
let scope = activation.create_scopechain(); let scope = activation.create_scopechain();
@ -209,7 +209,7 @@ fn dynamic_class<'gc>(
script: Script<'gc>, script: Script<'gc>,
// The `ClassObject` of the `Class` class // The `ClassObject` of the `Class` class
class_class: ClassObject<'gc>, class_class: ClassObject<'gc>,
) -> Result<(), Error> { ) -> Result<(), Error<'gc>> {
let (_, mut global, mut domain) = script.init(); let (_, mut global, mut domain) = script.init();
let class = class_object.inner_class_definition(); let class = class_object.inner_class_definition();
let name = class.read().name(); let name = class.read().name();
@ -226,12 +226,12 @@ fn class<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
class_def: GcCell<'gc, Class<'gc>>, class_def: GcCell<'gc, Class<'gc>>,
script: Script<'gc>, script: Script<'gc>,
) -> Result<ClassObject<'gc>, Error> { ) -> Result<ClassObject<'gc>, Error<'gc>> {
let (_, mut global, mut domain) = script.init(); let (_, mut global, mut domain) = script.init();
let class_read = class_def.read(); let class_read = class_def.read();
let super_class = if let Some(sc_name) = class_read.super_class_name() { let super_class = if let Some(sc_name) = class_read.super_class_name() {
let super_class: Result<Object<'gc>, Error> = activation let super_class: Result<Object<'gc>, Error<'gc>> = activation
.resolve_definition(sc_name) .resolve_definition(sc_name)
.ok() .ok()
.and_then(|v| v) .and_then(|v| v)
@ -278,7 +278,7 @@ fn constant<'gc>(
value: Value<'gc>, value: Value<'gc>,
script: Script<'gc>, script: Script<'gc>,
class: ClassObject<'gc>, class: ClassObject<'gc>,
) -> Result<(), Error> { ) -> Result<(), Error<'gc>> {
let (_, mut global, mut domain) = script.init(); let (_, mut global, mut domain) = script.init();
let name = QName::new(Namespace::package(package), name); let name = QName::new(Namespace::package(package), name);
domain.export_definition(name, script, mc)?; domain.export_definition(name, script, mc)?;
@ -293,7 +293,7 @@ fn namespace<'gc>(
name: impl Into<AvmString<'gc>>, name: impl Into<AvmString<'gc>>,
uri: impl Into<AvmString<'gc>>, uri: impl Into<AvmString<'gc>>,
script: Script<'gc>, script: Script<'gc>,
) -> Result<(), Error> { ) -> Result<(), Error<'gc>> {
let namespace = NamespaceObject::from_namespace(activation, Namespace::Namespace(uri.into()))?; let namespace = NamespaceObject::from_namespace(activation, Namespace::Namespace(uri.into()))?;
constant( constant(
activation.context.gc_context, activation.context.gc_context,
@ -323,7 +323,7 @@ macro_rules! avm2_system_class {
pub fn load_player_globals<'gc>( pub fn load_player_globals<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
domain: Domain<'gc>, domain: Domain<'gc>,
) -> Result<(), Error> { ) -> Result<(), Error<'gc>> {
let mc = activation.context.gc_context; let mc = activation.context.gc_context;
let globals = ScriptObject::custom_object(activation.context.gc_context, None, None); let globals = ScriptObject::custom_object(activation.context.gc_context, None, None);
@ -657,7 +657,7 @@ mod native {
fn load_playerglobal<'gc>( fn load_playerglobal<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
domain: Domain<'gc>, domain: Domain<'gc>,
) -> Result<(), Error> { ) -> Result<(), Error<'gc>> {
activation.avm2().native_method_table = native::NATIVE_METHOD_TABLE; activation.avm2().native_method_table = native::NATIVE_METHOD_TABLE;
activation.avm2().native_instance_allocator_table = native::NATIVE_INSTANCE_ALLOCATOR_TABLE; activation.avm2().native_instance_allocator_table = native::NATIVE_INSTANCE_ALLOCATOR_TABLE;

View File

@ -21,7 +21,7 @@ pub fn instance_init<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
activation.super_init(this, &[])?; activation.super_init(this, &[])?;
@ -55,7 +55,7 @@ pub fn class_init<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Ok(Value::Undefined) Ok(Value::Undefined)
} }
@ -64,7 +64,7 @@ pub fn length<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(array) = this.as_array_storage() { if let Some(array) = this.as_array_storage() {
return Ok(array.length().into()); return Ok(array.length().into());
@ -79,7 +79,7 @@ pub fn set_length<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(mut array) = this.as_array_storage_mut(activation.context.gc_context) { if let Some(mut array) = this.as_array_storage_mut(activation.context.gc_context) {
let size = args let size = args
@ -97,7 +97,7 @@ pub fn set_length<'gc>(
pub fn build_array<'gc>( pub fn build_array<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
array: ArrayStorage<'gc>, array: ArrayStorage<'gc>,
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Ok(ArrayObject::from_storage(activation, array)?.into()) Ok(ArrayObject::from_storage(activation, array)?.into())
} }
@ -107,7 +107,7 @@ pub fn concat<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
let mut base_array = this let mut base_array = this
.and_then(|this| this.as_array_storage().map(|a| a.clone())) .and_then(|this| this.as_array_storage().map(|a| a.clone()))
.unwrap_or_else(|| ArrayStorage::new(0)); .unwrap_or_else(|| ArrayStorage::new(0));
@ -129,7 +129,7 @@ pub fn resolve_array_hole<'gc>(
this: Object<'gc>, this: Object<'gc>,
i: usize, i: usize,
item: Option<Value<'gc>>, item: Option<Value<'gc>>,
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
item.map(Ok).unwrap_or_else(|| { item.map(Ok).unwrap_or_else(|| {
this.proto() this.proto()
.map(|p| { .map(|p| {
@ -150,9 +150,12 @@ pub fn join_inner<'gc, 'a, 'ctxt, C>(
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
mut conv: C, mut conv: C,
) -> Result<Value<'gc>, Error> ) -> Result<Value<'gc>, Error<'gc>>
where where
C: for<'b> FnMut(Value<'gc>, &'b mut Activation<'a, 'gc, 'ctxt>) -> Result<Value<'gc>, Error>, C: for<'b> FnMut(
Value<'gc>,
&'b mut Activation<'a, 'gc, 'ctxt>,
) -> Result<Value<'gc>, Error<'gc>>,
{ {
let mut separator = args.get(0).cloned().unwrap_or(Value::Undefined); let mut separator = args.get(0).cloned().unwrap_or(Value::Undefined);
if separator == Value::Undefined { if separator == Value::Undefined {
@ -190,7 +193,7 @@ pub fn join<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
join_inner(activation, this, args, |v, _act| Ok(v)) join_inner(activation, this, args, |v, _act| Ok(v))
} }
@ -199,7 +202,7 @@ pub fn to_string<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
join_inner(activation, this, &[",".into()], |v, _act| Ok(v)) join_inner(activation, this, &[",".into()], |v, _act| Ok(v))
} }
@ -208,7 +211,7 @@ pub fn to_locale_string<'gc>(
act: &mut Activation<'_, 'gc, '_>, act: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
join_inner(act, this, &[",".into()], |v, activation| { join_inner(act, this, &[",".into()], |v, activation| {
if let Ok(o) = v.coerce_to_object(activation) { if let Ok(o) = v.coerce_to_object(activation) {
o.call_property(&Multiname::public("toLocaleString"), &[], activation) o.call_property(&Multiname::public("toLocaleString"), &[], activation)
@ -223,7 +226,7 @@ pub fn value_of<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
join_inner(activation, this, &[",".into()], |v, _act| Ok(v)) join_inner(activation, this, &[",".into()], |v, _act| Ok(v))
} }
@ -256,7 +259,7 @@ impl<'gc> ArrayIter<'gc> {
pub fn new( pub fn new(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
array_object: Object<'gc>, array_object: Object<'gc>,
) -> Result<Self, Error> { ) -> Result<Self, Error<'gc>> {
Self::with_bounds(activation, array_object, 0, u32::MAX) Self::with_bounds(activation, array_object, 0, u32::MAX)
} }
@ -266,7 +269,7 @@ impl<'gc> ArrayIter<'gc> {
array_object: Object<'gc>, array_object: Object<'gc>,
start_index: u32, start_index: u32,
end_index: u32, end_index: u32,
) -> Result<Self, Error> { ) -> Result<Self, Error<'gc>> {
let length = array_object let length = array_object
.get_property(&Multiname::public("length"), activation)? .get_property(&Multiname::public("length"), activation)?
.coerce_to_u32(activation)?; .coerce_to_u32(activation)?;
@ -285,7 +288,7 @@ impl<'gc> ArrayIter<'gc> {
pub fn next( pub fn next(
&mut self, &mut self,
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
) -> Option<Result<(u32, Value<'gc>), Error>> { ) -> Option<Result<(u32, Value<'gc>), Error<'gc>>> {
if self.index < self.rev_index { if self.index < self.rev_index {
let i = self.index; let i = self.index;
@ -314,7 +317,7 @@ impl<'gc> ArrayIter<'gc> {
pub fn next_back( pub fn next_back(
&mut self, &mut self,
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
) -> Option<Result<(u32, Value<'gc>), Error>> { ) -> Option<Result<(u32, Value<'gc>), Error<'gc>>> {
if self.index < self.rev_index { if self.index < self.rev_index {
self.rev_index -= 1; self.rev_index -= 1;
@ -342,7 +345,7 @@ pub fn for_each<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
let callback = args let callback = args
.get(0) .get(0)
@ -367,7 +370,7 @@ pub fn map<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
let callback = args let callback = args
.get(0) .get(0)
@ -396,7 +399,7 @@ pub fn filter<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
let callback = args let callback = args
.get(0) .get(0)
@ -429,7 +432,7 @@ pub fn every<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
let callback = args let callback = args
.get(0) .get(0)
@ -462,7 +465,7 @@ pub fn some<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
let callback = args let callback = args
.get(0) .get(0)
@ -495,7 +498,7 @@ pub fn index_of<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(array) = this.as_array_storage() { if let Some(array) = this.as_array_storage() {
let search_val = args.get(0).cloned().unwrap_or(Value::Undefined); let search_val = args.get(0).cloned().unwrap_or(Value::Undefined);
@ -524,7 +527,7 @@ pub fn last_index_of<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(array) = this.as_array_storage() { if let Some(array) = this.as_array_storage() {
let search_val = args.get(0).cloned().unwrap_or(Value::Undefined); let search_val = args.get(0).cloned().unwrap_or(Value::Undefined);
@ -553,7 +556,7 @@ pub fn pop<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(mut array) = this.as_array_storage_mut(activation.context.gc_context) { if let Some(mut array) = this.as_array_storage_mut(activation.context.gc_context) {
return Ok(array.pop()); return Ok(array.pop());
@ -568,7 +571,7 @@ pub fn push<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(mut array) = this.as_array_storage_mut(activation.context.gc_context) { if let Some(mut array) = this.as_array_storage_mut(activation.context.gc_context) {
for arg in args { for arg in args {
@ -584,7 +587,7 @@ pub fn reverse<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(mut array) = this.as_array_storage_mut(activation.context.gc_context) { if let Some(mut array) = this.as_array_storage_mut(activation.context.gc_context) {
let mut last_non_hole_index = None; let mut last_non_hole_index = None;
@ -622,7 +625,7 @@ pub fn shift<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(mut array) = this.as_array_storage_mut(activation.context.gc_context) { if let Some(mut array) = this.as_array_storage_mut(activation.context.gc_context) {
return Ok(array.shift()); return Ok(array.shift());
@ -637,7 +640,7 @@ pub fn unshift<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(mut array) = this.as_array_storage_mut(activation.context.gc_context) { if let Some(mut array) = this.as_array_storage_mut(activation.context.gc_context) {
for arg in args.iter().rev() { for arg in args.iter().rev() {
@ -654,7 +657,7 @@ pub fn resolve_index<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
index: Value<'gc>, index: Value<'gc>,
length: usize, length: usize,
) -> Result<usize, Error> { ) -> Result<usize, Error<'gc>> {
let index = index.coerce_to_i32(activation)?; let index = index.coerce_to_i32(activation)?;
Ok(if index < 0 { Ok(if index < 0 {
@ -670,7 +673,7 @@ pub fn slice<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
let array_length = this.as_array_storage().map(|a| a.length()); let array_length = this.as_array_storage().map(|a| a.length());
@ -711,7 +714,7 @@ pub fn splice<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
let array_length = this.as_array_storage().map(|a| a.length()); let array_length = this.as_array_storage().map(|a| a.length());
@ -786,7 +789,11 @@ bitflags! {
/// the HRTB necessary to accept an activation. /// the HRTB necessary to accept an activation.
fn constrain<'a, 'gc, 'ctxt, F>(f: F) -> F fn constrain<'a, 'gc, 'ctxt, F>(f: F) -> F
where where
F: FnMut(&mut Activation<'a, 'gc, 'ctxt>, Value<'gc>, Value<'gc>) -> Result<Ordering, Error>, F: FnMut(
&mut Activation<'a, 'gc, 'ctxt>,
Value<'gc>,
Value<'gc>,
) -> Result<Ordering, Error<'gc>>,
{ {
f f
} }
@ -809,9 +816,13 @@ fn sort_inner<'a, 'gc, 'ctxt, C>(
values: &mut [(usize, Value<'gc>)], values: &mut [(usize, Value<'gc>)],
options: SortOptions, options: SortOptions,
mut sort_func: C, mut sort_func: C,
) -> Result<bool, Error> ) -> Result<bool, Error<'gc>>
where where
C: FnMut(&mut Activation<'a, 'gc, 'ctxt>, Value<'gc>, Value<'gc>) -> Result<Ordering, Error>, C: FnMut(
&mut Activation<'a, 'gc, 'ctxt>,
Value<'gc>,
Value<'gc>,
) -> Result<Ordering, Error<'gc>>,
{ {
let mut unique_sort_satisfied = true; let mut unique_sort_satisfied = true;
let mut error_signal = Ok(()); let mut error_signal = Ok(());
@ -852,7 +863,7 @@ pub fn compare_string_case_sensitive<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
a: Value<'gc>, a: Value<'gc>,
b: Value<'gc>, b: Value<'gc>,
) -> Result<Ordering, Error> { ) -> Result<Ordering, Error<'gc>> {
let string_a = a.coerce_to_string(activation)?; let string_a = a.coerce_to_string(activation)?;
let string_b = b.coerce_to_string(activation)?; let string_b = b.coerce_to_string(activation)?;
@ -863,7 +874,7 @@ pub fn compare_string_case_insensitive<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
a: Value<'gc>, a: Value<'gc>,
b: Value<'gc>, b: Value<'gc>,
) -> Result<Ordering, Error> { ) -> Result<Ordering, Error<'gc>> {
let string_a = a.coerce_to_string(activation)?; let string_a = a.coerce_to_string(activation)?;
let string_b = b.coerce_to_string(activation)?; let string_b = b.coerce_to_string(activation)?;
@ -874,7 +885,7 @@ pub fn compare_numeric<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
a: Value<'gc>, a: Value<'gc>,
b: Value<'gc>, b: Value<'gc>,
) -> Result<Ordering, Error> { ) -> Result<Ordering, Error<'gc>> {
let num_a = a.coerce_to_number(activation)?; let num_a = a.coerce_to_number(activation)?;
let num_b = b.coerce_to_number(activation)?; let num_b = b.coerce_to_number(activation)?;
@ -896,7 +907,7 @@ fn sort_postprocess<'gc>(
options: SortOptions, options: SortOptions,
unique_satisfied: bool, unique_satisfied: bool,
values: Vec<(usize, Value<'gc>)>, values: Vec<(usize, Value<'gc>)>,
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if unique_satisfied { if unique_satisfied {
if options.contains(SortOptions::RETURN_INDEXED_ARRAY) { if options.contains(SortOptions::RETURN_INDEXED_ARRAY) {
return build_array( return build_array(
@ -938,7 +949,7 @@ fn sort_postprocess<'gc>(
fn extract_array_values<'gc>( fn extract_array_values<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
value: Value<'gc>, value: Value<'gc>,
) -> Result<Option<Vec<Value<'gc>>>, Error> { ) -> Result<Option<Vec<Value<'gc>>>, Error<'gc>> {
let object = value.as_object(); let object = value.as_object();
let holey_vec = if let Some(object) = object { let holey_vec = if let Some(object) = object {
if let Some(field_array) = object.as_array_storage() { if let Some(field_array) = object.as_array_storage() {
@ -963,7 +974,7 @@ pub fn sort<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
let (compare_fnc, options) = if args.len() > 1 { let (compare_fnc, options) = if args.len() > 1 {
( (
@ -1053,7 +1064,7 @@ pub fn sort<'gc>(
fn extract_maybe_array_values<'gc>( fn extract_maybe_array_values<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
value: Value<'gc>, value: Value<'gc>,
) -> Result<Vec<Value<'gc>>, Error> { ) -> Result<Vec<Value<'gc>>, Error<'gc>> {
Ok(extract_array_values(activation, value)?.unwrap_or_else(|| vec![value])) Ok(extract_array_values(activation, value)?.unwrap_or_else(|| vec![value]))
} }
@ -1066,7 +1077,7 @@ fn extract_maybe_array_values<'gc>(
fn extract_maybe_array_strings<'gc>( fn extract_maybe_array_strings<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
value: Value<'gc>, value: Value<'gc>,
) -> Result<Vec<AvmString<'gc>>, Error> { ) -> Result<Vec<AvmString<'gc>>, Error<'gc>> {
let values = extract_maybe_array_values(activation, value)?; let values = extract_maybe_array_values(activation, value)?;
let mut out = Vec::with_capacity(values.len()); let mut out = Vec::with_capacity(values.len());
@ -1085,7 +1096,7 @@ fn extract_maybe_array_strings<'gc>(
fn extract_maybe_array_sort_options<'gc>( fn extract_maybe_array_sort_options<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
value: Value<'gc>, value: Value<'gc>,
) -> Result<Vec<SortOptions>, Error> { ) -> Result<Vec<SortOptions>, Error<'gc>> {
let values = extract_maybe_array_values(activation, value)?; let values = extract_maybe_array_values(activation, value)?;
let mut out = Vec::with_capacity(values.len()); let mut out = Vec::with_capacity(values.len());
@ -1102,7 +1113,7 @@ pub fn sort_on<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(field_names_value) = args.get(0).cloned() { if let Some(field_names_value) = args.get(0).cloned() {
let field_names = extract_maybe_array_strings(activation, field_names_value)?; let field_names = extract_maybe_array_strings(activation, field_names_value)?;

View File

@ -16,7 +16,7 @@ fn instance_init<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(mut prim) = this.as_primitive_mut(activation.context.gc_context) { if let Some(mut prim) = this.as_primitive_mut(activation.context.gc_context) {
if matches!(*prim, Value::Undefined | Value::Null) { if matches!(*prim, Value::Undefined | Value::Null) {
@ -38,7 +38,7 @@ fn native_instance_init<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
activation.super_init(this, args)?; activation.super_init(this, args)?;
} }
@ -51,7 +51,7 @@ fn class_init<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
let scope = activation.create_scopechain(); let scope = activation.create_scopechain();
let gc_context = activation.context.gc_context; let gc_context = activation.context.gc_context;
@ -94,7 +94,7 @@ fn to_string<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(this) = this.as_primitive() { if let Some(this) = this.as_primitive() {
match *this { match *this {
@ -113,7 +113,7 @@ fn value_of<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(this) = this.as_primitive() { if let Some(this) = this.as_primitive() {
return Ok(*this); return Ok(*this);

View File

@ -19,7 +19,7 @@ pub fn instance_init<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Err("Classes cannot be constructed.".into()) Err("Classes cannot be constructed.".into())
} }
@ -28,7 +28,7 @@ pub fn class_init<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Ok(Value::Undefined) Ok(Value::Undefined)
} }
@ -36,7 +36,7 @@ fn prototype<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(class) = this.as_class_object() { if let Some(class) = this.as_class_object() {
return Ok(class.prototype().into()); return Ok(class.prototype().into());

View File

@ -106,7 +106,7 @@ impl<'builder, 'activation_a, 'gc, 'gc_context, T: TimeZone>
self self
} }
fn year(&mut self, value: Option<&Value<'gc>>) -> Result<&mut Self, Error> { fn year(&mut self, value: Option<&Value<'gc>>) -> Result<&mut Self, Error<'gc>> {
self.year = match value { self.year = match value {
Some(value) => Some(Some(value.coerce_to_number(self.activation)?)), Some(value) => Some(Some(value.coerce_to_number(self.activation)?)),
None => None, None => None,
@ -114,7 +114,7 @@ impl<'builder, 'activation_a, 'gc, 'gc_context, T: TimeZone>
Ok(self) Ok(self)
} }
fn month(&mut self, value: Option<&Value<'gc>>) -> Result<&mut Self, Error> { fn month(&mut self, value: Option<&Value<'gc>>) -> Result<&mut Self, Error<'gc>> {
self.month = match value { self.month = match value {
Some(value) => Some(Some(value.coerce_to_number(self.activation)?)), Some(value) => Some(Some(value.coerce_to_number(self.activation)?)),
None => None, None => None,
@ -122,7 +122,7 @@ impl<'builder, 'activation_a, 'gc, 'gc_context, T: TimeZone>
Ok(self) Ok(self)
} }
fn day(&mut self, value: Option<&Value<'gc>>) -> Result<&mut Self, Error> { fn day(&mut self, value: Option<&Value<'gc>>) -> Result<&mut Self, Error<'gc>> {
self.day = match value { self.day = match value {
Some(value) => Some(Some(value.coerce_to_number(self.activation)?)), Some(value) => Some(Some(value.coerce_to_number(self.activation)?)),
None => None, None => None,
@ -130,7 +130,7 @@ impl<'builder, 'activation_a, 'gc, 'gc_context, T: TimeZone>
Ok(self) Ok(self)
} }
fn hour(&mut self, value: Option<&Value<'gc>>) -> Result<&mut Self, Error> { fn hour(&mut self, value: Option<&Value<'gc>>) -> Result<&mut Self, Error<'gc>> {
self.hour = match value { self.hour = match value {
Some(value) => Some(Some(value.coerce_to_number(self.activation)?)), Some(value) => Some(Some(value.coerce_to_number(self.activation)?)),
None => None, None => None,
@ -138,7 +138,7 @@ impl<'builder, 'activation_a, 'gc, 'gc_context, T: TimeZone>
Ok(self) Ok(self)
} }
fn minute(&mut self, value: Option<&Value<'gc>>) -> Result<&mut Self, Error> { fn minute(&mut self, value: Option<&Value<'gc>>) -> Result<&mut Self, Error<'gc>> {
self.minute = match value { self.minute = match value {
Some(value) => Some(Some(value.coerce_to_number(self.activation)?)), Some(value) => Some(Some(value.coerce_to_number(self.activation)?)),
None => None, None => None,
@ -146,7 +146,7 @@ impl<'builder, 'activation_a, 'gc, 'gc_context, T: TimeZone>
Ok(self) Ok(self)
} }
fn second(&mut self, value: Option<&Value<'gc>>) -> Result<&mut Self, Error> { fn second(&mut self, value: Option<&Value<'gc>>) -> Result<&mut Self, Error<'gc>> {
self.second = match value { self.second = match value {
Some(value) => Some(Some(value.coerce_to_number(self.activation)?)), Some(value) => Some(Some(value.coerce_to_number(self.activation)?)),
None => None, None => None,
@ -154,7 +154,7 @@ impl<'builder, 'activation_a, 'gc, 'gc_context, T: TimeZone>
Ok(self) Ok(self)
} }
fn millisecond(&mut self, value: Option<&Value<'gc>>) -> Result<&mut Self, Error> { fn millisecond(&mut self, value: Option<&Value<'gc>>) -> Result<&mut Self, Error<'gc>> {
self.millisecond = match value { self.millisecond = match value {
Some(value) => Some(Some(value.coerce_to_number(self.activation)?)), Some(value) => Some(Some(value.coerce_to_number(self.activation)?)),
None => None, None => None,
@ -243,7 +243,7 @@ pub fn instance_init<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
activation.super_init(this, &[])?; activation.super_init(this, &[])?;
if let Some(date) = this.as_date_object() { if let Some(date) = this.as_date_object() {
@ -296,7 +296,7 @@ pub fn class_init<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
let scope = activation.create_scopechain(); let scope = activation.create_scopechain();
let gc_context = activation.context.gc_context; let gc_context = activation.context.gc_context;
@ -327,7 +327,7 @@ pub fn time<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this.and_then(|this| this.as_date_object()) { if let Some(this) = this.and_then(|this| this.as_date_object()) {
return this.value_of(activation.context.gc_context); return this.value_of(activation.context.gc_context);
} }
@ -340,7 +340,7 @@ pub fn set_time<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this.and_then(|this| this.as_date_object()) { if let Some(this) = this.and_then(|this| this.as_date_object()) {
let new_time = args let new_time = args
.get(0) .get(0)
@ -364,7 +364,7 @@ pub fn milliseconds<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this.and_then(|this| this.as_date_object()) { if let Some(this) = this.and_then(|this| this.as_date_object()) {
if let Some(date) = this if let Some(date) = this
.date_time() .date_time()
@ -384,7 +384,7 @@ pub fn set_milliseconds<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this.and_then(|this| this.as_date_object()) { if let Some(this) = this.and_then(|this| this.as_date_object()) {
let timestamp = DateAdjustment::new(activation, &get_timezone()) let timestamp = DateAdjustment::new(activation, &get_timezone())
.millisecond(args.get(0))? .millisecond(args.get(0))?
@ -399,7 +399,7 @@ pub fn seconds<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this.and_then(|this| this.as_date_object()) { if let Some(this) = this.and_then(|this| this.as_date_object()) {
if let Some(date) = this if let Some(date) = this
.date_time() .date_time()
@ -419,7 +419,7 @@ pub fn set_seconds<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this.and_then(|this| this.as_date_object()) { if let Some(this) = this.and_then(|this| this.as_date_object()) {
let timestamp = DateAdjustment::new(activation, &get_timezone()) let timestamp = DateAdjustment::new(activation, &get_timezone())
.second(args.get(0))? .second(args.get(0))?
@ -435,7 +435,7 @@ pub fn minutes<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this.and_then(|this| this.as_date_object()) { if let Some(this) = this.and_then(|this| this.as_date_object()) {
if let Some(date) = this if let Some(date) = this
.date_time() .date_time()
@ -455,7 +455,7 @@ pub fn set_minutes<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this.and_then(|this| this.as_date_object()) { if let Some(this) = this.and_then(|this| this.as_date_object()) {
let timestamp = DateAdjustment::new(activation, &get_timezone()) let timestamp = DateAdjustment::new(activation, &get_timezone())
.minute(args.get(0))? .minute(args.get(0))?
@ -472,7 +472,7 @@ pub fn hours<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this.and_then(|this| this.as_date_object()) { if let Some(this) = this.and_then(|this| this.as_date_object()) {
if let Some(date) = this if let Some(date) = this
.date_time() .date_time()
@ -492,7 +492,7 @@ pub fn set_hours<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this.and_then(|this| this.as_date_object()) { if let Some(this) = this.and_then(|this| this.as_date_object()) {
let timestamp = DateAdjustment::new(activation, &get_timezone()) let timestamp = DateAdjustment::new(activation, &get_timezone())
.hour(args.get(0))? .hour(args.get(0))?
@ -510,7 +510,7 @@ pub fn date<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this.and_then(|this| this.as_date_object()) { if let Some(this) = this.and_then(|this| this.as_date_object()) {
if let Some(date) = this if let Some(date) = this
.date_time() .date_time()
@ -530,7 +530,7 @@ pub fn set_date<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this.and_then(|this| this.as_date_object()) { if let Some(this) = this.and_then(|this| this.as_date_object()) {
let timestamp = DateAdjustment::new(activation, &get_timezone()) let timestamp = DateAdjustment::new(activation, &get_timezone())
.day(args.get(0))? .day(args.get(0))?
@ -545,7 +545,7 @@ pub fn month<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this.and_then(|this| this.as_date_object()) { if let Some(this) = this.and_then(|this| this.as_date_object()) {
if let Some(date) = this if let Some(date) = this
.date_time() .date_time()
@ -565,7 +565,7 @@ pub fn set_month<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this.and_then(|this| this.as_date_object()) { if let Some(this) = this.and_then(|this| this.as_date_object()) {
let timestamp = DateAdjustment::new(activation, &get_timezone()) let timestamp = DateAdjustment::new(activation, &get_timezone())
.month(args.get(0))? .month(args.get(0))?
@ -581,7 +581,7 @@ pub fn full_year<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this.and_then(|this| this.as_date_object()) { if let Some(this) = this.and_then(|this| this.as_date_object()) {
if let Some(date) = this if let Some(date) = this
.date_time() .date_time()
@ -601,7 +601,7 @@ pub fn set_full_year<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this.and_then(|this| this.as_date_object()) { if let Some(this) = this.and_then(|this| this.as_date_object()) {
let timestamp = DateAdjustment::new(activation, &get_timezone()) let timestamp = DateAdjustment::new(activation, &get_timezone())
.year(args.get(0))? .year(args.get(0))?
@ -618,7 +618,7 @@ pub fn day<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this.and_then(|this| this.as_date_object()) { if let Some(this) = this.and_then(|this| this.as_date_object()) {
if let Some(date) = this if let Some(date) = this
.date_time() .date_time()
@ -638,7 +638,7 @@ pub fn milliseconds_utc<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this.and_then(|this| this.as_date_object()) { if let Some(this) = this.and_then(|this| this.as_date_object()) {
if let Some(date) = this.date_time() { if let Some(date) = this.date_time() {
return Ok((date.timestamp_subsec_millis() as f64).into()); return Ok((date.timestamp_subsec_millis() as f64).into());
@ -655,7 +655,7 @@ pub fn set_milliseconds_utc<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this.and_then(|this| this.as_date_object()) { if let Some(this) = this.and_then(|this| this.as_date_object()) {
let timestamp = DateAdjustment::new(activation, &Utc) let timestamp = DateAdjustment::new(activation, &Utc)
.millisecond(args.get(0))? .millisecond(args.get(0))?
@ -670,7 +670,7 @@ pub fn seconds_utc<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this.and_then(|this| this.as_date_object()) { if let Some(this) = this.and_then(|this| this.as_date_object()) {
if let Some(date) = this.date_time() { if let Some(date) = this.date_time() {
return Ok((date.second() as f64).into()); return Ok((date.second() as f64).into());
@ -687,7 +687,7 @@ pub fn set_seconds_utc<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this.and_then(|this| this.as_date_object()) { if let Some(this) = this.and_then(|this| this.as_date_object()) {
let timestamp = DateAdjustment::new(activation, &Utc) let timestamp = DateAdjustment::new(activation, &Utc)
.second(args.get(0))? .second(args.get(0))?
@ -703,7 +703,7 @@ pub fn minutes_utc<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this.and_then(|this| this.as_date_object()) { if let Some(this) = this.and_then(|this| this.as_date_object()) {
if let Some(date) = this.date_time() { if let Some(date) = this.date_time() {
return Ok((date.minute() as f64).into()); return Ok((date.minute() as f64).into());
@ -720,7 +720,7 @@ pub fn set_minutes_utc<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this.and_then(|this| this.as_date_object()) { if let Some(this) = this.and_then(|this| this.as_date_object()) {
let timestamp = DateAdjustment::new(activation, &Utc) let timestamp = DateAdjustment::new(activation, &Utc)
.minute(args.get(0))? .minute(args.get(0))?
@ -737,7 +737,7 @@ pub fn hours_utc<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this.and_then(|this| this.as_date_object()) { if let Some(this) = this.and_then(|this| this.as_date_object()) {
if let Some(date) = this.date_time() { if let Some(date) = this.date_time() {
return Ok((date.hour() as f64).into()); return Ok((date.hour() as f64).into());
@ -754,7 +754,7 @@ pub fn set_hours_utc<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this.and_then(|this| this.as_date_object()) { if let Some(this) = this.and_then(|this| this.as_date_object()) {
let timestamp = DateAdjustment::new(activation, &Utc) let timestamp = DateAdjustment::new(activation, &Utc)
.hour(args.get(0))? .hour(args.get(0))?
@ -772,7 +772,7 @@ pub fn date_utc<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this.and_then(|this| this.as_date_object()) { if let Some(this) = this.and_then(|this| this.as_date_object()) {
if let Some(date) = this.date_time() { if let Some(date) = this.date_time() {
return Ok((date.day() as f64).into()); return Ok((date.day() as f64).into());
@ -789,7 +789,7 @@ pub fn set_date_utc<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this.and_then(|this| this.as_date_object()) { if let Some(this) = this.and_then(|this| this.as_date_object()) {
let timestamp = DateAdjustment::new(activation, &Utc) let timestamp = DateAdjustment::new(activation, &Utc)
.day(args.get(0))? .day(args.get(0))?
@ -804,7 +804,7 @@ pub fn month_utc<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this.and_then(|this| this.as_date_object()) { if let Some(this) = this.and_then(|this| this.as_date_object()) {
if let Some(date) = this.date_time() { if let Some(date) = this.date_time() {
return Ok((date.month0() as f64).into()); return Ok((date.month0() as f64).into());
@ -821,7 +821,7 @@ pub fn set_month_utc<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this.and_then(|this| this.as_date_object()) { if let Some(this) = this.and_then(|this| this.as_date_object()) {
let timestamp = DateAdjustment::new(activation, &Utc) let timestamp = DateAdjustment::new(activation, &Utc)
.month(args.get(0))? .month(args.get(0))?
@ -837,7 +837,7 @@ pub fn full_year_utc<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this.and_then(|this| this.as_date_object()) { if let Some(this) = this.and_then(|this| this.as_date_object()) {
if let Some(date) = this.date_time() { if let Some(date) = this.date_time() {
return Ok((date.year() as f64).into()); return Ok((date.year() as f64).into());
@ -854,7 +854,7 @@ pub fn set_full_year_utc<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this.and_then(|this| this.as_date_object()) { if let Some(this) = this.and_then(|this| this.as_date_object()) {
let timestamp = DateAdjustment::new(activation, &Utc) let timestamp = DateAdjustment::new(activation, &Utc)
.year(args.get(0))? .year(args.get(0))?
@ -871,7 +871,7 @@ pub fn day_utc<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this.and_then(|this| this.as_date_object()) { if let Some(this) = this.and_then(|this| this.as_date_object()) {
if let Some(date) = this.date_time() { if let Some(date) = this.date_time() {
return Ok((date.weekday().num_days_from_sunday() as f64).into()); return Ok((date.weekday().num_days_from_sunday() as f64).into());
@ -888,7 +888,7 @@ pub fn timezone_offset<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this.and_then(|this| this.as_date_object()) { if let Some(this) = this.and_then(|this| this.as_date_object()) {
if let Some(date) = this if let Some(date) = this
.date_time() .date_time()
@ -909,7 +909,7 @@ pub fn utc<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
let date = DateAdjustment::new(activation, &Utc) let date = DateAdjustment::new(activation, &Utc)
.year(args.get(0))? .year(args.get(0))?
.month(args.get(1))? .month(args.get(1))?
@ -934,7 +934,7 @@ pub fn to_string<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this.and_then(|this| this.as_date_object()) { if let Some(this) = this.and_then(|this| this.as_date_object()) {
if let Some(date) = this if let Some(date) = this
.date_time() .date_time()
@ -958,7 +958,7 @@ pub fn to_utc_string<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this.and_then(|this| this.as_date_object()) { if let Some(this) = this.and_then(|this| this.as_date_object()) {
if let Some(date) = this.date_time() { if let Some(date) = this.date_time() {
return Ok(AvmString::new_utf8( return Ok(AvmString::new_utf8(
@ -979,7 +979,7 @@ pub fn to_locale_string<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this.and_then(|this| this.as_date_object()) { if let Some(this) = this.and_then(|this| this.as_date_object()) {
if let Some(date) = this if let Some(date) = this
.date_time() .date_time()
@ -1003,7 +1003,7 @@ pub fn to_time_string<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this.and_then(|this| this.as_date_object()) { if let Some(this) = this.and_then(|this| this.as_date_object()) {
if let Some(date) = this if let Some(date) = this
.date_time() .date_time()
@ -1027,7 +1027,7 @@ pub fn to_locale_time_string<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this.and_then(|this| this.as_date_object()) { if let Some(this) = this.and_then(|this| this.as_date_object()) {
if let Some(date) = this if let Some(date) = this
.date_time() .date_time()
@ -1051,7 +1051,7 @@ pub fn to_date_string<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this.and_then(|this| this.as_date_object()) { if let Some(this) = this.and_then(|this| this.as_date_object()) {
if let Some(date) = this if let Some(date) = this
.date_time() .date_time()
@ -1175,7 +1175,7 @@ pub fn parse<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
const DAYS: [&[u8]; 7] = [b"Sun", b"Mon", b"Tue", b"Wed", b"Thu", b"Fri", b"Sat"]; const DAYS: [&[u8]; 7] = [b"Sun", b"Mon", b"Tue", b"Wed", b"Thu", b"Fri", b"Sat"];
let date_str = args let date_str = args

View File

@ -10,7 +10,7 @@ pub fn get_stack_trace<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
use crate::avm2::TObject; use crate::avm2::TObject;
if let Some(error) = this.and_then(|this| this.as_error_object()) { if let Some(error) = this.and_then(|this| this.as_error_object()) {
return Ok(error.display_full(activation)?.into()); return Ok(error.display_full(activation)?.into());
@ -23,6 +23,6 @@ pub fn get_stack_trace<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Ok(Value::Null) Ok(Value::Null)
} }

View File

@ -9,7 +9,7 @@ pub fn generate_random_bytes<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
let length = args let length = args
.get(0) .get(0)
.unwrap_or(&Value::Undefined) .unwrap_or(&Value::Undefined)

View File

@ -17,7 +17,7 @@ pub fn instance_init<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(mut this) = this { if let Some(mut this) = this {
activation.super_init(this, &[])?; activation.super_init(this, &[])?;
@ -96,7 +96,7 @@ pub fn class_init<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Ok(Value::Undefined) Ok(Value::Undefined)
} }
@ -105,7 +105,7 @@ pub fn bitmap_data<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(bitmap) = this if let Some(bitmap) = this
.and_then(|this| this.as_display_object()) .and_then(|this| this.as_display_object())
.and_then(|dobj| dobj.as_bitmap()) .and_then(|dobj| dobj.as_bitmap())
@ -124,7 +124,7 @@ pub fn set_bitmap_data<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(bitmap) = this if let Some(bitmap) = this
.and_then(|this| this.as_display_object()) .and_then(|this| this.as_display_object())
.and_then(|dobj| dobj.as_bitmap()) .and_then(|dobj| dobj.as_bitmap())
@ -147,7 +147,7 @@ pub fn pixel_snapping<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Ok("auto".into()) Ok("auto".into())
} }
@ -156,7 +156,7 @@ pub fn set_pixel_snapping<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Err("Bitmap.pixelSnapping is a stub".into()) Err("Bitmap.pixelSnapping is a stub".into())
} }
@ -165,7 +165,7 @@ pub fn smoothing<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(bitmap) = this if let Some(bitmap) = this
.and_then(|this| this.as_display_object()) .and_then(|this| this.as_display_object())
.and_then(|dobj| dobj.as_bitmap()) .and_then(|dobj| dobj.as_bitmap())
@ -181,7 +181,7 @@ pub fn set_smoothing<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(bitmap) = this if let Some(bitmap) = this
.and_then(|this| this.as_display_object()) .and_then(|this| this.as_display_object())
.and_then(|dobj| dobj.as_bitmap()) .and_then(|dobj| dobj.as_bitmap())

View File

@ -23,7 +23,7 @@ pub fn instance_init<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
activation.super_init(this, &[])?; activation.super_init(this, &[])?;
@ -125,7 +125,7 @@ pub fn class_init<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Ok(Value::Undefined) Ok(Value::Undefined)
} }
@ -134,7 +134,7 @@ pub fn width<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(bitmap_data) = this.and_then(|t| t.as_bitmap_data()) { if let Some(bitmap_data) = this.and_then(|t| t.as_bitmap_data()) {
bitmap_data.read().check_valid()?; bitmap_data.read().check_valid()?;
return Ok((bitmap_data.read().width() as i32).into()); return Ok((bitmap_data.read().width() as i32).into());
@ -148,7 +148,7 @@ pub fn height<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(bitmap_data) = this.and_then(|t| t.as_bitmap_data()) { if let Some(bitmap_data) = this.and_then(|t| t.as_bitmap_data()) {
bitmap_data.read().check_valid()?; bitmap_data.read().check_valid()?;
return Ok((bitmap_data.read().height() as i32).into()); return Ok((bitmap_data.read().height() as i32).into());
@ -162,7 +162,7 @@ pub fn transparent<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(bitmap_data) = this.and_then(|t| t.as_bitmap_data()) { if let Some(bitmap_data) = this.and_then(|t| t.as_bitmap_data()) {
bitmap_data.read().check_valid()?; bitmap_data.read().check_valid()?;
return Ok(bitmap_data.read().transparency().into()); return Ok(bitmap_data.read().transparency().into());
@ -176,7 +176,7 @@ pub fn scroll<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(bitmap_data) = this.and_then(|t| t.as_bitmap_data()) { if let Some(bitmap_data) = this.and_then(|t| t.as_bitmap_data()) {
bitmap_data.read().check_valid()?; bitmap_data.read().check_valid()?;
let x = args let x = args
@ -201,7 +201,7 @@ pub fn copy_pixels<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(bitmap_data) = this.and_then(|t| t.as_bitmap_data()) { if let Some(bitmap_data) = this.and_then(|t| t.as_bitmap_data()) {
bitmap_data.read().check_valid()?; bitmap_data.read().check_valid()?;
let source_bitmap = args let source_bitmap = args
@ -321,7 +321,7 @@ pub fn get_pixel<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(bitmap_data) = this.and_then(|t| t.as_bitmap_data()) { if let Some(bitmap_data) = this.and_then(|t| t.as_bitmap_data()) {
bitmap_data.read().check_valid()?; bitmap_data.read().check_valid()?;
let x = args let x = args
@ -343,7 +343,7 @@ pub fn get_pixel32<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(bitmap_data) = this.and_then(|t| t.as_bitmap_data()) { if let Some(bitmap_data) = this.and_then(|t| t.as_bitmap_data()) {
let x = args let x = args
.get(0) .get(0)
@ -364,7 +364,7 @@ pub fn lock<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
log::warn!("BitmapData.lock - not yet implemented"); log::warn!("BitmapData.lock - not yet implemented");
Ok(Value::Undefined) Ok(Value::Undefined)
} }
@ -374,7 +374,7 @@ pub fn draw<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(bitmap_data) = this.and_then(|this| this.as_bitmap_data()) { if let Some(bitmap_data) = this.and_then(|this| this.as_bitmap_data()) {
bitmap_data.read().check_valid()?; bitmap_data.read().check_valid()?;
let mut transform = Transform::default(); let mut transform = Transform::default();
@ -444,7 +444,7 @@ pub fn fill_rect<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
let rectangle = args let rectangle = args
.get(0) .get(0)
.unwrap_or(&Value::Undefined) .unwrap_or(&Value::Undefined)
@ -485,7 +485,7 @@ pub fn dispose<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(bitmap_data) = this.and_then(|this| this.as_bitmap_data()) { if let Some(bitmap_data) = this.and_then(|this| this.as_bitmap_data()) {
// Don't check if we've already disposed this BitmapData - 'BitmapData.dispose()' can be called // Don't check if we've already disposed this BitmapData - 'BitmapData.dispose()' can be called
// multiple times // multiple times
@ -501,7 +501,7 @@ pub fn rect<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(bitmap_data) = this.and_then(|this| this.as_bitmap_data()) { if let Some(bitmap_data) = this.and_then(|this| this.as_bitmap_data()) {
let bd = bitmap_data.read(); let bd = bitmap_data.read();
return Ok(activation return Ok(activation
@ -522,7 +522,7 @@ pub fn apply_filter<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
log::warn!("BitmapData.applyFilter: Not yet implemented"); log::warn!("BitmapData.applyFilter: Not yet implemented");
Ok(Value::Undefined) Ok(Value::Undefined)
} }

View File

@ -26,7 +26,7 @@ pub fn instance_init<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Err("You cannot construct DisplayObject directly.".into()) Err("You cannot construct DisplayObject directly.".into())
} }
@ -35,7 +35,7 @@ pub fn native_instance_init<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
activation.super_init(this, &[])?; activation.super_init(this, &[])?;
@ -73,7 +73,7 @@ pub fn class_init<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Ok(Value::Undefined) Ok(Value::Undefined)
} }
@ -82,7 +82,7 @@ pub fn alpha<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(dobj) = this.and_then(|this| this.as_display_object()) { if let Some(dobj) = this.and_then(|this| this.as_display_object()) {
return Ok(dobj.alpha().into()); return Ok(dobj.alpha().into());
} }
@ -95,7 +95,7 @@ pub fn set_alpha<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(dobj) = this.and_then(|this| this.as_display_object()) { if let Some(dobj) = this.and_then(|this| this.as_display_object()) {
let new_alpha = args let new_alpha = args
.get(0) .get(0)
@ -113,7 +113,7 @@ pub fn height<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(dobj) = this.and_then(|this| this.as_display_object()) { if let Some(dobj) = this.and_then(|this| this.as_display_object()) {
return Ok(dobj.height().into()); return Ok(dobj.height().into());
} }
@ -126,7 +126,7 @@ pub fn set_height<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(dobj) = this.and_then(|this| this.as_display_object()) { if let Some(dobj) = this.and_then(|this| this.as_display_object()) {
let new_height = args let new_height = args
.get(0) .get(0)
@ -147,7 +147,7 @@ pub fn scale_y<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(dobj) = this.and_then(|this| this.as_display_object()) { if let Some(dobj) = this.and_then(|this| this.as_display_object()) {
return Ok(dobj return Ok(dobj
.scale_y(activation.context.gc_context) .scale_y(activation.context.gc_context)
@ -163,7 +163,7 @@ pub fn set_scale_y<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(dobj) = this.and_then(|this| this.as_display_object()) { if let Some(dobj) = this.and_then(|this| this.as_display_object()) {
let new_scale = args let new_scale = args
.get(0) .get(0)
@ -181,7 +181,7 @@ pub fn width<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(dobj) = this.and_then(|this| this.as_display_object()) { if let Some(dobj) = this.and_then(|this| this.as_display_object()) {
return Ok(dobj.width().into()); return Ok(dobj.width().into());
} }
@ -194,7 +194,7 @@ pub fn set_width<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(dobj) = this.and_then(|this| this.as_display_object()) { if let Some(dobj) = this.and_then(|this| this.as_display_object()) {
let new_width = args let new_width = args
.get(0) .get(0)
@ -215,7 +215,7 @@ pub fn scale_x<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(dobj) = this.and_then(|this| this.as_display_object()) { if let Some(dobj) = this.and_then(|this| this.as_display_object()) {
return Ok(dobj return Ok(dobj
.scale_x(activation.context.gc_context) .scale_x(activation.context.gc_context)
@ -231,7 +231,7 @@ pub fn set_scale_x<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(dobj) = this.and_then(|this| this.as_display_object()) { if let Some(dobj) = this.and_then(|this| this.as_display_object()) {
let new_scale = args let new_scale = args
.get(0) .get(0)
@ -249,7 +249,7 @@ pub fn filters<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
log::warn!("DisplayObject.filters getter - not yet implemented"); log::warn!("DisplayObject.filters getter - not yet implemented");
Ok(ArrayObject::empty(activation)?.into()) Ok(ArrayObject::empty(activation)?.into())
} }
@ -259,7 +259,7 @@ pub fn set_filters<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
log::warn!("DisplayObject.filters setter - not yet implemented"); log::warn!("DisplayObject.filters setter - not yet implemented");
Ok(Value::Undefined) Ok(Value::Undefined)
} }
@ -269,7 +269,7 @@ pub fn x<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(dobj) = this.and_then(|this| this.as_display_object()) { if let Some(dobj) = this.and_then(|this| this.as_display_object()) {
return Ok(dobj.x().into()); return Ok(dobj.x().into());
} }
@ -282,7 +282,7 @@ pub fn set_x<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(dobj) = this.and_then(|this| this.as_display_object()) { if let Some(dobj) = this.and_then(|this| this.as_display_object()) {
let new_x = args let new_x = args
.get(0) .get(0)
@ -301,7 +301,7 @@ pub fn y<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(dobj) = this.and_then(|this| this.as_display_object()) { if let Some(dobj) = this.and_then(|this| this.as_display_object()) {
return Ok(dobj.y().into()); return Ok(dobj.y().into());
} }
@ -314,7 +314,7 @@ pub fn set_y<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(dobj) = this.and_then(|this| this.as_display_object()) { if let Some(dobj) = this.and_then(|this| this.as_display_object()) {
let new_y = args let new_y = args
.get(0) .get(0)
@ -333,7 +333,7 @@ pub fn rotation<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(dobj) = this.and_then(|this| this.as_display_object()) { if let Some(dobj) = this.and_then(|this| this.as_display_object()) {
let rot: f64 = dobj.rotation(activation.context.gc_context).into(); let rot: f64 = dobj.rotation(activation.context.gc_context).into();
let rem = rot % 360.0; let rem = rot % 360.0;
@ -353,7 +353,7 @@ pub fn set_rotation<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(dobj) = this.and_then(|this| this.as_display_object()) { if let Some(dobj) = this.and_then(|this| this.as_display_object()) {
let new_rotation = args let new_rotation = args
.get(0) .get(0)
@ -372,7 +372,7 @@ pub fn name<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(dobj) = this.and_then(|this| this.as_display_object()) { if let Some(dobj) = this.and_then(|this| this.as_display_object()) {
return Ok(dobj.name().into()); return Ok(dobj.name().into());
} }
@ -385,7 +385,7 @@ pub fn set_name<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(dobj) = this.and_then(|this| this.as_display_object()) { if let Some(dobj) = this.and_then(|this| this.as_display_object()) {
let new_name = args let new_name = args
.get(0) .get(0)
@ -412,7 +412,7 @@ pub fn parent<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(dobj) = this.and_then(|this| this.as_display_object()) { if let Some(dobj) = this.and_then(|this| this.as_display_object()) {
return Ok(dobj return Ok(dobj
.avm2_parent() .avm2_parent()
@ -428,7 +428,7 @@ pub fn root<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(dobj) = this.and_then(|this| this.as_display_object()) { if let Some(dobj) = this.and_then(|this| this.as_display_object()) {
return Ok(dobj return Ok(dobj
.avm2_root(&mut activation.context) .avm2_root(&mut activation.context)
@ -444,7 +444,7 @@ pub fn stage<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(dobj) = this.and_then(|this| this.as_display_object()) { if let Some(dobj) = this.and_then(|this| this.as_display_object()) {
return Ok(dobj return Ok(dobj
.avm2_stage(&activation.context) .avm2_stage(&activation.context)
@ -460,7 +460,7 @@ pub fn visible<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(dobj) = this.and_then(|this| this.as_display_object()) { if let Some(dobj) = this.and_then(|this| this.as_display_object()) {
return Ok(dobj.visible().into()); return Ok(dobj.visible().into());
} }
@ -473,7 +473,7 @@ pub fn set_visible<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(dobj) = this.and_then(|this| this.as_display_object()) { if let Some(dobj) = this.and_then(|this| this.as_display_object()) {
let new_visible = args let new_visible = args
.get(0) .get(0)
@ -492,7 +492,7 @@ pub fn mouse_x<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(dobj) = this.and_then(|this| this.as_display_object()) { if let Some(dobj) = this.and_then(|this| this.as_display_object()) {
let local_mouse = dobj.global_to_local(*activation.context.mouse_position); let local_mouse = dobj.global_to_local(*activation.context.mouse_position);
@ -507,7 +507,7 @@ pub fn mouse_y<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(dobj) = this.and_then(|this| this.as_display_object()) { if let Some(dobj) = this.and_then(|this| this.as_display_object()) {
let local_mouse = dobj.global_to_local(*activation.context.mouse_position); let local_mouse = dobj.global_to_local(*activation.context.mouse_position);
@ -522,7 +522,7 @@ pub fn hit_test_point<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(dobj) = this.and_then(|this| this.as_display_object()) { if let Some(dobj) = this.and_then(|this| this.as_display_object()) {
let x = Twips::from_pixels( let x = Twips::from_pixels(
args.get(0) args.get(0)
@ -563,7 +563,7 @@ pub fn hit_test_object<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(dobj) = this.and_then(|this| this.as_display_object()) { if let Some(dobj) = this.and_then(|this| this.as_display_object()) {
if let Some(rhs_dobj) = args if let Some(rhs_dobj) = args
.get(0) .get(0)
@ -584,7 +584,7 @@ pub fn loader_info<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(dobj) = this.and_then(|this| this.as_display_object()) { if let Some(dobj) = this.and_then(|this| this.as_display_object()) {
// Contrary to the DisplayObject.loaderInfo documentation, // Contrary to the DisplayObject.loaderInfo documentation,
// Flash Player defines 'loaderInfo' for non-root DisplayObjects. // Flash Player defines 'loaderInfo' for non-root DisplayObjects.
@ -604,7 +604,7 @@ pub fn transform<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
return Ok(activation return Ok(activation
.avm2() .avm2()
@ -620,7 +620,7 @@ pub fn set_transform<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
let transform = args[0].coerce_to_object(activation)?; let transform = args[0].coerce_to_object(activation)?;
@ -653,7 +653,7 @@ pub fn blend_mode<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(dobj) = this.and_then(|this| this.as_display_object()) { if let Some(dobj) = this.and_then(|this| this.as_display_object()) {
let mode = let mode =
AvmString::new_utf8(activation.context.gc_context, dobj.blend_mode().to_string()); AvmString::new_utf8(activation.context.gc_context, dobj.blend_mode().to_string());
@ -667,7 +667,7 @@ pub fn set_blend_mode<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(dobj) = this.and_then(|this| this.as_display_object()) { if let Some(dobj) = this.and_then(|this| this.as_display_object()) {
let mode = args let mode = args
.get(0) .get(0)
@ -688,7 +688,7 @@ pub fn set_blend_mode<'gc>(
fn new_rectangle<'gc>( fn new_rectangle<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
rectangle: Rectangle, rectangle: Rectangle,
) -> Result<Object<'gc>, Error> { ) -> Result<Object<'gc>, Error<'gc>> {
let x = rectangle.x_min.to_pixels(); let x = rectangle.x_min.to_pixels();
let y = rectangle.y_min.to_pixels(); let y = rectangle.y_min.to_pixels();
let width = (rectangle.x_max - rectangle.x_min).to_pixels(); let width = (rectangle.x_max - rectangle.x_min).to_pixels();
@ -705,7 +705,7 @@ fn scroll_rect<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(dobj) = this.and_then(|this| this.as_display_object()) { if let Some(dobj) = this.and_then(|this| this.as_display_object()) {
if dobj.has_scroll_rect() { if dobj.has_scroll_rect() {
return Ok(new_rectangle(activation, dobj.next_scroll_rect())?.into()); return Ok(new_rectangle(activation, dobj.next_scroll_rect())?.into());
@ -719,7 +719,7 @@ fn scroll_rect<'gc>(
fn object_to_rectangle<'gc>( fn object_to_rectangle<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
object: Object<'gc>, object: Object<'gc>,
) -> Result<Rectangle, Error> { ) -> Result<Rectangle, Error<'gc>> {
const NAMES: &[&str] = &["x", "y", "width", "height"]; const NAMES: &[&str] = &["x", "y", "width", "height"];
let mut values = [0.0; 4]; let mut values = [0.0; 4];
for (&name, value) in NAMES.iter().zip(&mut values) { for (&name, value) in NAMES.iter().zip(&mut values) {
@ -740,7 +740,7 @@ fn set_scroll_rect<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(dobj) = this.and_then(|this| this.as_display_object()) { if let Some(dobj) = this.and_then(|this| this.as_display_object()) {
if let Some(rectangle) = args[0].as_object() { if let Some(rectangle) = args[0].as_object() {
// Flash only updates the "internal" scrollRect used by `localToLocal` when the next // Flash only updates the "internal" scrollRect used by `localToLocal` when the next
@ -771,7 +771,7 @@ fn local_to_global<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(dobj) = this.and_then(|this| this.as_display_object()) { if let Some(dobj) = this.and_then(|this| this.as_display_object()) {
let point = args let point = args
.get(0) .get(0)
@ -803,7 +803,7 @@ fn global_to_local<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(dobj) = this.and_then(|this| this.as_display_object()) { if let Some(dobj) = this.and_then(|this| this.as_display_object()) {
let point = args let point = args
.get(0) .get(0)
@ -835,7 +835,7 @@ fn mask<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this.and_then(|this| this.as_display_object()) { if let Some(this) = this.and_then(|this| this.as_display_object()) {
return Ok(this.masker().map_or(Value::Null, |m| m.object2())); return Ok(this.masker().map_or(Value::Null, |m| m.object2()));
} }
@ -846,7 +846,7 @@ fn set_mask<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this.and_then(|this| this.as_display_object()) { if let Some(this) = this.and_then(|this| this.as_display_object()) {
let mask = args.get(0).unwrap_or(&Value::Null); let mask = args.get(0).unwrap_or(&Value::Null);

View File

@ -19,7 +19,7 @@ pub fn instance_init<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Err("You cannot construct DisplayObjectContainer directly.".into()) Err("You cannot construct DisplayObjectContainer directly.".into())
} }
@ -28,7 +28,7 @@ pub fn native_instance_init<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
activation.super_init(this, &[])?; activation.super_init(this, &[])?;
} }
@ -41,7 +41,7 @@ pub fn class_init<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Ok(Value::Undefined) Ok(Value::Undefined)
} }
@ -55,7 +55,7 @@ fn validate_add_operation<'gc>(
new_parent: DisplayObject<'gc>, new_parent: DisplayObject<'gc>,
proposed_child: DisplayObject<'gc>, proposed_child: DisplayObject<'gc>,
proposed_index: usize, proposed_index: usize,
) -> Result<(), Error> { ) -> Result<(), Error<'gc>> {
let ctr = new_parent let ctr = new_parent
.as_container() .as_container()
.ok_or("ArgumentError: Parent is not a DisplayObjectContainer")?; .ok_or("ArgumentError: Parent is not a DisplayObjectContainer")?;
@ -88,7 +88,7 @@ fn validate_add_operation<'gc>(
fn validate_remove_operation<'gc>( fn validate_remove_operation<'gc>(
old_parent: DisplayObject<'gc>, old_parent: DisplayObject<'gc>,
proposed_child: DisplayObject<'gc>, proposed_child: DisplayObject<'gc>,
) -> Result<(), Error> { ) -> Result<(), Error<'gc>> {
let old_ctr = old_parent let old_ctr = old_parent
.as_container() .as_container()
.ok_or("ArgumentError: Parent is not a DisplayObjectContainer")?; .ok_or("ArgumentError: Parent is not a DisplayObjectContainer")?;
@ -132,7 +132,7 @@ pub fn get_child_at<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(dobj) = this if let Some(dobj) = this
.and_then(|this| this.as_display_object()) .and_then(|this| this.as_display_object())
.and_then(|this| this.as_container()) .and_then(|this| this.as_container())
@ -160,7 +160,7 @@ pub fn get_child_by_name<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(dobj) = this if let Some(dobj) = this
.and_then(|this| this.as_display_object()) .and_then(|this| this.as_display_object())
.and_then(|this| this.as_container()) .and_then(|this| this.as_container())
@ -186,7 +186,7 @@ pub fn add_child<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(parent) = this.and_then(|this| this.as_display_object()) { if let Some(parent) = this.and_then(|this| this.as_display_object()) {
if let Some(ctr) = parent.as_container() { if let Some(ctr) = parent.as_container() {
let child = args let child = args
@ -213,7 +213,7 @@ pub fn add_child_at<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(parent) = this.and_then(|this| this.as_display_object()) { if let Some(parent) = this.and_then(|this| this.as_display_object()) {
let child = args let child = args
.get(0) .get(0)
@ -242,7 +242,7 @@ pub fn remove_child<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(parent) = this.and_then(|this| this.as_display_object()) { if let Some(parent) = this.and_then(|this| this.as_display_object()) {
let child = args let child = args
.get(0) .get(0)
@ -266,7 +266,7 @@ pub fn num_children<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(parent) = this if let Some(parent) = this
.and_then(|this| this.as_display_object()) .and_then(|this| this.as_display_object())
.and_then(|this| this.as_container()) .and_then(|this| this.as_container())
@ -282,7 +282,7 @@ pub fn contains<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(parent) = this.and_then(|this| this.as_display_object()) { if let Some(parent) = this.and_then(|this| this.as_display_object()) {
if parent.as_container().is_some() { if parent.as_container().is_some() {
if let Some(child) = args if let Some(child) = args
@ -312,7 +312,7 @@ pub fn get_child_index<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(parent) = this.and_then(|this| this.as_display_object()) { if let Some(parent) = this.and_then(|this| this.as_display_object()) {
if let Some(ctr) = parent.as_container() { if let Some(ctr) = parent.as_container() {
let target_child = args let target_child = args
@ -340,7 +340,7 @@ pub fn remove_child_at<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(parent) = this.and_then(|this| this.as_display_object()) { if let Some(parent) = this.and_then(|this| this.as_display_object()) {
if let Some(mut ctr) = parent.as_container() { if let Some(mut ctr) = parent.as_container() {
let target_child = args let target_child = args
@ -374,7 +374,7 @@ pub fn remove_children<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(parent) = this.and_then(|this| this.as_display_object()) { if let Some(parent) = this.and_then(|this| this.as_display_object()) {
if let Some(mut ctr) = parent.as_container() { if let Some(mut ctr) = parent.as_container() {
let from = args let from = args
@ -425,7 +425,7 @@ pub fn set_child_index<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(parent) = this.and_then(|this| this.as_display_object()) { if let Some(parent) = this.and_then(|this| this.as_display_object()) {
let child = args let child = args
.get(0) .get(0)
@ -459,7 +459,7 @@ pub fn swap_children_at<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(parent) = this.and_then(|this| this.as_display_object()) { if let Some(parent) = this.and_then(|this| this.as_display_object()) {
if let Some(mut ctr) = parent.as_container() { if let Some(mut ctr) = parent.as_container() {
let index0 = args let index0 = args
@ -500,7 +500,7 @@ pub fn swap_children<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(parent) = this.and_then(|this| this.as_display_object()) { if let Some(parent) = this.and_then(|this| this.as_display_object()) {
if let Some(mut ctr) = parent.as_container() { if let Some(mut ctr) = parent.as_container() {
let child0 = args let child0 = args
@ -542,7 +542,7 @@ pub fn stop_all_movie_clips<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(parent) = this.and_then(|this| this.as_display_object()) { if let Some(parent) = this.and_then(|this| this.as_display_object()) {
if let Some(mc) = parent.as_movie_clip() { if let Some(mc) = parent.as_movie_clip() {
mc.stop(&mut activation.context); mc.stop(&mut activation.context);
@ -566,7 +566,7 @@ pub fn get_objects_under_point<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Err("DisplayObjectContainer.getObjectsUnderPoint not yet implemented".into()) Err("DisplayObjectContainer.getObjectsUnderPoint not yet implemented".into())
} }
@ -575,7 +575,7 @@ pub fn are_inaccessible_objects_under_point<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Err("DisplayObjectContainer.areInaccessibleObjectsUnderPoint not yet implemented".into()) Err("DisplayObjectContainer.areInaccessibleObjectsUnderPoint not yet implemented".into())
} }
@ -583,7 +583,7 @@ pub fn mouse_children<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
log::warn!("DisplayObjectContainer.mouseChildren getter: not yet implemented"); log::warn!("DisplayObjectContainer.mouseChildren getter: not yet implemented");
Ok(Value::Undefined) Ok(Value::Undefined)
} }
@ -592,7 +592,7 @@ pub fn set_mouse_children<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
log::warn!("DisplayObjectContainer.mouseChildren setter: not yet implemented"); log::warn!("DisplayObjectContainer.mouseChildren setter: not yet implemented");
Ok(Value::Undefined) Ok(Value::Undefined)
} }

View File

@ -17,7 +17,7 @@ pub fn instance_init<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
let name = args let name = args
.get(0) .get(0)
.cloned() .cloned()
@ -52,7 +52,7 @@ pub fn class_init<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Ok(Value::Undefined) Ok(Value::Undefined)
} }
/// Construct `FrameLabel`'s class. /// Construct `FrameLabel`'s class.

View File

@ -22,7 +22,7 @@ fn instance_init<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Err("Graphics cannot be constructed directly.".into()) Err("Graphics cannot be constructed directly.".into())
} }
@ -31,7 +31,7 @@ fn native_instance_init<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
activation.super_init(this, &[])?; activation.super_init(this, &[])?;
} }
@ -44,7 +44,7 @@ fn class_init<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Ok(Value::Undefined) Ok(Value::Undefined)
} }
@ -59,7 +59,7 @@ fn begin_fill<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this.and_then(|t| t.as_display_object()) { if let Some(this) = this.and_then(|t| t.as_display_object()) {
let color = args let color = args
.get(0) .get(0)
@ -85,7 +85,7 @@ fn clear<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this.and_then(|t| t.as_display_object()) { if let Some(this) = this.and_then(|t| t.as_display_object()) {
if let Some(mut draw) = this.as_drawing(activation.context.gc_context) { if let Some(mut draw) = this.as_drawing(activation.context.gc_context) {
draw.clear() draw.clear()
@ -100,7 +100,7 @@ fn curve_to<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this.and_then(|t| t.as_display_object()) { if let Some(this) = this.and_then(|t| t.as_display_object()) {
let x1 = Twips::from_pixels( let x1 = Twips::from_pixels(
args.get(0) args.get(0)
@ -140,7 +140,7 @@ fn end_fill<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this.and_then(|t| t.as_display_object()) { if let Some(this) = this.and_then(|t| t.as_display_object()) {
if let Some(mut draw) = this.as_drawing(activation.context.gc_context) { if let Some(mut draw) = this.as_drawing(activation.context.gc_context) {
draw.set_fill_style(None); draw.set_fill_style(None);
@ -153,7 +153,7 @@ fn end_fill<'gc>(
fn caps_to_cap_style<'gc>( fn caps_to_cap_style<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
caps: Value<'gc>, caps: Value<'gc>,
) -> Result<LineCapStyle, Error> { ) -> Result<LineCapStyle, Error<'gc>> {
if let Value::Null = caps { if let Value::Null = caps {
return Ok(LineCapStyle::None); return Ok(LineCapStyle::None);
} }
@ -172,7 +172,7 @@ fn joints_to_join_style<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
joints: Value<'gc>, joints: Value<'gc>,
miter_limit: f64, miter_limit: f64,
) -> Result<LineJoinStyle, Error> { ) -> Result<LineJoinStyle, Error<'gc>> {
if let Value::Null = joints { if let Value::Null = joints {
return Ok(LineJoinStyle::Round); return Ok(LineJoinStyle::Round);
} }
@ -187,7 +187,7 @@ fn joints_to_join_style<'gc>(
} }
} }
fn scale_mode_to_allow_scale_bits(scale_mode: &WStr) -> Result<(bool, bool), Error> { fn scale_mode_to_allow_scale_bits<'gc>(scale_mode: &WStr) -> Result<(bool, bool), Error<'gc>> {
if scale_mode == b"none" { if scale_mode == b"none" {
Ok((false, false)) Ok((false, false))
} else if scale_mode == b"horizontal" { } else if scale_mode == b"horizontal" {
@ -204,7 +204,7 @@ fn line_style<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this.and_then(|t| t.as_display_object()) { if let Some(this) = this.and_then(|t| t.as_display_object()) {
let thickness = args let thickness = args
.get(0) .get(0)
@ -275,7 +275,7 @@ fn line_to<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this.and_then(|t| t.as_display_object()) { if let Some(this) = this.and_then(|t| t.as_display_object()) {
let x = Twips::from_pixels( let x = Twips::from_pixels(
args.get(0) args.get(0)
@ -303,7 +303,7 @@ fn move_to<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this.and_then(|t| t.as_display_object()) { if let Some(this) = this.and_then(|t| t.as_display_object()) {
let x = Twips::from_pixels( let x = Twips::from_pixels(
args.get(0) args.get(0)
@ -331,7 +331,7 @@ fn draw_rect<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this.and_then(|t| t.as_display_object()) { if let Some(this) = this.and_then(|t| t.as_display_object()) {
let x = Twips::from_pixels( let x = Twips::from_pixels(
args.get(0) args.get(0)
@ -642,7 +642,7 @@ fn draw_round_rect<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this.and_then(|t| t.as_display_object()) { if let Some(this) = this.and_then(|t| t.as_display_object()) {
let x = args let x = args
.get(0) .get(0)
@ -696,7 +696,7 @@ fn draw_circle<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this.and_then(|t| t.as_display_object()) { if let Some(this) = this.and_then(|t| t.as_display_object()) {
let x = args let x = args
.get(0) .get(0)
@ -735,7 +735,7 @@ fn draw_ellipse<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this.and_then(|t| t.as_display_object()) { if let Some(this) = this.and_then(|t| t.as_display_object()) {
let x = args let x = args
.get(0) .get(0)

View File

@ -15,7 +15,7 @@ pub fn bodiless_method<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Err("Cannot execute non-native method without body".into()) Err("Cannot execute non-native method without body".into())
} }
@ -24,7 +24,7 @@ pub fn class_init<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Ok(Value::Undefined) Ok(Value::Undefined)
} }

View File

@ -17,7 +17,7 @@ pub fn instance_init<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Err("You cannot directly construct InteractiveObject.".into()) Err("You cannot directly construct InteractiveObject.".into())
} }
@ -26,7 +26,7 @@ pub fn native_instance_init<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
activation.super_init(this, &[])?; activation.super_init(this, &[])?;
} }
@ -39,7 +39,7 @@ pub fn class_init<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Ok(Value::Undefined) Ok(Value::Undefined)
} }
@ -48,7 +48,7 @@ pub fn mouse_enabled<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(int) = this if let Some(int) = this
.and_then(|t| t.as_display_object()) .and_then(|t| t.as_display_object())
.and_then(|dobj| dobj.as_interactive()) .and_then(|dobj| dobj.as_interactive())
@ -64,7 +64,7 @@ pub fn set_mouse_enabled<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(int) = this if let Some(int) = this
.and_then(|t| t.as_display_object()) .and_then(|t| t.as_display_object())
.and_then(|dobj| dobj.as_interactive()) .and_then(|dobj| dobj.as_interactive())
@ -85,7 +85,7 @@ pub fn double_click_enabled<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(int) = this if let Some(int) = this
.and_then(|t| t.as_display_object()) .and_then(|t| t.as_display_object())
.and_then(|dobj| dobj.as_interactive()) .and_then(|dobj| dobj.as_interactive())
@ -101,7 +101,7 @@ pub fn set_double_click_enabled<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(int) = this if let Some(int) = this
.and_then(|t| t.as_display_object()) .and_then(|t| t.as_display_object())
.and_then(|dobj| dobj.as_interactive()) .and_then(|dobj| dobj.as_interactive())
@ -122,7 +122,7 @@ fn context_menu<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(int) = this if let Some(int) = this
.and_then(|t| t.as_display_object()) .and_then(|t| t.as_display_object())
.and_then(|dobj| dobj.as_interactive()) .and_then(|dobj| dobj.as_interactive())
@ -138,7 +138,7 @@ fn set_context_menu<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(int) = this if let Some(int) = this
.and_then(|t| t.as_display_object()) .and_then(|t| t.as_display_object())
.and_then(|dobj| dobj.as_interactive()) .and_then(|dobj| dobj.as_interactive())

View File

@ -18,7 +18,7 @@ pub fn init<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(mut this) = this { if let Some(mut this) = this {
if this.as_display_object().is_none() { if this.as_display_object().is_none() {
let new_do = LoaderDisplay::new_with_avm2(activation.context.gc_context, this); let new_do = LoaderDisplay::new_with_avm2(activation.context.gc_context, this);
@ -47,7 +47,7 @@ pub fn load<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
let url_request = args[0].as_object().unwrap(); let url_request = args[0].as_object().unwrap();

View File

@ -24,7 +24,7 @@ pub fn instance_init<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Err("LoaderInfo cannot be constructed".into()) Err("LoaderInfo cannot be constructed".into())
} }
@ -33,7 +33,7 @@ pub fn native_instance_init<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
activation.super_init(this, &[])?; activation.super_init(this, &[])?;
} }
@ -46,7 +46,7 @@ pub fn class_init<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Ok(Value::Undefined) Ok(Value::Undefined)
} }
@ -55,7 +55,7 @@ pub fn action_script_version<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(loader_stream) = this if let Some(loader_stream) = this
.as_loader_info_object() .as_loader_info_object()
@ -81,7 +81,7 @@ pub fn application_domain<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(loader_stream) = this if let Some(loader_stream) = this
.as_loader_info_object() .as_loader_info_object()
@ -114,7 +114,7 @@ pub fn bytes_total<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(loader_stream) = this if let Some(loader_stream) = this
.as_loader_info_object() .as_loader_info_object()
@ -137,7 +137,7 @@ pub fn content<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(loader_stream) = this if let Some(loader_stream) = this
.as_loader_info_object() .as_loader_info_object()
@ -165,7 +165,7 @@ pub fn content_type<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(loader_stream) = this if let Some(loader_stream) = this
.as_loader_info_object() .as_loader_info_object()
@ -188,7 +188,7 @@ pub fn frame_rate<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(loader_stream) = this if let Some(loader_stream) = this
.as_loader_info_object() .as_loader_info_object()
@ -213,7 +213,7 @@ pub fn height<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(loader_stream) = this if let Some(loader_stream) = this
.as_loader_info_object() .as_loader_info_object()
@ -238,7 +238,7 @@ pub fn is_url_inaccessible<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Ok(false.into()) Ok(false.into())
} }
@ -247,7 +247,7 @@ pub fn swf_version<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(loader_stream) = this if let Some(loader_stream) = this
.as_loader_info_object() .as_loader_info_object()
@ -272,7 +272,7 @@ pub fn url<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(loader_stream) = this if let Some(loader_stream) = this
.as_loader_info_object() .as_loader_info_object()
@ -298,7 +298,7 @@ pub fn width<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(loader_stream) = this if let Some(loader_stream) = this
.as_loader_info_object() .as_loader_info_object()
@ -323,7 +323,7 @@ pub fn bytes<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(loader_stream) = this if let Some(loader_stream) = this
.as_loader_info_object() .as_loader_info_object()
@ -380,7 +380,7 @@ pub fn loader<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(loader_info) = this.as_ref().and_then(|this| this.as_loader_info_object()) { if let Some(loader_info) = this.as_ref().and_then(|this| this.as_loader_info_object()) {
Ok(loader_info.loader().map_or(Value::Null, |v| v.into())) Ok(loader_info.loader().map_or(Value::Null, |v| v.into()))
} else { } else {
@ -393,7 +393,7 @@ pub fn loader_url<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(loader_stream) = this if let Some(loader_stream) = this
.as_loader_info_object() .as_loader_info_object()
@ -417,7 +417,7 @@ pub fn parameters<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(loader_stream) = this if let Some(loader_stream) = this
.as_loader_info_object() .as_loader_info_object()
@ -453,7 +453,7 @@ pub fn shared_events<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(loader_info) = this.as_ref().and_then(|this| this.as_loader_info_object()) { if let Some(loader_info) = this.as_ref().and_then(|this| this.as_loader_info_object()) {
return Ok(loader_info.shared_events().into()); return Ok(loader_info.shared_events().into());
} }

View File

@ -21,7 +21,7 @@ pub fn instance_init<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
activation.super_init(this, &[])?; activation.super_init(this, &[])?;
@ -44,7 +44,7 @@ pub fn class_init<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Ok(Value::Undefined) Ok(Value::Undefined)
} }
@ -54,7 +54,7 @@ pub fn add_frame_script<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(mc) = this if let Some(mc) = this
.and_then(|o| o.as_display_object()) .and_then(|o| o.as_display_object())
.and_then(|dobj| dobj.as_movie_clip()) .and_then(|dobj| dobj.as_movie_clip())
@ -77,7 +77,7 @@ pub fn current_frame<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(mc) = this if let Some(mc) = this
.and_then(|o| o.as_display_object()) .and_then(|o| o.as_display_object())
.and_then(|dobj| dobj.as_movie_clip()) .and_then(|dobj| dobj.as_movie_clip())
@ -102,7 +102,7 @@ pub fn current_frame_label<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(mc) = this if let Some(mc) = this
.and_then(|o| o.as_display_object()) .and_then(|o| o.as_display_object())
.and_then(|dobj| dobj.as_movie_clip()) .and_then(|dobj| dobj.as_movie_clip())
@ -127,7 +127,7 @@ pub fn current_label<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(mc) = this if let Some(mc) = this
.and_then(|o| o.as_display_object()) .and_then(|o| o.as_display_object())
.and_then(|dobj| dobj.as_movie_clip()) .and_then(|dobj| dobj.as_movie_clip())
@ -151,7 +151,7 @@ fn labels_for_scene<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
mc: MovieClip<'gc>, mc: MovieClip<'gc>,
scene: &Scene, scene: &Scene,
) -> Result<(String, u16, Object<'gc>), Error> { ) -> Result<(String, u16, Object<'gc>), Error<'gc>> {
let Scene { let Scene {
name: scene_name, name: scene_name,
start: scene_start, start: scene_start,
@ -182,7 +182,7 @@ pub fn current_labels<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(mc) = this if let Some(mc) = this
.and_then(|o| o.as_display_object()) .and_then(|o| o.as_display_object())
.and_then(|dobj| dobj.as_movie_clip()) .and_then(|dobj| dobj.as_movie_clip())
@ -203,7 +203,7 @@ pub fn current_scene<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(mc) = this if let Some(mc) = this
.and_then(|o| o.as_display_object()) .and_then(|o| o.as_display_object())
.and_then(|dobj| dobj.as_movie_clip()) .and_then(|dobj| dobj.as_movie_clip())
@ -234,7 +234,7 @@ pub fn scenes<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(mc) = this if let Some(mc) = this
.and_then(|o| o.as_display_object()) .and_then(|o| o.as_display_object())
.and_then(|dobj| dobj.as_movie_clip()) .and_then(|dobj| dobj.as_movie_clip())
@ -279,7 +279,7 @@ pub fn frames_loaded<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(mc) = this if let Some(mc) = this
.and_then(|o| o.as_display_object()) .and_then(|o| o.as_display_object())
.and_then(|dobj| dobj.as_movie_clip()) .and_then(|dobj| dobj.as_movie_clip())
@ -295,7 +295,7 @@ pub fn is_playing<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(mc) = this if let Some(mc) = this
.and_then(|o| o.as_display_object()) .and_then(|o| o.as_display_object())
.and_then(|dobj| dobj.as_movie_clip()) .and_then(|dobj| dobj.as_movie_clip())
@ -311,7 +311,7 @@ pub fn total_frames<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(mc) = this if let Some(mc) = this
.and_then(|o| o.as_display_object()) .and_then(|o| o.as_display_object())
.and_then(|dobj| dobj.as_movie_clip()) .and_then(|dobj| dobj.as_movie_clip())
@ -327,7 +327,7 @@ pub fn goto_and_play<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(mc) = this if let Some(mc) = this
.and_then(|o| o.as_display_object()) .and_then(|o| o.as_display_object())
.and_then(|dobj| dobj.as_movie_clip()) .and_then(|dobj| dobj.as_movie_clip())
@ -344,7 +344,7 @@ pub fn goto_and_stop<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(mc) = this if let Some(mc) = this
.and_then(|o| o.as_display_object()) .and_then(|o| o.as_display_object())
.and_then(|dobj| dobj.as_movie_clip()) .and_then(|dobj| dobj.as_movie_clip())
@ -360,7 +360,7 @@ pub fn goto_frame<'gc>(
mc: MovieClip<'gc>, mc: MovieClip<'gc>,
args: &[Value<'gc>], args: &[Value<'gc>],
stop: bool, stop: bool,
) -> Result<(), Error> { ) -> Result<(), Error<'gc>> {
let frame_or_label = args.get(0).cloned().unwrap_or(Value::Null); let frame_or_label = args.get(0).cloned().unwrap_or(Value::Null);
let scene = match args.get(1).cloned().unwrap_or(Value::Null) { let scene = match args.get(1).cloned().unwrap_or(Value::Null) {
@ -410,7 +410,7 @@ pub fn stop<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(mc) = this if let Some(mc) = this
.and_then(|o| o.as_display_object()) .and_then(|o| o.as_display_object())
.and_then(|dobj| dobj.as_movie_clip()) .and_then(|dobj| dobj.as_movie_clip())
@ -426,7 +426,7 @@ pub fn play<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(mc) = this if let Some(mc) = this
.and_then(|o| o.as_display_object()) .and_then(|o| o.as_display_object())
.and_then(|dobj| dobj.as_movie_clip()) .and_then(|dobj| dobj.as_movie_clip())
@ -443,7 +443,7 @@ pub fn prev_frame<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(mc) = this if let Some(mc) = this
.and_then(|o| o.as_display_object()) .and_then(|o| o.as_display_object())
.and_then(|dobj| dobj.as_movie_clip()) .and_then(|dobj| dobj.as_movie_clip())
@ -459,7 +459,7 @@ pub fn next_frame<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(mc) = this if let Some(mc) = this
.and_then(|o| o.as_display_object()) .and_then(|o| o.as_display_object())
.and_then(|dobj| dobj.as_movie_clip()) .and_then(|dobj| dobj.as_movie_clip())
@ -475,7 +475,7 @@ pub fn prev_scene<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(mc) = this if let Some(mc) = this
.and_then(|o| o.as_display_object()) .and_then(|o| o.as_display_object())
.and_then(|dobj| dobj.as_movie_clip()) .and_then(|dobj| dobj.as_movie_clip())
@ -498,7 +498,7 @@ pub fn next_scene<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(mc) = this if let Some(mc) = this
.and_then(|o| o.as_display_object()) .and_then(|o| o.as_display_object())
.and_then(|dobj| dobj.as_movie_clip()) .and_then(|dobj| dobj.as_movie_clip())

View File

@ -19,7 +19,7 @@ pub fn instance_init<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
activation.super_init(this, &[])?; activation.super_init(this, &[])?;
@ -38,7 +38,7 @@ pub fn class_init<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Ok(Value::Undefined) Ok(Value::Undefined)
} }
@ -47,7 +47,7 @@ pub fn graphics<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(mut this) = this { if let Some(mut this) = this {
if let Some(dobj) = this.as_display_object() { if let Some(dobj) = this.as_display_object() {
// Lazily initialize the `Graphics` object in a hidden property. // Lazily initialize the `Graphics` object in a hidden property.

View File

@ -20,7 +20,7 @@ pub fn instance_init<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
activation.super_init(this, &[])?; activation.super_init(this, &[])?;
@ -73,7 +73,7 @@ pub fn class_init<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Ok(Value::Undefined) Ok(Value::Undefined)
} }
@ -82,7 +82,7 @@ pub fn down_state<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(btn) = this if let Some(btn) = this
.and_then(|this| this.as_display_object()) .and_then(|this| this.as_display_object())
.and_then(|this| this.as_avm2_button()) .and_then(|this| this.as_avm2_button())
@ -101,7 +101,7 @@ pub fn set_down_state<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(btn) = this if let Some(btn) = this
.and_then(|this| this.as_display_object()) .and_then(|this| this.as_display_object())
.and_then(|this| this.as_avm2_button()) .and_then(|this| this.as_avm2_button())
@ -124,7 +124,7 @@ pub fn over_state<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(btn) = this if let Some(btn) = this
.and_then(|this| this.as_display_object()) .and_then(|this| this.as_display_object())
.and_then(|this| this.as_avm2_button()) .and_then(|this| this.as_avm2_button())
@ -143,7 +143,7 @@ pub fn set_over_state<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(btn) = this if let Some(btn) = this
.and_then(|this| this.as_display_object()) .and_then(|this| this.as_display_object())
.and_then(|this| this.as_avm2_button()) .and_then(|this| this.as_avm2_button())
@ -166,7 +166,7 @@ pub fn hit_test_state<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(btn) = this if let Some(btn) = this
.and_then(|this| this.as_display_object()) .and_then(|this| this.as_display_object())
.and_then(|this| this.as_avm2_button()) .and_then(|this| this.as_avm2_button())
@ -185,7 +185,7 @@ pub fn set_hit_test_state<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(btn) = this if let Some(btn) = this
.and_then(|this| this.as_display_object()) .and_then(|this| this.as_display_object())
.and_then(|this| this.as_avm2_button()) .and_then(|this| this.as_avm2_button())
@ -208,7 +208,7 @@ pub fn up_state<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(btn) = this if let Some(btn) = this
.and_then(|this| this.as_display_object()) .and_then(|this| this.as_display_object())
.and_then(|this| this.as_avm2_button()) .and_then(|this| this.as_avm2_button())
@ -227,7 +227,7 @@ pub fn set_up_state<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(btn) = this if let Some(btn) = this
.and_then(|this| this.as_display_object()) .and_then(|this| this.as_display_object())
.and_then(|this| this.as_avm2_button()) .and_then(|this| this.as_avm2_button())
@ -250,7 +250,7 @@ pub fn track_as_menu<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(btn) = this if let Some(btn) = this
.and_then(|this| this.as_display_object()) .and_then(|this| this.as_display_object())
.and_then(|this| this.as_avm2_button()) .and_then(|this| this.as_avm2_button())
@ -266,7 +266,7 @@ pub fn set_track_as_menu<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(btn) = this if let Some(btn) = this
.and_then(|this| this.as_display_object()) .and_then(|this| this.as_display_object())
.and_then(|this| this.as_avm2_button()) .and_then(|this| this.as_avm2_button())
@ -290,7 +290,7 @@ pub fn enabled<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(btn) = this if let Some(btn) = this
.and_then(|this| this.as_display_object()) .and_then(|this| this.as_display_object())
.and_then(|this| this.as_avm2_button()) .and_then(|this| this.as_avm2_button())
@ -306,7 +306,7 @@ pub fn set_enabled<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(btn) = this if let Some(btn) = this
.and_then(|this| this.as_display_object()) .and_then(|this| this.as_display_object())
.and_then(|this| this.as_avm2_button()) .and_then(|this| this.as_avm2_button())
@ -328,7 +328,7 @@ pub fn use_hand_cursor<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(btn) = this if let Some(btn) = this
.and_then(|this| this.as_display_object()) .and_then(|this| this.as_display_object())
.and_then(|this| this.as_avm2_button()) .and_then(|this| this.as_avm2_button())
@ -344,7 +344,7 @@ pub fn set_use_hand_cursor<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(btn) = this if let Some(btn) = this
.and_then(|this| this.as_display_object()) .and_then(|this| this.as_display_object())
.and_then(|this| this.as_avm2_button()) .and_then(|this| this.as_avm2_button())

View File

@ -23,7 +23,7 @@ pub fn instance_init<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
activation.super_init(this, &[])?; activation.super_init(this, &[])?;
@ -47,7 +47,7 @@ pub fn class_init<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Ok(Value::Undefined) Ok(Value::Undefined)
} }
@ -56,7 +56,7 @@ pub fn graphics<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(mut this) = this { if let Some(mut this) = this {
if let Some(dobj) = this.as_display_object() { if let Some(dobj) = this.as_display_object() {
// Lazily initialize the `Graphics` object in a hidden property. // Lazily initialize the `Graphics` object in a hidden property.
@ -87,7 +87,7 @@ pub fn sound_transform<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(dobj) = this.and_then(|o| o.as_display_object()) { if let Some(dobj) = this.and_then(|o| o.as_display_object()) {
let dobj_st = dobj.base().sound_transform().clone(); let dobj_st = dobj.base().sound_transform().clone();
@ -102,7 +102,7 @@ pub fn set_sound_transform<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(dobj) = this.and_then(|o| o.as_display_object()) { if let Some(dobj) = this.and_then(|o| o.as_display_object()) {
let as3_st = args let as3_st = args
.get(0) .get(0)
@ -122,7 +122,7 @@ pub fn button_mode<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(mc) = this if let Some(mc) = this
.and_then(|o| o.as_display_object()) .and_then(|o| o.as_display_object())
.and_then(|o| o.as_movie_clip()) .and_then(|o| o.as_movie_clip())
@ -138,7 +138,7 @@ pub fn set_button_mode<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(mc) = this if let Some(mc) = this
.and_then(|o| o.as_display_object()) .and_then(|o| o.as_display_object())
.and_then(|o| o.as_movie_clip()) .and_then(|o| o.as_movie_clip())
@ -161,7 +161,7 @@ pub fn start_drag<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(display_object) = this.and_then(|this| this.as_display_object()) { if let Some(display_object) = this.and_then(|this| this.as_display_object()) {
let lock_center = args.get(0).map(|o| o.coerce_to_boolean()).unwrap_or(false); let lock_center = args.get(0).map(|o| o.coerce_to_boolean()).unwrap_or(false);
@ -220,7 +220,7 @@ fn stop_drag<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
// It doesn't matter which clip we call this on; it simply stops any active drag. // It doesn't matter which clip we call this on; it simply stops any active drag.
// we might not have had an opportunity to call `update_drag` // we might not have had an opportunity to call `update_drag`

View File

@ -20,7 +20,7 @@ pub fn instance_init<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Err("You cannot construct new instances of the Stage.".into()) Err("You cannot construct new instances of the Stage.".into())
} }
@ -29,7 +29,7 @@ pub fn native_instance_init<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
activation.super_init(this, args)?; activation.super_init(this, args)?;
} }
@ -42,7 +42,7 @@ pub fn class_init<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Ok(Value::Undefined) Ok(Value::Undefined)
} }
@ -51,7 +51,7 @@ pub fn set_accessibility_properties<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Err("Error: You cannot set accessibility properties on the stage.".into()) Err("Error: You cannot set accessibility properties on the stage.".into())
} }
@ -60,7 +60,7 @@ pub fn set_alpha<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Err("Error: You cannot set the stage's opacity.".into()) Err("Error: You cannot set the stage's opacity.".into())
} }
@ -69,7 +69,7 @@ pub fn set_blend_mode<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Err("Error: You cannot set the blend mode of the stage.".into()) Err("Error: You cannot set the blend mode of the stage.".into())
} }
@ -78,7 +78,7 @@ pub fn set_cache_as_bitmap<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Err("Error: You cannot set the stage to be cached as a bitmap.".into()) Err("Error: You cannot set the stage to be cached as a bitmap.".into())
} }
@ -87,7 +87,7 @@ pub fn set_context_menu<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Err("Error: You cannot set the stage's context menu.".into()) Err("Error: You cannot set the stage's context menu.".into())
} }
@ -96,7 +96,7 @@ pub fn set_filters<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Err("Error: You cannot apply filters to the stage.".into()) Err("Error: You cannot apply filters to the stage.".into())
} }
@ -105,7 +105,7 @@ pub fn set_focus_rect<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Err("Error: You cannot set the stage's focus rect.".into()) Err("Error: You cannot set the stage's focus rect.".into())
} }
@ -114,7 +114,7 @@ pub fn set_loader_info<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Err("Error: You cannot set the blend mode of the stage.".into()) Err("Error: You cannot set the blend mode of the stage.".into())
} }
@ -123,7 +123,7 @@ pub fn set_mask<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Err("Error: You cannot mask the stage.".into()) Err("Error: You cannot mask the stage.".into())
} }
@ -132,7 +132,7 @@ pub fn set_mouse_enabled<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Err("Error: You cannot enable or disable the mouse on the stage.".into()) Err("Error: You cannot enable or disable the mouse on the stage.".into())
} }
@ -141,7 +141,7 @@ pub fn name<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Ok(Value::Null) Ok(Value::Null)
} }
@ -150,7 +150,7 @@ pub fn set_name<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Err("Error: You cannot set the name of the stage.".into()) Err("Error: You cannot set the name of the stage.".into())
} }
@ -159,7 +159,7 @@ pub fn set_opaque_background<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Err("Error: You cannot give or take away the stage's opaque background.".into()) Err("Error: You cannot give or take away the stage's opaque background.".into())
} }
@ -168,7 +168,7 @@ pub fn set_rotation<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Err("Error: You cannot rotate the stage.".into()) Err("Error: You cannot rotate the stage.".into())
} }
@ -177,7 +177,7 @@ pub fn set_scale_nine_grid<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Err("Error: You cannot set the stage's 9-slice grid.".into()) Err("Error: You cannot set the stage's 9-slice grid.".into())
} }
@ -186,7 +186,7 @@ pub fn set_scale_x<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Err("Error: You cannot set the stage's horizontal scale.".into()) Err("Error: You cannot set the stage's horizontal scale.".into())
} }
@ -195,7 +195,7 @@ pub fn set_scale_y<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Err("Error: You cannot set the stage's vertical scale.".into()) Err("Error: You cannot set the stage's vertical scale.".into())
} }
@ -204,7 +204,7 @@ pub fn set_scroll_rect<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Err("Error: You cannot set the stage's scroll rectangle.".into()) Err("Error: You cannot set the stage's scroll rectangle.".into())
} }
@ -213,7 +213,7 @@ pub fn set_tab_enabled<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Err("Error: You cannot enable or disable tabbing the stage.".into()) Err("Error: You cannot enable or disable tabbing the stage.".into())
} }
@ -222,7 +222,7 @@ pub fn set_tab_index<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Err("Error: You cannot set the stage's tab index.".into()) Err("Error: You cannot set the stage's tab index.".into())
} }
@ -231,7 +231,7 @@ pub fn set_transform<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Err("Error: You cannot transform the stage.".into()) Err("Error: You cannot transform the stage.".into())
} }
@ -240,7 +240,7 @@ pub fn set_visible<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Err("Error: You cannot hide or unhide the stage.".into()) Err("Error: You cannot hide or unhide the stage.".into())
} }
@ -249,7 +249,7 @@ pub fn set_x<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Err("Error: You cannot move the stage horizontally.".into()) Err("Error: You cannot move the stage horizontally.".into())
} }
@ -258,7 +258,7 @@ pub fn set_y<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Err("Error: You cannot move the stage vertically.".into()) Err("Error: You cannot move the stage vertically.".into())
} }
@ -267,7 +267,7 @@ pub fn align<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
let align = activation.context.stage.align(); let align = activation.context.stage.align();
let mut s = WString::with_capacity(4, false); let mut s = WString::with_capacity(4, false);
// Match string values returned by AS. // Match string values returned by AS.
@ -296,7 +296,7 @@ pub fn set_align<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
let align = args let align = args
.get(0) .get(0)
.unwrap_or(&Value::Undefined) .unwrap_or(&Value::Undefined)
@ -315,7 +315,7 @@ pub fn browser_zoom_factor<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if this if this
.and_then(|this| this.as_display_object()) .and_then(|this| this.as_display_object())
.and_then(|this| this.as_stage()) .and_then(|this| this.as_stage())
@ -337,7 +337,7 @@ pub fn color<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(dobj) = this if let Some(dobj) = this
.and_then(|this| this.as_display_object()) .and_then(|this| this.as_display_object())
.and_then(|this| this.as_stage()) .and_then(|this| this.as_stage())
@ -354,7 +354,7 @@ pub fn set_color<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(dobj) = this if let Some(dobj) = this
.and_then(|this| this.as_display_object()) .and_then(|this| this.as_display_object())
.and_then(|this| this.as_stage()) .and_then(|this| this.as_stage())
@ -377,7 +377,7 @@ pub fn contents_scale_factor<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if this if this
.and_then(|this| this.as_display_object()) .and_then(|this| this.as_display_object())
.and_then(|this| this.as_stage()) .and_then(|this| this.as_stage())
@ -399,7 +399,7 @@ pub fn display_state<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
let display_state = AvmString::new_utf8( let display_state = AvmString::new_utf8(
activation.context.gc_context, activation.context.gc_context,
activation.context.stage.display_state().to_string(), activation.context.stage.display_state().to_string(),
@ -412,7 +412,7 @@ pub fn set_display_state<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Ok(mut display_state) = args if let Ok(mut display_state) = args
.get(0) .get(0)
.unwrap_or(&Value::Undefined) .unwrap_or(&Value::Undefined)
@ -442,7 +442,7 @@ pub fn focus<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Ok(activation Ok(activation
.context .context
.focus_tracker .focus_tracker
@ -457,7 +457,7 @@ pub fn set_focus<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
let focus = activation.context.focus_tracker; let focus = activation.context.focus_tracker;
match args.get(0).cloned().unwrap_or(Value::Undefined) { match args.get(0).cloned().unwrap_or(Value::Undefined) {
Value::Null => focus.set(None, &mut activation.context), Value::Null => focus.set(None, &mut activation.context),
@ -478,7 +478,7 @@ pub fn frame_rate<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Ok((*activation.context.frame_rate).into()) Ok((*activation.context.frame_rate).into())
} }
@ -487,7 +487,7 @@ pub fn set_frame_rate<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
let new_frame_rate = args let new_frame_rate = args
.get(0) .get(0)
.cloned() .cloned()
@ -502,7 +502,7 @@ pub fn show_default_context_menu<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Ok(activation.context.stage.show_menu().into()) Ok(activation.context.stage.show_menu().into())
} }
@ -510,7 +510,7 @@ pub fn set_show_default_context_menu<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
let show_default_context_menu = args.get(0).unwrap_or(&Value::Undefined).coerce_to_boolean(); let show_default_context_menu = args.get(0).unwrap_or(&Value::Undefined).coerce_to_boolean();
activation activation
.context .context
@ -524,7 +524,7 @@ pub fn scale_mode<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
let scale_mode = AvmString::new_utf8( let scale_mode = AvmString::new_utf8(
activation.context.gc_context, activation.context.gc_context,
activation.context.stage.scale_mode().to_string(), activation.context.stage.scale_mode().to_string(),
@ -537,7 +537,7 @@ pub fn set_scale_mode<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Ok(scale_mode) = args if let Ok(scale_mode) = args
.get(0) .get(0)
.unwrap_or(&Value::Undefined) .unwrap_or(&Value::Undefined)
@ -564,7 +564,7 @@ pub fn stage_focus_rect<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(dobj) = this if let Some(dobj) = this
.and_then(|this| this.as_display_object()) .and_then(|this| this.as_display_object())
.and_then(|this| this.as_stage()) .and_then(|this| this.as_stage())
@ -582,7 +582,7 @@ pub fn set_stage_focus_rect<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(dobj) = this if let Some(dobj) = this
.and_then(|this| this.as_display_object()) .and_then(|this| this.as_display_object())
.and_then(|this| this.as_stage()) .and_then(|this| this.as_stage())
@ -599,7 +599,7 @@ pub fn stage_width<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(dobj) = this if let Some(dobj) = this
.and_then(|this| this.as_display_object()) .and_then(|this| this.as_display_object())
.and_then(|this| this.as_stage()) .and_then(|this| this.as_stage())
@ -615,7 +615,7 @@ pub fn set_stage_width<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
// For some reason this value is settable but it does nothing. // For some reason this value is settable but it does nothing.
Ok(Value::Undefined) Ok(Value::Undefined)
} }
@ -625,7 +625,7 @@ pub fn stage_height<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(dobj) = this if let Some(dobj) = this
.and_then(|this| this.as_display_object()) .and_then(|this| this.as_display_object())
.and_then(|this| this.as_stage()) .and_then(|this| this.as_stage())
@ -641,7 +641,7 @@ pub fn set_stage_height<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
// For some reason this value is settable but it does nothing. // For some reason this value is settable but it does nothing.
Ok(Value::Undefined) Ok(Value::Undefined)
} }
@ -653,7 +653,7 @@ pub fn allows_full_screen<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Ok(true.into()) Ok(true.into())
} }
@ -664,7 +664,7 @@ pub fn allows_full_screen_interactive<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Ok(false.into()) Ok(false.into())
} }
@ -673,7 +673,7 @@ pub fn quality<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
let quality = activation.context.stage.quality().into_avm_str(); let quality = activation.context.stage.quality().into_avm_str();
Ok(AvmString::from(quality).into()) Ok(AvmString::from(quality).into())
} }
@ -683,7 +683,7 @@ pub fn set_quality<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
// Invalid values result in no change. // Invalid values result in no change.
if let Ok(quality) = args if let Ok(quality) = args
.get(0) .get(0)

View File

@ -11,7 +11,7 @@ pub fn init<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
let this = this.unwrap(); let this = this.unwrap();
let mut evt = this.as_event_mut(activation.context.gc_context).unwrap(); let mut evt = this.as_event_mut(activation.context.gc_context).unwrap();
evt.set_event_type( evt.set_event_type(
@ -40,7 +40,7 @@ pub fn get_bubbles<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(evt) = this.unwrap().as_event() { if let Some(evt) = this.unwrap().as_event() {
return Ok(evt.is_bubbling().into()); return Ok(evt.is_bubbling().into());
} }
@ -53,7 +53,7 @@ pub fn get_cancelable<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(evt) = this.unwrap().as_event() { if let Some(evt) = this.unwrap().as_event() {
return Ok(evt.is_cancelable().into()); return Ok(evt.is_cancelable().into());
} }
@ -66,7 +66,7 @@ pub fn get_type<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(evt) = this.unwrap().as_event() { if let Some(evt) = this.unwrap().as_event() {
return Ok(evt.event_type().into()); return Ok(evt.event_type().into());
} }
@ -79,7 +79,7 @@ pub fn get_target<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(evt) = this.unwrap().as_event() { if let Some(evt) = this.unwrap().as_event() {
return Ok(evt.target().map(|o| o.into()).unwrap_or(Value::Null)); return Ok(evt.target().map(|o| o.into()).unwrap_or(Value::Null));
} }
@ -92,7 +92,7 @@ pub fn get_current_target<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(evt) = this.unwrap().as_event() { if let Some(evt) = this.unwrap().as_event() {
return Ok(evt return Ok(evt
.current_target() .current_target()
@ -108,7 +108,7 @@ pub fn get_event_phase<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(evt) = this.unwrap().as_event() { if let Some(evt) = this.unwrap().as_event() {
let event_phase = evt.phase() as u32; let event_phase = evt.phase() as u32;
return Ok(event_phase.into()); return Ok(event_phase.into());
@ -122,7 +122,7 @@ pub fn is_default_prevented<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(evt) = this.unwrap().as_event() { if let Some(evt) = this.unwrap().as_event() {
return Ok(evt.is_cancelled().into()); return Ok(evt.is_cancelled().into());
} }
@ -135,7 +135,7 @@ pub fn prevent_default<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(mut evt) = this.unwrap().as_event_mut(activation.context.gc_context) { if let Some(mut evt) = this.unwrap().as_event_mut(activation.context.gc_context) {
evt.cancel(); evt.cancel();
} }
@ -148,7 +148,7 @@ pub fn stop_propagation<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(mut evt) = this.unwrap().as_event_mut(activation.context.gc_context) { if let Some(mut evt) = this.unwrap().as_event_mut(activation.context.gc_context) {
evt.stop_propagation(); evt.stop_propagation();
} }
@ -161,7 +161,7 @@ pub fn stop_immediate_propagation<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(mut evt) = this.unwrap().as_event_mut(activation.context.gc_context) { if let Some(mut evt) = this.unwrap().as_event_mut(activation.context.gc_context) {
evt.stop_immediate_propagation(); evt.stop_immediate_propagation();
} }

View File

@ -20,7 +20,7 @@ pub fn instance_init<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(mut this) = this { if let Some(mut this) = this {
activation.super_init(this, &[])?; activation.super_init(this, &[])?;
@ -44,7 +44,7 @@ pub fn instance_init<'gc>(
fn dispatch_list<'gc>( fn dispatch_list<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
mut this: Object<'gc>, mut this: Object<'gc>,
) -> Result<Object<'gc>, Error> { ) -> Result<Object<'gc>, Error<'gc>> {
match this.get_property( match this.get_property(
&Multiname::new(Namespace::private(NS_EVENT_DISPATCHER), "dispatch_list"), &Multiname::new(Namespace::private(NS_EVENT_DISPATCHER), "dispatch_list"),
activation, activation,
@ -68,7 +68,7 @@ pub fn add_event_listener<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
let dispatch_list = dispatch_list(activation, this)?; let dispatch_list = dispatch_list(activation, this)?;
let event_type = args let event_type = args
@ -109,7 +109,7 @@ pub fn remove_event_listener<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
let dispatch_list = dispatch_list(activation, this)?; let dispatch_list = dispatch_list(activation, this)?;
let event_type = args let event_type = args
@ -142,7 +142,7 @@ pub fn has_event_listener<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
let dispatch_list = dispatch_list(activation, this)?; let dispatch_list = dispatch_list(activation, this)?;
let event_type = args let event_type = args
@ -166,7 +166,7 @@ pub fn will_trigger<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
let dispatch_list = dispatch_list(activation, this)?; let dispatch_list = dispatch_list(activation, this)?;
let event_type = args let event_type = args
@ -204,7 +204,7 @@ pub fn dispatch_event<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
let event = args.get(0).cloned().unwrap_or(Value::Undefined).as_object(); let event = args.get(0).cloned().unwrap_or(Value::Undefined).as_object();
if event.map(|o| o.as_event().is_none()).unwrap_or(true) { if event.map(|o| o.as_event().is_none()).unwrap_or(true) {
@ -223,7 +223,7 @@ pub fn class_init<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Ok(Value::Undefined) Ok(Value::Undefined)
} }
@ -235,7 +235,7 @@ pub fn to_string<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
let object_proto = activation.avm2().classes().object.prototype(); let object_proto = activation.avm2().classes().object.prototype();
let name = Multiname::public("toString"); let name = Multiname::public("toString");
object_proto object_proto

View File

@ -9,7 +9,7 @@ pub fn get_stage_x<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
mouse_event::get_stage_x(activation, this, args) mouse_event::get_stage_x(activation, this, args)
} }
@ -18,6 +18,6 @@ pub fn get_stage_y<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
mouse_event::get_stage_y(activation, this, args) mouse_event::get_stage_y(activation, this, args)
} }

View File

@ -15,7 +15,7 @@ pub fn bodiless_method<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Err("Cannot execute non-native method without body".into()) Err("Cannot execute non-native method without body".into())
} }
@ -24,7 +24,7 @@ pub fn class_init<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Ok(Value::Undefined) Ok(Value::Undefined)
} }

View File

@ -11,7 +11,7 @@ pub fn get_stage_x<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(evt) = this.as_event() { if let Some(evt) = this.as_event() {
let local_x = this let local_x = this
@ -39,7 +39,7 @@ pub fn get_stage_y<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(evt) = this.as_event() { if let Some(evt) = this.as_event() {
let local_y = this let local_y = this

View File

@ -11,7 +11,7 @@ fn instance_init<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
activation.super_init(this, &[])?; activation.super_init(this, &[])?;
} }
@ -23,7 +23,7 @@ fn class_init<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Ok(Value::Undefined) Ok(Value::Undefined)
} }
@ -31,7 +31,7 @@ pub fn call<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if args.is_empty() { if args.is_empty() {
return Ok(Value::Null); return Ok(Value::Null);
} }
@ -58,7 +58,7 @@ pub fn available<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Ok(activation.context.external_interface.available().into()) Ok(activation.context.external_interface.available().into())
} }
@ -66,7 +66,7 @@ pub fn add_callback<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if args.len() < 2 { if args.len() < 2 {
return Ok(Value::Undefined); return Ok(Value::Undefined);
} }

View File

@ -9,7 +9,7 @@ use swf::Fixed8;
fn get_display_object<'gc>( fn get_display_object<'gc>(
this: Object<'gc>, this: Object<'gc>,
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
) -> Result<DisplayObject<'gc>, Error> { ) -> Result<DisplayObject<'gc>, Error<'gc>> {
Ok(this Ok(this
.get_property( .get_property(
&Multiname::new(Namespace::Private("".into()), "_displayObject"), &Multiname::new(Namespace::Private("".into()), "_displayObject"),
@ -25,7 +25,7 @@ pub fn init<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
this.unwrap().set_property( this.unwrap().set_property(
&Multiname::new(Namespace::Private("".into()), "_displayObject"), &Multiname::new(Namespace::Private("".into()), "_displayObject"),
args[0], args[0],
@ -38,7 +38,7 @@ pub fn get_color_transform<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
let this = this.unwrap(); let this = this.unwrap();
let ct_obj = *get_display_object(this, activation)? let ct_obj = *get_display_object(this, activation)?
.base() .base()
@ -50,7 +50,7 @@ pub fn set_color_transform<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
let this = this.unwrap(); let this = this.unwrap();
let ct = object_to_color_transform(args[0].coerce_to_object(activation)?, activation)?; let ct = object_to_color_transform(args[0].coerce_to_object(activation)?, activation)?;
get_display_object(this, activation)? get_display_object(this, activation)?
@ -63,7 +63,7 @@ pub fn get_matrix<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
let this = this.unwrap(); let this = this.unwrap();
let matrix = *get_display_object(this, activation)?.base().matrix(); let matrix = *get_display_object(this, activation)?.base().matrix();
matrix_to_object(matrix, activation) matrix_to_object(matrix, activation)
@ -73,7 +73,7 @@ pub fn set_matrix<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
let this = this.unwrap(); let this = this.unwrap();
let matrix = object_to_matrix(args[0].coerce_to_object(activation)?, activation)?; let matrix = object_to_matrix(args[0].coerce_to_object(activation)?, activation)?;
get_display_object(this, activation)? get_display_object(this, activation)?
@ -86,7 +86,7 @@ pub fn get_concatenated_matrix<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
let this = this.unwrap(); let this = this.unwrap();
let dobj = get_display_object(this, activation)?; let dobj = get_display_object(this, activation)?;
@ -127,7 +127,7 @@ pub fn get_concatenated_color_transform<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
log::warn!("Transform.concatenatedColorTransform: not yet implemented"); log::warn!("Transform.concatenatedColorTransform: not yet implemented");
Ok(Value::Undefined) Ok(Value::Undefined)
} }
@ -137,7 +137,7 @@ pub fn get_concatenated_color_transform<'gc>(
pub fn object_to_color_transform<'gc>( pub fn object_to_color_transform<'gc>(
object: Object<'gc>, object: Object<'gc>,
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
) -> Result<ColorTransform, Error> { ) -> Result<ColorTransform, Error<'gc>> {
let red_multiplier = object let red_multiplier = object
.get_property(&Multiname::public("redMultiplier"), activation)? .get_property(&Multiname::public("redMultiplier"), activation)?
.coerce_to_number(activation)?; .coerce_to_number(activation)?;
@ -177,7 +177,7 @@ pub fn object_to_color_transform<'gc>(
pub fn color_transform_to_object<'gc>( pub fn color_transform_to_object<'gc>(
color_transform: &ColorTransform, color_transform: &ColorTransform,
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
let args = [ let args = [
color_transform.r_mult.to_f64().into(), color_transform.r_mult.to_f64().into(),
color_transform.g_mult.to_f64().into(), color_transform.g_mult.to_f64().into(),
@ -196,7 +196,7 @@ pub fn color_transform_to_object<'gc>(
pub fn matrix_to_object<'gc>( pub fn matrix_to_object<'gc>(
matrix: Matrix, matrix: Matrix,
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
let args = [ let args = [
matrix.a.into(), matrix.a.into(),
matrix.b.into(), matrix.b.into(),
@ -216,7 +216,7 @@ pub fn matrix_to_object<'gc>(
pub fn object_to_matrix<'gc>( pub fn object_to_matrix<'gc>(
object: Object<'gc>, object: Object<'gc>,
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
) -> Result<Matrix, Error> { ) -> Result<Matrix, Error<'gc>> {
let a = object let a = object
.get_property(&Multiname::public("a"), activation)? .get_property(&Multiname::public("a"), activation)?
.coerce_to_number(activation)? as f32; .coerce_to_number(activation)? as f32;

View File

@ -20,7 +20,7 @@ pub fn instance_init<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
activation.super_init(this, &[])?; activation.super_init(this, &[])?;
@ -57,7 +57,7 @@ pub fn class_init<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Ok(Value::Undefined) Ok(Value::Undefined)
} }
@ -66,7 +66,7 @@ pub fn bytes_total<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(sound) = this.and_then(|this| this.as_sound()) { if let Some(sound) = this.and_then(|this| this.as_sound()) {
if let Some(length) = activation.context.audio.get_sound_size(sound) { if let Some(length) = activation.context.audio.get_sound_size(sound) {
return Ok((length).into()); return Ok((length).into());
@ -81,7 +81,7 @@ pub fn is_buffering<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
//STUB: We do not yet support network-loaded sounds. //STUB: We do not yet support network-loaded sounds.
Ok(false.into()) Ok(false.into())
} }
@ -91,7 +91,7 @@ pub fn url<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
//STUB: We do not yet support network-loaded sounds. //STUB: We do not yet support network-loaded sounds.
Ok(Value::Null) Ok(Value::Null)
} }
@ -101,7 +101,7 @@ pub fn length<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(sound) = this.and_then(|this| this.as_sound()) { if let Some(sound) = this.and_then(|this| this.as_sound()) {
if let Some(duration) = activation.context.audio.get_sound_duration(sound) { if let Some(duration) = activation.context.audio.get_sound_duration(sound) {
return Ok((duration).into()); return Ok((duration).into());
@ -116,7 +116,7 @@ pub fn play<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(sound) = this.and_then(|this| this.as_sound()) { if let Some(sound) = this.and_then(|this| this.as_sound()) {
let position = args let position = args
.get(0) .get(0)
@ -177,7 +177,7 @@ pub fn extract<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Err("Sound.extract is a stub.".into()) Err("Sound.extract is a stub.".into())
} }
@ -186,7 +186,7 @@ pub fn close<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Err("Sound.close is a stub.".into()) Err("Sound.close is a stub.".into())
} }
@ -195,7 +195,7 @@ pub fn load<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
let url_request = match args.get(0) { let url_request = match args.get(0) {
Some(Value::Object(request)) => request, Some(Value::Object(request)) => request,
@ -226,7 +226,7 @@ pub fn load_compressed_data_from_byte_array<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Err("Sound.loadCompressedDataFromByteArray is a stub.".into()) Err("Sound.loadCompressedDataFromByteArray is a stub.".into())
} }
@ -235,7 +235,7 @@ pub fn load_pcm_from_byte_array<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Err("Sound.loadPCMFromByteArray is a stub.".into()) Err("Sound.loadPCMFromByteArray is a stub.".into())
} }

View File

@ -17,7 +17,7 @@ pub fn instance_init<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
activation.super_init(this, &[])?; activation.super_init(this, &[])?;
} }
@ -30,7 +30,7 @@ pub fn class_init<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Ok(Value::Undefined) Ok(Value::Undefined)
} }
@ -39,7 +39,7 @@ pub fn left_peak<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Err("Sound.leftPeak is a stub.".into()) Err("Sound.leftPeak is a stub.".into())
} }
@ -48,7 +48,7 @@ pub fn right_peak<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Err("Sound.rightPeak is a stub.".into()) Err("Sound.rightPeak is a stub.".into())
} }
@ -57,7 +57,7 @@ pub fn position<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(instance) = this.and_then(|this| this.as_sound_channel()) { if let Some(instance) = this.and_then(|this| this.as_sound_channel()) {
return Ok(instance.position().into()); return Ok(instance.position().into());
} }
@ -69,7 +69,7 @@ pub fn sound_transform<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(instance) = this if let Some(instance) = this
.and_then(|this| this.as_sound_channel()) .and_then(|this| this.as_sound_channel())
.and_then(|channel| channel.instance()) .and_then(|channel| channel.instance())
@ -89,7 +89,7 @@ pub fn set_sound_transform<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(instance) = this if let Some(instance) = this
.and_then(|this| this.as_sound_channel()) .and_then(|this| this.as_sound_channel())
.and_then(|channel| channel.instance()) .and_then(|channel| channel.instance())
@ -114,7 +114,7 @@ pub fn stop<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(instance) = this if let Some(instance) = this
.and_then(|this| this.as_sound_channel()) .and_then(|this| this.as_sound_channel())
.and_then(|channel| channel.instance()) .and_then(|channel| channel.instance())

View File

@ -17,7 +17,7 @@ pub fn instance_init<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
activation.super_init(this, &[])?; activation.super_init(this, &[])?;
} }
@ -30,7 +30,7 @@ pub fn class_init<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Ok(Value::Undefined) Ok(Value::Undefined)
} }
@ -42,7 +42,7 @@ pub fn sound_transform<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
let dobj_st = activation.context.global_sound_transform().clone(); let dobj_st = activation.context.global_sound_transform().clone();
Ok(dobj_st.into_avm2_object(activation)?.into()) Ok(dobj_st.into_avm2_object(activation)?.into())
@ -56,7 +56,7 @@ pub fn set_sound_transform<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
let as3_st = args let as3_st = args
.get(0) .get(0)
.cloned() .cloned()
@ -74,7 +74,7 @@ pub fn stop_all<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
activation.context.stop_all_sounds(); activation.context.stop_all_sounds();
Ok(Value::Undefined) Ok(Value::Undefined)
@ -85,7 +85,7 @@ pub fn buffer_time<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Ok(activation.context.audio_manager.stream_buffer_time().into()) Ok(activation.context.audio_manager.stream_buffer_time().into())
} }
@ -94,7 +94,7 @@ pub fn set_buffer_time<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
let buffer_time = args let buffer_time = args
.get(0) .get(0)
.cloned() .cloned()
@ -114,7 +114,7 @@ pub fn are_sounds_inaccessible<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Err("SoundMixer.areSoundsInaccessible is a stub".into()) Err("SoundMixer.areSoundsInaccessible is a stub".into())
} }
@ -123,7 +123,7 @@ pub fn compute_spectrum<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Err("SoundMixer.computeSpectrum is a stub".into()) Err("SoundMixer.computeSpectrum is a stub".into())
} }

View File

@ -16,7 +16,7 @@ pub fn instance_init<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(mut this) = this { if let Some(mut this) = this {
activation.super_init(this, &[])?; activation.super_init(this, &[])?;
@ -43,7 +43,7 @@ pub fn class_init<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Ok(Value::Undefined) Ok(Value::Undefined)
} }
@ -52,7 +52,7 @@ pub fn pan<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
let left_to_right = this let left_to_right = this
.get_property(&Multiname::public("leftToRight"), activation)? .get_property(&Multiname::public("leftToRight"), activation)?
@ -80,7 +80,7 @@ pub fn set_pan<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(mut this) = this { if let Some(mut this) = this {
let pan = args let pan = args
.get(0) .get(0)

View File

@ -16,7 +16,7 @@ pub fn instance_init<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
activation.super_init(this, &[])?; activation.super_init(this, &[])?;
} }
@ -29,7 +29,7 @@ pub fn class_init<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Ok(Value::Undefined) Ok(Value::Undefined)
} }

View File

@ -14,7 +14,7 @@ pub fn instance_init<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Ok(Value::Undefined) Ok(Value::Undefined)
} }
@ -23,7 +23,7 @@ pub fn class_init<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Ok(Value::Undefined) Ok(Value::Undefined)
} }

View File

@ -17,7 +17,7 @@ fn instance_init<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(mut this) = this { if let Some(mut this) = this {
activation.super_init(this, &[])?; activation.super_init(this, &[])?;
@ -37,7 +37,7 @@ fn class_init<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Ok(Value::Undefined) Ok(Value::Undefined)
} }
@ -45,7 +45,7 @@ pub fn get_local<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
// TODO: It appears that Flash does some kind of escaping here: // TODO: It appears that Flash does some kind of escaping here:
// the name "foo\uD800" correspond to a file named "fooE#FB#FB#D.sol". // the name "foo\uD800" correspond to a file named "fooE#FB#FB#D.sol".
@ -212,7 +212,7 @@ pub fn flush<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
let data = this let data = this
.get_property(&Multiname::public("data"), activation)? .get_property(&Multiname::public("data"), activation)?

View File

@ -13,7 +13,7 @@ pub fn load<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
let request = match args.get(0) { let request = match args.get(0) {
Some(Value::Object(request)) => request, Some(Value::Object(request)) => request,
@ -45,7 +45,7 @@ fn spawn_fetch<'gc>(
loader_object: Object<'gc>, loader_object: Object<'gc>,
url_request: &Object<'gc>, url_request: &Object<'gc>,
data_format: DataFormat, data_format: DataFormat,
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
let url = url_request let url = url_request
.get_property(&Multiname::public("url"), activation)? .get_property(&Multiname::public("url"), activation)?
.coerce_to_string(activation)?; .coerce_to_string(activation)?;

View File

@ -16,7 +16,7 @@ pub fn instance_init<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
activation.super_init(this, &[])?; activation.super_init(this, &[])?;
} }
@ -29,7 +29,7 @@ pub fn class_init<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Ok(Value::Undefined) Ok(Value::Undefined)
} }
@ -38,7 +38,7 @@ pub fn current_domain<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
let appdomain = activation.caller_domain(); let appdomain = activation.caller_domain();
Ok(DomainObject::from_domain(activation, appdomain)?.into()) Ok(DomainObject::from_domain(activation, appdomain)?.into())
@ -49,7 +49,7 @@ pub fn parent_domain<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(appdomain) = this.and_then(|this| this.as_application_domain()) { if let Some(appdomain) = this.and_then(|this| this.as_application_domain()) {
if let Some(parent_domain) = appdomain.parent_domain() { if let Some(parent_domain) = appdomain.parent_domain() {
return Ok(DomainObject::from_domain(activation, parent_domain)?.into()); return Ok(DomainObject::from_domain(activation, parent_domain)?.into());
@ -64,7 +64,7 @@ pub fn get_definition<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(appdomain) = this.and_then(|this| this.as_application_domain()) { if let Some(appdomain) = this.and_then(|this| this.as_application_domain()) {
let local_name = args let local_name = args
.get(0) .get(0)
@ -90,7 +90,7 @@ pub fn has_definition<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(appdomain) = this.and_then(|this| this.as_application_domain()) { if let Some(appdomain) = this.and_then(|this| this.as_application_domain()) {
let local_name = args let local_name = args
.get(0) .get(0)
@ -110,7 +110,7 @@ pub fn set_domain_memory<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(Value::Object(arg)) = args.get(0) { if let Some(Value::Object(arg)) = args.get(0) {
if let Some(bytearray_obj) = arg.as_bytearray_object() { if let Some(bytearray_obj) = arg.as_bytearray_object() {
if let Some(appdomain) = this.and_then(|this| this.as_application_domain()) { if let Some(appdomain) = this.and_then(|this| this.as_application_domain()) {
@ -127,7 +127,7 @@ pub fn domain_memory<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(appdomain) = this.and_then(|this| this.as_application_domain()) { if let Some(appdomain) = this.and_then(|this| this.as_application_domain()) {
let bytearray_object: Object<'gc> = appdomain.domain_memory().into(); let bytearray_object: Object<'gc> = appdomain.domain_memory().into();
return Ok(bytearray_object.into()); return Ok(bytearray_object.into());

View File

@ -10,7 +10,7 @@ pub fn get_sandbox_type<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
let sandbox_type = activation.context.system.sandbox_type.to_string(); let sandbox_type = activation.context.system.sandbox_type.to_string();
return Ok(AvmString::new_utf8(activation.context.gc_context, sandbox_type).into()); return Ok(AvmString::new_utf8(activation.context.gc_context, sandbox_type).into());
} }
@ -19,7 +19,7 @@ pub fn allow_domain<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
log::warn!("Security.allowDomain not implemented"); log::warn!("Security.allowDomain not implemented");
Ok(Value::Undefined) Ok(Value::Undefined)
} }
@ -28,7 +28,7 @@ pub fn allow_insecure_domain<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
log::warn!("Security.allowInsecureDomain not implemented"); log::warn!("Security.allowInsecureDomain not implemented");
Ok(Value::Undefined) Ok(Value::Undefined)
} }
@ -37,7 +37,7 @@ pub fn load_policy_file<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
log::warn!("Security.loadPolicyFile not implemented"); log::warn!("Security.loadPolicyFile not implemented");
Ok(Value::Undefined) Ok(Value::Undefined)
} }
@ -46,7 +46,7 @@ pub fn show_settings<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
log::warn!("Security.showSettings not implemented"); log::warn!("Security.showSettings not implemented");
Ok(Value::Undefined) Ok(Value::Undefined)
} }

View File

@ -18,7 +18,7 @@ pub fn instance_init<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
activation.super_init(this, &[])?; activation.super_init(this, &[])?;
} }
@ -31,7 +31,7 @@ pub fn class_init<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Ok(Value::Undefined) Ok(Value::Undefined)
} }
@ -40,7 +40,7 @@ pub fn font_name<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some((movie, character_id)) = this.and_then(|this| this.instance_of()).and_then(|this| { if let Some((movie, character_id)) = this.and_then(|this| this.instance_of()).and_then(|this| {
activation activation
.context .context
@ -70,7 +70,7 @@ pub fn font_style<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some((movie, character_id)) = this.and_then(|this| this.instance_of()).and_then(|this| { if let Some((movie, character_id)) = this.and_then(|this| this.instance_of()).and_then(|this| {
activation activation
.context .context
@ -101,7 +101,7 @@ pub fn font_type<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some((movie, character_id)) = this.and_then(|this| this.instance_of()).and_then(|this| { if let Some((movie, character_id)) = this.and_then(|this| this.instance_of()).and_then(|this| {
activation activation
.context .context
@ -128,7 +128,7 @@ pub fn has_glyphs<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some((movie, character_id)) = this.and_then(|this| this.instance_of()).and_then(|this| { if let Some((movie, character_id)) = this.and_then(|this| this.instance_of()).and_then(|this| {
activation activation
.context .context
@ -160,7 +160,7 @@ pub fn enumerate_fonts<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Err("Font.enumerateFonts is a stub".into()) Err("Font.enumerateFonts is a stub".into())
} }
@ -169,7 +169,7 @@ pub fn register_font<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Err("Font.registerFont is a stub".into()) Err("Font.registerFont is a stub".into())
} }

View File

@ -22,7 +22,7 @@ pub fn instance_init<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
activation.super_init(this, &[])?; activation.super_init(this, &[])?;
@ -42,7 +42,7 @@ pub fn class_init<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Ok(Value::Undefined) Ok(Value::Undefined)
} }
@ -50,7 +50,7 @@ pub fn autosize<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this if let Some(this) = this
.and_then(|this| this.as_display_object()) .and_then(|this| this.as_display_object())
.and_then(|this| this.as_edit_text()) .and_then(|this| this.as_edit_text())
@ -70,7 +70,7 @@ pub fn set_autosize<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this if let Some(this) = this
.and_then(|this| this.as_display_object()) .and_then(|this| this.as_display_object())
.and_then(|this| this.as_edit_text()) .and_then(|this| this.as_edit_text())
@ -101,7 +101,7 @@ pub fn background<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this if let Some(this) = this
.and_then(|this| this.as_display_object()) .and_then(|this| this.as_display_object())
.and_then(|this| this.as_edit_text()) .and_then(|this| this.as_edit_text())
@ -116,7 +116,7 @@ pub fn set_background<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this if let Some(this) = this
.and_then(|this| this.as_display_object()) .and_then(|this| this.as_display_object())
.and_then(|this| this.as_edit_text()) .and_then(|this| this.as_edit_text())
@ -136,7 +136,7 @@ pub fn background_color<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this if let Some(this) = this
.and_then(|this| this.as_display_object()) .and_then(|this| this.as_display_object())
.and_then(|this| this.as_edit_text()) .and_then(|this| this.as_edit_text())
@ -151,7 +151,7 @@ pub fn set_background_color<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this if let Some(this) = this
.and_then(|this| this.as_display_object()) .and_then(|this| this.as_display_object())
.and_then(|this| this.as_edit_text()) .and_then(|this| this.as_edit_text())
@ -171,7 +171,7 @@ pub fn border<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this if let Some(this) = this
.and_then(|this| this.as_display_object()) .and_then(|this| this.as_display_object())
.and_then(|this| this.as_edit_text()) .and_then(|this| this.as_edit_text())
@ -186,7 +186,7 @@ pub fn set_border<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this if let Some(this) = this
.and_then(|this| this.as_display_object()) .and_then(|this| this.as_display_object())
.and_then(|this| this.as_edit_text()) .and_then(|this| this.as_edit_text())
@ -206,7 +206,7 @@ pub fn border_color<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this if let Some(this) = this
.and_then(|this| this.as_display_object()) .and_then(|this| this.as_display_object())
.and_then(|this| this.as_edit_text()) .and_then(|this| this.as_edit_text())
@ -221,7 +221,7 @@ pub fn set_border_color<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this if let Some(this) = this
.and_then(|this| this.as_display_object()) .and_then(|this| this.as_display_object())
.and_then(|this| this.as_edit_text()) .and_then(|this| this.as_edit_text())
@ -241,7 +241,7 @@ pub fn default_text_format<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this if let Some(this) = this
.and_then(|this| this.as_display_object()) .and_then(|this| this.as_display_object())
.and_then(|this| this.as_edit_text()) .and_then(|this| this.as_edit_text())
@ -256,7 +256,7 @@ pub fn set_default_text_format<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this if let Some(this) = this
.and_then(|this| this.as_display_object()) .and_then(|this| this.as_display_object())
.and_then(|this| this.as_edit_text()) .and_then(|this| this.as_edit_text())
@ -277,7 +277,7 @@ pub fn display_as_password<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this if let Some(this) = this
.and_then(|this| this.as_display_object()) .and_then(|this| this.as_display_object())
.and_then(|this| this.as_edit_text()) .and_then(|this| this.as_edit_text())
@ -292,7 +292,7 @@ pub fn set_display_as_password<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this if let Some(this) = this
.and_then(|this| this.as_display_object()) .and_then(|this| this.as_display_object())
.and_then(|this| this.as_edit_text()) .and_then(|this| this.as_edit_text())
@ -313,7 +313,7 @@ pub fn embed_fonts<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this if let Some(this) = this
.and_then(|this| this.as_display_object()) .and_then(|this| this.as_display_object())
.and_then(|this| this.as_edit_text()) .and_then(|this| this.as_edit_text())
@ -328,7 +328,7 @@ pub fn set_embed_fonts<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this if let Some(this) = this
.and_then(|this| this.as_display_object()) .and_then(|this| this.as_display_object())
.and_then(|this| this.as_edit_text()) .and_then(|this| this.as_edit_text())
@ -349,7 +349,7 @@ pub fn html_text<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this if let Some(this) = this
.and_then(|this| this.as_display_object()) .and_then(|this| this.as_display_object())
.and_then(|this| this.as_edit_text()) .and_then(|this| this.as_edit_text())
@ -364,7 +364,7 @@ pub fn set_html_text<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this if let Some(this) = this
.and_then(|this| this.as_display_object()) .and_then(|this| this.as_display_object())
.and_then(|this| this.as_edit_text()) .and_then(|this| this.as_edit_text())
@ -385,7 +385,7 @@ pub fn length<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this if let Some(this) = this
.and_then(|this| this.as_display_object()) .and_then(|this| this.as_display_object())
.and_then(|this| this.as_edit_text()) .and_then(|this| this.as_edit_text())
@ -400,7 +400,7 @@ pub fn multiline<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this if let Some(this) = this
.and_then(|this| this.as_display_object()) .and_then(|this| this.as_display_object())
.and_then(|this| this.as_edit_text()) .and_then(|this| this.as_edit_text())
@ -415,7 +415,7 @@ pub fn set_multiline<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this if let Some(this) = this
.and_then(|this| this.as_display_object()) .and_then(|this| this.as_display_object())
.and_then(|this| this.as_edit_text()) .and_then(|this| this.as_edit_text())
@ -436,7 +436,7 @@ pub fn selectable<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this if let Some(this) = this
.and_then(|this| this.as_display_object()) .and_then(|this| this.as_display_object())
.and_then(|this| this.as_edit_text()) .and_then(|this| this.as_edit_text())
@ -451,7 +451,7 @@ pub fn set_selectable<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this if let Some(this) = this
.and_then(|this| this.as_display_object()) .and_then(|this| this.as_display_object())
.and_then(|this| this.as_edit_text()) .and_then(|this| this.as_edit_text())
@ -472,7 +472,7 @@ pub fn text<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this if let Some(this) = this
.and_then(|this| this.as_display_object()) .and_then(|this| this.as_display_object())
.and_then(|this| this.as_edit_text()) .and_then(|this| this.as_edit_text())
@ -487,7 +487,7 @@ pub fn set_text<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this if let Some(this) = this
.and_then(|this| this.as_display_object()) .and_then(|this| this.as_display_object())
.and_then(|this| this.as_edit_text()) .and_then(|this| this.as_edit_text())
@ -508,7 +508,7 @@ pub fn text_color<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this if let Some(this) = this
.and_then(|this| this.as_display_object()) .and_then(|this| this.as_display_object())
.and_then(|this| this.as_edit_text()) .and_then(|this| this.as_edit_text())
@ -527,7 +527,7 @@ pub fn set_text_color<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this if let Some(this) = this
.and_then(|this| this.as_display_object()) .and_then(|this| this.as_display_object())
.and_then(|this| this.as_edit_text()) .and_then(|this| this.as_edit_text())
@ -558,7 +558,7 @@ pub fn text_height<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this if let Some(this) = this
.and_then(|this| this.as_display_object()) .and_then(|this| this.as_display_object())
.and_then(|this| this.as_edit_text()) .and_then(|this| this.as_edit_text())
@ -574,7 +574,7 @@ pub fn text_width<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this if let Some(this) = this
.and_then(|this| this.as_display_object()) .and_then(|this| this.as_display_object())
.and_then(|this| this.as_edit_text()) .and_then(|this| this.as_edit_text())
@ -590,7 +590,7 @@ pub fn get_type<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this if let Some(this) = this
.and_then(|this| this.as_display_object()) .and_then(|this| this.as_display_object())
.and_then(|this| this.as_edit_text()) .and_then(|this| this.as_edit_text())
@ -608,7 +608,7 @@ pub fn set_type<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this if let Some(this) = this
.and_then(|this| this.as_display_object()) .and_then(|this| this.as_display_object())
.and_then(|this| this.as_edit_text()) .and_then(|this| this.as_edit_text())
@ -635,7 +635,7 @@ pub fn word_wrap<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this if let Some(this) = this
.and_then(|this| this.as_display_object()) .and_then(|this| this.as_display_object())
.and_then(|this| this.as_edit_text()) .and_then(|this| this.as_edit_text())
@ -650,7 +650,7 @@ pub fn set_word_wrap<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this if let Some(this) = this
.and_then(|this| this.as_display_object()) .and_then(|this| this.as_display_object())
.and_then(|this| this.as_edit_text()) .and_then(|this| this.as_edit_text())
@ -671,7 +671,7 @@ pub fn append_text<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this if let Some(this) = this
.and_then(|this| this.as_display_object()) .and_then(|this| this.as_display_object())
.and_then(|this| this.as_edit_text()) .and_then(|this| this.as_edit_text())
@ -698,7 +698,7 @@ pub fn get_text_format<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this if let Some(this) = this
.and_then(|this| this.as_display_object()) .and_then(|this| this.as_display_object())
.and_then(|this| this.as_edit_text()) .and_then(|this| this.as_edit_text())
@ -733,7 +733,7 @@ pub fn replace_selected_text<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this if let Some(this) = this
.and_then(|this| this.as_display_object()) .and_then(|this| this.as_display_object())
.and_then(|this| this.as_edit_text()) .and_then(|this| this.as_edit_text())
@ -762,7 +762,7 @@ pub fn replace_text<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this if let Some(this) = this
.and_then(|this| this.as_display_object()) .and_then(|this| this.as_display_object())
.and_then(|this| this.as_edit_text()) .and_then(|this| this.as_edit_text())
@ -798,7 +798,7 @@ pub fn set_selection<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this if let Some(this) = this
.and_then(|this| this.as_display_object()) .and_then(|this| this.as_display_object())
.and_then(|this| this.as_edit_text()) .and_then(|this| this.as_edit_text())
@ -830,7 +830,7 @@ pub fn set_text_format<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this if let Some(this) = this
.and_then(|this| this.as_display_object()) .and_then(|this| this.as_display_object())
.and_then(|this| this.as_edit_text()) .and_then(|this| this.as_edit_text())
@ -880,7 +880,7 @@ pub fn anti_alias_type<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
log::warn!("TextField.antiAliasType getter: not yet implemented"); log::warn!("TextField.antiAliasType getter: not yet implemented");
Ok(Value::Undefined) Ok(Value::Undefined)
} }
@ -889,7 +889,7 @@ pub fn set_anti_alias_type<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
log::warn!("TextField.antiAliasType setter: not yet implemented"); log::warn!("TextField.antiAliasType setter: not yet implemented");
Ok(Value::Undefined) Ok(Value::Undefined)
} }

View File

@ -19,7 +19,7 @@ pub fn instance_init<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
activation.super_init(this, &[])?; activation.super_init(this, &[])?;
@ -100,7 +100,7 @@ pub fn class_init<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Ok(Value::Undefined) Ok(Value::Undefined)
} }
@ -136,7 +136,7 @@ macro_rules! setter {
fn align<'gc>( fn align<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
text_format: &TextFormat, text_format: &TextFormat,
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Ok(text_format Ok(text_format
.align .align
.as_ref() .as_ref()
@ -152,7 +152,7 @@ fn set_align<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
text_format: &mut TextFormat, text_format: &mut TextFormat,
value: &Value<'gc>, value: &Value<'gc>,
) -> Result<(), Error> { ) -> Result<(), Error<'gc>> {
let value = match value { let value = match value {
Value::Undefined | Value::Null => { Value::Undefined | Value::Null => {
text_format.align = None; text_format.align = None;
@ -181,7 +181,7 @@ fn set_align<'gc>(
fn block_indent<'gc>( fn block_indent<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
text_format: &TextFormat, text_format: &TextFormat,
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Ok(text_format Ok(text_format
.block_indent .block_indent
.as_ref() .as_ref()
@ -192,7 +192,7 @@ fn set_block_indent<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
text_format: &mut TextFormat, text_format: &mut TextFormat,
value: &Value<'gc>, value: &Value<'gc>,
) -> Result<(), Error> { ) -> Result<(), Error<'gc>> {
text_format.block_indent = match value { text_format.block_indent = match value {
Value::Undefined | Value::Null => None, Value::Undefined | Value::Null => None,
value => Some(round_to_even(value.coerce_to_number(activation)?).into()), value => Some(round_to_even(value.coerce_to_number(activation)?).into()),
@ -203,7 +203,7 @@ fn set_block_indent<'gc>(
fn bold<'gc>( fn bold<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
text_format: &TextFormat, text_format: &TextFormat,
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Ok(text_format Ok(text_format
.bold .bold
.as_ref() .as_ref()
@ -214,7 +214,7 @@ fn set_bold<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
text_format: &mut TextFormat, text_format: &mut TextFormat,
value: &Value<'gc>, value: &Value<'gc>,
) -> Result<(), Error> { ) -> Result<(), Error<'gc>> {
text_format.bold = match value { text_format.bold = match value {
Value::Undefined | Value::Null => None, Value::Undefined | Value::Null => None,
value => Some(value.coerce_to_boolean()), value => Some(value.coerce_to_boolean()),
@ -225,7 +225,7 @@ fn set_bold<'gc>(
fn bullet<'gc>( fn bullet<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
text_format: &TextFormat, text_format: &TextFormat,
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Ok(text_format Ok(text_format
.bullet .bullet
.as_ref() .as_ref()
@ -236,7 +236,7 @@ fn set_bullet<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
text_format: &mut TextFormat, text_format: &mut TextFormat,
value: &Value<'gc>, value: &Value<'gc>,
) -> Result<(), Error> { ) -> Result<(), Error<'gc>> {
text_format.bullet = match value { text_format.bullet = match value {
Value::Undefined | Value::Null => None, Value::Undefined | Value::Null => None,
value => Some(value.coerce_to_boolean()), value => Some(value.coerce_to_boolean()),
@ -247,7 +247,7 @@ fn set_bullet<'gc>(
fn color<'gc>( fn color<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
text_format: &TextFormat, text_format: &TextFormat,
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Ok(text_format Ok(text_format
.color .color
.as_ref() .as_ref()
@ -258,7 +258,7 @@ fn set_color<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
text_format: &mut TextFormat, text_format: &mut TextFormat,
value: &Value<'gc>, value: &Value<'gc>,
) -> Result<(), Error> { ) -> Result<(), Error<'gc>> {
text_format.color = match value { text_format.color = match value {
Value::Undefined | Value::Null => None, Value::Undefined | Value::Null => None,
value => Some(swf::Color::from_rgba(value.coerce_to_u32(activation)?)), value => Some(swf::Color::from_rgba(value.coerce_to_u32(activation)?)),
@ -269,7 +269,7 @@ fn set_color<'gc>(
fn font<'gc>( fn font<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
text_format: &TextFormat, text_format: &TextFormat,
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Ok(text_format.font.as_ref().map_or(Value::Null, |font| { Ok(text_format.font.as_ref().map_or(Value::Null, |font| {
AvmString::new(activation.context.gc_context, font.as_wstr()).into() AvmString::new(activation.context.gc_context, font.as_wstr()).into()
})) }))
@ -279,7 +279,7 @@ fn set_font<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
text_format: &mut TextFormat, text_format: &mut TextFormat,
value: &Value<'gc>, value: &Value<'gc>,
) -> Result<(), Error> { ) -> Result<(), Error<'gc>> {
text_format.font = match value { text_format.font = match value {
Value::Undefined | Value::Null => None, Value::Undefined | Value::Null => None,
value => Some(value.coerce_to_string(activation)?.as_wstr().into()), value => Some(value.coerce_to_string(activation)?.as_wstr().into()),
@ -290,7 +290,7 @@ fn set_font<'gc>(
fn indent<'gc>( fn indent<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
text_format: &TextFormat, text_format: &TextFormat,
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Ok(text_format Ok(text_format
.indent .indent
.as_ref() .as_ref()
@ -301,7 +301,7 @@ fn set_indent<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
text_format: &mut TextFormat, text_format: &mut TextFormat,
value: &Value<'gc>, value: &Value<'gc>,
) -> Result<(), Error> { ) -> Result<(), Error<'gc>> {
text_format.indent = match value { text_format.indent = match value {
Value::Undefined | Value::Null => None, Value::Undefined | Value::Null => None,
value => Some(round_to_even(value.coerce_to_number(activation)?).into()), value => Some(round_to_even(value.coerce_to_number(activation)?).into()),
@ -312,7 +312,7 @@ fn set_indent<'gc>(
fn italic<'gc>( fn italic<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
text_format: &TextFormat, text_format: &TextFormat,
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Ok(text_format Ok(text_format
.italic .italic
.as_ref() .as_ref()
@ -323,7 +323,7 @@ fn set_italic<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
text_format: &mut TextFormat, text_format: &mut TextFormat,
value: &Value<'gc>, value: &Value<'gc>,
) -> Result<(), Error> { ) -> Result<(), Error<'gc>> {
text_format.italic = match value { text_format.italic = match value {
Value::Undefined | Value::Null => None, Value::Undefined | Value::Null => None,
value => Some(value.coerce_to_boolean()), value => Some(value.coerce_to_boolean()),
@ -334,7 +334,7 @@ fn set_italic<'gc>(
fn kerning<'gc>( fn kerning<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
text_format: &TextFormat, text_format: &TextFormat,
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Ok(text_format Ok(text_format
.kerning .kerning
.as_ref() .as_ref()
@ -345,7 +345,7 @@ fn set_kerning<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
text_format: &mut TextFormat, text_format: &mut TextFormat,
value: &Value<'gc>, value: &Value<'gc>,
) -> Result<(), Error> { ) -> Result<(), Error<'gc>> {
text_format.kerning = match value { text_format.kerning = match value {
Value::Undefined | Value::Null => None, Value::Undefined | Value::Null => None,
value => Some(value.coerce_to_boolean()), value => Some(value.coerce_to_boolean()),
@ -356,7 +356,7 @@ fn set_kerning<'gc>(
fn leading<'gc>( fn leading<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
text_format: &TextFormat, text_format: &TextFormat,
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Ok(text_format Ok(text_format
.leading .leading
.as_ref() .as_ref()
@ -367,7 +367,7 @@ fn set_leading<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
text_format: &mut TextFormat, text_format: &mut TextFormat,
value: &Value<'gc>, value: &Value<'gc>,
) -> Result<(), Error> { ) -> Result<(), Error<'gc>> {
text_format.leading = match value { text_format.leading = match value {
Value::Undefined | Value::Null => None, Value::Undefined | Value::Null => None,
value => Some(round_to_even(value.coerce_to_number(activation)?).into()), value => Some(round_to_even(value.coerce_to_number(activation)?).into()),
@ -378,7 +378,7 @@ fn set_leading<'gc>(
fn left_margin<'gc>( fn left_margin<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
text_format: &TextFormat, text_format: &TextFormat,
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Ok(text_format Ok(text_format
.left_margin .left_margin
.as_ref() .as_ref()
@ -389,7 +389,7 @@ fn set_left_margin<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
text_format: &mut TextFormat, text_format: &mut TextFormat,
value: &Value<'gc>, value: &Value<'gc>,
) -> Result<(), Error> { ) -> Result<(), Error<'gc>> {
text_format.left_margin = match value { text_format.left_margin = match value {
Value::Undefined | Value::Null => None, Value::Undefined | Value::Null => None,
value => Some(round_to_even(value.coerce_to_number(activation)?).into()), value => Some(round_to_even(value.coerce_to_number(activation)?).into()),
@ -400,7 +400,7 @@ fn set_left_margin<'gc>(
fn letter_spacing<'gc>( fn letter_spacing<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
text_format: &TextFormat, text_format: &TextFormat,
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Ok(text_format Ok(text_format
.letter_spacing .letter_spacing
.as_ref() .as_ref()
@ -411,7 +411,7 @@ fn set_letter_spacing<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
text_format: &mut TextFormat, text_format: &mut TextFormat,
value: &Value<'gc>, value: &Value<'gc>,
) -> Result<(), Error> { ) -> Result<(), Error<'gc>> {
text_format.letter_spacing = match value { text_format.letter_spacing = match value {
Value::Undefined | Value::Null => None, Value::Undefined | Value::Null => None,
value => Some(value.coerce_to_number(activation)?), value => Some(value.coerce_to_number(activation)?),
@ -422,7 +422,7 @@ fn set_letter_spacing<'gc>(
fn right_margin<'gc>( fn right_margin<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
text_format: &TextFormat, text_format: &TextFormat,
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Ok(text_format Ok(text_format
.right_margin .right_margin
.as_ref() .as_ref()
@ -433,7 +433,7 @@ fn set_right_margin<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
text_format: &mut TextFormat, text_format: &mut TextFormat,
value: &Value<'gc>, value: &Value<'gc>,
) -> Result<(), Error> { ) -> Result<(), Error<'gc>> {
text_format.right_margin = match value { text_format.right_margin = match value {
Value::Undefined | Value::Null => None, Value::Undefined | Value::Null => None,
value => Some(round_to_even(value.coerce_to_number(activation)?).into()), value => Some(round_to_even(value.coerce_to_number(activation)?).into()),
@ -444,7 +444,7 @@ fn set_right_margin<'gc>(
fn size<'gc>( fn size<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
text_format: &TextFormat, text_format: &TextFormat,
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Ok(text_format Ok(text_format
.size .size
.as_ref() .as_ref()
@ -455,7 +455,7 @@ fn set_size<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
text_format: &mut TextFormat, text_format: &mut TextFormat,
value: &Value<'gc>, value: &Value<'gc>,
) -> Result<(), Error> { ) -> Result<(), Error<'gc>> {
text_format.size = match value { text_format.size = match value {
Value::Undefined | Value::Null => None, Value::Undefined | Value::Null => None,
value => Some(round_to_even(value.coerce_to_number(activation)?).into()), value => Some(round_to_even(value.coerce_to_number(activation)?).into()),
@ -466,7 +466,7 @@ fn set_size<'gc>(
fn tab_stops<'gc>( fn tab_stops<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
text_format: &TextFormat, text_format: &TextFormat,
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
text_format text_format
.tab_stops .tab_stops
.as_ref() .as_ref()
@ -480,14 +480,14 @@ fn set_tab_stops<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
text_format: &mut TextFormat, text_format: &mut TextFormat,
value: &Value<'gc>, value: &Value<'gc>,
) -> Result<(), Error> { ) -> Result<(), Error<'gc>> {
text_format.tab_stops = match value { text_format.tab_stops = match value {
Value::Undefined | Value::Null => None, Value::Undefined | Value::Null => None,
value => { value => {
let object = value.coerce_to_object(activation)?; let object = value.coerce_to_object(activation)?;
let length = object.as_array_storage().map_or(0, |v| v.length()); let length = object.as_array_storage().map_or(0, |v| v.length());
let tab_stops: Result<Vec<_>, Error> = (0..length) let tab_stops: Result<Vec<_>, Error<'gc>> = (0..length)
.map(|i| { .map(|i| {
let element = object.get_property( let element = object.get_property(
&Multiname::public(AvmString::new_utf8( &Multiname::public(AvmString::new_utf8(
@ -508,7 +508,7 @@ fn set_tab_stops<'gc>(
fn target<'gc>( fn target<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
text_format: &TextFormat, text_format: &TextFormat,
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Ok(text_format.target.as_ref().map_or(Value::Null, |target| { Ok(text_format.target.as_ref().map_or(Value::Null, |target| {
AvmString::new(activation.context.gc_context, target.as_wstr()).into() AvmString::new(activation.context.gc_context, target.as_wstr()).into()
})) }))
@ -518,7 +518,7 @@ fn set_target<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
text_format: &mut TextFormat, text_format: &mut TextFormat,
value: &Value<'gc>, value: &Value<'gc>,
) -> Result<(), Error> { ) -> Result<(), Error<'gc>> {
text_format.target = match value { text_format.target = match value {
Value::Undefined | Value::Null => None, Value::Undefined | Value::Null => None,
value => Some(value.coerce_to_string(activation)?.as_wstr().into()), value => Some(value.coerce_to_string(activation)?.as_wstr().into()),
@ -529,7 +529,7 @@ fn set_target<'gc>(
fn underline<'gc>( fn underline<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
text_format: &TextFormat, text_format: &TextFormat,
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Ok(text_format Ok(text_format
.underline .underline
.as_ref() .as_ref()
@ -540,7 +540,7 @@ fn set_underline<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
text_format: &mut TextFormat, text_format: &mut TextFormat,
value: &Value<'gc>, value: &Value<'gc>,
) -> Result<(), Error> { ) -> Result<(), Error<'gc>> {
text_format.underline = match value { text_format.underline = match value {
Value::Undefined | Value::Null => None, Value::Undefined | Value::Null => None,
value => Some(value.coerce_to_boolean()), value => Some(value.coerce_to_boolean()),
@ -551,7 +551,7 @@ fn set_underline<'gc>(
fn url<'gc>( fn url<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
text_format: &TextFormat, text_format: &TextFormat,
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Ok(text_format.url.as_ref().map_or(Value::Null, |url| { Ok(text_format.url.as_ref().map_or(Value::Null, |url| {
AvmString::new(activation.context.gc_context, url.as_wstr()).into() AvmString::new(activation.context.gc_context, url.as_wstr()).into()
})) }))
@ -561,7 +561,7 @@ fn set_url<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
text_format: &mut TextFormat, text_format: &mut TextFormat,
value: &Value<'gc>, value: &Value<'gc>,
) -> Result<(), Error> { ) -> Result<(), Error<'gc>> {
text_format.url = match value { text_format.url = match value {
Value::Undefined | Value::Null => None, Value::Undefined | Value::Null => None,
value => Some(value.coerce_to_string(activation)?.as_wstr().into()), value => Some(value.coerce_to_string(activation)?.as_wstr().into()),

View File

@ -7,7 +7,7 @@ pub fn hide_built_in_items<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
// TODO: replace this by a proper implementation. // TODO: replace this by a proper implementation.
log::warn!("flash.ui.ContextMenu is a stub"); log::warn!("flash.ui.ContextMenu is a stub");
activation activation

View File

@ -17,7 +17,7 @@ pub fn class_init<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Ok(Value::Undefined) Ok(Value::Undefined)
} }
@ -26,7 +26,7 @@ pub fn instance_init<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Ok(Value::Undefined) Ok(Value::Undefined)
} }
@ -351,7 +351,7 @@ fn caps_lock<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
log::warn!("Keyboard.capsLock: not yet implemented"); log::warn!("Keyboard.capsLock: not yet implemented");
Ok(false.into()) Ok(false.into())
} }
@ -360,7 +360,7 @@ fn has_virtual_keyboard<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
log::warn!("Keyboard.hasVirtualKeyboard: not yet implemented"); log::warn!("Keyboard.hasVirtualKeyboard: not yet implemented");
Ok(false.into()) Ok(false.into())
} }
@ -369,7 +369,7 @@ fn num_lock<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
log::warn!("Keyboard.numLock: not yet implemented"); log::warn!("Keyboard.numLock: not yet implemented");
Ok(false.into()) Ok(false.into())
} }
@ -378,7 +378,7 @@ fn physical_keyboard_type<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
log::warn!("Keyboard.physicalKeyboardType: not yet implemented"); log::warn!("Keyboard.physicalKeyboardType: not yet implemented");
Ok(AvmString::new_utf8(activation.context.gc_context, "alphanumeric").into()) Ok(AvmString::new_utf8(activation.context.gc_context, "alphanumeric").into())
} }
@ -387,7 +387,7 @@ fn is_accessible<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
log::warn!("Keyboard.isAccessible: not yet implemented"); log::warn!("Keyboard.isAccessible: not yet implemented");
Ok(true.into()) Ok(true.into())
} }

View File

@ -15,7 +15,7 @@ fn instance_init<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Err("The Mouse class cannot be constructed.".into()) Err("The Mouse class cannot be constructed.".into())
} }
@ -23,7 +23,7 @@ fn class_init<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Ok(Value::Undefined) Ok(Value::Undefined)
} }
@ -31,7 +31,7 @@ fn hide<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
activation.context.ui.set_mouse_visible(false); activation.context.ui.set_mouse_visible(false);
Ok(Value::Undefined) Ok(Value::Undefined)
} }
@ -40,7 +40,7 @@ fn show<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
activation.context.ui.set_mouse_visible(true); activation.context.ui.set_mouse_visible(true);
Ok(Value::Undefined) Ok(Value::Undefined)
} }

View File

@ -21,7 +21,7 @@ pub fn get_timer<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Ok((Instant::now() Ok((Instant::now()
.duration_since(activation.context.start_time) .duration_since(activation.context.start_time)
.as_millis() as u32) .as_millis() as u32)
@ -33,7 +33,7 @@ pub fn set_interval<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if args.len() < 2 { if args.len() < 2 {
return Err(Error::from("setInterval: not enough arguments")); return Err(Error::from("setInterval: not enough arguments"));
} }
@ -62,7 +62,7 @@ pub fn clear_interval<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
let id = args let id = args
.get(0) .get(0)
.ok_or("clearInterval: not enough arguments")? .ok_or("clearInterval: not enough arguments")?
@ -76,7 +76,7 @@ pub fn set_timeout<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if args.len() < 2 { if args.len() < 2 {
return Err(Error::from("setTimeout: not enough arguments")); return Err(Error::from("setTimeout: not enough arguments"));
} }
@ -105,7 +105,7 @@ pub fn clear_timeout<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
let id = args let id = args
.get(0) .get(0)
.ok_or("clearTimeout: not enough arguments")? .ok_or("clearTimeout: not enough arguments")?
@ -119,7 +119,7 @@ pub fn escape_multi_byte<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
let s = args let s = args
.get(0) .get(0)
.unwrap_or(&Value::Undefined) .unwrap_or(&Value::Undefined)
@ -145,7 +145,7 @@ pub fn get_qualified_class_name<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
let obj = args let obj = args
.get(0) .get(0)
.unwrap_or(&Value::Undefined) .unwrap_or(&Value::Undefined)
@ -172,7 +172,7 @@ pub fn get_qualified_superclass_name<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
let obj = args let obj = args
.get(0) .get(0)
.unwrap_or(&Value::Undefined) .unwrap_or(&Value::Undefined)
@ -203,7 +203,7 @@ pub fn get_definition_by_name<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
let appdomain = activation.caller_domain(); let appdomain = activation.caller_domain();
let name = args let name = args
.get(0) .get(0)

View File

@ -21,7 +21,7 @@ pub fn instance_init<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
activation.super_init(this, &[])?; activation.super_init(this, &[])?;
@ -55,7 +55,7 @@ pub fn class_init<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Ok(Value::Undefined) Ok(Value::Undefined)
} }
@ -64,7 +64,7 @@ pub fn write_byte<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(mut bytearray) = this.as_bytearray_mut(activation.context.gc_context) { if let Some(mut bytearray) = this.as_bytearray_mut(activation.context.gc_context) {
let byte = args let byte = args
@ -84,7 +84,7 @@ pub fn write_bytes<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
let bytearray = args let bytearray = args
.get(0) .get(0)
@ -138,7 +138,7 @@ pub fn read_bytes<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
let bytearray = args let bytearray = args
.get(0) .get(0)
@ -186,7 +186,7 @@ pub fn write_utf<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(mut bytearray) = this.as_bytearray_mut(activation.context.gc_context) { if let Some(mut bytearray) = this.as_bytearray_mut(activation.context.gc_context) {
if let Some(utf_string) = args.get(0) { if let Some(utf_string) = args.get(0) {
@ -207,7 +207,7 @@ pub fn read_utf<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(bytearray) = this.as_bytearray() { if let Some(bytearray) = this.as_bytearray() {
return Ok(AvmString::new_utf8_bytes( return Ok(AvmString::new_utf8_bytes(
@ -224,7 +224,7 @@ pub fn to_string<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(bytearray) = this.as_bytearray() { if let Some(bytearray) = this.as_bytearray() {
return Ok( return Ok(
@ -240,7 +240,7 @@ pub fn clear<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(mut bytearray) = this.as_bytearray_mut(activation.context.gc_context) { if let Some(mut bytearray) = this.as_bytearray_mut(activation.context.gc_context) {
bytearray.clear(); bytearray.clear();
@ -255,7 +255,7 @@ pub fn position<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(bytearray) = this.as_bytearray() { if let Some(bytearray) = this.as_bytearray() {
return Ok(bytearray.position().into()); return Ok(bytearray.position().into());
@ -269,7 +269,7 @@ pub fn set_position<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(bytearray) = this.as_bytearray() { if let Some(bytearray) = this.as_bytearray() {
let num = args let num = args
@ -287,7 +287,7 @@ pub fn bytes_available<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(bytearray) = this.as_bytearray() { if let Some(bytearray) = this.as_bytearray() {
return Ok(bytearray.bytes_available().into()); return Ok(bytearray.bytes_available().into());
@ -301,7 +301,7 @@ pub fn length<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(bytearray) = this.as_bytearray() { if let Some(bytearray) = this.as_bytearray() {
return Ok(bytearray.len().into()); return Ok(bytearray.len().into());
@ -315,7 +315,7 @@ pub fn set_length<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(mut bytearray) = this.as_bytearray_mut(activation.context.gc_context) { if let Some(mut bytearray) = this.as_bytearray_mut(activation.context.gc_context) {
let len = args let len = args
@ -333,7 +333,7 @@ pub fn endian<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(bytearray) = this.as_bytearray() { if let Some(bytearray) = this.as_bytearray() {
return Ok(match bytearray.endian() { return Ok(match bytearray.endian() {
@ -350,7 +350,7 @@ pub fn set_endian<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(mut bytearray) = this.as_bytearray_mut(activation.context.gc_context) { if let Some(mut bytearray) = this.as_bytearray_mut(activation.context.gc_context) {
let endian = args let endian = args
@ -374,7 +374,7 @@ pub fn read_short<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(bytearray) = this.as_bytearray() { if let Some(bytearray) = this.as_bytearray() {
return Ok(bytearray.read_short()?.into()); return Ok(bytearray.read_short()?.into());
@ -388,7 +388,7 @@ pub fn read_unsigned_short<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(bytearray) = this.as_bytearray() { if let Some(bytearray) = this.as_bytearray() {
return Ok(bytearray.read_unsigned_short()?.into()); return Ok(bytearray.read_unsigned_short()?.into());
@ -402,7 +402,7 @@ pub fn read_double<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(bytearray) = this.as_bytearray() { if let Some(bytearray) = this.as_bytearray() {
return Ok(bytearray.read_double()?.into()); return Ok(bytearray.read_double()?.into());
@ -416,7 +416,7 @@ pub fn read_float<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(bytearray) = this.as_bytearray() { if let Some(bytearray) = this.as_bytearray() {
return Ok(bytearray.read_float()?.into()); return Ok(bytearray.read_float()?.into());
@ -430,7 +430,7 @@ pub fn read_int<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(bytearray) = this.as_bytearray() { if let Some(bytearray) = this.as_bytearray() {
return Ok(bytearray.read_int()?.into()); return Ok(bytearray.read_int()?.into());
@ -444,7 +444,7 @@ pub fn read_unsigned_int<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(bytearray) = this.as_bytearray() { if let Some(bytearray) = this.as_bytearray() {
return Ok(bytearray.read_unsigned_int()?.into()); return Ok(bytearray.read_unsigned_int()?.into());
@ -458,7 +458,7 @@ pub fn read_boolean<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(bytearray) = this.as_bytearray() { if let Some(bytearray) = this.as_bytearray() {
return Ok(bytearray.read_boolean()?.into()); return Ok(bytearray.read_boolean()?.into());
@ -472,7 +472,7 @@ pub fn read_byte<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(bytearray) = this.as_bytearray() { if let Some(bytearray) = this.as_bytearray() {
return Ok(bytearray.read_byte()?.into()); return Ok(bytearray.read_byte()?.into());
@ -486,7 +486,7 @@ pub fn read_utf_bytes<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(bytearray) = this.as_bytearray() { if let Some(bytearray) = this.as_bytearray() {
let len = args let len = args
@ -508,7 +508,7 @@ pub fn read_unsigned_byte<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(bytearray) = this.as_bytearray() { if let Some(bytearray) = this.as_bytearray() {
return Ok(bytearray.read_unsigned_byte()?.into()); return Ok(bytearray.read_unsigned_byte()?.into());
@ -522,7 +522,7 @@ pub fn write_float<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(mut bytearray) = this.as_bytearray_mut(activation.context.gc_context) { if let Some(mut bytearray) = this.as_bytearray_mut(activation.context.gc_context) {
let num = args let num = args
@ -540,7 +540,7 @@ pub fn write_double<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(mut bytearray) = this.as_bytearray_mut(activation.context.gc_context) { if let Some(mut bytearray) = this.as_bytearray_mut(activation.context.gc_context) {
let num = args let num = args
@ -558,7 +558,7 @@ pub fn write_boolean<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(mut bytearray) = this.as_bytearray_mut(activation.context.gc_context) { if let Some(mut bytearray) = this.as_bytearray_mut(activation.context.gc_context) {
let num = args.get(0).unwrap_or(&Value::Undefined).coerce_to_boolean(); let num = args.get(0).unwrap_or(&Value::Undefined).coerce_to_boolean();
@ -573,7 +573,7 @@ pub fn write_int<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(mut bytearray) = this.as_bytearray_mut(activation.context.gc_context) { if let Some(mut bytearray) = this.as_bytearray_mut(activation.context.gc_context) {
let num = args let num = args
@ -591,7 +591,7 @@ pub fn write_unsigned_int<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(mut bytearray) = this.as_bytearray_mut(activation.context.gc_context) { if let Some(mut bytearray) = this.as_bytearray_mut(activation.context.gc_context) {
let num = args let num = args
@ -609,7 +609,7 @@ pub fn write_short<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(mut bytearray) = this.as_bytearray_mut(activation.context.gc_context) { if let Some(mut bytearray) = this.as_bytearray_mut(activation.context.gc_context) {
let num = args let num = args
@ -627,7 +627,7 @@ pub fn write_multibyte<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(mut bytearray) = this.as_bytearray_mut(activation.context.gc_context) { if let Some(mut bytearray) = this.as_bytearray_mut(activation.context.gc_context) {
let string = args let string = args
@ -653,7 +653,7 @@ pub fn read_multibyte<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(bytearray) = this.as_bytearray() { if let Some(bytearray) = this.as_bytearray() {
let len = args let len = args
@ -679,7 +679,7 @@ pub fn write_utf_bytes<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(mut bytearray) = this.as_bytearray_mut(activation.context.gc_context) { if let Some(mut bytearray) = this.as_bytearray_mut(activation.context.gc_context) {
let string = args let string = args
@ -697,7 +697,7 @@ pub fn compress<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(mut bytearray) = this.as_bytearray_mut(activation.context.gc_context) { if let Some(mut bytearray) = this.as_bytearray_mut(activation.context.gc_context) {
let algorithm = args let algorithm = args
@ -717,7 +717,7 @@ pub fn uncompress<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(mut bytearray) = this.as_bytearray_mut(activation.context.gc_context) { if let Some(mut bytearray) = this.as_bytearray_mut(activation.context.gc_context) {
let algorithm = args let algorithm = args
@ -737,7 +737,7 @@ pub fn deflate<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(mut bytearray) = this.as_bytearray_mut(activation.context.gc_context) { if let Some(mut bytearray) = this.as_bytearray_mut(activation.context.gc_context) {
let buffer = bytearray.compress(CompressionAlgorithm::Deflate)?; let buffer = bytearray.compress(CompressionAlgorithm::Deflate)?;
@ -753,7 +753,7 @@ pub fn inflate<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(mut bytearray) = this.as_bytearray_mut(activation.context.gc_context) { if let Some(mut bytearray) = this.as_bytearray_mut(activation.context.gc_context) {
let buffer = bytearray.decompress(CompressionAlgorithm::Deflate)?; let buffer = bytearray.decompress(CompressionAlgorithm::Deflate)?;
@ -769,7 +769,7 @@ pub fn read_object<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(bytearray) = this.as_bytearray() { if let Some(bytearray) = this.as_bytearray() {
let bytes = bytearray.read_at(bytearray.bytes_available(), bytearray.position())?; let bytes = bytearray.read_at(bytearray.bytes_available(), bytearray.position())?;
@ -808,7 +808,7 @@ pub fn object_encoding<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(bytearray) = this.as_bytearray() { if let Some(bytearray) = this.as_bytearray() {
return Ok((bytearray.object_encoding() as u8).into()); return Ok((bytearray.object_encoding() as u8).into());
@ -822,7 +822,7 @@ pub fn set_object_encoding<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(mut bytearray) = this.as_bytearray_mut(activation.context.gc_context) { if let Some(mut bytearray) = this.as_bytearray_mut(activation.context.gc_context) {
let new_encoding = args let new_encoding = args

View File

@ -16,7 +16,7 @@ pub fn instance_init<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
activation.super_init(this, &[])?; activation.super_init(this, &[])?;
} }
@ -29,7 +29,7 @@ pub fn class_init<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Ok(Value::Undefined) Ok(Value::Undefined)
} }

View File

@ -15,7 +15,7 @@ pub fn instance_init<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Ok(Value::Undefined) Ok(Value::Undefined)
} }
@ -24,7 +24,7 @@ pub fn class_init<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Ok(Value::Undefined) Ok(Value::Undefined)
} }
@ -33,7 +33,7 @@ pub fn get_property<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Err("getproperty is not implemented for this Proxy".into()) Err("getproperty is not implemented for this Proxy".into())
} }
@ -42,7 +42,7 @@ pub fn set_property<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Err("setproperty is not implemented for this Proxy".into()) Err("setproperty is not implemented for this Proxy".into())
} }
@ -51,7 +51,7 @@ pub fn delete_property<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Err("deleteproperty is not implemented for this Proxy".into()) Err("deleteproperty is not implemented for this Proxy".into())
} }
@ -60,7 +60,7 @@ pub fn call_property<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Err("callproperty is not implemented for this Proxy".into()) Err("callproperty is not implemented for this Proxy".into())
} }
@ -69,7 +69,7 @@ pub fn has_property<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Err("hasproperty is not implemented for this Proxy".into()) Err("hasproperty is not implemented for this Proxy".into())
} }
@ -78,7 +78,7 @@ pub fn is_attribute<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Err("isattribute is not implemented for this Proxy".into()) Err("isattribute is not implemented for this Proxy".into())
} }
@ -87,7 +87,7 @@ pub fn get_descendants<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Err("getdescendants is not implemented for this Proxy".into()) Err("getdescendants is not implemented for this Proxy".into())
} }
@ -96,7 +96,7 @@ pub fn next_name_index<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Err("hasnext/nextNameIndex is not implemented for this Proxy".into()) Err("hasnext/nextNameIndex is not implemented for this Proxy".into())
} }
@ -105,7 +105,7 @@ pub fn next_name<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Err("nextname is not implemented for this Proxy".into()) Err("nextname is not implemented for this Proxy".into())
} }
@ -114,7 +114,7 @@ pub fn next_value<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Err("nextvalue is not implemented for this Proxy".into()) Err("nextvalue is not implemented for this Proxy".into())
} }

View File

@ -13,7 +13,7 @@ pub fn stop<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
let mut this = this.expect("`this` should be set in native method!"); let mut this = this.expect("`this` should be set in native method!");
let id = this let id = this
.get_property( .get_property(
@ -40,7 +40,7 @@ pub fn start<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
let mut this = this.expect("`this` should be set in native method!"); let mut this = this.expect("`this` should be set in native method!");
let id = this let id = this
.get_property( .get_property(

View File

@ -17,7 +17,7 @@ pub fn instance_init<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
activation.super_init(this, &[])?; activation.super_init(this, &[])?;
} }
@ -30,7 +30,7 @@ pub fn class_init<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
let scope = activation.create_scopechain(); let scope = activation.create_scopechain();
let this_class = this.as_class_object().unwrap(); let this_class = this.as_class_object().unwrap();
@ -79,7 +79,7 @@ fn call<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
func: Option<Object<'gc>>, func: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
let this = args let this = args
.get(0) .get(0)
.and_then(|v| v.coerce_to_object(activation).ok()) .and_then(|v| v.coerce_to_object(activation).ok())
@ -101,7 +101,7 @@ fn apply<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
func: Option<Object<'gc>>, func: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
let this = args let this = args
.get(0) .get(0)
.and_then(|v| v.coerce_to_object(activation).ok()) .and_then(|v| v.coerce_to_object(activation).ok())
@ -137,7 +137,7 @@ fn prototype<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(function) = this.as_function_object() { if let Some(function) = this.as_function_object() {
if let Some(proto) = function.prototype() { if let Some(proto) = function.prototype() {
@ -154,7 +154,7 @@ fn set_prototype<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(function) = this.as_function_object() { if let Some(function) = this.as_function_object() {
let new_proto = args let new_proto = args

View File

@ -20,7 +20,7 @@ pub fn instance_init<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Ok(Value::Undefined) Ok(Value::Undefined)
} }
@ -29,7 +29,7 @@ pub fn class_init<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Ok(Value::Undefined) Ok(Value::Undefined)
} }

View File

@ -17,7 +17,7 @@ fn instance_init<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(mut prim) = this.as_primitive_mut(activation.context.gc_context) { if let Some(mut prim) = this.as_primitive_mut(activation.context.gc_context) {
if matches!(*prim, Value::Undefined | Value::Null) { if matches!(*prim, Value::Undefined | Value::Null) {
@ -39,7 +39,7 @@ fn native_instance_init<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
activation.super_init(this, args)?; activation.super_init(this, args)?;
} }
@ -52,7 +52,7 @@ fn class_init<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
let scope = activation.create_scopechain(); let scope = activation.create_scopechain();
let gc_context = activation.context.gc_context; let gc_context = activation.context.gc_context;
@ -135,7 +135,7 @@ fn to_exponential<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(this) = this.as_primitive() { if let Some(this) = this.as_primitive() {
if let Value::Integer(number) = *this { if let Value::Integer(number) = *this {
@ -169,7 +169,7 @@ fn to_fixed<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(this) = this.as_primitive() { if let Some(this) = this.as_primitive() {
if let Value::Integer(number) = *this { if let Value::Integer(number) = *this {
@ -200,7 +200,7 @@ fn to_precision<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(this) = this.as_primitive() { if let Some(this) = this.as_primitive() {
if let Value::Integer(number) = *this { if let Value::Integer(number) = *this {
@ -227,7 +227,7 @@ fn to_string<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(this) = this.as_primitive() { if let Some(this) = this.as_primitive() {
if let Value::Integer(number) = *this { if let Value::Integer(number) = *this {
@ -254,7 +254,7 @@ fn value_of<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(this) = this.as_primitive() { if let Some(this) = this.as_primitive() {
return Ok(*this); return Ok(*this);

View File

@ -23,7 +23,7 @@ fn deserialize_json_inner<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
json: JsonValue, json: JsonValue,
reviver: Option<Object<'gc>>, reviver: Option<Object<'gc>>,
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Ok(match json { Ok(match json {
JsonValue::Null => Value::Null, JsonValue::Null => Value::Null,
JsonValue::String(s) => AvmString::new_utf8(activation.context.gc_context, s).into(), JsonValue::String(s) => AvmString::new_utf8(activation.context.gc_context, s).into(),
@ -75,7 +75,7 @@ fn deserialize_json<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
json: JsonValue, json: JsonValue,
reviver: Option<Object<'gc>>, reviver: Option<Object<'gc>>,
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
let val = deserialize_json_inner(activation, json, reviver)?; let val = deserialize_json_inner(activation, json, reviver)?;
match reviver { match reviver {
None => Ok(val), None => Ok(val),
@ -118,7 +118,7 @@ impl<'gc> AvmSerializer<'gc> {
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
key: impl Fn() -> AvmString<'gc>, key: impl Fn() -> AvmString<'gc>,
value: Value<'gc>, value: Value<'gc>,
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
let (eval_key, value) = if value.is_primitive() { let (eval_key, value) = if value.is_primitive() {
(None, value) (None, value)
} else { } else {
@ -149,7 +149,7 @@ impl<'gc> AvmSerializer<'gc> {
&mut self, &mut self,
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
obj: Object<'gc>, obj: Object<'gc>,
) -> Result<JsonValue, Error> { ) -> Result<JsonValue, Error<'gc>> {
let mut js_obj = JsonObject::new(); let mut js_obj = JsonObject::new();
// If the user supplied a PropList, we use that to find properties on the object. // If the user supplied a PropList, we use that to find properties on the object.
if let Some(Replacer::PropList(props)) = self.replacer { if let Some(Replacer::PropList(props)) = self.replacer {
@ -194,7 +194,7 @@ impl<'gc> AvmSerializer<'gc> {
&mut self, &mut self,
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
iterable: Object<'gc>, iterable: Object<'gc>,
) -> Result<JsonValue, Error> { ) -> Result<JsonValue, Error<'gc>> {
let mut js_arr = Vec::new(); let mut js_arr = Vec::new();
let mut iter = ArrayIter::new(activation, iterable)?; let mut iter = ArrayIter::new(activation, iterable)?;
while let Some(r) = iter.next(activation) { while let Some(r) = iter.next(activation) {
@ -211,7 +211,7 @@ impl<'gc> AvmSerializer<'gc> {
&mut self, &mut self,
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
value: Value<'gc>, value: Value<'gc>,
) -> Result<JsonValue, Error> { ) -> Result<JsonValue, Error<'gc>> {
Ok(match value { Ok(match value {
Value::Null => JsonValue::Null, Value::Null => JsonValue::Null,
Value::Undefined => JsonValue::Null, Value::Undefined => JsonValue::Null,
@ -247,7 +247,7 @@ impl<'gc> AvmSerializer<'gc> {
&mut self, &mut self,
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
value: Value<'gc>, value: Value<'gc>,
) -> Result<JsonValue, Error> { ) -> Result<JsonValue, Error<'gc>> {
let mapped = self.map_value(activation, || "".into(), value)?; let mapped = self.map_value(activation, || "".into(), value)?;
self.serialize_value(activation, mapped) self.serialize_value(activation, mapped)
} }
@ -258,7 +258,7 @@ pub fn instance_init<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Err("ArgumentError: Error #2012: JSON class cannot be instantiated.".into()) Err("ArgumentError: Error #2012: JSON class cannot be instantiated.".into())
} }
@ -267,7 +267,7 @@ pub fn class_init<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Ok(Value::Undefined) Ok(Value::Undefined)
} }
@ -276,7 +276,7 @@ pub fn parse<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
let input = args let input = args
.get(0) .get(0)
.unwrap_or(&Value::Undefined) .unwrap_or(&Value::Undefined)
@ -292,7 +292,7 @@ pub fn stringify<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
let val = args.get(0).unwrap_or(&Value::Undefined); let val = args.get(0).unwrap_or(&Value::Undefined);
let replacer = args.get(1).unwrap_or(&Value::Undefined).as_object(); let replacer = args.get(1).unwrap_or(&Value::Undefined).as_object();
let spaces = args.get(2).unwrap_or(&Value::Undefined); let spaces = args.get(2).unwrap_or(&Value::Undefined);

View File

@ -12,7 +12,7 @@ macro_rules! wrap_std {
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(input) = args.get(0) { if let Some(input) = args.get(0) {
Ok($std(input.coerce_to_number(activation)?).into()) Ok($std(input.coerce_to_number(activation)?).into())
} else { } else {
@ -39,7 +39,7 @@ pub fn round<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(x) = args.get(0) { if let Some(x) = args.get(0) {
let x = x.coerce_to_number(activation)?; let x = x.coerce_to_number(activation)?;
// Note that Flash Math.round always rounds toward infinity, // Note that Flash Math.round always rounds toward infinity,
@ -54,7 +54,7 @@ pub fn atan2<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
let y = args let y = args
.get(0) .get(0)
.unwrap_or(&Value::Undefined) .unwrap_or(&Value::Undefined)
@ -70,7 +70,7 @@ pub fn max<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
let mut cur_max = f64::NEG_INFINITY; let mut cur_max = f64::NEG_INFINITY;
for arg in args { for arg in args {
let val = arg.coerce_to_number(activation)?; let val = arg.coerce_to_number(activation)?;
@ -87,7 +87,7 @@ pub fn min<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
let mut cur_min = f64::INFINITY; let mut cur_min = f64::INFINITY;
for arg in args { for arg in args {
let val = arg.coerce_to_number(activation)?; let val = arg.coerce_to_number(activation)?;
@ -104,7 +104,7 @@ pub fn pow<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
let n = args let n = args
.get(0) .get(0)
.unwrap_or(&Value::Undefined) .unwrap_or(&Value::Undefined)
@ -120,6 +120,6 @@ pub fn random<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Ok(activation.context.rng.gen_range(0.0f64..1.0f64).into()) Ok(activation.context.rng.gen_range(0.0f64..1.0f64).into())
} }

View File

@ -16,7 +16,7 @@ pub fn instance_init<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Err("Namespace constructor is a stub.".into()) Err("Namespace constructor is a stub.".into())
} }
@ -24,7 +24,7 @@ fn class_call<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Err("Namespace constructor is a stub.".into()) Err("Namespace constructor is a stub.".into())
} }
@ -33,7 +33,7 @@ pub fn native_instance_init<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
activation.super_init(this, args)?; activation.super_init(this, args)?;
} }
@ -46,7 +46,7 @@ pub fn class_init<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Ok(Value::Undefined) Ok(Value::Undefined)
} }

View File

@ -16,7 +16,7 @@ fn instance_init<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(mut prim) = this.as_primitive_mut(activation.context.gc_context) { if let Some(mut prim) = this.as_primitive_mut(activation.context.gc_context) {
if matches!(*prim, Value::Undefined | Value::Null) { if matches!(*prim, Value::Undefined | Value::Null) {
@ -38,7 +38,7 @@ fn native_instance_init<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
activation.super_init(this, args)?; activation.super_init(this, args)?;
} }
@ -51,7 +51,7 @@ fn class_init<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
let scope = activation.create_scopechain(); let scope = activation.create_scopechain();
let gc_context = activation.context.gc_context; let gc_context = activation.context.gc_context;
@ -133,7 +133,7 @@ fn to_locale_string<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(this) = this.as_primitive() { if let Some(this) = this.as_primitive() {
return Ok(this.coerce_to_string(activation)?.into()); return Ok(this.coerce_to_string(activation)?.into());
@ -148,7 +148,7 @@ fn to_exponential<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(this) = this.as_primitive() { if let Some(this) = this.as_primitive() {
if let Value::Number(number) = *this { if let Value::Number(number) = *this {
@ -182,7 +182,7 @@ fn to_fixed<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(this) = this.as_primitive() { if let Some(this) = this.as_primitive() {
if let Value::Number(number) = *this { if let Value::Number(number) = *this {
@ -212,7 +212,7 @@ pub fn print_with_precision<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
number: f64, number: f64,
wanted_digits: usize, wanted_digits: usize,
) -> Result<AvmString<'gc>, Error> { ) -> Result<AvmString<'gc>, Error<'gc>> {
let mut available_digits = number.abs().log10().floor(); let mut available_digits = number.abs().log10().floor();
if available_digits.is_nan() || available_digits.is_infinite() { if available_digits.is_nan() || available_digits.is_infinite() {
available_digits = 1.0; available_digits = 1.0;
@ -244,7 +244,7 @@ fn to_precision<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(this) = this.as_primitive() { if let Some(this) = this.as_primitive() {
if let Value::Number(number) = *this { if let Value::Number(number) = *this {
@ -270,7 +270,7 @@ pub fn print_with_radix<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
mut number: f64, mut number: f64,
radix: usize, radix: usize,
) -> Result<AvmString<'gc>, Error> { ) -> Result<AvmString<'gc>, Error<'gc>> {
if radix == 10 { if radix == 10 {
return Value::from(number).coerce_to_string(activation); return Value::from(number).coerce_to_string(activation);
} }
@ -313,7 +313,7 @@ fn to_string<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(this) = this.as_primitive() { if let Some(this) = this.as_primitive() {
if let Value::Number(number) = *this { if let Value::Number(number) = *this {
@ -340,7 +340,7 @@ fn value_of<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(this) = this.as_primitive() { if let Some(this) = this.as_primitive() {
return Ok(*this); return Ok(*this);

View File

@ -17,7 +17,7 @@ pub fn instance_init<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Ok(Value::Undefined) Ok(Value::Undefined)
} }
@ -25,7 +25,7 @@ fn class_call<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
let this_class = activation.subclass_object().unwrap(); let this_class = activation.subclass_object().unwrap();
if args.is_empty() { if args.is_empty() {
@ -43,7 +43,7 @@ pub fn class_init<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
let scope = activation.create_scopechain(); let scope = activation.create_scopechain();
let gc_context = activation.context.gc_context; let gc_context = activation.context.gc_context;
@ -164,7 +164,7 @@ fn to_string<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_: &[Value<'gc>], _: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
this.map(|t| t.to_string(activation)) this.map(|t| t.to_string(activation))
.unwrap_or(Ok(Value::Undefined)) .unwrap_or(Ok(Value::Undefined))
} }
@ -174,7 +174,7 @@ fn to_locale_string<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_: &[Value<'gc>], _: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
this.map(|t| t.to_locale_string(activation)) this.map(|t| t.to_locale_string(activation))
.unwrap_or(Ok(Value::Undefined)) .unwrap_or(Ok(Value::Undefined))
} }
@ -184,7 +184,7 @@ fn value_of<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_: &[Value<'gc>], _: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
this.map(|t| t.value_of(activation.context.gc_context)) this.map(|t| t.value_of(activation.context.gc_context))
.unwrap_or(Ok(Value::Undefined)) .unwrap_or(Ok(Value::Undefined))
} }
@ -194,10 +194,12 @@ pub fn has_own_property<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
let this: Result<Object<'gc>, Error> = this.ok_or_else(|| "No valid this parameter".into()); let this: Result<Object<'gc>, Error<'gc>> =
this.ok_or_else(|| "No valid this parameter".into());
let this = this?; let this = this?;
let name: Result<&Value<'gc>, Error> = args.get(0).ok_or_else(|| "No name specified".into()); let name: Result<&Value<'gc>, Error<'gc>> =
args.get(0).ok_or_else(|| "No name specified".into());
let name = name?.coerce_to_string(activation)?; let name = name?.coerce_to_string(activation)?;
let multiname = Multiname::public(name); let multiname = Multiname::public(name);
@ -209,8 +211,8 @@ pub fn is_prototype_of<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
let search_proto: Result<Object<'gc>, Error> = let search_proto: Result<Object<'gc>, Error<'gc>> =
this.ok_or_else(|| "No valid this parameter".into()); this.ok_or_else(|| "No valid this parameter".into());
let search_proto = search_proto?; let search_proto = search_proto?;
let mut target_proto = args.get(0).cloned().unwrap_or(Value::Undefined); let mut target_proto = args.get(0).cloned().unwrap_or(Value::Undefined);
@ -231,10 +233,12 @@ pub fn property_is_enumerable<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
let this: Result<Object<'gc>, Error> = this.ok_or_else(|| "No valid this parameter".into()); let this: Result<Object<'gc>, Error<'gc>> =
this.ok_or_else(|| "No valid this parameter".into());
let this = this?; let this = this?;
let name: Result<&Value<'gc>, Error> = args.get(0).ok_or_else(|| "No name specified".into()); let name: Result<&Value<'gc>, Error<'gc>> =
args.get(0).ok_or_else(|| "No name specified".into());
let name = name?.coerce_to_string(activation)?; let name = name?.coerce_to_string(activation)?;
Ok(this.property_is_enumerable(name).into()) Ok(this.property_is_enumerable(name).into())
@ -245,10 +249,12 @@ pub fn set_property_is_enumerable<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
let this: Result<Object<'gc>, Error> = this.ok_or_else(|| "No valid this parameter".into()); let this: Result<Object<'gc>, Error<'gc>> =
this.ok_or_else(|| "No valid this parameter".into());
let this = this?; let this = this?;
let name: Result<&Value<'gc>, Error> = args.get(0).ok_or_else(|| "No name specified".into()); let name: Result<&Value<'gc>, Error<'gc>> =
args.get(0).ok_or_else(|| "No name specified".into());
let name = name?.coerce_to_string(activation)?; let name = name?.coerce_to_string(activation)?;
if let Some(Value::Bool(is_enum)) = args.get(1) { if let Some(Value::Bool(is_enum)) = args.get(1) {

View File

@ -16,7 +16,7 @@ pub fn instance_init<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this.and_then(|t| t.as_qname_object()) { if let Some(this) = this.and_then(|t| t.as_qname_object()) {
if this.qname().is_none() { if this.qname().is_none() {
let (namespace, local_arg) = if args.len() > 1 { let (namespace, local_arg) = if args.len() > 1 {
@ -64,7 +64,7 @@ pub fn class_init<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
let this = this.unwrap(); let this = this.unwrap();
let scope = activation.create_scopechain(); let scope = activation.create_scopechain();
let this_class = this.as_class_object().unwrap(); let this_class = this.as_class_object().unwrap();
@ -115,7 +115,7 @@ pub fn local_name<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this.and_then(|t| t.as_qname_object()) { if let Some(this) = this.and_then(|t| t.as_qname_object()) {
if let Some(qname) = this.qname() { if let Some(qname) = this.qname() {
return Ok(qname.local_name().into()); return Ok(qname.local_name().into());
@ -130,7 +130,7 @@ pub fn uri<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this.and_then(|t| t.as_qname_object()) { if let Some(this) = this.and_then(|t| t.as_qname_object()) {
if let Some(qname) = this.qname() { if let Some(qname) = this.qname() {
return Ok(match qname.namespace() { return Ok(match qname.namespace() {
@ -148,7 +148,7 @@ pub fn to_string<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this.and_then(|t| t.as_qname_object()) { if let Some(this) = this.and_then(|t| t.as_qname_object()) {
if let Some(qname) = this.qname() { if let Some(qname) = this.qname() {
return Ok(qname.as_uri(activation.context.gc_context).into()); return Ok(qname.as_uri(activation.context.gc_context).into());
@ -163,7 +163,7 @@ pub fn value_of<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
return Ok(this.into()); return Ok(this.into());
} }

View File

@ -18,7 +18,7 @@ pub fn instance_init<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
activation.super_init(this, &[])?; activation.super_init(this, &[])?;
@ -57,7 +57,7 @@ fn class_call<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
let this_class = activation.subclass_object().unwrap(); let this_class = activation.subclass_object().unwrap();
if args.len() == 1 { if args.len() == 1 {
@ -74,7 +74,7 @@ pub fn class_init<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Ok(Value::Undefined) Ok(Value::Undefined)
} }
@ -83,7 +83,7 @@ pub fn dotall<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(regexp) = this.as_regexp() { if let Some(regexp) = this.as_regexp() {
return Ok(regexp.flags().contains(RegExpFlags::DOTALL).into()); return Ok(regexp.flags().contains(RegExpFlags::DOTALL).into());
@ -98,7 +98,7 @@ pub fn extended<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(regexp) = this.as_regexp() { if let Some(regexp) = this.as_regexp() {
return Ok(regexp.flags().contains(RegExpFlags::EXTENDED).into()); return Ok(regexp.flags().contains(RegExpFlags::EXTENDED).into());
@ -113,7 +113,7 @@ pub fn global<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(regexp) = this.as_regexp() { if let Some(regexp) = this.as_regexp() {
return Ok(regexp.flags().contains(RegExpFlags::GLOBAL).into()); return Ok(regexp.flags().contains(RegExpFlags::GLOBAL).into());
@ -128,7 +128,7 @@ pub fn ignore_case<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(regexp) = this.as_regexp() { if let Some(regexp) = this.as_regexp() {
return Ok(regexp.flags().contains(RegExpFlags::IGNORE_CASE).into()); return Ok(regexp.flags().contains(RegExpFlags::IGNORE_CASE).into());
@ -143,7 +143,7 @@ pub fn multiline<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(regexp) = this.as_regexp() { if let Some(regexp) = this.as_regexp() {
return Ok(regexp.flags().contains(RegExpFlags::MULTILINE).into()); return Ok(regexp.flags().contains(RegExpFlags::MULTILINE).into());
@ -158,7 +158,7 @@ pub fn last_index<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(re) = this.as_regexp() { if let Some(re) = this.as_regexp() {
return Ok(re.last_index().into()); return Ok(re.last_index().into());
@ -173,7 +173,7 @@ pub fn set_last_index<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(mut re) = this.as_regexp_mut(activation.context.gc_context) { if let Some(mut re) = this.as_regexp_mut(activation.context.gc_context) {
let i = args let i = args
@ -192,7 +192,7 @@ pub fn source<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(re) = this.as_regexp() { if let Some(re) = this.as_regexp() {
return Ok(re.source().into()); return Ok(re.source().into());
@ -207,7 +207,7 @@ pub fn exec<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(mut re) = this.as_regexp_mut(activation.context.gc_context) { if let Some(mut re) = this.as_regexp_mut(activation.context.gc_context) {
let text = args let text = args
@ -253,7 +253,7 @@ pub fn test<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(mut re) = this.as_regexp_mut(activation.context.gc_context) { if let Some(mut re) = this.as_regexp_mut(activation.context.gc_context) {
let text = args let text = args

View File

@ -20,7 +20,7 @@ pub fn instance_init<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
activation.super_init(this, &[])?; activation.super_init(this, &[])?;
@ -43,7 +43,7 @@ pub fn class_init<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Ok(Value::Undefined) Ok(Value::Undefined)
} }
@ -52,7 +52,7 @@ fn length<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Value::String(s) = this.value_of(activation.context.gc_context)? { if let Value::String(s) = this.value_of(activation.context.gc_context)? {
return Ok(s.len().into()); return Ok(s.len().into());
@ -67,7 +67,7 @@ fn char_at<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Value::String(s) = this.value_of(activation.context.gc_context)? { if let Value::String(s) = this.value_of(activation.context.gc_context)? {
// This function takes Number, so if we use coerce_to_i32 instead of coerce_to_number, the value may overflow. // This function takes Number, so if we use coerce_to_i32 instead of coerce_to_number, the value may overflow.
@ -97,7 +97,7 @@ fn char_code_at<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Value::String(s) = this.value_of(activation.context.gc_context)? { if let Value::String(s) = this.value_of(activation.context.gc_context)? {
// This function takes Number, so if we use coerce_to_i32 instead of coerce_to_number, the value may overflow. // This function takes Number, so if we use coerce_to_i32 instead of coerce_to_number, the value may overflow.
@ -123,7 +123,7 @@ fn concat<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
let mut ret = WString::from(Value::from(this).coerce_to_string(activation)?.as_wstr()); let mut ret = WString::from(Value::from(this).coerce_to_string(activation)?.as_wstr());
for arg in args { for arg in args {
@ -141,7 +141,7 @@ fn from_char_code<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
let mut out = WString::with_capacity(args.len(), false); let mut out = WString::with_capacity(args.len(), false);
for arg in args { for arg in args {
let i = arg.coerce_to_u32(activation)? as u16; let i = arg.coerce_to_u32(activation)? as u16;
@ -159,7 +159,7 @@ fn index_of<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
let this = Value::from(this).coerce_to_string(activation)?; let this = Value::from(this).coerce_to_string(activation)?;
let pattern = match args.get(0) { let pattern = match args.get(0) {
@ -187,7 +187,7 @@ fn last_index_of<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
let this = Value::from(this).coerce_to_string(activation)?; let this = Value::from(this).coerce_to_string(activation)?;
let pattern = match args.get(0) { let pattern = match args.get(0) {
@ -220,7 +220,7 @@ fn locale_compare<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
let this = Value::from(this).coerce_to_string(activation)?; let this = Value::from(this).coerce_to_string(activation)?;
let other = match args.get(0) { let other = match args.get(0) {
@ -254,7 +254,7 @@ fn match_s<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let (Some(this), pattern) = (this, args.get(0).unwrap_or(&Value::Undefined)) { if let (Some(this), pattern) = (this, args.get(0).unwrap_or(&Value::Undefined)) {
let this = Value::from(this).coerce_to_string(activation)?; let this = Value::from(this).coerce_to_string(activation)?;
@ -321,7 +321,7 @@ fn replace<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
let this = Value::from(this).coerce_to_string(activation)?; let this = Value::from(this).coerce_to_string(activation)?;
let pattern = args.get(0).unwrap_or(&Value::Undefined); let pattern = args.get(0).unwrap_or(&Value::Undefined);
@ -368,7 +368,7 @@ fn search<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let (Some(this), pattern) = (this, args.get(0).unwrap_or(&Value::Undefined)) { if let (Some(this), pattern) = (this, args.get(0).unwrap_or(&Value::Undefined)) {
let this = Value::from(this).coerce_to_string(activation)?; let this = Value::from(this).coerce_to_string(activation)?;
@ -405,7 +405,7 @@ fn slice<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
let this = Value::from(this).coerce_to_string(activation)?; let this = Value::from(this).coerce_to_string(activation)?;
let start_index = match args.get(0) { let start_index = match args.get(0) {
@ -437,7 +437,7 @@ fn split<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
let delimiter = args.get(0).unwrap_or(&Value::Undefined); let delimiter = args.get(0).unwrap_or(&Value::Undefined);
if matches!(delimiter, Value::Undefined) { if matches!(delimiter, Value::Undefined) {
@ -497,7 +497,7 @@ fn substr<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
let this_val = Value::from(this); let this_val = Value::from(this);
let this = this_val.coerce_to_string(activation)?; let this = this_val.coerce_to_string(activation)?;
@ -536,7 +536,7 @@ fn substring<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
let this_val = Value::from(this); let this_val = Value::from(this);
let this = this_val.coerce_to_string(activation)?; let this = this_val.coerce_to_string(activation)?;
@ -575,7 +575,7 @@ fn to_lower_case<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
let this_val = Value::from(this); let this_val = Value::from(this);
let this = this_val.coerce_to_string(activation)?; let this = this_val.coerce_to_string(activation)?;
@ -595,7 +595,7 @@ fn to_upper_case<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
let this_val = Value::from(this); let this_val = Value::from(this);
let this = this_val.coerce_to_string(activation)?; let this = this_val.coerce_to_string(activation)?;

View File

@ -10,7 +10,7 @@ pub fn trace<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
match args { match args {
[] => activation.context.avm_trace(""), [] => activation.context.avm_trace(""),
[arg] => { [arg] => {
@ -34,7 +34,7 @@ pub fn is_finite<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(val) = args.get(0) { if let Some(val) = args.get(0) {
Ok(val.coerce_to_number(activation)?.is_finite().into()) Ok(val.coerce_to_number(activation)?.is_finite().into())
} else { } else {
@ -46,7 +46,7 @@ pub fn is_nan<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(val) = args.get(0) { if let Some(val) = args.get(0) {
Ok(val.coerce_to_number(activation)?.is_nan().into()) Ok(val.coerce_to_number(activation)?.is_nan().into())
} else { } else {
@ -58,7 +58,7 @@ pub fn parse_int<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
let string = match args.get(0).unwrap_or(&Value::Undefined) { let string = match args.get(0).unwrap_or(&Value::Undefined) {
Value::Undefined => "null".into(), Value::Undefined => "null".into(),
value => value.coerce_to_string(activation)?, value => value.coerce_to_string(activation)?,
@ -77,7 +77,7 @@ pub fn parse_float<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(value) = args.get(0) { if let Some(value) = args.get(0) {
let string = value.coerce_to_string(activation)?; let string = value.coerce_to_string(activation)?;
let swf_version = activation.context.swf.version(); let swf_version = activation.context.swf.version();
@ -93,7 +93,7 @@ pub fn escape<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
let value = match args.first() { let value = match args.first() {
None => return Ok("undefined".into()), None => return Ok("undefined".into()),
Some(Value::Undefined) => return Ok("null".into()), Some(Value::Undefined) => return Ok("null".into()),

View File

@ -17,7 +17,7 @@ fn instance_init<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(mut prim) = this.as_primitive_mut(activation.context.gc_context) { if let Some(mut prim) = this.as_primitive_mut(activation.context.gc_context) {
if matches!(*prim, Value::Undefined | Value::Null) { if matches!(*prim, Value::Undefined | Value::Null) {
@ -39,7 +39,7 @@ fn native_instance_init<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
activation.super_init(this, args)?; activation.super_init(this, args)?;
} }
@ -52,7 +52,7 @@ fn class_init<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
let scope = activation.create_scopechain(); let scope = activation.create_scopechain();
let gc_context = activation.context.gc_context; let gc_context = activation.context.gc_context;
@ -134,7 +134,7 @@ fn to_exponential<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(this) = this.as_primitive() { if let Some(this) = this.as_primitive() {
if let Value::Integer(number) = *this { if let Value::Integer(number) = *this {
@ -168,7 +168,7 @@ fn to_fixed<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(this) = this.as_primitive() { if let Some(this) = this.as_primitive() {
if let Value::Integer(number) = *this { if let Value::Integer(number) = *this {
@ -199,7 +199,7 @@ fn to_precision<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(this) = this.as_primitive() { if let Some(this) = this.as_primitive() {
if let Value::Integer(number) = *this { if let Value::Integer(number) = *this {
@ -226,7 +226,7 @@ fn to_string<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(this) = this.as_primitive() { if let Some(this) = this.as_primitive() {
if let Value::Integer(number) = *this { if let Value::Integer(number) = *this {
@ -253,7 +253,7 @@ fn value_of<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(this) = this.as_primitive() { if let Some(this) = this.as_primitive() {
return Ok(*this); return Ok(*this);

View File

@ -24,7 +24,7 @@ pub fn instance_init<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
activation.super_init(this, &[])?; activation.super_init(this, &[])?;
@ -52,7 +52,7 @@ fn class_call<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if args.len() != 1 { if args.len() != 1 {
return Err("Argument count mismatch on class coercion".into()); return Err("Argument count mismatch on class coercion".into());
} }
@ -93,7 +93,7 @@ pub fn class_init<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
let mut globals = activation.global_scope().unwrap(); let mut globals = activation.global_scope().unwrap();
let mut domain = activation.domain(); let mut domain = activation.domain();
@ -178,7 +178,7 @@ pub fn specialized_class_init<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
let mut proto = this let mut proto = this
.get_property(&Multiname::public("prototype"), activation)? .get_property(&Multiname::public("prototype"), activation)?
@ -239,7 +239,7 @@ pub fn length<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(vector) = this.as_vector_storage() { if let Some(vector) = this.as_vector_storage() {
return Ok(vector.length().into()); return Ok(vector.length().into());
@ -254,7 +254,7 @@ pub fn set_length<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(mut vector) = this.as_vector_storage_mut(activation.context.gc_context) { if let Some(mut vector) = this.as_vector_storage_mut(activation.context.gc_context) {
let new_length = args let new_length = args
@ -275,7 +275,7 @@ pub fn fixed<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(vector) = this.as_vector_storage() { if let Some(vector) = this.as_vector_storage() {
return Ok(vector.is_fixed().into()); return Ok(vector.is_fixed().into());
@ -290,7 +290,7 @@ pub fn set_fixed<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(mut vector) = this.as_vector_storage_mut(activation.context.gc_context) { if let Some(mut vector) = this.as_vector_storage_mut(activation.context.gc_context) {
let new_fixed = args let new_fixed = args
@ -311,7 +311,7 @@ pub fn concat<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
let mut new_vector_storage = if let Some(vector) = this.as_vector_storage() { let mut new_vector_storage = if let Some(vector) = this.as_vector_storage() {
vector.clone() vector.clone()
@ -378,9 +378,12 @@ fn join_inner<'gc, 'a, 'ctxt, C>(
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
mut conv: C, mut conv: C,
) -> Result<Value<'gc>, Error> ) -> Result<Value<'gc>, Error<'gc>>
where where
C: for<'b> FnMut(Value<'gc>, &'b mut Activation<'a, 'gc, 'ctxt>) -> Result<Value<'gc>, Error>, C: for<'b> FnMut(
Value<'gc>,
&'b mut Activation<'a, 'gc, 'ctxt>,
) -> Result<Value<'gc>, Error<'gc>>,
{ {
let mut separator = args.get(0).cloned().unwrap_or(Value::Undefined); let mut separator = args.get(0).cloned().unwrap_or(Value::Undefined);
if separator == Value::Undefined { if separator == Value::Undefined {
@ -416,7 +419,7 @@ pub fn join<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
join_inner(activation, this, args, |v, _act| Ok(v)) join_inner(activation, this, args, |v, _act| Ok(v))
} }
@ -425,7 +428,7 @@ pub fn to_string<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
join_inner(activation, this, &[",".into()], |v, _act| Ok(v)) join_inner(activation, this, &[",".into()], |v, _act| Ok(v))
} }
@ -434,7 +437,7 @@ pub fn to_locale_string<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
join_inner(activation, this, &[",".into()], |v, act| { join_inner(activation, this, &[",".into()], |v, act| {
if let Ok(o) = v.coerce_to_object(act) { if let Ok(o) = v.coerce_to_object(act) {
o.call_property(&Multiname::public("toLocaleString"), &[], act) o.call_property(&Multiname::public("toLocaleString"), &[], act)
@ -449,7 +452,7 @@ pub fn every<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
let callback = args let callback = args
.get(0) .get(0)
@ -482,7 +485,7 @@ pub fn some<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
let callback = args let callback = args
.get(0) .get(0)
@ -515,7 +518,7 @@ pub fn filter<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
let callback = args let callback = args
.get(0) .get(0)
@ -556,7 +559,7 @@ pub fn for_each<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
let callback = args let callback = args
.get(0) .get(0)
@ -581,7 +584,7 @@ pub fn index_of<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
let search_for = args.get(0).cloned().unwrap_or(Value::Undefined); let search_for = args.get(0).cloned().unwrap_or(Value::Undefined);
let from_index = args let from_index = args
@ -618,7 +621,7 @@ pub fn last_index_of<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
let search_for = args.get(0).cloned().unwrap_or(Value::Undefined); let search_for = args.get(0).cloned().unwrap_or(Value::Undefined);
let from_index = args let from_index = args
@ -655,7 +658,7 @@ pub fn map<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
let callback = args let callback = args
.get(0) .get(0)
@ -693,7 +696,7 @@ pub fn pop<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(mut vs) = this.as_vector_storage_mut(activation.context.gc_context) { if let Some(mut vs) = this.as_vector_storage_mut(activation.context.gc_context) {
return vs.pop(activation); return vs.pop(activation);
@ -708,7 +711,7 @@ pub fn push<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(mut vs) = this.as_vector_storage_mut(activation.context.gc_context) { if let Some(mut vs) = this.as_vector_storage_mut(activation.context.gc_context) {
let value_type = vs.value_type(); let value_type = vs.value_type();
@ -731,7 +734,7 @@ pub fn shift<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(mut vs) = this.as_vector_storage_mut(activation.context.gc_context) { if let Some(mut vs) = this.as_vector_storage_mut(activation.context.gc_context) {
return vs.shift(activation); return vs.shift(activation);
@ -746,7 +749,7 @@ pub fn unshift<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(mut vs) = this.as_vector_storage_mut(activation.context.gc_context) { if let Some(mut vs) = this.as_vector_storage_mut(activation.context.gc_context) {
let value_type = vs.value_type(); let value_type = vs.value_type();
@ -769,7 +772,7 @@ pub fn insert_at<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(mut vs) = this.as_vector_storage_mut(activation.context.gc_context) { if let Some(mut vs) = this.as_vector_storage_mut(activation.context.gc_context) {
let index = args let index = args
@ -796,7 +799,7 @@ pub fn remove_at<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(mut vs) = this.as_vector_storage_mut(activation.context.gc_context) { if let Some(mut vs) = this.as_vector_storage_mut(activation.context.gc_context) {
let index = args let index = args
@ -817,7 +820,7 @@ pub fn reverse<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(mut vs) = this.as_vector_storage_mut(activation.context.gc_context) { if let Some(mut vs) = this.as_vector_storage_mut(activation.context.gc_context) {
vs.reverse(); vs.reverse();
@ -834,7 +837,7 @@ pub fn slice<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(vs) = this.as_vector_storage_mut(activation.context.gc_context) { if let Some(vs) = this.as_vector_storage_mut(activation.context.gc_context) {
let from = args let from = args
@ -874,7 +877,7 @@ pub fn sort<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(vs) = this.as_vector_storage_mut(activation.context.gc_context) { if let Some(vs) = this.as_vector_storage_mut(activation.context.gc_context) {
let fn_or_options = args.get(0).cloned().unwrap_or(Value::Undefined); let fn_or_options = args.get(0).cloned().unwrap_or(Value::Undefined);
@ -961,7 +964,7 @@ pub fn splice<'gc>(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,
args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(this) = this { if let Some(this) = this {
if let Some(mut vs) = this.as_vector_storage_mut(activation.context.gc_context) { if let Some(mut vs) = this.as_vector_storage_mut(activation.context.gc_context) {
let start_len = args let start_len = args

View File

@ -16,7 +16,7 @@ pub fn instance_init<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Ok(Value::Undefined) Ok(Value::Undefined)
} }
@ -25,7 +25,7 @@ pub fn class_init<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Ok(Value::Undefined) Ok(Value::Undefined)
} }

View File

@ -16,7 +16,7 @@ pub fn instance_init<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Ok(Value::Undefined) Ok(Value::Undefined)
} }
@ -25,7 +25,7 @@ pub fn class_init<'gc>(
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_this: Option<Object<'gc>>, _this: Option<Object<'gc>>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Ok(Value::Undefined) Ok(Value::Undefined)
} }

View File

@ -35,7 +35,7 @@ pub type NativeMethodImpl = for<'gc> fn(
&mut Activation<'_, 'gc, '_>, &mut Activation<'_, 'gc, '_>,
Option<Object<'gc>>, Option<Object<'gc>>,
&[Value<'gc>], &[Value<'gc>],
) -> Result<Value<'gc>, Error>; ) -> Result<Value<'gc>, Error<'gc>>;
/// Configuration of a single parameter of a method. /// Configuration of a single parameter of a method.
#[derive(Clone, Collect, Debug)] #[derive(Clone, Collect, Debug)]
@ -56,7 +56,7 @@ impl<'gc> ParamConfig<'gc> {
config: &AbcMethodParam, config: &AbcMethodParam,
txunit: TranslationUnit<'gc>, txunit: TranslationUnit<'gc>,
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
) -> Result<Self, Error> { ) -> Result<Self, Error<'gc>> {
let param_name = if let Some(name) = &config.name { let param_name = if let Some(name) = &config.name {
txunit.pool_string(name.0, activation.context.gc_context)? txunit.pool_string(name.0, activation.context.gc_context)?
} else { } else {
@ -138,7 +138,7 @@ impl<'gc> BytecodeMethod<'gc> {
abc_method: Index<AbcMethod>, abc_method: Index<AbcMethod>,
is_function: bool, is_function: bool,
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
) -> Result<Self, Error> { ) -> Result<Self, Error<'gc>> {
let abc = txunit.abc(); let abc = txunit.abc();
let mut signature = Vec::new(); let mut signature = Vec::new();
@ -348,7 +348,7 @@ impl<'gc> Method<'gc> {
/// Access the bytecode of this method. /// Access the bytecode of this method.
/// ///
/// This function returns `Err` if there is no bytecode for this method. /// This function returns `Err` if there is no bytecode for this method.
pub fn into_bytecode(self) -> Result<Gc<'gc, BytecodeMethod<'gc>>, Error> { pub fn into_bytecode(self) -> Result<Gc<'gc, BytecodeMethod<'gc>>, Error<'gc>> {
match self { match self {
Method::Native { .. } => { Method::Native { .. } => {
Err("Attempted to unwrap a native method as a user-defined one".into()) Err("Attempted to unwrap a native method as a user-defined one".into())

View File

@ -106,7 +106,7 @@ impl<'gc> Multiname<'gc> {
translation_unit: TranslationUnit<'gc>, translation_unit: TranslationUnit<'gc>,
namespace_set_index: Index<AbcNamespaceSet>, namespace_set_index: Index<AbcNamespaceSet>,
mc: MutationContext<'gc, '_>, mc: MutationContext<'gc, '_>,
) -> Result<NamespaceSet<'gc>, Error> { ) -> Result<NamespaceSet<'gc>, Error<'gc>> {
if namespace_set_index.0 == 0 { if namespace_set_index.0 == 0 {
//TODO: What is namespace set zero? //TODO: What is namespace set zero?
let result = NamespaceSet::multiple(vec![], mc); let result = NamespaceSet::multiple(vec![], mc);
@ -115,7 +115,7 @@ impl<'gc> Multiname<'gc> {
let actual_index = namespace_set_index.0 as usize - 1; let actual_index = namespace_set_index.0 as usize - 1;
let abc = translation_unit.abc(); let abc = translation_unit.abc();
let ns_set: Result<_, Error> = abc let ns_set: Result<_, Error<'gc>> = abc
.constant_pool .constant_pool
.namespace_sets .namespace_sets
.get(actual_index) .get(actual_index)
@ -143,7 +143,7 @@ impl<'gc> Multiname<'gc> {
translation_unit: TranslationUnit<'gc>, translation_unit: TranslationUnit<'gc>,
multiname_index: Index<AbcMultiname>, multiname_index: Index<AbcMultiname>,
mc: MutationContext<'gc, '_>, mc: MutationContext<'gc, '_>,
) -> Result<Self, Error> { ) -> Result<Self, Error<'gc>> {
let abc = translation_unit.abc(); let abc = translation_unit.abc();
let abc_multiname = Self::resolve_multiname_index(&abc, multiname_index)?; let abc_multiname = Self::resolve_multiname_index(&abc, multiname_index)?;
@ -223,7 +223,7 @@ impl<'gc> Multiname<'gc> {
pub fn fill_with_runtime_params( pub fn fill_with_runtime_params(
&self, &self,
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
) -> Result<Self, Error> { ) -> Result<Self, Error<'gc>> {
let name = if self.has_lazy_name() { let name = if self.has_lazy_name() {
Some(activation.avm2().pop().coerce_to_string(activation)?) Some(activation.avm2().pop().coerce_to_string(activation)?)
} else { } else {
@ -251,8 +251,8 @@ impl<'gc> Multiname<'gc> {
pub fn resolve_multiname_index( pub fn resolve_multiname_index(
abc: &AbcFile, abc: &AbcFile,
multiname_index: Index<AbcMultiname>, multiname_index: Index<AbcMultiname>,
) -> Result<&AbcMultiname, Error> { ) -> Result<&AbcMultiname, Error<'gc>> {
let actual_index: Result<usize, Error> = (multiname_index.0 as usize) let actual_index: Result<usize, Error<'gc>> = (multiname_index.0 as usize)
.checked_sub(1) .checked_sub(1)
.ok_or_else(|| "Attempted to resolve a multiname at index zero. This is a bug.".into()); .ok_or_else(|| "Attempted to resolve a multiname at index zero. This is a bug.".into());

View File

@ -27,14 +27,14 @@ impl<'gc> Namespace<'gc> {
translation_unit: TranslationUnit<'gc>, translation_unit: TranslationUnit<'gc>,
namespace_index: Index<AbcNamespace>, namespace_index: Index<AbcNamespace>,
mc: MutationContext<'gc, '_>, mc: MutationContext<'gc, '_>,
) -> Result<Self, Error> { ) -> Result<Self, Error<'gc>> {
if namespace_index.0 == 0 { if namespace_index.0 == 0 {
return Ok(Self::Any); return Ok(Self::Any);
} }
let actual_index = namespace_index.0 as usize - 1; let actual_index = namespace_index.0 as usize - 1;
let abc = translation_unit.abc(); let abc = translation_unit.abc();
let abc_namespace: Result<_, Error> = abc let abc_namespace: Result<_, Error<'gc>> = abc
.constant_pool .constant_pool
.namespaces .namespaces
.get(actual_index) .get(actual_index)

View File

@ -128,7 +128,7 @@ pub trait TObject<'gc>: 'gc + Collect + Debug + Into<Object<'gc>> + Clone + Copy
self, self,
name: &Multiname<'gc>, name: &Multiname<'gc>,
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
self.base().get_property_local(name, activation) self.base().get_property_local(name, activation)
} }
@ -144,7 +144,7 @@ pub trait TObject<'gc>: 'gc + Collect + Debug + Into<Object<'gc>> + Clone + Copy
mut self, mut self,
multiname: &Multiname<'gc>, multiname: &Multiname<'gc>,
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
match self.vtable().and_then(|vtable| vtable.get_trait(multiname)) { match self.vtable().and_then(|vtable| vtable.get_trait(multiname)) {
Some(Property::Slot { slot_id }) | Some(Property::ConstSlot { slot_id }) => { Some(Property::Slot { slot_id }) | Some(Property::ConstSlot { slot_id }) => {
self.base().get_slot(slot_id) self.base().get_slot(slot_id)
@ -183,7 +183,7 @@ pub trait TObject<'gc>: 'gc + Collect + Debug + Into<Object<'gc>> + Clone + Copy
name: &Multiname<'gc>, name: &Multiname<'gc>,
value: Value<'gc>, value: Value<'gc>,
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
) -> Result<(), Error> { ) -> Result<(), Error<'gc>> {
let mut base = self.base_mut(activation.context.gc_context); let mut base = self.base_mut(activation.context.gc_context);
base.set_property_local(name, value, activation) base.set_property_local(name, value, activation)
} }
@ -200,7 +200,7 @@ pub trait TObject<'gc>: 'gc + Collect + Debug + Into<Object<'gc>> + Clone + Copy
multiname: &Multiname<'gc>, multiname: &Multiname<'gc>,
value: Value<'gc>, value: Value<'gc>,
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
) -> Result<(), Error> { ) -> Result<(), Error<'gc>> {
match self.vtable().and_then(|vtable| vtable.get_trait(multiname)) { match self.vtable().and_then(|vtable| vtable.get_trait(multiname)) {
Some(Property::Slot { slot_id }) => { Some(Property::Slot { slot_id }) => {
let value = self let value = self
@ -238,7 +238,7 @@ pub trait TObject<'gc>: 'gc + Collect + Debug + Into<Object<'gc>> + Clone + Copy
name: &Multiname<'gc>, name: &Multiname<'gc>,
value: Value<'gc>, value: Value<'gc>,
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
) -> Result<(), Error> { ) -> Result<(), Error<'gc>> {
let mut base = self.base_mut(activation.context.gc_context); let mut base = self.base_mut(activation.context.gc_context);
base.init_property_local(name, value, activation) base.init_property_local(name, value, activation)
} }
@ -253,7 +253,7 @@ pub trait TObject<'gc>: 'gc + Collect + Debug + Into<Object<'gc>> + Clone + Copy
multiname: &Multiname<'gc>, multiname: &Multiname<'gc>,
value: Value<'gc>, value: Value<'gc>,
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
) -> Result<(), Error> { ) -> Result<(), Error<'gc>> {
match self.vtable().and_then(|vtable| vtable.get_trait(multiname)) { match self.vtable().and_then(|vtable| vtable.get_trait(multiname)) {
Some(Property::Slot { slot_id }) | Some(Property::ConstSlot { slot_id }) => { Some(Property::Slot { slot_id }) | Some(Property::ConstSlot { slot_id }) => {
let value = self let value = self
@ -288,7 +288,7 @@ pub trait TObject<'gc>: 'gc + Collect + Debug + Into<Object<'gc>> + Clone + Copy
multiname: &Multiname<'gc>, multiname: &Multiname<'gc>,
arguments: &[Value<'gc>], arguments: &[Value<'gc>],
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
// Note: normally this would just call into ScriptObjectData::call_property_local // Note: normally this would just call into ScriptObjectData::call_property_local
// but because calling into ScriptObjectData borrows it for entire duration, // but because calling into ScriptObjectData borrows it for entire duration,
// we run a risk of a double borrow if the inner call borrows again. // we run a risk of a double borrow if the inner call borrows again.
@ -311,7 +311,7 @@ pub trait TObject<'gc>: 'gc + Collect + Debug + Into<Object<'gc>> + Clone + Copy
multiname: &Multiname<'gc>, multiname: &Multiname<'gc>,
arguments: &[Value<'gc>], arguments: &[Value<'gc>],
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
match self.vtable().and_then(|vtable| vtable.get_trait(multiname)) { match self.vtable().and_then(|vtable| vtable.get_trait(multiname)) {
Some(Property::Slot { slot_id }) | Some(Property::ConstSlot { slot_id }) => { Some(Property::Slot { slot_id }) | Some(Property::ConstSlot { slot_id }) => {
let obj = self.base().get_slot(slot_id)?.as_callable( let obj = self.base().get_slot(slot_id)?.as_callable(
@ -372,7 +372,7 @@ pub trait TObject<'gc>: 'gc + Collect + Debug + Into<Object<'gc>> + Clone + Copy
} }
/// Retrieve a slot by its index. /// Retrieve a slot by its index.
fn get_slot(self, id: u32) -> Result<Value<'gc>, Error> { fn get_slot(self, id: u32) -> Result<Value<'gc>, Error<'gc>> {
let base = self.base(); let base = self.base();
base.get_slot(id) base.get_slot(id)
@ -384,7 +384,7 @@ pub trait TObject<'gc>: 'gc + Collect + Debug + Into<Object<'gc>> + Clone + Copy
id: u32, id: u32,
value: Value<'gc>, value: Value<'gc>,
mc: MutationContext<'gc, '_>, mc: MutationContext<'gc, '_>,
) -> Result<(), Error> { ) -> Result<(), Error<'gc>> {
let mut base = self.base_mut(mc); let mut base = self.base_mut(mc);
base.set_slot(id, value, mc) base.set_slot(id, value, mc)
@ -396,7 +396,7 @@ pub trait TObject<'gc>: 'gc + Collect + Debug + Into<Object<'gc>> + Clone + Copy
id: u32, id: u32,
value: Value<'gc>, value: Value<'gc>,
mc: MutationContext<'gc, '_>, mc: MutationContext<'gc, '_>,
) -> Result<(), Error> { ) -> Result<(), Error<'gc>> {
let mut base = self.base_mut(mc); let mut base = self.base_mut(mc);
base.init_slot(id, value, mc) base.init_slot(id, value, mc)
@ -411,7 +411,7 @@ pub trait TObject<'gc>: 'gc + Collect + Debug + Into<Object<'gc>> + Clone + Copy
id: u32, id: u32,
arguments: &[Value<'gc>], arguments: &[Value<'gc>],
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if self.get_bound_method(id).is_none() { if self.get_bound_method(id).is_none() {
if let Some(vtable) = self.vtable() { if let Some(vtable) = self.vtable() {
if let Some(bound_method) = vtable.make_bound_method(activation, self.into(), id) { if let Some(bound_method) = vtable.make_bound_method(activation, self.into(), id) {
@ -436,7 +436,7 @@ pub trait TObject<'gc>: 'gc + Collect + Debug + Into<Object<'gc>> + Clone + Copy
self, self,
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
name: &Multiname<'gc>, name: &Multiname<'gc>,
) -> Result<bool, Error> { ) -> Result<bool, Error<'gc>> {
Ok(self.has_property(name)) Ok(self.has_property(name))
} }
@ -472,7 +472,7 @@ pub trait TObject<'gc>: 'gc + Collect + Debug + Into<Object<'gc>> + Clone + Copy
self, self,
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
name: &Multiname<'gc>, name: &Multiname<'gc>,
) -> Result<bool, Error> { ) -> Result<bool, Error<'gc>> {
let mut base = self.base_mut(activation.context.gc_context); let mut base = self.base_mut(activation.context.gc_context);
Ok(base.delete_property_local(name)) Ok(base.delete_property_local(name))
@ -485,7 +485,7 @@ pub trait TObject<'gc>: 'gc + Collect + Debug + Into<Object<'gc>> + Clone + Copy
&self, &self,
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
multiname: &Multiname<'gc>, multiname: &Multiname<'gc>,
) -> Result<bool, Error> { ) -> Result<bool, Error<'gc>> {
match self.vtable().and_then(|vtable| vtable.get_trait(multiname)) { match self.vtable().and_then(|vtable| vtable.get_trait(multiname)) {
None => { None => {
if self if self
@ -539,7 +539,7 @@ pub trait TObject<'gc>: 'gc + Collect + Debug + Into<Object<'gc>> + Clone + Copy
self, self,
last_index: u32, last_index: u32,
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
) -> Result<Option<u32>, Error> { ) -> Result<Option<u32>, Error<'gc>> {
let base = self.base(); let base = self.base();
Ok(base.get_next_enumerant(last_index)) Ok(base.get_next_enumerant(last_index))
@ -555,7 +555,7 @@ pub trait TObject<'gc>: 'gc + Collect + Debug + Into<Object<'gc>> + Clone + Copy
self, self,
index: u32, index: u32,
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
let base = self.base(); let base = self.base();
Ok(base.get_enumerant_name(index).unwrap_or(Value::Undefined)) Ok(base.get_enumerant_name(index).unwrap_or(Value::Undefined))
@ -569,7 +569,7 @@ pub trait TObject<'gc>: 'gc + Collect + Debug + Into<Object<'gc>> + Clone + Copy
self, self,
index: u32, index: u32,
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
let name = self let name = self
.get_enumerant_name(index, activation)? .get_enumerant_name(index, activation)?
.coerce_to_string(activation)?; .coerce_to_string(activation)?;
@ -637,7 +637,7 @@ pub trait TObject<'gc>: 'gc + Collect + Debug + Into<Object<'gc>> + Clone + Copy
_reciever: Option<Object<'gc>>, _reciever: Option<Object<'gc>>,
_arguments: &[Value<'gc>], _arguments: &[Value<'gc>],
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
Err("Object is not callable".into()) Err("Object is not callable".into())
} }
@ -661,7 +661,7 @@ pub trait TObject<'gc>: 'gc + Collect + Debug + Into<Object<'gc>> + Clone + Copy
self, self,
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Object<'gc>, Error> { ) -> Result<Object<'gc>, Error<'gc>> {
Err("Object is not constructable".into()) Err("Object is not constructable".into())
} }
@ -673,7 +673,7 @@ pub trait TObject<'gc>: 'gc + Collect + Debug + Into<Object<'gc>> + Clone + Copy
multiname: &Multiname<'gc>, multiname: &Multiname<'gc>,
args: &[Value<'gc>], args: &[Value<'gc>],
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
) -> Result<Object<'gc>, Error> { ) -> Result<Object<'gc>, Error<'gc>> {
let ctor = self.get_property(multiname, activation)?.as_callable( let ctor = self.get_property(multiname, activation)?.as_callable(
activation, activation,
Some(multiname), Some(multiname),
@ -702,7 +702,7 @@ pub trait TObject<'gc>: 'gc + Collect + Debug + Into<Object<'gc>> + Clone + Copy
&self, &self,
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_params: &[Value<'gc>], _params: &[Value<'gc>],
) -> Result<ClassObject<'gc>, Error> { ) -> Result<ClassObject<'gc>, Error<'gc>> {
Err("Not a parameterized type".into()) Err("Not a parameterized type".into())
} }
@ -724,7 +724,10 @@ pub trait TObject<'gc>: 'gc + Collect + Debug + Into<Object<'gc>> + Clone + Copy
/// coercions happen by defining `toString` in a downstream class or /// coercions happen by defining `toString` in a downstream class or
/// prototype; this is then picked up by the VM runtime when doing /// prototype; this is then picked up by the VM runtime when doing
/// coercions. /// coercions.
fn to_string(&self, activation: &mut Activation<'_, 'gc, '_>) -> Result<Value<'gc>, Error> { fn to_string(
&self,
activation: &mut Activation<'_, 'gc, '_>,
) -> Result<Value<'gc>, Error<'gc>> {
let class_name = self let class_name = self
.instance_of_class_definition() .instance_of_class_definition()
.map(|c| c.read().name().local_name()) .map(|c| c.read().name().local_name())
@ -748,7 +751,7 @@ pub trait TObject<'gc>: 'gc + Collect + Debug + Into<Object<'gc>> + Clone + Copy
fn to_locale_string( fn to_locale_string(
&self, &self,
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
let class_name = self let class_name = self
.instance_of_class_definition() .instance_of_class_definition()
.map(|c| c.read().name().local_name()) .map(|c| c.read().name().local_name())
@ -766,7 +769,7 @@ pub trait TObject<'gc>: 'gc + Collect + Debug + Into<Object<'gc>> + Clone + Copy
/// ///
/// `valueOf` is a method used to request an object be coerced to a /// `valueOf` is a method used to request an object be coerced to a
/// primitive value. Typically, this would be a number of some kind. /// primitive value. Typically, this would be a number of some kind.
fn value_of(&self, mc: MutationContext<'gc, '_>) -> Result<Value<'gc>, Error>; fn value_of(&self, mc: MutationContext<'gc, '_>) -> Result<Value<'gc>, Error<'gc>>;
/// Determine if this object is an instance of a given type. /// Determine if this object is an instance of a given type.
/// ///
@ -781,7 +784,7 @@ pub trait TObject<'gc>: 'gc + Collect + Debug + Into<Object<'gc>> + Clone + Copy
&self, &self,
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
class: Object<'gc>, class: Object<'gc>,
) -> Result<bool, Error> { ) -> Result<bool, Error<'gc>> {
let type_proto = class let type_proto = class
.get_property(&Multiname::public("prototype"), activation)? .get_property(&Multiname::public("prototype"), activation)?
.as_object(); .as_object();
@ -797,7 +800,7 @@ pub trait TObject<'gc>: 'gc + Collect + Debug + Into<Object<'gc>> + Clone + Copy
/// ///
/// The given object `type_proto` should be the prototype we are checking /// The given object `type_proto` should be the prototype we are checking
/// against this object. /// against this object.
fn has_prototype_in_chain(&self, type_proto: Object<'gc>) -> Result<bool, Error> { fn has_prototype_in_chain(&self, type_proto: Object<'gc>) -> Result<bool, Error<'gc>> {
let mut my_proto = self.proto(); let mut my_proto = self.proto();
//TODO: Is it a verification error to do `obj instanceof bare_object`? //TODO: Is it a verification error to do `obj instanceof bare_object`?

View File

@ -15,7 +15,7 @@ use std::cell::{Ref, RefMut};
pub fn array_allocator<'gc>( pub fn array_allocator<'gc>(
class: ClassObject<'gc>, class: ClassObject<'gc>,
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
) -> Result<Object<'gc>, Error> { ) -> Result<Object<'gc>, Error<'gc>> {
let base = ScriptObjectData::new(class); let base = ScriptObjectData::new(class);
Ok(ArrayObject(GcCell::allocate( Ok(ArrayObject(GcCell::allocate(
@ -45,7 +45,7 @@ pub struct ArrayObjectData<'gc> {
impl<'gc> ArrayObject<'gc> { impl<'gc> ArrayObject<'gc> {
/// Construct an empty array. /// Construct an empty array.
pub fn empty(activation: &mut Activation<'_, 'gc, '_>) -> Result<Object<'gc>, Error> { pub fn empty(activation: &mut Activation<'_, 'gc, '_>) -> Result<Object<'gc>, Error<'gc>> {
Self::from_storage(activation, ArrayStorage::new(0)) Self::from_storage(activation, ArrayStorage::new(0))
} }
@ -55,7 +55,7 @@ impl<'gc> ArrayObject<'gc> {
pub fn from_storage( pub fn from_storage(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
array: ArrayStorage<'gc>, array: ArrayStorage<'gc>,
) -> Result<Object<'gc>, Error> { ) -> Result<Object<'gc>, Error<'gc>> {
let class = activation.avm2().classes().array; let class = activation.avm2().classes().array;
let base = ScriptObjectData::new(class); let base = ScriptObjectData::new(class);
@ -89,7 +89,7 @@ impl<'gc> TObject<'gc> for ArrayObject<'gc> {
self, self,
name: &Multiname<'gc>, name: &Multiname<'gc>,
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
let read = self.0.read(); let read = self.0.read();
if name.contains_public_namespace() { if name.contains_public_namespace() {
@ -110,7 +110,7 @@ impl<'gc> TObject<'gc> for ArrayObject<'gc> {
name: &Multiname<'gc>, name: &Multiname<'gc>,
value: Value<'gc>, value: Value<'gc>,
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
) -> Result<(), Error> { ) -> Result<(), Error<'gc>> {
let mut write = self.0.write(activation.context.gc_context); let mut write = self.0.write(activation.context.gc_context);
if name.contains_public_namespace() { if name.contains_public_namespace() {
@ -130,7 +130,7 @@ impl<'gc> TObject<'gc> for ArrayObject<'gc> {
name: &Multiname<'gc>, name: &Multiname<'gc>,
value: Value<'gc>, value: Value<'gc>,
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
) -> Result<(), Error> { ) -> Result<(), Error<'gc>> {
let mut write = self.0.write(activation.context.gc_context); let mut write = self.0.write(activation.context.gc_context);
if name.contains_public_namespace() { if name.contains_public_namespace() {
@ -149,7 +149,7 @@ impl<'gc> TObject<'gc> for ArrayObject<'gc> {
self, self,
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
name: &Multiname<'gc>, name: &Multiname<'gc>,
) -> Result<bool, Error> { ) -> Result<bool, Error<'gc>> {
if name.contains_public_namespace() { if name.contains_public_namespace() {
if let Some(name) = name.local_name() { if let Some(name) = name.local_name() {
if let Ok(index) = name.parse::<usize>() { if let Ok(index) = name.parse::<usize>() {
@ -185,7 +185,7 @@ impl<'gc> TObject<'gc> for ArrayObject<'gc> {
self, self,
mut last_index: u32, mut last_index: u32,
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
) -> Result<Option<u32>, Error> { ) -> Result<Option<u32>, Error<'gc>> {
let read = self.0.read(); let read = self.0.read();
let num_enumerants = read.base.num_enumerants(); let num_enumerants = read.base.num_enumerants();
let array_length = read.array.length() as u32; let array_length = read.array.length() as u32;
@ -211,7 +211,7 @@ impl<'gc> TObject<'gc> for ArrayObject<'gc> {
self, self,
index: u32, index: u32,
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
let arr_len = self.0.read().array.length() as u32; let arr_len = self.0.read().array.length() as u32;
if arr_len >= index { if arr_len >= index {
Ok(index Ok(index
@ -233,11 +233,14 @@ impl<'gc> TObject<'gc> for ArrayObject<'gc> {
|| self.base().property_is_enumerable(name) || self.base().property_is_enumerable(name)
} }
fn to_string(&self, _activation: &mut Activation<'_, 'gc, '_>) -> Result<Value<'gc>, Error> { fn to_string(
&self,
_activation: &mut Activation<'_, 'gc, '_>,
) -> Result<Value<'gc>, Error<'gc>> {
Ok(Value::Object(Object::from(*self))) Ok(Value::Object(Object::from(*self)))
} }
fn value_of(&self, _mc: MutationContext<'gc, '_>) -> Result<Value<'gc>, Error> { fn value_of(&self, _mc: MutationContext<'gc, '_>) -> Result<Value<'gc>, Error<'gc>> {
Ok(Value::Object(Object::from(*self))) Ok(Value::Object(Object::from(*self)))
} }

View File

@ -13,7 +13,7 @@ use std::cell::{Ref, RefMut};
pub fn bitmapdata_allocator<'gc>( pub fn bitmapdata_allocator<'gc>(
class: ClassObject<'gc>, class: ClassObject<'gc>,
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
) -> Result<Object<'gc>, Error> { ) -> Result<Object<'gc>, Error<'gc>> {
let base = ScriptObjectData::new(class); let base = ScriptObjectData::new(class);
Ok(BitmapDataObject(GcCell::allocate( Ok(BitmapDataObject(GcCell::allocate(
@ -44,7 +44,7 @@ impl<'gc> BitmapDataObject<'gc> {
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
bitmap_data: GcCell<'gc, BitmapData<'gc>>, bitmap_data: GcCell<'gc, BitmapData<'gc>>,
class: ClassObject<'gc>, class: ClassObject<'gc>,
) -> Result<Object<'gc>, Error> { ) -> Result<Object<'gc>, Error<'gc>> {
let mut instance = Self(GcCell::allocate( let mut instance = Self(GcCell::allocate(
activation.context.gc_context, activation.context.gc_context,
BitmapDataObjectData { BitmapDataObjectData {
@ -76,7 +76,7 @@ impl<'gc> TObject<'gc> for BitmapDataObject<'gc> {
self.0.as_ptr() as *const ObjectPtr self.0.as_ptr() as *const ObjectPtr
} }
fn value_of(&self, _mc: MutationContext<'gc, '_>) -> Result<Value<'gc>, Error> { fn value_of(&self, _mc: MutationContext<'gc, '_>) -> Result<Value<'gc>, Error<'gc>> {
Ok(Value::Object(Object::from(*self))) Ok(Value::Object(Object::from(*self)))
} }

View File

@ -12,7 +12,7 @@ use std::cell::{Ref, RefMut};
pub fn bytearray_allocator<'gc>( pub fn bytearray_allocator<'gc>(
class: ClassObject<'gc>, class: ClassObject<'gc>,
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
) -> Result<Object<'gc>, Error> { ) -> Result<Object<'gc>, Error<'gc>> {
let base = ScriptObjectData::new(class); let base = ScriptObjectData::new(class);
Ok(ByteArrayObject(GcCell::allocate( Ok(ByteArrayObject(GcCell::allocate(
@ -42,7 +42,7 @@ impl<'gc> ByteArrayObject<'gc> {
pub fn from_storage( pub fn from_storage(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
bytes: ByteArrayStorage, bytes: ByteArrayStorage,
) -> Result<Object<'gc>, Error> { ) -> Result<Object<'gc>, Error<'gc>> {
let class = activation.avm2().classes().bytearray; let class = activation.avm2().classes().bytearray;
let base = ScriptObjectData::new(class); let base = ScriptObjectData::new(class);
@ -79,7 +79,7 @@ impl<'gc> TObject<'gc> for ByteArrayObject<'gc> {
self, self,
name: &Multiname<'gc>, name: &Multiname<'gc>,
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
let read = self.0.read(); let read = self.0.read();
if name.contains_public_namespace() { if name.contains_public_namespace() {
@ -102,7 +102,7 @@ impl<'gc> TObject<'gc> for ByteArrayObject<'gc> {
name: &Multiname<'gc>, name: &Multiname<'gc>,
value: Value<'gc>, value: Value<'gc>,
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
) -> Result<(), Error> { ) -> Result<(), Error<'gc>> {
let mut write = self.0.write(activation.context.gc_context); let mut write = self.0.write(activation.context.gc_context);
if name.contains_public_namespace() { if name.contains_public_namespace() {
@ -125,7 +125,7 @@ impl<'gc> TObject<'gc> for ByteArrayObject<'gc> {
name: &Multiname<'gc>, name: &Multiname<'gc>,
value: Value<'gc>, value: Value<'gc>,
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
) -> Result<(), Error> { ) -> Result<(), Error<'gc>> {
let mut write = self.0.write(activation.context.gc_context); let mut write = self.0.write(activation.context.gc_context);
if name.contains_public_namespace() { if name.contains_public_namespace() {
@ -147,7 +147,7 @@ impl<'gc> TObject<'gc> for ByteArrayObject<'gc> {
self, self,
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
name: &Multiname<'gc>, name: &Multiname<'gc>,
) -> Result<bool, Error> { ) -> Result<bool, Error<'gc>> {
if name.contains_public_namespace() { if name.contains_public_namespace() {
if let Some(name) = name.local_name() { if let Some(name) = name.local_name() {
if let Ok(index) = name.parse::<usize>() { if let Ok(index) = name.parse::<usize>() {
@ -179,7 +179,7 @@ impl<'gc> TObject<'gc> for ByteArrayObject<'gc> {
self.0.read().base.has_own_property(name) self.0.read().base.has_own_property(name)
} }
fn value_of(&self, _mc: MutationContext<'gc, '_>) -> Result<Value<'gc>, Error> { fn value_of(&self, _mc: MutationContext<'gc, '_>) -> Result<Value<'gc>, Error<'gc>> {
Ok(Value::Object(Object::from(*self))) Ok(Value::Object(Object::from(*self)))
} }

View File

@ -103,7 +103,7 @@ impl<'gc> ClassObject<'gc> {
self, self,
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
superclass_object: Option<ClassObject<'gc>>, superclass_object: Option<ClassObject<'gc>>,
) -> Result<Object<'gc>, Error> { ) -> Result<Object<'gc>, Error<'gc>> {
let proto = activation let proto = activation
.avm2() .avm2()
.classes() .classes()
@ -130,7 +130,7 @@ impl<'gc> ClassObject<'gc> {
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
class: GcCell<'gc, Class<'gc>>, class: GcCell<'gc, Class<'gc>>,
superclass_object: Option<ClassObject<'gc>>, superclass_object: Option<ClassObject<'gc>>,
) -> Result<Self, Error> { ) -> Result<Self, Error<'gc>> {
let class_object = Self::from_class_partial(activation, class, superclass_object)?; let class_object = Self::from_class_partial(activation, class, superclass_object)?;
let class_proto = class_object.allocate_prototype(activation, superclass_object)?; let class_proto = class_object.allocate_prototype(activation, superclass_object)?;
@ -159,7 +159,7 @@ impl<'gc> ClassObject<'gc> {
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
class: GcCell<'gc, Class<'gc>>, class: GcCell<'gc, Class<'gc>>,
superclass_object: Option<ClassObject<'gc>>, superclass_object: Option<ClassObject<'gc>>,
) -> Result<Self, Error> { ) -> Result<Self, Error<'gc>> {
let scope = activation.create_scopechain(); let scope = activation.create_scopechain();
if let Some(base_class) = superclass_object.map(|b| b.inner_class_definition()) { if let Some(base_class) = superclass_object.map(|b| b.inner_class_definition()) {
if base_class.read().is_final() { if base_class.read().is_final() {
@ -239,7 +239,7 @@ impl<'gc> ClassObject<'gc> {
pub fn into_finished_class( pub fn into_finished_class(
mut self, mut self,
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
) -> Result<Self, Error> { ) -> Result<Self, Error<'gc>> {
let class = self.inner_class_definition(); let class = self.inner_class_definition();
self.instance_of().ok_or( self.instance_of().ok_or(
"Cannot finish initialization of core class without it being linked to a type!", "Cannot finish initialization of core class without it being linked to a type!",
@ -282,7 +282,7 @@ impl<'gc> ClassObject<'gc> {
self, self,
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
class_proto: Object<'gc>, class_proto: Object<'gc>,
) -> Result<(), Error> { ) -> Result<(), Error<'gc>> {
self.0.write(activation.context.gc_context).prototype = Some(class_proto); self.0.write(activation.context.gc_context).prototype = Some(class_proto);
class_proto.set_property_local( class_proto.set_property_local(
&Multiname::public("constructor"), &Multiname::public("constructor"),
@ -303,7 +303,10 @@ impl<'gc> ClassObject<'gc> {
/// This should be done after all instance traits has been resolved, as /// This should be done after all instance traits has been resolved, as
/// instance traits will be resolved to their corresponding methods at this /// instance traits will be resolved to their corresponding methods at this
/// time. /// time.
pub fn link_interfaces(self, activation: &mut Activation<'_, 'gc, '_>) -> Result<(), Error> { pub fn link_interfaces(
self,
activation: &mut Activation<'_, 'gc, '_>,
) -> Result<(), Error<'gc>> {
let mut write = self.0.write(activation.context.gc_context); let mut write = self.0.write(activation.context.gc_context);
let class = write.class; let class = write.class;
let scope = write.class_scope; let scope = write.class_scope;
@ -392,7 +395,7 @@ impl<'gc> ClassObject<'gc> {
pub fn run_class_initializer( pub fn run_class_initializer(
self, self,
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
) -> Result<(), Error> { ) -> Result<(), Error<'gc>> {
let object: Object<'gc> = self.into(); let object: Object<'gc> = self.into();
let scope = self.0.read().class_scope; let scope = self.0.read().class_scope;
@ -466,7 +469,7 @@ impl<'gc> ClassObject<'gc> {
receiver: Option<Object<'gc>>, receiver: Option<Object<'gc>>,
arguments: &[Value<'gc>], arguments: &[Value<'gc>],
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
let scope = self.0.read().instance_scope; let scope = self.0.read().instance_scope;
let constructor = let constructor =
Executable::from_method(self.0.read().constructor.clone(), scope, None, Some(self)); Executable::from_method(self.0.read().constructor.clone(), scope, None, Some(self));
@ -484,7 +487,7 @@ impl<'gc> ClassObject<'gc> {
receiver: Option<Object<'gc>>, receiver: Option<Object<'gc>>,
arguments: &[Value<'gc>], arguments: &[Value<'gc>],
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
let scope = self.0.read().instance_scope; let scope = self.0.read().instance_scope;
let constructor = Executable::from_method( let constructor = Executable::from_method(
self.0.read().native_constructor.clone(), self.0.read().native_constructor.clone(),
@ -526,7 +529,7 @@ impl<'gc> ClassObject<'gc> {
reciever: Object<'gc>, reciever: Object<'gc>,
arguments: &[Value<'gc>], arguments: &[Value<'gc>],
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
let property = self.instance_vtable().get_trait(multiname); let property = self.instance_vtable().get_trait(multiname);
if property.is_none() { if property.is_none() {
return Err(format!( return Err(format!(
@ -585,7 +588,7 @@ impl<'gc> ClassObject<'gc> {
multiname: &Multiname<'gc>, multiname: &Multiname<'gc>,
reciever: Object<'gc>, reciever: Object<'gc>,
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
let property = self.instance_vtable().get_trait(multiname); let property = self.instance_vtable().get_trait(multiname);
if property.is_none() { if property.is_none() {
return Err(format!( return Err(format!(
@ -649,7 +652,7 @@ impl<'gc> ClassObject<'gc> {
value: Value<'gc>, value: Value<'gc>,
mut reciever: Object<'gc>, mut reciever: Object<'gc>,
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
) -> Result<(), Error> { ) -> Result<(), Error<'gc>> {
let property = self.instance_vtable().get_trait(multiname); let property = self.instance_vtable().get_trait(multiname);
if property.is_none() { if property.is_none() {
return Err(format!( return Err(format!(
@ -773,7 +776,10 @@ impl<'gc> TObject<'gc> for ClassObject<'gc> {
self.0.as_ptr() as *const ObjectPtr self.0.as_ptr() as *const ObjectPtr
} }
fn to_string(&self, activation: &mut Activation<'_, 'gc, '_>) -> Result<Value<'gc>, Error> { fn to_string(
&self,
activation: &mut Activation<'_, 'gc, '_>,
) -> Result<Value<'gc>, Error<'gc>> {
Ok(AvmString::new_utf8( Ok(AvmString::new_utf8(
activation.context.gc_context, activation.context.gc_context,
format!("[class {}]", self.0.read().class.read().name().local_name()), format!("[class {}]", self.0.read().class.read().name().local_name()),
@ -784,11 +790,11 @@ impl<'gc> TObject<'gc> for ClassObject<'gc> {
fn to_locale_string( fn to_locale_string(
&self, &self,
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
self.to_string(activation) self.to_string(activation)
} }
fn value_of(&self, _mc: MutationContext<'gc, '_>) -> Result<Value<'gc>, Error> { fn value_of(&self, _mc: MutationContext<'gc, '_>) -> Result<Value<'gc>, Error<'gc>> {
Ok(Value::Object(Object::from(*self))) Ok(Value::Object(Object::from(*self)))
} }
@ -797,7 +803,7 @@ impl<'gc> TObject<'gc> for ClassObject<'gc> {
receiver: Option<Object<'gc>>, receiver: Option<Object<'gc>>,
arguments: &[Value<'gc>], arguments: &[Value<'gc>],
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if let Some(call_handler) = self.0.read().call_handler.clone() { if let Some(call_handler) = self.0.read().call_handler.clone() {
let scope = self.0.read().class_scope; let scope = self.0.read().class_scope;
let func = Executable::from_method(call_handler, scope, None, Some(self)); let func = Executable::from_method(call_handler, scope, None, Some(self));
@ -816,7 +822,7 @@ impl<'gc> TObject<'gc> for ClassObject<'gc> {
self, self,
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
arguments: &[Value<'gc>], arguments: &[Value<'gc>],
) -> Result<Object<'gc>, Error> { ) -> Result<Object<'gc>, Error<'gc>> {
let instance_allocator = self.0.read().instance_allocator.0; let instance_allocator = self.0.read().instance_allocator.0;
let mut instance = instance_allocator(self, activation)?; let mut instance = instance_allocator(self, activation)?;
@ -854,7 +860,7 @@ impl<'gc> TObject<'gc> for ClassObject<'gc> {
&self, &self,
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
nullable_params: &[Value<'gc>], nullable_params: &[Value<'gc>],
) -> Result<ClassObject<'gc>, Error> { ) -> Result<ClassObject<'gc>, Error<'gc>> {
let self_class = self.inner_class_definition(); let self_class = self.inner_class_definition();
if !self_class.read().is_generic() { if !self_class.read().is_generic() {

View File

@ -11,7 +11,7 @@ use std::cell::{Ref, RefMut};
pub fn date_allocator<'gc>( pub fn date_allocator<'gc>(
class: ClassObject<'gc>, class: ClassObject<'gc>,
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
) -> Result<Object<'gc>, Error> { ) -> Result<Object<'gc>, Error<'gc>> {
let base = ScriptObjectData::new(class); let base = ScriptObjectData::new(class);
Ok(DateObject(GcCell::allocate( Ok(DateObject(GcCell::allocate(
@ -64,7 +64,7 @@ impl<'gc> TObject<'gc> for DateObject<'gc> {
self.0.as_ptr() as *const ObjectPtr self.0.as_ptr() as *const ObjectPtr
} }
fn value_of(&self, _mc: MutationContext<'gc, '_>) -> Result<Value<'gc>, Error> { fn value_of(&self, _mc: MutationContext<'gc, '_>) -> Result<Value<'gc>, Error<'gc>> {
if let Some(date) = self.date_time() { if let Some(date) = self.date_time() {
Ok((date.timestamp_millis() as f64).into()) Ok((date.timestamp_millis() as f64).into())
} else { } else {

View File

@ -14,7 +14,7 @@ use std::cell::{Ref, RefMut};
pub fn dictionary_allocator<'gc>( pub fn dictionary_allocator<'gc>(
class: ClassObject<'gc>, class: ClassObject<'gc>,
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
) -> Result<Object<'gc>, Error> { ) -> Result<Object<'gc>, Error<'gc>> {
let base = ScriptObjectData::new(class); let base = ScriptObjectData::new(class);
Ok(DictionaryObject(GcCell::allocate( Ok(DictionaryObject(GcCell::allocate(
@ -90,7 +90,7 @@ impl<'gc> TObject<'gc> for DictionaryObject<'gc> {
self.0.as_ptr() as *const ObjectPtr self.0.as_ptr() as *const ObjectPtr
} }
fn value_of(&self, _mc: MutationContext<'gc, '_>) -> Result<Value<'gc>, Error> { fn value_of(&self, _mc: MutationContext<'gc, '_>) -> Result<Value<'gc>, Error<'gc>> {
Ok(Object::from(*self).into()) Ok(Object::from(*self).into())
} }
@ -102,7 +102,7 @@ impl<'gc> TObject<'gc> for DictionaryObject<'gc> {
self, self,
last_index: u32, last_index: u32,
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
) -> Result<Option<u32>, Error> { ) -> Result<Option<u32>, Error<'gc>> {
let read = self.0.read(); let read = self.0.read();
let num_enumerants = read.base.num_enumerants(); let num_enumerants = read.base.num_enumerants();
let object_space_length = read.object_space.keys().len() as u32; let object_space_length = read.object_space.keys().len() as u32;
@ -118,7 +118,7 @@ impl<'gc> TObject<'gc> for DictionaryObject<'gc> {
self, self,
index: u32, index: u32,
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
let read = self.0.read(); let read = self.0.read();
let object_space_len = read.object_space.keys().len() as u32; let object_space_len = read.object_space.keys().len() as u32;
if object_space_len >= index { if object_space_len >= index {

View File

@ -82,11 +82,11 @@ impl<'gc> TObject<'gc> for DispatchObject<'gc> {
self, self,
_activation: &mut Activation<'_, 'gc, '_>, _activation: &mut Activation<'_, 'gc, '_>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Object<'gc>, Error> { ) -> Result<Object<'gc>, Error<'gc>> {
Err("Cannot construct internal event dispatcher structures.".into()) Err("Cannot construct internal event dispatcher structures.".into())
} }
fn value_of(&self, _mc: MutationContext<'gc, '_>) -> Result<Value<'gc>, Error> { fn value_of(&self, _mc: MutationContext<'gc, '_>) -> Result<Value<'gc>, Error<'gc>> {
Err("Cannot subclass internal event dispatcher structures.".into()) Err("Cannot subclass internal event dispatcher structures.".into())
} }

View File

@ -13,7 +13,7 @@ use std::cell::{Ref, RefMut};
pub fn appdomain_allocator<'gc>( pub fn appdomain_allocator<'gc>(
class: ClassObject<'gc>, class: ClassObject<'gc>,
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
) -> Result<Object<'gc>, Error> { ) -> Result<Object<'gc>, Error<'gc>> {
let domain = activation.domain(); let domain = activation.domain();
let base = ScriptObjectData::new(class); let base = ScriptObjectData::new(class);
@ -46,7 +46,7 @@ impl<'gc> DomainObject<'gc> {
pub fn from_domain( pub fn from_domain(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
domain: Domain<'gc>, domain: Domain<'gc>,
) -> Result<Object<'gc>, Error> { ) -> Result<Object<'gc>, Error<'gc>> {
let class = activation.avm2().classes().application_domain; let class = activation.avm2().classes().application_domain;
let base = ScriptObjectData::new(class); let base = ScriptObjectData::new(class);
let mut this: Object<'gc> = DomainObject(GcCell::allocate( let mut this: Object<'gc> = DomainObject(GcCell::allocate(
@ -79,7 +79,7 @@ impl<'gc> TObject<'gc> for DomainObject<'gc> {
Some(self.0.read().domain) Some(self.0.read().domain)
} }
fn value_of(&self, _mc: MutationContext<'gc, '_>) -> Result<Value<'gc>, Error> { fn value_of(&self, _mc: MutationContext<'gc, '_>) -> Result<Value<'gc>, Error<'gc>> {
let this: Object<'gc> = Object::DomainObject(*self); let this: Object<'gc> = Object::DomainObject(*self);
Ok(this.into()) Ok(this.into())

View File

@ -17,7 +17,7 @@ use std::cell::{Ref, RefMut};
pub fn error_allocator<'gc>( pub fn error_allocator<'gc>(
class: ClassObject<'gc>, class: ClassObject<'gc>,
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
) -> Result<Object<'gc>, Error> { ) -> Result<Object<'gc>, Error<'gc>> {
let base = ScriptObjectData::new(class); let base = ScriptObjectData::new(class);
Ok(ErrorObject(GcCell::allocate( Ok(ErrorObject(GcCell::allocate(
@ -49,7 +49,7 @@ impl<'gc> ErrorObject<'gc> {
pub fn display( pub fn display(
&self, &self,
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
) -> Result<AvmString<'gc>, Error> { ) -> Result<AvmString<'gc>, Error<'gc>> {
let name = self let name = self
.get_property(&Multiname::public("name"), activation)? .get_property(&Multiname::public("name"), activation)?
.coerce_to_string(activation)?; .coerce_to_string(activation)?;
@ -70,7 +70,7 @@ impl<'gc> ErrorObject<'gc> {
pub fn display_full( pub fn display_full(
&self, &self,
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
) -> Result<AvmString<'gc>, Error> { ) -> Result<AvmString<'gc>, Error<'gc>> {
let mut output = WString::new(); let mut output = WString::new();
output.push_str(&self.display(activation)?); output.push_str(&self.display(activation)?);
self.call_stack().display(&mut output); self.call_stack().display(&mut output);
@ -96,11 +96,14 @@ impl<'gc> TObject<'gc> for ErrorObject<'gc> {
self.0.as_ptr() as *const ObjectPtr self.0.as_ptr() as *const ObjectPtr
} }
fn value_of(&self, _mc: MutationContext<'gc, '_>) -> Result<Value<'gc>, Error> { fn value_of(&self, _mc: MutationContext<'gc, '_>) -> Result<Value<'gc>, Error<'gc>> {
Ok(Value::Object(Object::from(*self))) Ok(Value::Object(Object::from(*self)))
} }
fn to_string(&self, activation: &mut Activation<'_, 'gc, '_>) -> Result<Value<'gc>, Error> { fn to_string(
&self,
activation: &mut Activation<'_, 'gc, '_>,
) -> Result<Value<'gc>, Error<'gc>> {
Ok(self.display(activation)?.into()) Ok(self.display(activation)?.into())
} }

View File

@ -19,7 +19,7 @@ use std::fmt::Debug;
pub fn event_allocator<'gc>( pub fn event_allocator<'gc>(
class: ClassObject<'gc>, class: ClassObject<'gc>,
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
) -> Result<Object<'gc>, Error> { ) -> Result<Object<'gc>, Error<'gc>> {
let base = ScriptObjectData::new(class); let base = ScriptObjectData::new(class);
Ok(EventObject(GcCell::allocate( Ok(EventObject(GcCell::allocate(
@ -157,7 +157,7 @@ impl<'gc> TObject<'gc> for EventObject<'gc> {
self.0.as_ptr() as *const ObjectPtr self.0.as_ptr() as *const ObjectPtr
} }
fn value_of(&self, _mc: MutationContext<'gc, '_>) -> Result<Value<'gc>, Error> { fn value_of(&self, _mc: MutationContext<'gc, '_>) -> Result<Value<'gc>, Error<'gc>> {
Ok(Value::Object((*self).into())) Ok(Value::Object((*self).into()))
} }

View File

@ -38,7 +38,7 @@ impl<'gc> FunctionObject<'gc> {
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
method: Method<'gc>, method: Method<'gc>,
scope: ScopeChain<'gc>, scope: ScopeChain<'gc>,
) -> Result<FunctionObject<'gc>, Error> { ) -> Result<FunctionObject<'gc>, Error<'gc>> {
let this = Self::from_method(activation, method, scope, None, None); let this = Self::from_method(activation, method, scope, None, None);
let es3_proto = ScriptObject::custom_object( let es3_proto = ScriptObject::custom_object(
activation.context.gc_context, activation.context.gc_context,
@ -99,18 +99,21 @@ impl<'gc> TObject<'gc> for FunctionObject<'gc> {
self.0.as_ptr() as *const ObjectPtr self.0.as_ptr() as *const ObjectPtr
} }
fn to_string(&self, _activation: &mut Activation<'_, 'gc, '_>) -> Result<Value<'gc>, Error> { fn to_string(
&self,
_activation: &mut Activation<'_, 'gc, '_>,
) -> Result<Value<'gc>, Error<'gc>> {
Ok("function Function() {}".into()) Ok("function Function() {}".into())
} }
fn to_locale_string( fn to_locale_string(
&self, &self,
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
self.to_string(activation) self.to_string(activation)
} }
fn value_of(&self, _mc: MutationContext<'gc, '_>) -> Result<Value<'gc>, Error> { fn value_of(&self, _mc: MutationContext<'gc, '_>) -> Result<Value<'gc>, Error<'gc>> {
Ok(Value::Object(Object::from(*self))) Ok(Value::Object(Object::from(*self)))
} }
@ -127,7 +130,7 @@ impl<'gc> TObject<'gc> for FunctionObject<'gc> {
receiver: Option<Object<'gc>>, receiver: Option<Object<'gc>>,
arguments: &[Value<'gc>], arguments: &[Value<'gc>],
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
self.0 self.0
.read() .read()
.exec .exec
@ -138,7 +141,7 @@ impl<'gc> TObject<'gc> for FunctionObject<'gc> {
self, self,
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
arguments: &[Value<'gc>], arguments: &[Value<'gc>],
) -> Result<Object<'gc>, Error> { ) -> Result<Object<'gc>, Error<'gc>> {
let prototype = self.prototype().unwrap(); let prototype = self.prototype().unwrap();
let instance = let instance =

View File

@ -18,7 +18,7 @@ use std::sync::Arc;
pub fn loaderinfo_allocator<'gc>( pub fn loaderinfo_allocator<'gc>(
class: ClassObject<'gc>, class: ClassObject<'gc>,
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
) -> Result<Object<'gc>, Error> { ) -> Result<Object<'gc>, Error<'gc>> {
let base = ScriptObjectData::new(class); let base = ScriptObjectData::new(class);
Ok(LoaderInfoObject(GcCell::allocate( Ok(LoaderInfoObject(GcCell::allocate(
@ -87,7 +87,7 @@ impl<'gc> LoaderInfoObject<'gc> {
movie: Arc<SwfMovie>, movie: Arc<SwfMovie>,
root: DisplayObject<'gc>, root: DisplayObject<'gc>,
loader: Option<Object<'gc>>, loader: Option<Object<'gc>>,
) -> Result<Object<'gc>, Error> { ) -> Result<Object<'gc>, Error<'gc>> {
let class = activation.avm2().classes().loaderinfo; let class = activation.avm2().classes().loaderinfo;
let base = ScriptObjectData::new(class); let base = ScriptObjectData::new(class);
let loaded_stream = Some(LoaderStream::Swf(movie, root)); let loaded_stream = Some(LoaderStream::Swf(movie, root));
@ -120,7 +120,7 @@ impl<'gc> LoaderInfoObject<'gc> {
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
movie: Arc<SwfMovie>, movie: Arc<SwfMovie>,
loader: Option<Object<'gc>>, loader: Option<Object<'gc>>,
) -> Result<Object<'gc>, Error> { ) -> Result<Object<'gc>, Error<'gc>> {
let class = activation.avm2().classes().loaderinfo; let class = activation.avm2().classes().loaderinfo;
let base = ScriptObjectData::new(class); let base = ScriptObjectData::new(class);
@ -210,7 +210,7 @@ impl<'gc> TObject<'gc> for LoaderInfoObject<'gc> {
self.0.as_ptr() as *const ObjectPtr self.0.as_ptr() as *const ObjectPtr
} }
fn value_of(&self, _mc: MutationContext<'gc, '_>) -> Result<Value<'gc>, Error> { fn value_of(&self, _mc: MutationContext<'gc, '_>) -> Result<Value<'gc>, Error<'gc>> {
Ok(Value::Object((*self).into())) Ok(Value::Object((*self).into()))
} }

View File

@ -13,7 +13,7 @@ use std::cell::{Ref, RefMut};
pub fn namespace_allocator<'gc>( pub fn namespace_allocator<'gc>(
class: ClassObject<'gc>, class: ClassObject<'gc>,
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
) -> Result<Object<'gc>, Error> { ) -> Result<Object<'gc>, Error<'gc>> {
let base = ScriptObjectData::new(class); let base = ScriptObjectData::new(class);
Ok(NamespaceObject(GcCell::allocate( Ok(NamespaceObject(GcCell::allocate(
@ -46,7 +46,7 @@ impl<'gc> NamespaceObject<'gc> {
pub fn from_namespace( pub fn from_namespace(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
namespace: Namespace<'gc>, namespace: Namespace<'gc>,
) -> Result<Object<'gc>, Error> { ) -> Result<Object<'gc>, Error<'gc>> {
let class = activation.avm2().classes().namespace; let class = activation.avm2().classes().namespace;
let base = ScriptObjectData::new(class); let base = ScriptObjectData::new(class);
@ -76,11 +76,14 @@ impl<'gc> TObject<'gc> for NamespaceObject<'gc> {
self.0.as_ptr() as *const ObjectPtr self.0.as_ptr() as *const ObjectPtr
} }
fn to_string(&self, _activation: &mut Activation<'_, 'gc, '_>) -> Result<Value<'gc>, Error> { fn to_string(
&self,
_activation: &mut Activation<'_, 'gc, '_>,
) -> Result<Value<'gc>, Error<'gc>> {
Ok(self.0.read().namespace.as_uri().into()) Ok(self.0.read().namespace.as_uri().into())
} }
fn value_of(&self, _mc: MutationContext<'gc, '_>) -> Result<Value<'gc>, Error> { fn value_of(&self, _mc: MutationContext<'gc, '_>) -> Result<Value<'gc>, Error<'gc>> {
Ok(self.0.read().namespace.as_uri().into()) Ok(self.0.read().namespace.as_uri().into())
} }

View File

@ -14,7 +14,7 @@ use gc_arena::{Collect, GcCell, MutationContext};
pub fn primitive_allocator<'gc>( pub fn primitive_allocator<'gc>(
class: ClassObject<'gc>, class: ClassObject<'gc>,
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
) -> Result<Object<'gc>, Error> { ) -> Result<Object<'gc>, Error<'gc>> {
let base = ScriptObjectData::new(class); let base = ScriptObjectData::new(class);
Ok(PrimitiveObject(GcCell::allocate( Ok(PrimitiveObject(GcCell::allocate(
@ -53,7 +53,7 @@ impl<'gc> PrimitiveObject<'gc> {
pub fn from_primitive( pub fn from_primitive(
primitive: Value<'gc>, primitive: Value<'gc>,
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
) -> Result<Object<'gc>, Error> { ) -> Result<Object<'gc>, Error<'gc>> {
if !primitive.is_primitive() { if !primitive.is_primitive() {
return Err("Attempted to box an object as a primitive".into()); return Err("Attempted to box an object as a primitive".into());
} }
@ -102,14 +102,17 @@ impl<'gc> TObject<'gc> for PrimitiveObject<'gc> {
self.0.as_ptr() as *const ObjectPtr self.0.as_ptr() as *const ObjectPtr
} }
fn to_string(&self, _activation: &mut Activation<'_, 'gc, '_>) -> Result<Value<'gc>, Error> { fn to_string(
&self,
_activation: &mut Activation<'_, 'gc, '_>,
) -> Result<Value<'gc>, Error<'gc>> {
Ok(self.0.read().primitive) Ok(self.0.read().primitive)
} }
fn to_locale_string( fn to_locale_string(
&self, &self,
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
match self.0.read().primitive { match self.0.read().primitive {
val @ Value::Integer(_) => Ok(val), val @ Value::Integer(_) => Ok(val),
_ => { _ => {
@ -127,7 +130,7 @@ impl<'gc> TObject<'gc> for PrimitiveObject<'gc> {
} }
} }
fn value_of(&self, _mc: MutationContext<'gc, '_>) -> Result<Value<'gc>, Error> { fn value_of(&self, _mc: MutationContext<'gc, '_>) -> Result<Value<'gc>, Error<'gc>> {
Ok(self.0.read().primitive) Ok(self.0.read().primitive)
} }

View File

@ -16,7 +16,7 @@ use std::cell::{Ref, RefMut};
pub fn proxy_allocator<'gc>( pub fn proxy_allocator<'gc>(
class: ClassObject<'gc>, class: ClassObject<'gc>,
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
) -> Result<Object<'gc>, Error> { ) -> Result<Object<'gc>, Error<'gc>> {
let base = ScriptObjectData::new(class); let base = ScriptObjectData::new(class);
Ok(ProxyObject(GcCell::allocate( Ok(ProxyObject(GcCell::allocate(
@ -50,7 +50,7 @@ impl<'gc> TObject<'gc> for ProxyObject<'gc> {
self.0.as_ptr() as *const ObjectPtr self.0.as_ptr() as *const ObjectPtr
} }
fn value_of(&self, _mc: MutationContext<'gc, '_>) -> Result<Value<'gc>, Error> { fn value_of(&self, _mc: MutationContext<'gc, '_>) -> Result<Value<'gc>, Error<'gc>> {
Ok(Object::from(*self).into()) Ok(Object::from(*self).into())
} }
@ -58,7 +58,7 @@ impl<'gc> TObject<'gc> for ProxyObject<'gc> {
self, self,
multiname: &Multiname<'gc>, multiname: &Multiname<'gc>,
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
// NOTE: This is incorrect behavior. // NOTE: This is incorrect behavior.
// `QName` should instead store the whole multiname's namespace set, // `QName` should instead store the whole multiname's namespace set,
// so that it can be used to index other objects using the same // so that it can be used to index other objects using the same
@ -94,7 +94,7 @@ impl<'gc> TObject<'gc> for ProxyObject<'gc> {
multiname: &Multiname<'gc>, multiname: &Multiname<'gc>,
value: Value<'gc>, value: Value<'gc>,
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
) -> Result<(), Error> { ) -> Result<(), Error<'gc>> {
// NOTE: This is incorrect behavior. // NOTE: This is incorrect behavior.
// `QName` should instead store the whole multiname's namespace set, // `QName` should instead store the whole multiname's namespace set,
// so that it can be used to index other objects using the same // so that it can be used to index other objects using the same
@ -121,7 +121,7 @@ impl<'gc> TObject<'gc> for ProxyObject<'gc> {
.map(|c| c.read().is_sealed()) .map(|c| c.read().is_sealed())
.unwrap_or(false) .unwrap_or(false)
{ {
let local_name: Result<AvmString<'gc>, Error> = multiname let local_name: Result<AvmString<'gc>, Error<'gc>> = multiname
.local_name() .local_name()
.ok_or_else(|| "Cannot set undefined property using any name".into()); .ok_or_else(|| "Cannot set undefined property using any name".into());
let _ = local_name?; let _ = local_name?;
@ -136,7 +136,7 @@ impl<'gc> TObject<'gc> for ProxyObject<'gc> {
multiname: &Multiname<'gc>, multiname: &Multiname<'gc>,
arguments: &[Value<'gc>], arguments: &[Value<'gc>],
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
// NOTE: This is incorrect behavior. // NOTE: This is incorrect behavior.
// `QName` should instead store the whole multiname's namespace set, // `QName` should instead store the whole multiname's namespace set,
// so that it can be used to index other objects using the same // so that it can be used to index other objects using the same
@ -173,7 +173,7 @@ impl<'gc> TObject<'gc> for ProxyObject<'gc> {
self, self,
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
multiname: &Multiname<'gc>, multiname: &Multiname<'gc>,
) -> Result<bool, Error> { ) -> Result<bool, Error<'gc>> {
// NOTE: This is incorrect behavior. // NOTE: This is incorrect behavior.
// `QName` should instead store the whole multiname's namespace set, // `QName` should instead store the whole multiname's namespace set,
// so that it can be used to index other objects using the same // so that it can be used to index other objects using the same
@ -209,7 +209,7 @@ impl<'gc> TObject<'gc> for ProxyObject<'gc> {
self, self,
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
name: &Multiname<'gc>, name: &Multiname<'gc>,
) -> Result<bool, Error> { ) -> Result<bool, Error<'gc>> {
Ok(self Ok(self
.call_property( .call_property(
&Multiname::new(Namespace::Namespace(NS_FLASH_PROXY.into()), "hasProperty"), &Multiname::new(Namespace::Namespace(NS_FLASH_PROXY.into()), "hasProperty"),
@ -224,7 +224,7 @@ impl<'gc> TObject<'gc> for ProxyObject<'gc> {
self, self,
last_index: u32, last_index: u32,
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
) -> Result<Option<u32>, Error> { ) -> Result<Option<u32>, Error<'gc>> {
Ok(Some( Ok(Some(
self.call_property( self.call_property(
&Multiname::new(Namespace::Namespace(NS_FLASH_PROXY.into()), "nextNameIndex"), &Multiname::new(Namespace::Namespace(NS_FLASH_PROXY.into()), "nextNameIndex"),
@ -239,7 +239,7 @@ impl<'gc> TObject<'gc> for ProxyObject<'gc> {
self, self,
index: u32, index: u32,
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
self.call_property( self.call_property(
&Multiname::new(Namespace::Namespace(NS_FLASH_PROXY.into()), "nextName"), &Multiname::new(Namespace::Namespace(NS_FLASH_PROXY.into()), "nextName"),
&[index.into()], &[index.into()],
@ -251,7 +251,7 @@ impl<'gc> TObject<'gc> for ProxyObject<'gc> {
self, self,
index: u32, index: u32,
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
self.call_property( self.call_property(
&Multiname::new(Namespace::Namespace(NS_FLASH_PROXY.into()), "nextValue"), &Multiname::new(Namespace::Namespace(NS_FLASH_PROXY.into()), "nextValue"),
&[index.into()], &[index.into()],

View File

@ -13,7 +13,7 @@ use std::cell::{Ref, RefMut};
pub fn qname_allocator<'gc>( pub fn qname_allocator<'gc>(
class: ClassObject<'gc>, class: ClassObject<'gc>,
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
) -> Result<Object<'gc>, Error> { ) -> Result<Object<'gc>, Error<'gc>> {
let base = ScriptObjectData::new(class); let base = ScriptObjectData::new(class);
Ok(QNameObject(GcCell::allocate( Ok(QNameObject(GcCell::allocate(
@ -43,7 +43,7 @@ impl<'gc> QNameObject<'gc> {
pub fn from_qname( pub fn from_qname(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
qname: QName<'gc>, qname: QName<'gc>,
) -> Result<Object<'gc>, Error> { ) -> Result<Object<'gc>, Error<'gc>> {
let class = activation.avm2().classes().qname; let class = activation.avm2().classes().qname;
let base = ScriptObjectData::new(class); let base = ScriptObjectData::new(class);
@ -87,7 +87,7 @@ impl<'gc> TObject<'gc> for QNameObject<'gc> {
self.0.as_ptr() as *const ObjectPtr self.0.as_ptr() as *const ObjectPtr
} }
fn value_of(&self, _mc: MutationContext<'gc, '_>) -> Result<Value<'gc>, Error> { fn value_of(&self, _mc: MutationContext<'gc, '_>) -> Result<Value<'gc>, Error<'gc>> {
Ok(Value::Object(Object::from(*self))) Ok(Value::Object(Object::from(*self)))
} }

View File

@ -14,7 +14,7 @@ use std::cell::{Ref, RefMut};
pub fn regexp_allocator<'gc>( pub fn regexp_allocator<'gc>(
class: ClassObject<'gc>, class: ClassObject<'gc>,
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
) -> Result<Object<'gc>, Error> { ) -> Result<Object<'gc>, Error<'gc>> {
let base = ScriptObjectData::new(class); let base = ScriptObjectData::new(class);
Ok(RegExpObject(GcCell::allocate( Ok(RegExpObject(GcCell::allocate(
@ -44,7 +44,7 @@ impl<'gc> RegExpObject<'gc> {
pub fn from_regexp( pub fn from_regexp(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
regexp: RegExp<'gc>, regexp: RegExp<'gc>,
) -> Result<Object<'gc>, Error> { ) -> Result<Object<'gc>, Error<'gc>> {
let class = activation.avm2().classes().regexp; let class = activation.avm2().classes().regexp;
let base = ScriptObjectData::new(class); let base = ScriptObjectData::new(class);
@ -74,11 +74,14 @@ impl<'gc> TObject<'gc> for RegExpObject<'gc> {
self.0.as_ptr() as *const ObjectPtr self.0.as_ptr() as *const ObjectPtr
} }
fn to_string(&self, _activation: &mut Activation<'_, 'gc, '_>) -> Result<Value<'gc>, Error> { fn to_string(
&self,
_activation: &mut Activation<'_, 'gc, '_>,
) -> Result<Value<'gc>, Error<'gc>> {
Ok(Value::Object(Object::from(*self))) Ok(Value::Object(Object::from(*self)))
} }
fn value_of(&self, mc: MutationContext<'gc, '_>) -> Result<Value<'gc>, Error> { fn value_of(&self, mc: MutationContext<'gc, '_>) -> Result<Value<'gc>, Error<'gc>> {
let read = self.0.read(); let read = self.0.read();
let mut s = WString::new(); let mut s = WString::new();
s.push_byte(b'/'); s.push_byte(b'/');

View File

@ -17,7 +17,7 @@ use std::fmt::Debug;
pub fn scriptobject_allocator<'gc>( pub fn scriptobject_allocator<'gc>(
class: ClassObject<'gc>, class: ClassObject<'gc>,
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
) -> Result<Object<'gc>, Error> { ) -> Result<Object<'gc>, Error<'gc>> {
let base = ScriptObjectData::new(class); let base = ScriptObjectData::new(class);
Ok(ScriptObject(GcCell::allocate(activation.context.gc_context, base)).into()) Ok(ScriptObject(GcCell::allocate(activation.context.gc_context, base)).into())
@ -72,7 +72,7 @@ impl<'gc> TObject<'gc> for ScriptObject<'gc> {
self.0.as_ptr() as *const ObjectPtr self.0.as_ptr() as *const ObjectPtr
} }
fn value_of(&self, _mc: MutationContext<'gc, '_>) -> Result<Value<'gc>, Error> { fn value_of(&self, _mc: MutationContext<'gc, '_>) -> Result<Value<'gc>, Error<'gc>> {
Ok(Value::Object(Object::from(*self))) Ok(Value::Object(Object::from(*self)))
} }
} }
@ -145,7 +145,7 @@ impl<'gc> ScriptObjectData<'gc> {
&self, &self,
multiname: &Multiname<'gc>, multiname: &Multiname<'gc>,
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
) -> Result<Value<'gc>, Error> { ) -> Result<Value<'gc>, Error<'gc>> {
if !multiname.contains_public_namespace() { if !multiname.contains_public_namespace() {
return Err(format!( return Err(format!(
"Non-public property {} not found on Object", "Non-public property {} not found on Object",
@ -205,7 +205,7 @@ impl<'gc> ScriptObjectData<'gc> {
multiname: &Multiname<'gc>, multiname: &Multiname<'gc>,
value: Value<'gc>, value: Value<'gc>,
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
) -> Result<(), Error> { ) -> Result<(), Error<'gc>> {
if self if self
.instance_of() .instance_of()
.map(|cls| cls.inner_class_definition().read().is_sealed()) .map(|cls| cls.inner_class_definition().read().is_sealed())
@ -257,7 +257,7 @@ impl<'gc> ScriptObjectData<'gc> {
multiname: &Multiname<'gc>, multiname: &Multiname<'gc>,
value: Value<'gc>, value: Value<'gc>,
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
) -> Result<(), Error> { ) -> Result<(), Error<'gc>> {
self.set_property_local(multiname, value, activation) self.set_property_local(multiname, value, activation)
} }
@ -274,7 +274,7 @@ impl<'gc> ScriptObjectData<'gc> {
} }
} }
pub fn get_slot(&self, id: u32) -> Result<Value<'gc>, Error> { pub fn get_slot(&self, id: u32) -> Result<Value<'gc>, Error<'gc>> {
self.slots self.slots
.get(id as usize) .get(id as usize)
.cloned() .cloned()
@ -287,7 +287,7 @@ impl<'gc> ScriptObjectData<'gc> {
id: u32, id: u32,
value: Value<'gc>, value: Value<'gc>,
_mc: MutationContext<'gc, '_>, _mc: MutationContext<'gc, '_>,
) -> Result<(), Error> { ) -> Result<(), Error<'gc>> {
if let Some(slot) = self.slots.get_mut(id as usize) { if let Some(slot) = self.slots.get_mut(id as usize) {
*slot = value; *slot = value;
Ok(()) Ok(())
@ -302,7 +302,7 @@ impl<'gc> ScriptObjectData<'gc> {
id: u32, id: u32,
value: Value<'gc>, value: Value<'gc>,
_mc: MutationContext<'gc, '_>, _mc: MutationContext<'gc, '_>,
) -> Result<(), Error> { ) -> Result<(), Error<'gc>> {
if let Some(slot) = self.slots.get_mut(id as usize) { if let Some(slot) = self.slots.get_mut(id as usize) {
*slot = value; *slot = value;
Ok(()) Ok(())

View File

@ -13,7 +13,7 @@ use std::cell::{Ref, RefMut};
pub fn sound_allocator<'gc>( pub fn sound_allocator<'gc>(
class: ClassObject<'gc>, class: ClassObject<'gc>,
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
) -> Result<Object<'gc>, Error> { ) -> Result<Object<'gc>, Error<'gc>> {
let base = ScriptObjectData::new(class); let base = ScriptObjectData::new(class);
Ok(SoundObject(GcCell::allocate( Ok(SoundObject(GcCell::allocate(
@ -48,7 +48,7 @@ impl<'gc> SoundObject<'gc> {
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
class: ClassObject<'gc>, class: ClassObject<'gc>,
sound: SoundHandle, sound: SoundHandle,
) -> Result<Object<'gc>, Error> { ) -> Result<Object<'gc>, Error<'gc>> {
let base = ScriptObjectData::new(class); let base = ScriptObjectData::new(class);
let mut sound_object: Object<'gc> = SoundObject(GcCell::allocate( let mut sound_object: Object<'gc> = SoundObject(GcCell::allocate(
@ -80,7 +80,7 @@ impl<'gc> TObject<'gc> for SoundObject<'gc> {
self.0.as_ptr() as *const ObjectPtr self.0.as_ptr() as *const ObjectPtr
} }
fn value_of(&self, _mc: MutationContext<'gc, '_>) -> Result<Value<'gc>, Error> { fn value_of(&self, _mc: MutationContext<'gc, '_>) -> Result<Value<'gc>, Error<'gc>> {
Ok(Object::from(*self).into()) Ok(Object::from(*self).into())
} }

View File

@ -13,7 +13,7 @@ use std::cell::{Ref, RefMut};
pub fn soundchannel_allocator<'gc>( pub fn soundchannel_allocator<'gc>(
class: ClassObject<'gc>, class: ClassObject<'gc>,
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
) -> Result<Object<'gc>, Error> { ) -> Result<Object<'gc>, Error<'gc>> {
let base = ScriptObjectData::new(class); let base = ScriptObjectData::new(class);
Ok(SoundChannelObject(GcCell::allocate( Ok(SoundChannelObject(GcCell::allocate(
@ -50,7 +50,7 @@ impl<'gc> SoundChannelObject<'gc> {
pub fn from_sound_instance( pub fn from_sound_instance(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
sound: SoundInstanceHandle, sound: SoundInstanceHandle,
) -> Result<Self, Error> { ) -> Result<Self, Error<'gc>> {
let class = activation.avm2().classes().soundchannel; let class = activation.avm2().classes().soundchannel;
let base = ScriptObjectData::new(class); let base = ScriptObjectData::new(class);
@ -94,7 +94,7 @@ impl<'gc> TObject<'gc> for SoundChannelObject<'gc> {
RefMut::map(self.0.write(mc), |write| &mut write.base) RefMut::map(self.0.write(mc), |write| &mut write.base)
} }
fn value_of(&self, _mc: MutationContext<'gc, '_>) -> Result<Value<'gc>, Error> { fn value_of(&self, _mc: MutationContext<'gc, '_>) -> Result<Value<'gc>, Error<'gc>> {
Ok(Object::from(*self).into()) Ok(Object::from(*self).into())
} }

View File

@ -14,7 +14,7 @@ use std::fmt::Debug;
pub fn stage_allocator<'gc>( pub fn stage_allocator<'gc>(
class: ClassObject<'gc>, class: ClassObject<'gc>,
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
) -> Result<Object<'gc>, Error> { ) -> Result<Object<'gc>, Error<'gc>> {
let base = ScriptObjectData::new(class); let base = ScriptObjectData::new(class);
Ok(StageObject(GcCell::allocate( Ok(StageObject(GcCell::allocate(
@ -56,7 +56,7 @@ impl<'gc> StageObject<'gc> {
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
display_object: DisplayObject<'gc>, display_object: DisplayObject<'gc>,
class: ClassObject<'gc>, class: ClassObject<'gc>,
) -> Result<Self, Error> { ) -> Result<Self, Error<'gc>> {
let mut instance = Self(GcCell::allocate( let mut instance = Self(GcCell::allocate(
activation.context.gc_context, activation.context.gc_context,
StageObjectData { StageObjectData {
@ -78,7 +78,7 @@ impl<'gc> StageObject<'gc> {
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
display_object: DisplayObject<'gc>, display_object: DisplayObject<'gc>,
class: ClassObject<'gc>, class: ClassObject<'gc>,
) -> Result<Self, Error> { ) -> Result<Self, Error<'gc>> {
let this = Self::for_display_object(activation, display_object, class)?; let this = Self::for_display_object(activation, display_object, class)?;
class.call_native_init(Some(this.into()), &[], activation)?; class.call_native_init(Some(this.into()), &[], activation)?;
@ -90,7 +90,7 @@ impl<'gc> StageObject<'gc> {
pub fn graphics( pub fn graphics(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
display_object: DisplayObject<'gc>, display_object: DisplayObject<'gc>,
) -> Result<Self, Error> { ) -> Result<Self, Error<'gc>> {
let class = activation.avm2().classes().graphics; let class = activation.avm2().classes().graphics;
let mut this = Self(GcCell::allocate( let mut this = Self(GcCell::allocate(
activation.context.gc_context, activation.context.gc_context,
@ -128,7 +128,7 @@ impl<'gc> TObject<'gc> for StageObject<'gc> {
self.0.write(mc).display_object = Some(obj); self.0.write(mc).display_object = Some(obj);
} }
fn value_of(&self, _mc: MutationContext<'gc, '_>) -> Result<Value<'gc>, Error> { fn value_of(&self, _mc: MutationContext<'gc, '_>) -> Result<Value<'gc>, Error<'gc>> {
Ok(Value::Object(Object::from(*self))) Ok(Value::Object(Object::from(*self)))
} }
} }

View File

@ -13,7 +13,7 @@ use std::cell::{Ref, RefMut};
pub fn textformat_allocator<'gc>( pub fn textformat_allocator<'gc>(
class: ClassObject<'gc>, class: ClassObject<'gc>,
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
) -> Result<Object<'gc>, Error> { ) -> Result<Object<'gc>, Error<'gc>> {
let base = ScriptObjectData::new(class); let base = ScriptObjectData::new(class);
Ok(TextFormatObject(GcCell::allocate( Ok(TextFormatObject(GcCell::allocate(
@ -43,7 +43,7 @@ impl<'gc> TextFormatObject<'gc> {
pub fn from_text_format( pub fn from_text_format(
activation: &mut Activation<'_, 'gc, '_>, activation: &mut Activation<'_, 'gc, '_>,
text_format: TextFormat, text_format: TextFormat,
) -> Result<Object<'gc>, Error> { ) -> Result<Object<'gc>, Error<'gc>> {
let class = activation.avm2().classes().textformat; let class = activation.avm2().classes().textformat;
let base = ScriptObjectData::new(class); let base = ScriptObjectData::new(class);
@ -71,7 +71,7 @@ impl<'gc> TObject<'gc> for TextFormatObject<'gc> {
self.0.as_ptr() as *const ObjectPtr self.0.as_ptr() as *const ObjectPtr
} }
fn value_of(&self, _mc: MutationContext<'gc, '_>) -> Result<Value<'gc>, Error> { fn value_of(&self, _mc: MutationContext<'gc, '_>) -> Result<Value<'gc>, Error<'gc>> {
Ok(Value::Object(Object::from(*self))) Ok(Value::Object(Object::from(*self)))
} }

Some files were not shown because too many files have changed in this diff Show More