avm2: Add 'gc lifetime parameter to avm2::Error
This commit is contained in:
parent
b1760063ec
commit
3e65a554fa
|
@ -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
|
||||
/// 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.
|
||||
#[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 mut activation = Activation::from_nothing(context.reborrow());
|
||||
globals::load_player_globals(&mut activation, globals)
|
||||
|
@ -141,7 +141,7 @@ impl<'gc> Avm2<'gc> {
|
|||
pub fn run_script_initializer(
|
||||
script: Script<'gc>,
|
||||
context: &mut UpdateContext<'_, 'gc, '_>,
|
||||
) -> Result<(), Error> {
|
||||
) -> Result<(), Error<'gc>> {
|
||||
let mut init_activation = Activation::from_script(context.reborrow(), script)?;
|
||||
|
||||
let (method, scope, _domain) = script.init();
|
||||
|
@ -185,7 +185,7 @@ impl<'gc> Avm2<'gc> {
|
|||
context: &mut UpdateContext<'_, 'gc, '_>,
|
||||
event: Object<'gc>,
|
||||
target: Object<'gc>,
|
||||
) -> Result<bool, Error> {
|
||||
) -> Result<bool, Error<'gc>> {
|
||||
use crate::avm2::events::dispatch_event;
|
||||
let mut activation = Activation::from_nothing(context.reborrow());
|
||||
dispatch_event(&mut activation, target, event)
|
||||
|
@ -234,7 +234,7 @@ impl<'gc> Avm2<'gc> {
|
|||
context: &mut UpdateContext<'_, 'gc, '_>,
|
||||
event: Object<'gc>,
|
||||
on_type: ClassObject<'gc>,
|
||||
) -> Result<(), Error> {
|
||||
) -> Result<(), Error<'gc>> {
|
||||
let base_event = event.as_event().unwrap(); // TODO: unwrap?
|
||||
let event_name = base_event.event_type();
|
||||
drop(base_event);
|
||||
|
@ -278,7 +278,7 @@ impl<'gc> Avm2<'gc> {
|
|||
reciever: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
context: &mut UpdateContext<'_, 'gc, '_>,
|
||||
) -> Result<(), Error> {
|
||||
) -> Result<(), Error<'gc>> {
|
||||
let mut evt_activation = Activation::from_nothing(context.reborrow());
|
||||
callable.call(reciever, args, &mut evt_activation)?;
|
||||
|
||||
|
@ -290,7 +290,7 @@ impl<'gc> Avm2<'gc> {
|
|||
context: &mut UpdateContext<'_, 'gc, '_>,
|
||||
do_abc: DoAbc,
|
||||
domain: Domain<'gc>,
|
||||
) -> Result<(), Error> {
|
||||
) -> Result<(), Error<'gc>> {
|
||||
let mut read = Reader::new(do_abc.data);
|
||||
|
||||
let abc_file = Rc::new(read.read()?);
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -91,7 +91,7 @@ pub fn recursive_serialize<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
obj: Object<'gc>,
|
||||
elements: &mut Vec<Element>,
|
||||
) -> Result<(), Error> {
|
||||
) -> Result<(), Error<'gc>> {
|
||||
let mut last_index = obj.get_next_enumerant(0, activation)?;
|
||||
while let Some(index) = last_index {
|
||||
let name = obj
|
||||
|
@ -111,7 +111,7 @@ pub fn recursive_serialize<'gc>(
|
|||
pub fn deserialize_value<'gc>(
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
val: &AmfValue,
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Ok(match val {
|
||||
AmfValue::Null => Value::Null,
|
||||
AmfValue::Undefined => Value::Undefined,
|
||||
|
@ -215,7 +215,7 @@ pub fn deserialize_value<'gc>(
|
|||
pub fn deserialize_lso<'gc>(
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
lso: &Lso,
|
||||
) -> Result<Object<'gc>, Error> {
|
||||
) -> Result<Object<'gc>, Error<'gc>> {
|
||||
let mut obj = activation
|
||||
.avm2()
|
||||
.classes()
|
||||
|
|
|
@ -96,14 +96,14 @@ impl ByteArrayStorage {
|
|||
|
||||
/// Write bytes at the next position in the ByteArray, growing if needed.
|
||||
#[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.position.set(self.position.get() + buf.len());
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[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.position.set(self.position.get() + amnt);
|
||||
Ok(())
|
||||
|
@ -111,7 +111,7 @@ impl ByteArrayStorage {
|
|||
|
||||
/// Reads any amount of bytes from the current position in the ByteArray
|
||||
#[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())?;
|
||||
self.position.set(self.position.get() + amnt);
|
||||
Ok(bytes)
|
||||
|
@ -119,7 +119,7 @@ impl ByteArrayStorage {
|
|||
|
||||
/// Reads any amount of bytes at any offset in the ByteArray
|
||||
#[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
|
||||
.get(offset..)
|
||||
.and_then(|bytes| bytes.get(..amnt))
|
||||
|
@ -128,7 +128,7 @@ impl ByteArrayStorage {
|
|||
|
||||
/// Write bytes at any offset in the ByteArray
|
||||
/// 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
|
||||
.checked_add(buf.len())
|
||||
.ok_or("RangeError: Cannot overflow usize")?;
|
||||
|
@ -144,7 +144,11 @@ impl ByteArrayStorage {
|
|||
|
||||
/// Write bytes at any offset in 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
|
||||
.get_mut(offset..)
|
||||
.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.
|
||||
/// Will automatically grow the ByteArray to fit the new buffer
|
||||
pub fn write_at_within(
|
||||
pub fn write_at_within<'gc>(
|
||||
&mut self,
|
||||
start: usize,
|
||||
amnt: usize,
|
||||
offset: usize,
|
||||
) -> Result<(), Error> {
|
||||
) -> Result<(), Error<'gc>> {
|
||||
// First verify that reading from `start` to `amnt` is valid
|
||||
let end = start
|
||||
.checked_add(amnt)
|
||||
|
@ -180,7 +184,10 @@ impl ByteArrayStorage {
|
|||
}
|
||||
|
||||
/// 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();
|
||||
match algorithm {
|
||||
CompressionAlgorithm::Zlib => {
|
||||
|
@ -202,7 +209,10 @@ impl ByteArrayStorage {
|
|||
}
|
||||
|
||||
/// 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();
|
||||
match algorithm {
|
||||
CompressionAlgorithm::Zlib => {
|
||||
|
@ -223,22 +233,22 @@ impl ByteArrayStorage {
|
|||
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 val = self.read_bytes(len.into())?;
|
||||
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])
|
||||
}
|
||||
|
||||
pub fn read_boolean(&self) -> Result<bool, Error> {
|
||||
pub fn read_boolean<'gc>(&self) -> Result<bool, Error<'gc>> {
|
||||
Ok(self.read_bytes(1)? != [0])
|
||||
}
|
||||
|
||||
// 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()) {
|
||||
self.write_unsigned_short(str_size)?;
|
||||
self.write_bytes(utf_string.as_bytes())
|
||||
|
@ -393,7 +403,7 @@ macro_rules! impl_write{
|
|||
=>
|
||||
{
|
||||
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 {
|
||||
Endian::Big => val.to_be_bytes(),
|
||||
Endian::Little => val.to_le_bytes(),
|
||||
|
@ -409,7 +419,7 @@ macro_rules! impl_read{
|
|||
=>
|
||||
{
|
||||
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 {
|
||||
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())
|
||||
|
|
|
@ -77,7 +77,7 @@ macro_rules! define_indirect_properties {
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>]
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
use crate::avm2::Multiname;
|
||||
use crate::avm2::globals::NS_RUFFLE_INTERNAL;
|
||||
|
||||
|
@ -121,7 +121,7 @@ pub(crate) use define_indirect_properties;
|
|||
/// read for traits).
|
||||
/// * `activation` - The current AVM2 activation.
|
||||
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)]
|
||||
#[collect(require_static)]
|
||||
|
@ -303,15 +303,15 @@ impl<'gc> Class<'gc> {
|
|||
unit: TranslationUnit<'gc>,
|
||||
class_index: u32,
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
) -> Result<GcCell<'gc, Self>, Error> {
|
||||
) -> Result<GcCell<'gc, Self>, Error<'gc>> {
|
||||
let abc = unit.abc();
|
||||
let abc_class: Result<&AbcClass, Error> = abc
|
||||
let abc_class: Result<&AbcClass, Error<'gc>> = abc
|
||||
.classes
|
||||
.get(class_index as usize)
|
||||
.ok_or_else(|| "LoadError: Class index not valid".into());
|
||||
let abc_class = abc_class?;
|
||||
|
||||
let abc_instance: Result<&AbcInstance, Error> = abc
|
||||
let abc_instance: Result<&AbcInstance, Error<'gc>> = abc
|
||||
.instances
|
||||
.get(class_index as usize)
|
||||
.ok_or_else(|| "LoadError: Instance index not valid".into());
|
||||
|
@ -406,7 +406,7 @@ impl<'gc> Class<'gc> {
|
|||
unit: TranslationUnit<'gc>,
|
||||
class_index: u32,
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
) -> Result<(), Error> {
|
||||
) -> Result<(), Error<'gc>> {
|
||||
if self.traits_loaded {
|
||||
return Ok(());
|
||||
}
|
||||
|
@ -414,13 +414,13 @@ impl<'gc> Class<'gc> {
|
|||
self.traits_loaded = true;
|
||||
|
||||
let abc = unit.abc();
|
||||
let abc_class: Result<&AbcClass, Error> = abc
|
||||
let abc_class: Result<&AbcClass, Error<'gc>> = abc
|
||||
.classes
|
||||
.get(class_index as usize)
|
||||
.ok_or_else(|| "LoadError: Class index not valid".into());
|
||||
let abc_class = abc_class?;
|
||||
|
||||
let abc_instance: Result<&AbcInstance, Error> = abc
|
||||
let abc_instance: Result<&AbcInstance, Error<'gc>> = abc
|
||||
.instances
|
||||
.get(class_index as usize)
|
||||
.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
|
||||
/// has been resolved. It will return Ok for a valid class, and a
|
||||
/// 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.
|
||||
if self.is_system {
|
||||
return Ok(());
|
||||
|
@ -513,7 +513,7 @@ impl<'gc> Class<'gc> {
|
|||
translation_unit: TranslationUnit<'gc>,
|
||||
method: &AbcMethod,
|
||||
body: &AbcMethodBody,
|
||||
) -> Result<GcCell<'gc, Self>, Error> {
|
||||
) -> Result<GcCell<'gc, Self>, Error<'gc>> {
|
||||
let name =
|
||||
translation_unit.pool_string(method.name.as_u30(), activation.context.gc_context)?;
|
||||
let mut traits = Vec::with_capacity(body.traits.len());
|
||||
|
|
|
@ -107,7 +107,7 @@ impl<'gc> Domain<'gc> {
|
|||
pub fn get_defining_script(
|
||||
self,
|
||||
multiname: &Multiname<'gc>,
|
||||
) -> Result<Option<(QName<'gc>, Script<'gc>)>, Error> {
|
||||
) -> Result<Option<(QName<'gc>, Script<'gc>)>, Error<'gc>> {
|
||||
let read = self.0.read();
|
||||
|
||||
if let Some(name) = multiname.local_name() {
|
||||
|
@ -129,7 +129,7 @@ impl<'gc> Domain<'gc> {
|
|||
self,
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
name: QName<'gc>,
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
let (name, mut script) = self
|
||||
.get_defining_script(&name.into())?
|
||||
.ok_or_else(|| format!("MovieClip Symbol {} does not exist", name.local_name()))?;
|
||||
|
@ -147,7 +147,7 @@ impl<'gc> Domain<'gc> {
|
|||
name: QName<'gc>,
|
||||
script: Script<'gc>,
|
||||
mc: MutationContext<'gc, '_>,
|
||||
) -> Result<(), Error> {
|
||||
) -> Result<(), Error<'gc>> {
|
||||
if self.has_definition(name) {
|
||||
return Err(format!(
|
||||
"VerifyError: Attempted to redefine existing name {}",
|
||||
|
@ -185,7 +185,7 @@ impl<'gc> Domain<'gc> {
|
|||
pub fn init_default_domain_memory(
|
||||
self,
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
) -> Result<(), Error> {
|
||||
) -> Result<(), Error<'gc>> {
|
||||
let bytearray_class = activation.avm2().classes().bytearray;
|
||||
|
||||
let domain_memory = bytearray_class.construct(activation, &[])?;
|
||||
|
|
|
@ -372,7 +372,7 @@ pub fn dispatch_event_to_target<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
target: Object<'gc>,
|
||||
event: Object<'gc>,
|
||||
) -> Result<(), Error> {
|
||||
) -> Result<(), Error<'gc>> {
|
||||
avm_debug!(
|
||||
activation.context.avm2,
|
||||
"Event dispatch: {} to {:?}",
|
||||
|
@ -435,7 +435,7 @@ pub fn dispatch_event<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Object<'gc>,
|
||||
event: Object<'gc>,
|
||||
) -> Result<bool, Error> {
|
||||
) -> Result<bool, Error<'gc>> {
|
||||
let target = this
|
||||
.get_property(
|
||||
&Multiname::new(Namespace::private(NS_EVENT_DISPATCHER), "target"),
|
||||
|
|
|
@ -108,7 +108,7 @@ impl<'gc> Executable<'gc> {
|
|||
mut arguments: &[Value<'gc>],
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
callee: Object<'gc>,
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
let ret = match self {
|
||||
Executable::Native(bm) => {
|
||||
let method = bm.method.method;
|
||||
|
|
|
@ -186,7 +186,7 @@ fn function<'gc>(
|
|||
name: &'static str,
|
||||
nf: NativeMethodImpl,
|
||||
script: Script<'gc>,
|
||||
) -> Result<(), Error> {
|
||||
) -> Result<(), Error<'gc>> {
|
||||
let (_, mut global, mut domain) = script.init();
|
||||
let mc = activation.context.gc_context;
|
||||
let scope = activation.create_scopechain();
|
||||
|
@ -209,7 +209,7 @@ fn dynamic_class<'gc>(
|
|||
script: Script<'gc>,
|
||||
// The `ClassObject` of the `Class` class
|
||||
class_class: ClassObject<'gc>,
|
||||
) -> Result<(), Error> {
|
||||
) -> Result<(), Error<'gc>> {
|
||||
let (_, mut global, mut domain) = script.init();
|
||||
let class = class_object.inner_class_definition();
|
||||
let name = class.read().name();
|
||||
|
@ -226,12 +226,12 @@ fn class<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
class_def: GcCell<'gc, Class<'gc>>,
|
||||
script: Script<'gc>,
|
||||
) -> Result<ClassObject<'gc>, Error> {
|
||||
) -> Result<ClassObject<'gc>, Error<'gc>> {
|
||||
let (_, mut global, mut domain) = script.init();
|
||||
|
||||
let class_read = class_def.read();
|
||||
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)
|
||||
.ok()
|
||||
.and_then(|v| v)
|
||||
|
@ -278,7 +278,7 @@ fn constant<'gc>(
|
|||
value: Value<'gc>,
|
||||
script: Script<'gc>,
|
||||
class: ClassObject<'gc>,
|
||||
) -> Result<(), Error> {
|
||||
) -> Result<(), Error<'gc>> {
|
||||
let (_, mut global, mut domain) = script.init();
|
||||
let name = QName::new(Namespace::package(package), name);
|
||||
domain.export_definition(name, script, mc)?;
|
||||
|
@ -293,7 +293,7 @@ fn namespace<'gc>(
|
|||
name: impl Into<AvmString<'gc>>,
|
||||
uri: impl Into<AvmString<'gc>>,
|
||||
script: Script<'gc>,
|
||||
) -> Result<(), Error> {
|
||||
) -> Result<(), Error<'gc>> {
|
||||
let namespace = NamespaceObject::from_namespace(activation, Namespace::Namespace(uri.into()))?;
|
||||
constant(
|
||||
activation.context.gc_context,
|
||||
|
@ -323,7 +323,7 @@ macro_rules! avm2_system_class {
|
|||
pub fn load_player_globals<'gc>(
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
domain: Domain<'gc>,
|
||||
) -> Result<(), Error> {
|
||||
) -> Result<(), Error<'gc>> {
|
||||
let mc = activation.context.gc_context;
|
||||
|
||||
let globals = ScriptObject::custom_object(activation.context.gc_context, None, None);
|
||||
|
@ -657,7 +657,7 @@ mod native {
|
|||
fn load_playerglobal<'gc>(
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
domain: Domain<'gc>,
|
||||
) -> Result<(), Error> {
|
||||
) -> Result<(), Error<'gc>> {
|
||||
activation.avm2().native_method_table = native::NATIVE_METHOD_TABLE;
|
||||
activation.avm2().native_instance_allocator_table = native::NATIVE_INSTANCE_ALLOCATOR_TABLE;
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ pub fn instance_init<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
activation.super_init(this, &[])?;
|
||||
|
||||
|
@ -55,7 +55,7 @@ pub fn class_init<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Ok(Value::Undefined)
|
||||
}
|
||||
|
||||
|
@ -64,7 +64,7 @@ pub fn length<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(array) = this.as_array_storage() {
|
||||
return Ok(array.length().into());
|
||||
|
@ -79,7 +79,7 @@ pub fn set_length<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(mut array) = this.as_array_storage_mut(activation.context.gc_context) {
|
||||
let size = args
|
||||
|
@ -97,7 +97,7 @@ pub fn set_length<'gc>(
|
|||
pub fn build_array<'gc>(
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
array: ArrayStorage<'gc>,
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Ok(ArrayObject::from_storage(activation, array)?.into())
|
||||
}
|
||||
|
||||
|
@ -107,7 +107,7 @@ pub fn concat<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
let mut base_array = this
|
||||
.and_then(|this| this.as_array_storage().map(|a| a.clone()))
|
||||
.unwrap_or_else(|| ArrayStorage::new(0));
|
||||
|
@ -129,7 +129,7 @@ pub fn resolve_array_hole<'gc>(
|
|||
this: Object<'gc>,
|
||||
i: usize,
|
||||
item: Option<Value<'gc>>,
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
item.map(Ok).unwrap_or_else(|| {
|
||||
this.proto()
|
||||
.map(|p| {
|
||||
|
@ -150,9 +150,12 @@ pub fn join_inner<'gc, 'a, 'ctxt, C>(
|
|||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
mut conv: C,
|
||||
) -> Result<Value<'gc>, Error>
|
||||
) -> Result<Value<'gc>, Error<'gc>>
|
||||
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);
|
||||
if separator == Value::Undefined {
|
||||
|
@ -190,7 +193,7 @@ pub fn join<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
join_inner(activation, this, args, |v, _act| Ok(v))
|
||||
}
|
||||
|
||||
|
@ -199,7 +202,7 @@ pub fn to_string<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
join_inner(activation, this, &[",".into()], |v, _act| Ok(v))
|
||||
}
|
||||
|
||||
|
@ -208,7 +211,7 @@ pub fn to_locale_string<'gc>(
|
|||
act: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
join_inner(act, this, &[",".into()], |v, activation| {
|
||||
if let Ok(o) = v.coerce_to_object(activation) {
|
||||
o.call_property(&Multiname::public("toLocaleString"), &[], activation)
|
||||
|
@ -223,7 +226,7 @@ pub fn value_of<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
join_inner(activation, this, &[",".into()], |v, _act| Ok(v))
|
||||
}
|
||||
|
||||
|
@ -256,7 +259,7 @@ impl<'gc> ArrayIter<'gc> {
|
|||
pub fn new(
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
array_object: Object<'gc>,
|
||||
) -> Result<Self, Error> {
|
||||
) -> Result<Self, Error<'gc>> {
|
||||
Self::with_bounds(activation, array_object, 0, u32::MAX)
|
||||
}
|
||||
|
||||
|
@ -266,7 +269,7 @@ impl<'gc> ArrayIter<'gc> {
|
|||
array_object: Object<'gc>,
|
||||
start_index: u32,
|
||||
end_index: u32,
|
||||
) -> Result<Self, Error> {
|
||||
) -> Result<Self, Error<'gc>> {
|
||||
let length = array_object
|
||||
.get_property(&Multiname::public("length"), activation)?
|
||||
.coerce_to_u32(activation)?;
|
||||
|
@ -285,7 +288,7 @@ impl<'gc> ArrayIter<'gc> {
|
|||
pub fn next(
|
||||
&mut self,
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
) -> Option<Result<(u32, Value<'gc>), Error>> {
|
||||
) -> Option<Result<(u32, Value<'gc>), Error<'gc>>> {
|
||||
if self.index < self.rev_index {
|
||||
let i = self.index;
|
||||
|
||||
|
@ -314,7 +317,7 @@ impl<'gc> ArrayIter<'gc> {
|
|||
pub fn next_back(
|
||||
&mut self,
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
) -> Option<Result<(u32, Value<'gc>), Error>> {
|
||||
) -> Option<Result<(u32, Value<'gc>), Error<'gc>>> {
|
||||
if self.index < self.rev_index {
|
||||
self.rev_index -= 1;
|
||||
|
||||
|
@ -342,7 +345,7 @@ pub fn for_each<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
let callback = args
|
||||
.get(0)
|
||||
|
@ -367,7 +370,7 @@ pub fn map<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
let callback = args
|
||||
.get(0)
|
||||
|
@ -396,7 +399,7 @@ pub fn filter<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
let callback = args
|
||||
.get(0)
|
||||
|
@ -429,7 +432,7 @@ pub fn every<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
let callback = args
|
||||
.get(0)
|
||||
|
@ -462,7 +465,7 @@ pub fn some<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
let callback = args
|
||||
.get(0)
|
||||
|
@ -495,7 +498,7 @@ pub fn index_of<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(array) = this.as_array_storage() {
|
||||
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, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(array) = this.as_array_storage() {
|
||||
let search_val = args.get(0).cloned().unwrap_or(Value::Undefined);
|
||||
|
@ -553,7 +556,7 @@ pub fn pop<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(mut array) = this.as_array_storage_mut(activation.context.gc_context) {
|
||||
return Ok(array.pop());
|
||||
|
@ -568,7 +571,7 @@ pub fn push<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(mut array) = this.as_array_storage_mut(activation.context.gc_context) {
|
||||
for arg in args {
|
||||
|
@ -584,7 +587,7 @@ pub fn reverse<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(mut array) = this.as_array_storage_mut(activation.context.gc_context) {
|
||||
let mut last_non_hole_index = None;
|
||||
|
@ -622,7 +625,7 @@ pub fn shift<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(mut array) = this.as_array_storage_mut(activation.context.gc_context) {
|
||||
return Ok(array.shift());
|
||||
|
@ -637,7 +640,7 @@ pub fn unshift<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(mut array) = this.as_array_storage_mut(activation.context.gc_context) {
|
||||
for arg in args.iter().rev() {
|
||||
|
@ -654,7 +657,7 @@ pub fn resolve_index<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
index: Value<'gc>,
|
||||
length: usize,
|
||||
) -> Result<usize, Error> {
|
||||
) -> Result<usize, Error<'gc>> {
|
||||
let index = index.coerce_to_i32(activation)?;
|
||||
|
||||
Ok(if index < 0 {
|
||||
|
@ -670,7 +673,7 @@ pub fn slice<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
let array_length = this.as_array_storage().map(|a| a.length());
|
||||
|
||||
|
@ -711,7 +714,7 @@ pub fn splice<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
let array_length = this.as_array_storage().map(|a| a.length());
|
||||
|
||||
|
@ -786,7 +789,11 @@ bitflags! {
|
|||
/// the HRTB necessary to accept an activation.
|
||||
fn constrain<'a, 'gc, 'ctxt, F>(f: F) -> F
|
||||
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
|
||||
}
|
||||
|
@ -809,9 +816,13 @@ fn sort_inner<'a, 'gc, 'ctxt, C>(
|
|||
values: &mut [(usize, Value<'gc>)],
|
||||
options: SortOptions,
|
||||
mut sort_func: C,
|
||||
) -> Result<bool, Error>
|
||||
) -> Result<bool, Error<'gc>>
|
||||
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 error_signal = Ok(());
|
||||
|
@ -852,7 +863,7 @@ pub fn compare_string_case_sensitive<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
a: Value<'gc>,
|
||||
b: Value<'gc>,
|
||||
) -> Result<Ordering, Error> {
|
||||
) -> Result<Ordering, Error<'gc>> {
|
||||
let string_a = a.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, '_>,
|
||||
a: Value<'gc>,
|
||||
b: Value<'gc>,
|
||||
) -> Result<Ordering, Error> {
|
||||
) -> Result<Ordering, Error<'gc>> {
|
||||
let string_a = a.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, '_>,
|
||||
a: Value<'gc>,
|
||||
b: Value<'gc>,
|
||||
) -> Result<Ordering, Error> {
|
||||
) -> Result<Ordering, Error<'gc>> {
|
||||
let num_a = a.coerce_to_number(activation)?;
|
||||
let num_b = b.coerce_to_number(activation)?;
|
||||
|
||||
|
@ -896,7 +907,7 @@ fn sort_postprocess<'gc>(
|
|||
options: SortOptions,
|
||||
unique_satisfied: bool,
|
||||
values: Vec<(usize, Value<'gc>)>,
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if unique_satisfied {
|
||||
if options.contains(SortOptions::RETURN_INDEXED_ARRAY) {
|
||||
return build_array(
|
||||
|
@ -938,7 +949,7 @@ fn sort_postprocess<'gc>(
|
|||
fn extract_array_values<'gc>(
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
value: Value<'gc>,
|
||||
) -> Result<Option<Vec<Value<'gc>>>, Error> {
|
||||
) -> Result<Option<Vec<Value<'gc>>>, Error<'gc>> {
|
||||
let object = value.as_object();
|
||||
let holey_vec = if let Some(object) = object {
|
||||
if let Some(field_array) = object.as_array_storage() {
|
||||
|
@ -963,7 +974,7 @@ pub fn sort<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
let (compare_fnc, options) = if args.len() > 1 {
|
||||
(
|
||||
|
@ -1053,7 +1064,7 @@ pub fn sort<'gc>(
|
|||
fn extract_maybe_array_values<'gc>(
|
||||
activation: &mut Activation<'_, '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]))
|
||||
}
|
||||
|
||||
|
@ -1066,7 +1077,7 @@ fn extract_maybe_array_values<'gc>(
|
|||
fn extract_maybe_array_strings<'gc>(
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
value: Value<'gc>,
|
||||
) -> Result<Vec<AvmString<'gc>>, Error> {
|
||||
) -> Result<Vec<AvmString<'gc>>, Error<'gc>> {
|
||||
let values = extract_maybe_array_values(activation, value)?;
|
||||
|
||||
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>(
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
value: Value<'gc>,
|
||||
) -> Result<Vec<SortOptions>, Error> {
|
||||
) -> Result<Vec<SortOptions>, Error<'gc>> {
|
||||
let values = extract_maybe_array_values(activation, value)?;
|
||||
|
||||
let mut out = Vec::with_capacity(values.len());
|
||||
|
@ -1102,7 +1113,7 @@ pub fn sort_on<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(field_names_value) = args.get(0).cloned() {
|
||||
let field_names = extract_maybe_array_strings(activation, field_names_value)?;
|
||||
|
|
|
@ -16,7 +16,7 @@ fn instance_init<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(mut prim) = this.as_primitive_mut(activation.context.gc_context) {
|
||||
if matches!(*prim, Value::Undefined | Value::Null) {
|
||||
|
@ -38,7 +38,7 @@ fn native_instance_init<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
activation.super_init(this, args)?;
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ fn class_init<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
let scope = activation.create_scopechain();
|
||||
let gc_context = activation.context.gc_context;
|
||||
|
@ -94,7 +94,7 @@ fn to_string<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(this) = this.as_primitive() {
|
||||
match *this {
|
||||
|
@ -113,7 +113,7 @@ fn value_of<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(this) = this.as_primitive() {
|
||||
return Ok(*this);
|
||||
|
|
|
@ -19,7 +19,7 @@ pub fn instance_init<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Err("Classes cannot be constructed.".into())
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,7 @@ pub fn class_init<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Ok(Value::Undefined)
|
||||
}
|
||||
|
||||
|
@ -36,7 +36,7 @@ fn prototype<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(class) = this.as_class_object() {
|
||||
return Ok(class.prototype().into());
|
||||
|
|
|
@ -106,7 +106,7 @@ impl<'builder, 'activation_a, 'gc, 'gc_context, T: TimeZone>
|
|||
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 {
|
||||
Some(value) => Some(Some(value.coerce_to_number(self.activation)?)),
|
||||
None => None,
|
||||
|
@ -114,7 +114,7 @@ impl<'builder, 'activation_a, 'gc, 'gc_context, T: TimeZone>
|
|||
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 {
|
||||
Some(value) => Some(Some(value.coerce_to_number(self.activation)?)),
|
||||
None => None,
|
||||
|
@ -122,7 +122,7 @@ impl<'builder, 'activation_a, 'gc, 'gc_context, T: TimeZone>
|
|||
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 {
|
||||
Some(value) => Some(Some(value.coerce_to_number(self.activation)?)),
|
||||
None => None,
|
||||
|
@ -130,7 +130,7 @@ impl<'builder, 'activation_a, 'gc, 'gc_context, T: TimeZone>
|
|||
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 {
|
||||
Some(value) => Some(Some(value.coerce_to_number(self.activation)?)),
|
||||
None => None,
|
||||
|
@ -138,7 +138,7 @@ impl<'builder, 'activation_a, 'gc, 'gc_context, T: TimeZone>
|
|||
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 {
|
||||
Some(value) => Some(Some(value.coerce_to_number(self.activation)?)),
|
||||
None => None,
|
||||
|
@ -146,7 +146,7 @@ impl<'builder, 'activation_a, 'gc, 'gc_context, T: TimeZone>
|
|||
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 {
|
||||
Some(value) => Some(Some(value.coerce_to_number(self.activation)?)),
|
||||
None => None,
|
||||
|
@ -154,7 +154,7 @@ impl<'builder, 'activation_a, 'gc, 'gc_context, T: TimeZone>
|
|||
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 {
|
||||
Some(value) => Some(Some(value.coerce_to_number(self.activation)?)),
|
||||
None => None,
|
||||
|
@ -243,7 +243,7 @@ pub fn instance_init<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
activation.super_init(this, &[])?;
|
||||
if let Some(date) = this.as_date_object() {
|
||||
|
@ -296,7 +296,7 @@ pub fn class_init<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
let scope = activation.create_scopechain();
|
||||
let gc_context = activation.context.gc_context;
|
||||
|
@ -327,7 +327,7 @@ pub fn time<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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()) {
|
||||
return this.value_of(activation.context.gc_context);
|
||||
}
|
||||
|
@ -340,7 +340,7 @@ pub fn set_time<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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()) {
|
||||
let new_time = args
|
||||
.get(0)
|
||||
|
@ -364,7 +364,7 @@ pub fn milliseconds<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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(date) = this
|
||||
.date_time()
|
||||
|
@ -384,7 +384,7 @@ pub fn set_milliseconds<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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()) {
|
||||
let timestamp = DateAdjustment::new(activation, &get_timezone())
|
||||
.millisecond(args.get(0))?
|
||||
|
@ -399,7 +399,7 @@ pub fn seconds<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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(date) = this
|
||||
.date_time()
|
||||
|
@ -419,7 +419,7 @@ pub fn set_seconds<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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()) {
|
||||
let timestamp = DateAdjustment::new(activation, &get_timezone())
|
||||
.second(args.get(0))?
|
||||
|
@ -435,7 +435,7 @@ pub fn minutes<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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(date) = this
|
||||
.date_time()
|
||||
|
@ -455,7 +455,7 @@ pub fn set_minutes<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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()) {
|
||||
let timestamp = DateAdjustment::new(activation, &get_timezone())
|
||||
.minute(args.get(0))?
|
||||
|
@ -472,7 +472,7 @@ pub fn hours<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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(date) = this
|
||||
.date_time()
|
||||
|
@ -492,7 +492,7 @@ pub fn set_hours<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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()) {
|
||||
let timestamp = DateAdjustment::new(activation, &get_timezone())
|
||||
.hour(args.get(0))?
|
||||
|
@ -510,7 +510,7 @@ pub fn date<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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(date) = this
|
||||
.date_time()
|
||||
|
@ -530,7 +530,7 @@ pub fn set_date<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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()) {
|
||||
let timestamp = DateAdjustment::new(activation, &get_timezone())
|
||||
.day(args.get(0))?
|
||||
|
@ -545,7 +545,7 @@ pub fn month<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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(date) = this
|
||||
.date_time()
|
||||
|
@ -565,7 +565,7 @@ pub fn set_month<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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()) {
|
||||
let timestamp = DateAdjustment::new(activation, &get_timezone())
|
||||
.month(args.get(0))?
|
||||
|
@ -581,7 +581,7 @@ pub fn full_year<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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(date) = this
|
||||
.date_time()
|
||||
|
@ -601,7 +601,7 @@ pub fn set_full_year<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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()) {
|
||||
let timestamp = DateAdjustment::new(activation, &get_timezone())
|
||||
.year(args.get(0))?
|
||||
|
@ -618,7 +618,7 @@ pub fn day<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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(date) = this
|
||||
.date_time()
|
||||
|
@ -638,7 +638,7 @@ pub fn milliseconds_utc<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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(date) = this.date_time() {
|
||||
return Ok((date.timestamp_subsec_millis() as f64).into());
|
||||
|
@ -655,7 +655,7 @@ pub fn set_milliseconds_utc<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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()) {
|
||||
let timestamp = DateAdjustment::new(activation, &Utc)
|
||||
.millisecond(args.get(0))?
|
||||
|
@ -670,7 +670,7 @@ pub fn seconds_utc<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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(date) = this.date_time() {
|
||||
return Ok((date.second() as f64).into());
|
||||
|
@ -687,7 +687,7 @@ pub fn set_seconds_utc<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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()) {
|
||||
let timestamp = DateAdjustment::new(activation, &Utc)
|
||||
.second(args.get(0))?
|
||||
|
@ -703,7 +703,7 @@ pub fn minutes_utc<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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(date) = this.date_time() {
|
||||
return Ok((date.minute() as f64).into());
|
||||
|
@ -720,7 +720,7 @@ pub fn set_minutes_utc<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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()) {
|
||||
let timestamp = DateAdjustment::new(activation, &Utc)
|
||||
.minute(args.get(0))?
|
||||
|
@ -737,7 +737,7 @@ pub fn hours_utc<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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(date) = this.date_time() {
|
||||
return Ok((date.hour() as f64).into());
|
||||
|
@ -754,7 +754,7 @@ pub fn set_hours_utc<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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()) {
|
||||
let timestamp = DateAdjustment::new(activation, &Utc)
|
||||
.hour(args.get(0))?
|
||||
|
@ -772,7 +772,7 @@ pub fn date_utc<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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(date) = this.date_time() {
|
||||
return Ok((date.day() as f64).into());
|
||||
|
@ -789,7 +789,7 @@ pub fn set_date_utc<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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()) {
|
||||
let timestamp = DateAdjustment::new(activation, &Utc)
|
||||
.day(args.get(0))?
|
||||
|
@ -804,7 +804,7 @@ pub fn month_utc<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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(date) = this.date_time() {
|
||||
return Ok((date.month0() as f64).into());
|
||||
|
@ -821,7 +821,7 @@ pub fn set_month_utc<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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()) {
|
||||
let timestamp = DateAdjustment::new(activation, &Utc)
|
||||
.month(args.get(0))?
|
||||
|
@ -837,7 +837,7 @@ pub fn full_year_utc<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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(date) = this.date_time() {
|
||||
return Ok((date.year() as f64).into());
|
||||
|
@ -854,7 +854,7 @@ pub fn set_full_year_utc<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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()) {
|
||||
let timestamp = DateAdjustment::new(activation, &Utc)
|
||||
.year(args.get(0))?
|
||||
|
@ -871,7 +871,7 @@ pub fn day_utc<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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(date) = this.date_time() {
|
||||
return Ok((date.weekday().num_days_from_sunday() as f64).into());
|
||||
|
@ -888,7 +888,7 @@ pub fn timezone_offset<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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(date) = this
|
||||
.date_time()
|
||||
|
@ -909,7 +909,7 @@ pub fn utc<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
let date = DateAdjustment::new(activation, &Utc)
|
||||
.year(args.get(0))?
|
||||
.month(args.get(1))?
|
||||
|
@ -934,7 +934,7 @@ pub fn to_string<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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(date) = this
|
||||
.date_time()
|
||||
|
@ -958,7 +958,7 @@ pub fn to_utc_string<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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(date) = this.date_time() {
|
||||
return Ok(AvmString::new_utf8(
|
||||
|
@ -979,7 +979,7 @@ pub fn to_locale_string<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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(date) = this
|
||||
.date_time()
|
||||
|
@ -1003,7 +1003,7 @@ pub fn to_time_string<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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(date) = this
|
||||
.date_time()
|
||||
|
@ -1027,7 +1027,7 @@ pub fn to_locale_time_string<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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(date) = this
|
||||
.date_time()
|
||||
|
@ -1051,7 +1051,7 @@ pub fn to_date_string<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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(date) = this
|
||||
.date_time()
|
||||
|
@ -1175,7 +1175,7 @@ pub fn parse<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'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"];
|
||||
|
||||
let date_str = args
|
||||
|
|
|
@ -10,7 +10,7 @@ pub fn get_stack_trace<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
use crate::avm2::TObject;
|
||||
if let Some(error) = this.and_then(|this| this.as_error_object()) {
|
||||
return Ok(error.display_full(activation)?.into());
|
||||
|
@ -23,6 +23,6 @@ pub fn get_stack_trace<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Ok(Value::Null)
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ pub fn generate_random_bytes<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
let length = args
|
||||
.get(0)
|
||||
.unwrap_or(&Value::Undefined)
|
||||
|
|
|
@ -17,7 +17,7 @@ pub fn instance_init<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(mut this) = this {
|
||||
activation.super_init(this, &[])?;
|
||||
|
||||
|
@ -96,7 +96,7 @@ pub fn class_init<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Ok(Value::Undefined)
|
||||
}
|
||||
|
||||
|
@ -105,7 +105,7 @@ pub fn bitmap_data<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(bitmap) = this
|
||||
.and_then(|this| this.as_display_object())
|
||||
.and_then(|dobj| dobj.as_bitmap())
|
||||
|
@ -124,7 +124,7 @@ pub fn set_bitmap_data<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(bitmap) = this
|
||||
.and_then(|this| this.as_display_object())
|
||||
.and_then(|dobj| dobj.as_bitmap())
|
||||
|
@ -147,7 +147,7 @@ pub fn pixel_snapping<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Ok("auto".into())
|
||||
}
|
||||
|
||||
|
@ -156,7 +156,7 @@ pub fn set_pixel_snapping<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Err("Bitmap.pixelSnapping is a stub".into())
|
||||
}
|
||||
|
||||
|
@ -165,7 +165,7 @@ pub fn smoothing<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(bitmap) = this
|
||||
.and_then(|this| this.as_display_object())
|
||||
.and_then(|dobj| dobj.as_bitmap())
|
||||
|
@ -181,7 +181,7 @@ pub fn set_smoothing<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(bitmap) = this
|
||||
.and_then(|this| this.as_display_object())
|
||||
.and_then(|dobj| dobj.as_bitmap())
|
||||
|
|
|
@ -23,7 +23,7 @@ pub fn instance_init<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
activation.super_init(this, &[])?;
|
||||
|
||||
|
@ -125,7 +125,7 @@ pub fn class_init<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Ok(Value::Undefined)
|
||||
}
|
||||
|
||||
|
@ -134,7 +134,7 @@ pub fn width<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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()) {
|
||||
bitmap_data.read().check_valid()?;
|
||||
return Ok((bitmap_data.read().width() as i32).into());
|
||||
|
@ -148,7 +148,7 @@ pub fn height<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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()) {
|
||||
bitmap_data.read().check_valid()?;
|
||||
return Ok((bitmap_data.read().height() as i32).into());
|
||||
|
@ -162,7 +162,7 @@ pub fn transparent<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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()) {
|
||||
bitmap_data.read().check_valid()?;
|
||||
return Ok(bitmap_data.read().transparency().into());
|
||||
|
@ -176,7 +176,7 @@ pub fn scroll<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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()) {
|
||||
bitmap_data.read().check_valid()?;
|
||||
let x = args
|
||||
|
@ -201,7 +201,7 @@ pub fn copy_pixels<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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()) {
|
||||
bitmap_data.read().check_valid()?;
|
||||
let source_bitmap = args
|
||||
|
@ -321,7 +321,7 @@ pub fn get_pixel<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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()) {
|
||||
bitmap_data.read().check_valid()?;
|
||||
let x = args
|
||||
|
@ -343,7 +343,7 @@ pub fn get_pixel32<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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()) {
|
||||
let x = args
|
||||
.get(0)
|
||||
|
@ -364,7 +364,7 @@ pub fn lock<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
log::warn!("BitmapData.lock - not yet implemented");
|
||||
Ok(Value::Undefined)
|
||||
}
|
||||
|
@ -374,7 +374,7 @@ pub fn draw<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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()) {
|
||||
bitmap_data.read().check_valid()?;
|
||||
let mut transform = Transform::default();
|
||||
|
@ -444,7 +444,7 @@ pub fn fill_rect<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
let rectangle = args
|
||||
.get(0)
|
||||
.unwrap_or(&Value::Undefined)
|
||||
|
@ -485,7 +485,7 @@ pub fn dispose<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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()) {
|
||||
// Don't check if we've already disposed this BitmapData - 'BitmapData.dispose()' can be called
|
||||
// multiple times
|
||||
|
@ -501,7 +501,7 @@ pub fn rect<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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()) {
|
||||
let bd = bitmap_data.read();
|
||||
return Ok(activation
|
||||
|
@ -522,7 +522,7 @@ pub fn apply_filter<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
log::warn!("BitmapData.applyFilter: Not yet implemented");
|
||||
Ok(Value::Undefined)
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ pub fn instance_init<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Err("You cannot construct DisplayObject directly.".into())
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,7 @@ pub fn native_instance_init<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
activation.super_init(this, &[])?;
|
||||
|
||||
|
@ -73,7 +73,7 @@ pub fn class_init<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Ok(Value::Undefined)
|
||||
}
|
||||
|
||||
|
@ -82,7 +82,7 @@ pub fn alpha<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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()) {
|
||||
return Ok(dobj.alpha().into());
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ pub fn set_alpha<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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()) {
|
||||
let new_alpha = args
|
||||
.get(0)
|
||||
|
@ -113,7 +113,7 @@ pub fn height<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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()) {
|
||||
return Ok(dobj.height().into());
|
||||
}
|
||||
|
@ -126,7 +126,7 @@ pub fn set_height<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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()) {
|
||||
let new_height = args
|
||||
.get(0)
|
||||
|
@ -147,7 +147,7 @@ pub fn scale_y<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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()) {
|
||||
return Ok(dobj
|
||||
.scale_y(activation.context.gc_context)
|
||||
|
@ -163,7 +163,7 @@ pub fn set_scale_y<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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()) {
|
||||
let new_scale = args
|
||||
.get(0)
|
||||
|
@ -181,7 +181,7 @@ pub fn width<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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()) {
|
||||
return Ok(dobj.width().into());
|
||||
}
|
||||
|
@ -194,7 +194,7 @@ pub fn set_width<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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()) {
|
||||
let new_width = args
|
||||
.get(0)
|
||||
|
@ -215,7 +215,7 @@ pub fn scale_x<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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()) {
|
||||
return Ok(dobj
|
||||
.scale_x(activation.context.gc_context)
|
||||
|
@ -231,7 +231,7 @@ pub fn set_scale_x<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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()) {
|
||||
let new_scale = args
|
||||
.get(0)
|
||||
|
@ -249,7 +249,7 @@ pub fn filters<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
log::warn!("DisplayObject.filters getter - not yet implemented");
|
||||
Ok(ArrayObject::empty(activation)?.into())
|
||||
}
|
||||
|
@ -259,7 +259,7 @@ pub fn set_filters<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
log::warn!("DisplayObject.filters setter - not yet implemented");
|
||||
Ok(Value::Undefined)
|
||||
}
|
||||
|
@ -269,7 +269,7 @@ pub fn x<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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()) {
|
||||
return Ok(dobj.x().into());
|
||||
}
|
||||
|
@ -282,7 +282,7 @@ pub fn set_x<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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()) {
|
||||
let new_x = args
|
||||
.get(0)
|
||||
|
@ -301,7 +301,7 @@ pub fn y<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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()) {
|
||||
return Ok(dobj.y().into());
|
||||
}
|
||||
|
@ -314,7 +314,7 @@ pub fn set_y<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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()) {
|
||||
let new_y = args
|
||||
.get(0)
|
||||
|
@ -333,7 +333,7 @@ pub fn rotation<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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()) {
|
||||
let rot: f64 = dobj.rotation(activation.context.gc_context).into();
|
||||
let rem = rot % 360.0;
|
||||
|
@ -353,7 +353,7 @@ pub fn set_rotation<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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()) {
|
||||
let new_rotation = args
|
||||
.get(0)
|
||||
|
@ -372,7 +372,7 @@ pub fn name<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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()) {
|
||||
return Ok(dobj.name().into());
|
||||
}
|
||||
|
@ -385,7 +385,7 @@ pub fn set_name<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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()) {
|
||||
let new_name = args
|
||||
.get(0)
|
||||
|
@ -412,7 +412,7 @@ pub fn parent<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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()) {
|
||||
return Ok(dobj
|
||||
.avm2_parent()
|
||||
|
@ -428,7 +428,7 @@ pub fn root<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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()) {
|
||||
return Ok(dobj
|
||||
.avm2_root(&mut activation.context)
|
||||
|
@ -444,7 +444,7 @@ pub fn stage<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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()) {
|
||||
return Ok(dobj
|
||||
.avm2_stage(&activation.context)
|
||||
|
@ -460,7 +460,7 @@ pub fn visible<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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()) {
|
||||
return Ok(dobj.visible().into());
|
||||
}
|
||||
|
@ -473,7 +473,7 @@ pub fn set_visible<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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()) {
|
||||
let new_visible = args
|
||||
.get(0)
|
||||
|
@ -492,7 +492,7 @@ pub fn mouse_x<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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()) {
|
||||
let local_mouse = dobj.global_to_local(*activation.context.mouse_position);
|
||||
|
||||
|
@ -507,7 +507,7 @@ pub fn mouse_y<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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()) {
|
||||
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, '_>,
|
||||
this: Option<Object<'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()) {
|
||||
let x = Twips::from_pixels(
|
||||
args.get(0)
|
||||
|
@ -563,7 +563,7 @@ pub fn hit_test_object<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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(rhs_dobj) = args
|
||||
.get(0)
|
||||
|
@ -584,7 +584,7 @@ pub fn loader_info<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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()) {
|
||||
// Contrary to the DisplayObject.loaderInfo documentation,
|
||||
// Flash Player defines 'loaderInfo' for non-root DisplayObjects.
|
||||
|
@ -604,7 +604,7 @@ pub fn transform<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
return Ok(activation
|
||||
.avm2()
|
||||
|
@ -620,7 +620,7 @@ pub fn set_transform<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
let transform = args[0].coerce_to_object(activation)?;
|
||||
|
||||
|
@ -653,7 +653,7 @@ pub fn blend_mode<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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()) {
|
||||
let mode =
|
||||
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, '_>,
|
||||
this: Option<Object<'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()) {
|
||||
let mode = args
|
||||
.get(0)
|
||||
|
@ -688,7 +688,7 @@ pub fn set_blend_mode<'gc>(
|
|||
fn new_rectangle<'gc>(
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
rectangle: Rectangle,
|
||||
) -> Result<Object<'gc>, Error> {
|
||||
) -> Result<Object<'gc>, Error<'gc>> {
|
||||
let x = rectangle.x_min.to_pixels();
|
||||
let y = rectangle.y_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, '_>,
|
||||
this: Option<Object<'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 dobj.has_scroll_rect() {
|
||||
return Ok(new_rectangle(activation, dobj.next_scroll_rect())?.into());
|
||||
|
@ -719,7 +719,7 @@ fn scroll_rect<'gc>(
|
|||
fn object_to_rectangle<'gc>(
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
object: Object<'gc>,
|
||||
) -> Result<Rectangle, Error> {
|
||||
) -> Result<Rectangle, Error<'gc>> {
|
||||
const NAMES: &[&str] = &["x", "y", "width", "height"];
|
||||
let mut values = [0.0; 4];
|
||||
for (&name, value) in NAMES.iter().zip(&mut values) {
|
||||
|
@ -740,7 +740,7 @@ fn set_scroll_rect<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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(rectangle) = args[0].as_object() {
|
||||
// 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, '_>,
|
||||
this: Option<Object<'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()) {
|
||||
let point = args
|
||||
.get(0)
|
||||
|
@ -803,7 +803,7 @@ fn global_to_local<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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()) {
|
||||
let point = args
|
||||
.get(0)
|
||||
|
@ -835,7 +835,7 @@ fn mask<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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()) {
|
||||
return Ok(this.masker().map_or(Value::Null, |m| m.object2()));
|
||||
}
|
||||
|
@ -846,7 +846,7 @@ fn set_mask<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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()) {
|
||||
let mask = args.get(0).unwrap_or(&Value::Null);
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ pub fn instance_init<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Err("You cannot construct DisplayObjectContainer directly.".into())
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,7 @@ pub fn native_instance_init<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
activation.super_init(this, &[])?;
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ pub fn class_init<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Ok(Value::Undefined)
|
||||
}
|
||||
|
||||
|
@ -55,7 +55,7 @@ fn validate_add_operation<'gc>(
|
|||
new_parent: DisplayObject<'gc>,
|
||||
proposed_child: DisplayObject<'gc>,
|
||||
proposed_index: usize,
|
||||
) -> Result<(), Error> {
|
||||
) -> Result<(), Error<'gc>> {
|
||||
let ctr = new_parent
|
||||
.as_container()
|
||||
.ok_or("ArgumentError: Parent is not a DisplayObjectContainer")?;
|
||||
|
@ -88,7 +88,7 @@ fn validate_add_operation<'gc>(
|
|||
fn validate_remove_operation<'gc>(
|
||||
old_parent: DisplayObject<'gc>,
|
||||
proposed_child: DisplayObject<'gc>,
|
||||
) -> Result<(), Error> {
|
||||
) -> Result<(), Error<'gc>> {
|
||||
let old_ctr = old_parent
|
||||
.as_container()
|
||||
.ok_or("ArgumentError: Parent is not a DisplayObjectContainer")?;
|
||||
|
@ -132,7 +132,7 @@ pub fn get_child_at<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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())
|
||||
.and_then(|this| this.as_container())
|
||||
|
@ -160,7 +160,7 @@ pub fn get_child_by_name<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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())
|
||||
.and_then(|this| this.as_container())
|
||||
|
@ -186,7 +186,7 @@ pub fn add_child<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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(ctr) = parent.as_container() {
|
||||
let child = args
|
||||
|
@ -213,7 +213,7 @@ pub fn add_child_at<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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()) {
|
||||
let child = args
|
||||
.get(0)
|
||||
|
@ -242,7 +242,7 @@ pub fn remove_child<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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()) {
|
||||
let child = args
|
||||
.get(0)
|
||||
|
@ -266,7 +266,7 @@ pub fn num_children<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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())
|
||||
.and_then(|this| this.as_container())
|
||||
|
@ -282,7 +282,7 @@ pub fn contains<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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 parent.as_container().is_some() {
|
||||
if let Some(child) = args
|
||||
|
@ -312,7 +312,7 @@ pub fn get_child_index<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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(ctr) = parent.as_container() {
|
||||
let target_child = args
|
||||
|
@ -340,7 +340,7 @@ pub fn remove_child_at<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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(mut ctr) = parent.as_container() {
|
||||
let target_child = args
|
||||
|
@ -374,7 +374,7 @@ pub fn remove_children<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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(mut ctr) = parent.as_container() {
|
||||
let from = args
|
||||
|
@ -425,7 +425,7 @@ pub fn set_child_index<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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()) {
|
||||
let child = args
|
||||
.get(0)
|
||||
|
@ -459,7 +459,7 @@ pub fn swap_children_at<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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(mut ctr) = parent.as_container() {
|
||||
let index0 = args
|
||||
|
@ -500,7 +500,7 @@ pub fn swap_children<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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(mut ctr) = parent.as_container() {
|
||||
let child0 = args
|
||||
|
@ -542,7 +542,7 @@ pub fn stop_all_movie_clips<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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(mc) = parent.as_movie_clip() {
|
||||
mc.stop(&mut activation.context);
|
||||
|
@ -566,7 +566,7 @@ pub fn get_objects_under_point<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Err("DisplayObjectContainer.getObjectsUnderPoint not yet implemented".into())
|
||||
}
|
||||
|
||||
|
@ -575,7 +575,7 @@ pub fn are_inaccessible_objects_under_point<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Err("DisplayObjectContainer.areInaccessibleObjectsUnderPoint not yet implemented".into())
|
||||
}
|
||||
|
||||
|
@ -583,7 +583,7 @@ pub fn mouse_children<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
log::warn!("DisplayObjectContainer.mouseChildren getter: not yet implemented");
|
||||
Ok(Value::Undefined)
|
||||
}
|
||||
|
@ -592,7 +592,7 @@ pub fn set_mouse_children<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
log::warn!("DisplayObjectContainer.mouseChildren setter: not yet implemented");
|
||||
Ok(Value::Undefined)
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ pub fn instance_init<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
let name = args
|
||||
.get(0)
|
||||
.cloned()
|
||||
|
@ -52,7 +52,7 @@ pub fn class_init<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Ok(Value::Undefined)
|
||||
}
|
||||
/// Construct `FrameLabel`'s class.
|
||||
|
|
|
@ -22,7 +22,7 @@ fn instance_init<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Err("Graphics cannot be constructed directly.".into())
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,7 @@ fn native_instance_init<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
activation.super_init(this, &[])?;
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ fn class_init<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Ok(Value::Undefined)
|
||||
}
|
||||
|
||||
|
@ -59,7 +59,7 @@ fn begin_fill<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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()) {
|
||||
let color = args
|
||||
.get(0)
|
||||
|
@ -85,7 +85,7 @@ fn clear<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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(mut draw) = this.as_drawing(activation.context.gc_context) {
|
||||
draw.clear()
|
||||
|
@ -100,7 +100,7 @@ fn curve_to<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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()) {
|
||||
let x1 = Twips::from_pixels(
|
||||
args.get(0)
|
||||
|
@ -140,7 +140,7 @@ fn end_fill<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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(mut draw) = this.as_drawing(activation.context.gc_context) {
|
||||
draw.set_fill_style(None);
|
||||
|
@ -153,7 +153,7 @@ fn end_fill<'gc>(
|
|||
fn caps_to_cap_style<'gc>(
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
caps: Value<'gc>,
|
||||
) -> Result<LineCapStyle, Error> {
|
||||
) -> Result<LineCapStyle, Error<'gc>> {
|
||||
if let Value::Null = caps {
|
||||
return Ok(LineCapStyle::None);
|
||||
}
|
||||
|
@ -172,7 +172,7 @@ fn joints_to_join_style<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
joints: Value<'gc>,
|
||||
miter_limit: f64,
|
||||
) -> Result<LineJoinStyle, Error> {
|
||||
) -> Result<LineJoinStyle, Error<'gc>> {
|
||||
if let Value::Null = joints {
|
||||
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" {
|
||||
Ok((false, false))
|
||||
} else if scale_mode == b"horizontal" {
|
||||
|
@ -204,7 +204,7 @@ fn line_style<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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()) {
|
||||
let thickness = args
|
||||
.get(0)
|
||||
|
@ -275,7 +275,7 @@ fn line_to<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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()) {
|
||||
let x = Twips::from_pixels(
|
||||
args.get(0)
|
||||
|
@ -303,7 +303,7 @@ fn move_to<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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()) {
|
||||
let x = Twips::from_pixels(
|
||||
args.get(0)
|
||||
|
@ -331,7 +331,7 @@ fn draw_rect<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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()) {
|
||||
let x = Twips::from_pixels(
|
||||
args.get(0)
|
||||
|
@ -642,7 +642,7 @@ fn draw_round_rect<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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()) {
|
||||
let x = args
|
||||
.get(0)
|
||||
|
@ -696,7 +696,7 @@ fn draw_circle<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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()) {
|
||||
let x = args
|
||||
.get(0)
|
||||
|
@ -735,7 +735,7 @@ fn draw_ellipse<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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()) {
|
||||
let x = args
|
||||
.get(0)
|
||||
|
|
|
@ -15,7 +15,7 @@ pub fn bodiless_method<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Err("Cannot execute non-native method without body".into())
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,7 @@ pub fn class_init<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Ok(Value::Undefined)
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ pub fn instance_init<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Err("You cannot directly construct InteractiveObject.".into())
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,7 @@ pub fn native_instance_init<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
activation.super_init(this, &[])?;
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ pub fn class_init<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Ok(Value::Undefined)
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@ pub fn mouse_enabled<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(int) = this
|
||||
.and_then(|t| t.as_display_object())
|
||||
.and_then(|dobj| dobj.as_interactive())
|
||||
|
@ -64,7 +64,7 @@ pub fn set_mouse_enabled<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(int) = this
|
||||
.and_then(|t| t.as_display_object())
|
||||
.and_then(|dobj| dobj.as_interactive())
|
||||
|
@ -85,7 +85,7 @@ pub fn double_click_enabled<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(int) = this
|
||||
.and_then(|t| t.as_display_object())
|
||||
.and_then(|dobj| dobj.as_interactive())
|
||||
|
@ -101,7 +101,7 @@ pub fn set_double_click_enabled<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(int) = this
|
||||
.and_then(|t| t.as_display_object())
|
||||
.and_then(|dobj| dobj.as_interactive())
|
||||
|
@ -122,7 +122,7 @@ fn context_menu<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(int) = this
|
||||
.and_then(|t| t.as_display_object())
|
||||
.and_then(|dobj| dobj.as_interactive())
|
||||
|
@ -138,7 +138,7 @@ fn set_context_menu<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(int) = this
|
||||
.and_then(|t| t.as_display_object())
|
||||
.and_then(|dobj| dobj.as_interactive())
|
||||
|
|
|
@ -18,7 +18,7 @@ pub fn init<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(mut this) = this {
|
||||
if this.as_display_object().is_none() {
|
||||
let new_do = LoaderDisplay::new_with_avm2(activation.context.gc_context, this);
|
||||
|
@ -47,7 +47,7 @@ pub fn load<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
let url_request = args[0].as_object().unwrap();
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ pub fn instance_init<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Err("LoaderInfo cannot be constructed".into())
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@ pub fn native_instance_init<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
activation.super_init(this, &[])?;
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ pub fn class_init<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Ok(Value::Undefined)
|
||||
}
|
||||
|
||||
|
@ -55,7 +55,7 @@ pub fn action_script_version<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(loader_stream) = this
|
||||
.as_loader_info_object()
|
||||
|
@ -81,7 +81,7 @@ pub fn application_domain<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(loader_stream) = this
|
||||
.as_loader_info_object()
|
||||
|
@ -114,7 +114,7 @@ pub fn bytes_total<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(loader_stream) = this
|
||||
.as_loader_info_object()
|
||||
|
@ -137,7 +137,7 @@ pub fn content<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(loader_stream) = this
|
||||
.as_loader_info_object()
|
||||
|
@ -165,7 +165,7 @@ pub fn content_type<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(loader_stream) = this
|
||||
.as_loader_info_object()
|
||||
|
@ -188,7 +188,7 @@ pub fn frame_rate<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(loader_stream) = this
|
||||
.as_loader_info_object()
|
||||
|
@ -213,7 +213,7 @@ pub fn height<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(loader_stream) = this
|
||||
.as_loader_info_object()
|
||||
|
@ -238,7 +238,7 @@ pub fn is_url_inaccessible<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Ok(false.into())
|
||||
}
|
||||
|
||||
|
@ -247,7 +247,7 @@ pub fn swf_version<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(loader_stream) = this
|
||||
.as_loader_info_object()
|
||||
|
@ -272,7 +272,7 @@ pub fn url<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(loader_stream) = this
|
||||
.as_loader_info_object()
|
||||
|
@ -298,7 +298,7 @@ pub fn width<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(loader_stream) = this
|
||||
.as_loader_info_object()
|
||||
|
@ -323,7 +323,7 @@ pub fn bytes<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(loader_stream) = this
|
||||
.as_loader_info_object()
|
||||
|
@ -380,7 +380,7 @@ pub fn loader<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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()) {
|
||||
Ok(loader_info.loader().map_or(Value::Null, |v| v.into()))
|
||||
} else {
|
||||
|
@ -393,7 +393,7 @@ pub fn loader_url<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(loader_stream) = this
|
||||
.as_loader_info_object()
|
||||
|
@ -417,7 +417,7 @@ pub fn parameters<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(loader_stream) = this
|
||||
.as_loader_info_object()
|
||||
|
@ -453,7 +453,7 @@ pub fn shared_events<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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()) {
|
||||
return Ok(loader_info.shared_events().into());
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ pub fn instance_init<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
activation.super_init(this, &[])?;
|
||||
|
||||
|
@ -44,7 +44,7 @@ pub fn class_init<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Ok(Value::Undefined)
|
||||
}
|
||||
|
||||
|
@ -54,7 +54,7 @@ pub fn add_frame_script<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(mc) = this
|
||||
.and_then(|o| o.as_display_object())
|
||||
.and_then(|dobj| dobj.as_movie_clip())
|
||||
|
@ -77,7 +77,7 @@ pub fn current_frame<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(mc) = this
|
||||
.and_then(|o| o.as_display_object())
|
||||
.and_then(|dobj| dobj.as_movie_clip())
|
||||
|
@ -102,7 +102,7 @@ pub fn current_frame_label<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(mc) = this
|
||||
.and_then(|o| o.as_display_object())
|
||||
.and_then(|dobj| dobj.as_movie_clip())
|
||||
|
@ -127,7 +127,7 @@ pub fn current_label<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(mc) = this
|
||||
.and_then(|o| o.as_display_object())
|
||||
.and_then(|dobj| dobj.as_movie_clip())
|
||||
|
@ -151,7 +151,7 @@ fn labels_for_scene<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
mc: MovieClip<'gc>,
|
||||
scene: &Scene,
|
||||
) -> Result<(String, u16, Object<'gc>), Error> {
|
||||
) -> Result<(String, u16, Object<'gc>), Error<'gc>> {
|
||||
let Scene {
|
||||
name: scene_name,
|
||||
start: scene_start,
|
||||
|
@ -182,7 +182,7 @@ pub fn current_labels<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(mc) = this
|
||||
.and_then(|o| o.as_display_object())
|
||||
.and_then(|dobj| dobj.as_movie_clip())
|
||||
|
@ -203,7 +203,7 @@ pub fn current_scene<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(mc) = this
|
||||
.and_then(|o| o.as_display_object())
|
||||
.and_then(|dobj| dobj.as_movie_clip())
|
||||
|
@ -234,7 +234,7 @@ pub fn scenes<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(mc) = this
|
||||
.and_then(|o| o.as_display_object())
|
||||
.and_then(|dobj| dobj.as_movie_clip())
|
||||
|
@ -279,7 +279,7 @@ pub fn frames_loaded<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(mc) = this
|
||||
.and_then(|o| o.as_display_object())
|
||||
.and_then(|dobj| dobj.as_movie_clip())
|
||||
|
@ -295,7 +295,7 @@ pub fn is_playing<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(mc) = this
|
||||
.and_then(|o| o.as_display_object())
|
||||
.and_then(|dobj| dobj.as_movie_clip())
|
||||
|
@ -311,7 +311,7 @@ pub fn total_frames<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(mc) = this
|
||||
.and_then(|o| o.as_display_object())
|
||||
.and_then(|dobj| dobj.as_movie_clip())
|
||||
|
@ -327,7 +327,7 @@ pub fn goto_and_play<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(mc) = this
|
||||
.and_then(|o| o.as_display_object())
|
||||
.and_then(|dobj| dobj.as_movie_clip())
|
||||
|
@ -344,7 +344,7 @@ pub fn goto_and_stop<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(mc) = this
|
||||
.and_then(|o| o.as_display_object())
|
||||
.and_then(|dobj| dobj.as_movie_clip())
|
||||
|
@ -360,7 +360,7 @@ pub fn goto_frame<'gc>(
|
|||
mc: MovieClip<'gc>,
|
||||
args: &[Value<'gc>],
|
||||
stop: bool,
|
||||
) -> Result<(), Error> {
|
||||
) -> Result<(), Error<'gc>> {
|
||||
let frame_or_label = args.get(0).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, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(mc) = this
|
||||
.and_then(|o| o.as_display_object())
|
||||
.and_then(|dobj| dobj.as_movie_clip())
|
||||
|
@ -426,7 +426,7 @@ pub fn play<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(mc) = this
|
||||
.and_then(|o| o.as_display_object())
|
||||
.and_then(|dobj| dobj.as_movie_clip())
|
||||
|
@ -443,7 +443,7 @@ pub fn prev_frame<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(mc) = this
|
||||
.and_then(|o| o.as_display_object())
|
||||
.and_then(|dobj| dobj.as_movie_clip())
|
||||
|
@ -459,7 +459,7 @@ pub fn next_frame<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(mc) = this
|
||||
.and_then(|o| o.as_display_object())
|
||||
.and_then(|dobj| dobj.as_movie_clip())
|
||||
|
@ -475,7 +475,7 @@ pub fn prev_scene<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(mc) = this
|
||||
.and_then(|o| o.as_display_object())
|
||||
.and_then(|dobj| dobj.as_movie_clip())
|
||||
|
@ -498,7 +498,7 @@ pub fn next_scene<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(mc) = this
|
||||
.and_then(|o| o.as_display_object())
|
||||
.and_then(|dobj| dobj.as_movie_clip())
|
||||
|
|
|
@ -19,7 +19,7 @@ pub fn instance_init<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
activation.super_init(this, &[])?;
|
||||
|
||||
|
@ -38,7 +38,7 @@ pub fn class_init<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Ok(Value::Undefined)
|
||||
}
|
||||
|
||||
|
@ -47,7 +47,7 @@ pub fn graphics<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(mut this) = this {
|
||||
if let Some(dobj) = this.as_display_object() {
|
||||
// Lazily initialize the `Graphics` object in a hidden property.
|
||||
|
|
|
@ -20,7 +20,7 @@ pub fn instance_init<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
activation.super_init(this, &[])?;
|
||||
|
||||
|
@ -73,7 +73,7 @@ pub fn class_init<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Ok(Value::Undefined)
|
||||
}
|
||||
|
||||
|
@ -82,7 +82,7 @@ pub fn down_state<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(btn) = this
|
||||
.and_then(|this| this.as_display_object())
|
||||
.and_then(|this| this.as_avm2_button())
|
||||
|
@ -101,7 +101,7 @@ pub fn set_down_state<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(btn) = this
|
||||
.and_then(|this| this.as_display_object())
|
||||
.and_then(|this| this.as_avm2_button())
|
||||
|
@ -124,7 +124,7 @@ pub fn over_state<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(btn) = this
|
||||
.and_then(|this| this.as_display_object())
|
||||
.and_then(|this| this.as_avm2_button())
|
||||
|
@ -143,7 +143,7 @@ pub fn set_over_state<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(btn) = this
|
||||
.and_then(|this| this.as_display_object())
|
||||
.and_then(|this| this.as_avm2_button())
|
||||
|
@ -166,7 +166,7 @@ pub fn hit_test_state<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(btn) = this
|
||||
.and_then(|this| this.as_display_object())
|
||||
.and_then(|this| this.as_avm2_button())
|
||||
|
@ -185,7 +185,7 @@ pub fn set_hit_test_state<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(btn) = this
|
||||
.and_then(|this| this.as_display_object())
|
||||
.and_then(|this| this.as_avm2_button())
|
||||
|
@ -208,7 +208,7 @@ pub fn up_state<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(btn) = this
|
||||
.and_then(|this| this.as_display_object())
|
||||
.and_then(|this| this.as_avm2_button())
|
||||
|
@ -227,7 +227,7 @@ pub fn set_up_state<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(btn) = this
|
||||
.and_then(|this| this.as_display_object())
|
||||
.and_then(|this| this.as_avm2_button())
|
||||
|
@ -250,7 +250,7 @@ pub fn track_as_menu<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(btn) = this
|
||||
.and_then(|this| this.as_display_object())
|
||||
.and_then(|this| this.as_avm2_button())
|
||||
|
@ -266,7 +266,7 @@ pub fn set_track_as_menu<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(btn) = this
|
||||
.and_then(|this| this.as_display_object())
|
||||
.and_then(|this| this.as_avm2_button())
|
||||
|
@ -290,7 +290,7 @@ pub fn enabled<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(btn) = this
|
||||
.and_then(|this| this.as_display_object())
|
||||
.and_then(|this| this.as_avm2_button())
|
||||
|
@ -306,7 +306,7 @@ pub fn set_enabled<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(btn) = this
|
||||
.and_then(|this| this.as_display_object())
|
||||
.and_then(|this| this.as_avm2_button())
|
||||
|
@ -328,7 +328,7 @@ pub fn use_hand_cursor<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(btn) = this
|
||||
.and_then(|this| this.as_display_object())
|
||||
.and_then(|this| this.as_avm2_button())
|
||||
|
@ -344,7 +344,7 @@ pub fn set_use_hand_cursor<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(btn) = this
|
||||
.and_then(|this| this.as_display_object())
|
||||
.and_then(|this| this.as_avm2_button())
|
||||
|
|
|
@ -23,7 +23,7 @@ pub fn instance_init<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
activation.super_init(this, &[])?;
|
||||
|
||||
|
@ -47,7 +47,7 @@ pub fn class_init<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Ok(Value::Undefined)
|
||||
}
|
||||
|
||||
|
@ -56,7 +56,7 @@ pub fn graphics<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(mut this) = this {
|
||||
if let Some(dobj) = this.as_display_object() {
|
||||
// Lazily initialize the `Graphics` object in a hidden property.
|
||||
|
@ -87,7 +87,7 @@ pub fn sound_transform<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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()) {
|
||||
let dobj_st = dobj.base().sound_transform().clone();
|
||||
|
||||
|
@ -102,7 +102,7 @@ pub fn set_sound_transform<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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()) {
|
||||
let as3_st = args
|
||||
.get(0)
|
||||
|
@ -122,7 +122,7 @@ pub fn button_mode<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(mc) = this
|
||||
.and_then(|o| o.as_display_object())
|
||||
.and_then(|o| o.as_movie_clip())
|
||||
|
@ -138,7 +138,7 @@ pub fn set_button_mode<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(mc) = this
|
||||
.and_then(|o| o.as_display_object())
|
||||
.and_then(|o| o.as_movie_clip())
|
||||
|
@ -161,7 +161,7 @@ pub fn start_drag<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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()) {
|
||||
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, '_>,
|
||||
_this: Option<Object<'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.
|
||||
|
||||
// we might not have had an opportunity to call `update_drag`
|
||||
|
|
|
@ -20,7 +20,7 @@ pub fn instance_init<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Err("You cannot construct new instances of the Stage.".into())
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,7 @@ pub fn native_instance_init<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
activation.super_init(this, args)?;
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ pub fn class_init<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Ok(Value::Undefined)
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,7 @@ pub fn set_accessibility_properties<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Err("Error: You cannot set accessibility properties on the stage.".into())
|
||||
}
|
||||
|
||||
|
@ -60,7 +60,7 @@ pub fn set_alpha<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Err("Error: You cannot set the stage's opacity.".into())
|
||||
}
|
||||
|
||||
|
@ -69,7 +69,7 @@ pub fn set_blend_mode<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'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())
|
||||
}
|
||||
|
||||
|
@ -78,7 +78,7 @@ pub fn set_cache_as_bitmap<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'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())
|
||||
}
|
||||
|
||||
|
@ -87,7 +87,7 @@ pub fn set_context_menu<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Err("Error: You cannot set the stage's context menu.".into())
|
||||
}
|
||||
|
||||
|
@ -96,7 +96,7 @@ pub fn set_filters<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Err("Error: You cannot apply filters to the stage.".into())
|
||||
}
|
||||
|
||||
|
@ -105,7 +105,7 @@ pub fn set_focus_rect<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
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, '_>,
|
||||
_this: Option<Object<'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())
|
||||
}
|
||||
|
||||
|
@ -123,7 +123,7 @@ pub fn set_mask<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Err("Error: You cannot mask the stage.".into())
|
||||
}
|
||||
|
||||
|
@ -132,7 +132,7 @@ pub fn set_mouse_enabled<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'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())
|
||||
}
|
||||
|
||||
|
@ -141,7 +141,7 @@ pub fn name<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Ok(Value::Null)
|
||||
}
|
||||
|
||||
|
@ -150,7 +150,7 @@ pub fn set_name<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
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, '_>,
|
||||
_this: Option<Object<'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())
|
||||
}
|
||||
|
||||
|
@ -168,7 +168,7 @@ pub fn set_rotation<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Err("Error: You cannot rotate the stage.".into())
|
||||
}
|
||||
|
||||
|
@ -177,7 +177,7 @@ pub fn set_scale_nine_grid<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'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())
|
||||
}
|
||||
|
||||
|
@ -186,7 +186,7 @@ pub fn set_scale_x<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
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, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
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, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
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, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
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, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Err("Error: You cannot set the stage's tab index.".into())
|
||||
}
|
||||
|
||||
|
@ -231,7 +231,7 @@ pub fn set_transform<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Err("Error: You cannot transform the stage.".into())
|
||||
}
|
||||
|
||||
|
@ -240,7 +240,7 @@ pub fn set_visible<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Err("Error: You cannot hide or unhide the stage.".into())
|
||||
}
|
||||
|
||||
|
@ -249,7 +249,7 @@ pub fn set_x<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Err("Error: You cannot move the stage horizontally.".into())
|
||||
}
|
||||
|
||||
|
@ -258,7 +258,7 @@ pub fn set_y<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Err("Error: You cannot move the stage vertically.".into())
|
||||
}
|
||||
|
||||
|
@ -267,7 +267,7 @@ pub fn align<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
let align = activation.context.stage.align();
|
||||
let mut s = WString::with_capacity(4, false);
|
||||
// Match string values returned by AS.
|
||||
|
@ -296,7 +296,7 @@ pub fn set_align<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
let align = args
|
||||
.get(0)
|
||||
.unwrap_or(&Value::Undefined)
|
||||
|
@ -315,7 +315,7 @@ pub fn browser_zoom_factor<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if this
|
||||
.and_then(|this| this.as_display_object())
|
||||
.and_then(|this| this.as_stage())
|
||||
|
@ -337,7 +337,7 @@ pub fn color<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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())
|
||||
.and_then(|this| this.as_stage())
|
||||
|
@ -354,7 +354,7 @@ pub fn set_color<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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())
|
||||
.and_then(|this| this.as_stage())
|
||||
|
@ -377,7 +377,7 @@ pub fn contents_scale_factor<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if this
|
||||
.and_then(|this| this.as_display_object())
|
||||
.and_then(|this| this.as_stage())
|
||||
|
@ -399,7 +399,7 @@ pub fn display_state<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
let display_state = AvmString::new_utf8(
|
||||
activation.context.gc_context,
|
||||
activation.context.stage.display_state().to_string(),
|
||||
|
@ -412,7 +412,7 @@ pub fn set_display_state<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Ok(mut display_state) = args
|
||||
.get(0)
|
||||
.unwrap_or(&Value::Undefined)
|
||||
|
@ -442,7 +442,7 @@ pub fn focus<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Ok(activation
|
||||
.context
|
||||
.focus_tracker
|
||||
|
@ -457,7 +457,7 @@ pub fn set_focus<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
let focus = activation.context.focus_tracker;
|
||||
match args.get(0).cloned().unwrap_or(Value::Undefined) {
|
||||
Value::Null => focus.set(None, &mut activation.context),
|
||||
|
@ -478,7 +478,7 @@ pub fn frame_rate<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Ok((*activation.context.frame_rate).into())
|
||||
}
|
||||
|
||||
|
@ -487,7 +487,7 @@ pub fn set_frame_rate<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
let new_frame_rate = args
|
||||
.get(0)
|
||||
.cloned()
|
||||
|
@ -502,7 +502,7 @@ pub fn show_default_context_menu<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Ok(activation.context.stage.show_menu().into())
|
||||
}
|
||||
|
||||
|
@ -510,7 +510,7 @@ pub fn set_show_default_context_menu<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'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();
|
||||
activation
|
||||
.context
|
||||
|
@ -524,7 +524,7 @@ pub fn scale_mode<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
let scale_mode = AvmString::new_utf8(
|
||||
activation.context.gc_context,
|
||||
activation.context.stage.scale_mode().to_string(),
|
||||
|
@ -537,7 +537,7 @@ pub fn set_scale_mode<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Ok(scale_mode) = args
|
||||
.get(0)
|
||||
.unwrap_or(&Value::Undefined)
|
||||
|
@ -564,7 +564,7 @@ pub fn stage_focus_rect<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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())
|
||||
.and_then(|this| this.as_stage())
|
||||
|
@ -582,7 +582,7 @@ pub fn set_stage_focus_rect<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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())
|
||||
.and_then(|this| this.as_stage())
|
||||
|
@ -599,7 +599,7 @@ pub fn stage_width<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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())
|
||||
.and_then(|this| this.as_stage())
|
||||
|
@ -615,7 +615,7 @@ pub fn set_stage_width<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
// For some reason this value is settable but it does nothing.
|
||||
Ok(Value::Undefined)
|
||||
}
|
||||
|
@ -625,7 +625,7 @@ pub fn stage_height<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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())
|
||||
.and_then(|this| this.as_stage())
|
||||
|
@ -641,7 +641,7 @@ pub fn set_stage_height<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
// For some reason this value is settable but it does nothing.
|
||||
Ok(Value::Undefined)
|
||||
}
|
||||
|
@ -653,7 +653,7 @@ pub fn allows_full_screen<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Ok(true.into())
|
||||
}
|
||||
|
||||
|
@ -664,7 +664,7 @@ pub fn allows_full_screen_interactive<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Ok(false.into())
|
||||
}
|
||||
|
||||
|
@ -673,7 +673,7 @@ pub fn quality<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
let quality = activation.context.stage.quality().into_avm_str();
|
||||
Ok(AvmString::from(quality).into())
|
||||
}
|
||||
|
@ -683,7 +683,7 @@ pub fn set_quality<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
// Invalid values result in no change.
|
||||
if let Ok(quality) = args
|
||||
.get(0)
|
||||
|
|
|
@ -11,7 +11,7 @@ pub fn init<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
let this = this.unwrap();
|
||||
let mut evt = this.as_event_mut(activation.context.gc_context).unwrap();
|
||||
evt.set_event_type(
|
||||
|
@ -40,7 +40,7 @@ pub fn get_bubbles<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(evt) = this.unwrap().as_event() {
|
||||
return Ok(evt.is_bubbling().into());
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ pub fn get_cancelable<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(evt) = this.unwrap().as_event() {
|
||||
return Ok(evt.is_cancelable().into());
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ pub fn get_type<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(evt) = this.unwrap().as_event() {
|
||||
return Ok(evt.event_type().into());
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ pub fn get_target<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(evt) = this.unwrap().as_event() {
|
||||
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, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(evt) = this.unwrap().as_event() {
|
||||
return Ok(evt
|
||||
.current_target()
|
||||
|
@ -108,7 +108,7 @@ pub fn get_event_phase<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(evt) = this.unwrap().as_event() {
|
||||
let event_phase = evt.phase() as u32;
|
||||
return Ok(event_phase.into());
|
||||
|
@ -122,7 +122,7 @@ pub fn is_default_prevented<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(evt) = this.unwrap().as_event() {
|
||||
return Ok(evt.is_cancelled().into());
|
||||
}
|
||||
|
@ -135,7 +135,7 @@ pub fn prevent_default<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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) {
|
||||
evt.cancel();
|
||||
}
|
||||
|
@ -148,7 +148,7 @@ pub fn stop_propagation<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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) {
|
||||
evt.stop_propagation();
|
||||
}
|
||||
|
@ -161,7 +161,7 @@ pub fn stop_immediate_propagation<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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) {
|
||||
evt.stop_immediate_propagation();
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ pub fn instance_init<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(mut this) = this {
|
||||
activation.super_init(this, &[])?;
|
||||
|
||||
|
@ -44,7 +44,7 @@ pub fn instance_init<'gc>(
|
|||
fn dispatch_list<'gc>(
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
mut this: Object<'gc>,
|
||||
) -> Result<Object<'gc>, Error> {
|
||||
) -> Result<Object<'gc>, Error<'gc>> {
|
||||
match this.get_property(
|
||||
&Multiname::new(Namespace::private(NS_EVENT_DISPATCHER), "dispatch_list"),
|
||||
activation,
|
||||
|
@ -68,7 +68,7 @@ pub fn add_event_listener<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
let dispatch_list = dispatch_list(activation, this)?;
|
||||
let event_type = args
|
||||
|
@ -109,7 +109,7 @@ pub fn remove_event_listener<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
let dispatch_list = dispatch_list(activation, this)?;
|
||||
let event_type = args
|
||||
|
@ -142,7 +142,7 @@ pub fn has_event_listener<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
let dispatch_list = dispatch_list(activation, this)?;
|
||||
let event_type = args
|
||||
|
@ -166,7 +166,7 @@ pub fn will_trigger<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
let dispatch_list = dispatch_list(activation, this)?;
|
||||
let event_type = args
|
||||
|
@ -204,7 +204,7 @@ pub fn dispatch_event<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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();
|
||||
|
||||
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, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Ok(Value::Undefined)
|
||||
}
|
||||
|
||||
|
@ -235,7 +235,7 @@ pub fn to_string<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
let object_proto = activation.avm2().classes().object.prototype();
|
||||
let name = Multiname::public("toString");
|
||||
object_proto
|
||||
|
|
|
@ -9,7 +9,7 @@ pub fn get_stage_x<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
mouse_event::get_stage_x(activation, this, args)
|
||||
}
|
||||
|
||||
|
@ -18,6 +18,6 @@ pub fn get_stage_y<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
mouse_event::get_stage_y(activation, this, args)
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ pub fn bodiless_method<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Err("Cannot execute non-native method without body".into())
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,7 @@ pub fn class_init<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Ok(Value::Undefined)
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ pub fn get_stage_x<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(evt) = this.as_event() {
|
||||
let local_x = this
|
||||
|
@ -39,7 +39,7 @@ pub fn get_stage_y<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(evt) = this.as_event() {
|
||||
let local_y = this
|
||||
|
|
|
@ -11,7 +11,7 @@ fn instance_init<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
activation.super_init(this, &[])?;
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ fn class_init<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Ok(Value::Undefined)
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,7 @@ pub fn call<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if args.is_empty() {
|
||||
return Ok(Value::Null);
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ pub fn available<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Ok(activation.context.external_interface.available().into())
|
||||
}
|
||||
|
||||
|
@ -66,7 +66,7 @@ pub fn add_callback<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if args.len() < 2 {
|
||||
return Ok(Value::Undefined);
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ use swf::Fixed8;
|
|||
fn get_display_object<'gc>(
|
||||
this: Object<'gc>,
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
) -> Result<DisplayObject<'gc>, Error> {
|
||||
) -> Result<DisplayObject<'gc>, Error<'gc>> {
|
||||
Ok(this
|
||||
.get_property(
|
||||
&Multiname::new(Namespace::Private("".into()), "_displayObject"),
|
||||
|
@ -25,7 +25,7 @@ pub fn init<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
this.unwrap().set_property(
|
||||
&Multiname::new(Namespace::Private("".into()), "_displayObject"),
|
||||
args[0],
|
||||
|
@ -38,7 +38,7 @@ pub fn get_color_transform<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
let this = this.unwrap();
|
||||
let ct_obj = *get_display_object(this, activation)?
|
||||
.base()
|
||||
|
@ -50,7 +50,7 @@ pub fn set_color_transform<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
let this = this.unwrap();
|
||||
let ct = object_to_color_transform(args[0].coerce_to_object(activation)?, activation)?;
|
||||
get_display_object(this, activation)?
|
||||
|
@ -63,7 +63,7 @@ pub fn get_matrix<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
let this = this.unwrap();
|
||||
let matrix = *get_display_object(this, activation)?.base().matrix();
|
||||
matrix_to_object(matrix, activation)
|
||||
|
@ -73,7 +73,7 @@ pub fn set_matrix<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
let this = this.unwrap();
|
||||
let matrix = object_to_matrix(args[0].coerce_to_object(activation)?, activation)?;
|
||||
get_display_object(this, activation)?
|
||||
|
@ -86,7 +86,7 @@ pub fn get_concatenated_matrix<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
let this = this.unwrap();
|
||||
|
||||
let dobj = get_display_object(this, activation)?;
|
||||
|
@ -127,7 +127,7 @@ pub fn get_concatenated_color_transform<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
log::warn!("Transform.concatenatedColorTransform: not yet implemented");
|
||||
Ok(Value::Undefined)
|
||||
}
|
||||
|
@ -137,7 +137,7 @@ pub fn get_concatenated_color_transform<'gc>(
|
|||
pub fn object_to_color_transform<'gc>(
|
||||
object: Object<'gc>,
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
) -> Result<ColorTransform, Error> {
|
||||
) -> Result<ColorTransform, Error<'gc>> {
|
||||
let red_multiplier = object
|
||||
.get_property(&Multiname::public("redMultiplier"), activation)?
|
||||
.coerce_to_number(activation)?;
|
||||
|
@ -177,7 +177,7 @@ pub fn object_to_color_transform<'gc>(
|
|||
pub fn color_transform_to_object<'gc>(
|
||||
color_transform: &ColorTransform,
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
let args = [
|
||||
color_transform.r_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>(
|
||||
matrix: Matrix,
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
let args = [
|
||||
matrix.a.into(),
|
||||
matrix.b.into(),
|
||||
|
@ -216,7 +216,7 @@ pub fn matrix_to_object<'gc>(
|
|||
pub fn object_to_matrix<'gc>(
|
||||
object: Object<'gc>,
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
) -> Result<Matrix, Error> {
|
||||
) -> Result<Matrix, Error<'gc>> {
|
||||
let a = object
|
||||
.get_property(&Multiname::public("a"), activation)?
|
||||
.coerce_to_number(activation)? as f32;
|
||||
|
|
|
@ -20,7 +20,7 @@ pub fn instance_init<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
activation.super_init(this, &[])?;
|
||||
|
||||
|
@ -57,7 +57,7 @@ pub fn class_init<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Ok(Value::Undefined)
|
||||
}
|
||||
|
||||
|
@ -66,7 +66,7 @@ pub fn bytes_total<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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(length) = activation.context.audio.get_sound_size(sound) {
|
||||
return Ok((length).into());
|
||||
|
@ -81,7 +81,7 @@ pub fn is_buffering<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
//STUB: We do not yet support network-loaded sounds.
|
||||
Ok(false.into())
|
||||
}
|
||||
|
@ -91,7 +91,7 @@ pub fn url<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
//STUB: We do not yet support network-loaded sounds.
|
||||
Ok(Value::Null)
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ pub fn length<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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(duration) = activation.context.audio.get_sound_duration(sound) {
|
||||
return Ok((duration).into());
|
||||
|
@ -116,7 +116,7 @@ pub fn play<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(sound) = this.and_then(|this| this.as_sound()) {
|
||||
let position = args
|
||||
.get(0)
|
||||
|
@ -177,7 +177,7 @@ pub fn extract<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Err("Sound.extract is a stub.".into())
|
||||
}
|
||||
|
||||
|
@ -186,7 +186,7 @@ pub fn close<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Err("Sound.close is a stub.".into())
|
||||
}
|
||||
|
||||
|
@ -195,7 +195,7 @@ pub fn load<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
let url_request = match args.get(0) {
|
||||
Some(Value::Object(request)) => request,
|
||||
|
@ -226,7 +226,7 @@ pub fn load_compressed_data_from_byte_array<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Err("Sound.loadCompressedDataFromByteArray is a stub.".into())
|
||||
}
|
||||
|
||||
|
@ -235,7 +235,7 @@ pub fn load_pcm_from_byte_array<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Err("Sound.loadPCMFromByteArray is a stub.".into())
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ pub fn instance_init<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
activation.super_init(this, &[])?;
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ pub fn class_init<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Ok(Value::Undefined)
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,7 @@ pub fn left_peak<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Err("Sound.leftPeak is a stub.".into())
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@ pub fn right_peak<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Err("Sound.rightPeak is a stub.".into())
|
||||
}
|
||||
|
||||
|
@ -57,7 +57,7 @@ pub fn position<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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()) {
|
||||
return Ok(instance.position().into());
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ pub fn sound_transform<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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())
|
||||
.and_then(|channel| channel.instance())
|
||||
|
@ -89,7 +89,7 @@ pub fn set_sound_transform<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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())
|
||||
.and_then(|channel| channel.instance())
|
||||
|
@ -114,7 +114,7 @@ pub fn stop<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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())
|
||||
.and_then(|channel| channel.instance())
|
||||
|
|
|
@ -17,7 +17,7 @@ pub fn instance_init<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
activation.super_init(this, &[])?;
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ pub fn class_init<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Ok(Value::Undefined)
|
||||
}
|
||||
|
||||
|
@ -42,7 +42,7 @@ pub fn sound_transform<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
let dobj_st = activation.context.global_sound_transform().clone();
|
||||
|
||||
Ok(dobj_st.into_avm2_object(activation)?.into())
|
||||
|
@ -56,7 +56,7 @@ pub fn set_sound_transform<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
let as3_st = args
|
||||
.get(0)
|
||||
.cloned()
|
||||
|
@ -74,7 +74,7 @@ pub fn stop_all<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
activation.context.stop_all_sounds();
|
||||
|
||||
Ok(Value::Undefined)
|
||||
|
@ -85,7 +85,7 @@ pub fn buffer_time<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Ok(activation.context.audio_manager.stream_buffer_time().into())
|
||||
}
|
||||
|
||||
|
@ -94,7 +94,7 @@ pub fn set_buffer_time<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
let buffer_time = args
|
||||
.get(0)
|
||||
.cloned()
|
||||
|
@ -114,7 +114,7 @@ pub fn are_sounds_inaccessible<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Err("SoundMixer.areSoundsInaccessible is a stub".into())
|
||||
}
|
||||
|
||||
|
@ -123,7 +123,7 @@ pub fn compute_spectrum<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Err("SoundMixer.computeSpectrum is a stub".into())
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ pub fn instance_init<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(mut this) = this {
|
||||
activation.super_init(this, &[])?;
|
||||
|
||||
|
@ -43,7 +43,7 @@ pub fn class_init<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Ok(Value::Undefined)
|
||||
}
|
||||
|
||||
|
@ -52,7 +52,7 @@ pub fn pan<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
let left_to_right = this
|
||||
.get_property(&Multiname::public("leftToRight"), activation)?
|
||||
|
@ -80,7 +80,7 @@ pub fn set_pan<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(mut this) = this {
|
||||
let pan = args
|
||||
.get(0)
|
||||
|
|
|
@ -16,7 +16,7 @@ pub fn instance_init<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
activation.super_init(this, &[])?;
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ pub fn class_init<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Ok(Value::Undefined)
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ pub fn instance_init<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Ok(Value::Undefined)
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,7 @@ pub fn class_init<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Ok(Value::Undefined)
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ fn instance_init<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(mut this) = this {
|
||||
activation.super_init(this, &[])?;
|
||||
|
||||
|
@ -37,7 +37,7 @@ fn class_init<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Ok(Value::Undefined)
|
||||
}
|
||||
|
||||
|
@ -45,7 +45,7 @@ pub fn get_local<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
// 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".
|
||||
|
||||
|
@ -212,7 +212,7 @@ pub fn flush<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
let data = this
|
||||
.get_property(&Multiname::public("data"), activation)?
|
||||
|
|
|
@ -13,7 +13,7 @@ pub fn load<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
let request = match args.get(0) {
|
||||
Some(Value::Object(request)) => request,
|
||||
|
@ -45,7 +45,7 @@ fn spawn_fetch<'gc>(
|
|||
loader_object: Object<'gc>,
|
||||
url_request: &Object<'gc>,
|
||||
data_format: DataFormat,
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
let url = url_request
|
||||
.get_property(&Multiname::public("url"), activation)?
|
||||
.coerce_to_string(activation)?;
|
||||
|
|
|
@ -16,7 +16,7 @@ pub fn instance_init<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
activation.super_init(this, &[])?;
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ pub fn class_init<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Ok(Value::Undefined)
|
||||
}
|
||||
|
||||
|
@ -38,7 +38,7 @@ pub fn current_domain<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
let appdomain = activation.caller_domain();
|
||||
|
||||
Ok(DomainObject::from_domain(activation, appdomain)?.into())
|
||||
|
@ -49,7 +49,7 @@ pub fn parent_domain<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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(parent_domain) = appdomain.parent_domain() {
|
||||
return Ok(DomainObject::from_domain(activation, parent_domain)?.into());
|
||||
|
@ -64,7 +64,7 @@ pub fn get_definition<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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()) {
|
||||
let local_name = args
|
||||
.get(0)
|
||||
|
@ -90,7 +90,7 @@ pub fn has_definition<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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()) {
|
||||
let local_name = args
|
||||
.get(0)
|
||||
|
@ -110,7 +110,7 @@ pub fn set_domain_memory<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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(bytearray_obj) = arg.as_bytearray_object() {
|
||||
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, '_>,
|
||||
this: Option<Object<'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()) {
|
||||
let bytearray_object: Object<'gc> = appdomain.domain_memory().into();
|
||||
return Ok(bytearray_object.into());
|
||||
|
|
|
@ -10,7 +10,7 @@ pub fn get_sandbox_type<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
let sandbox_type = activation.context.system.sandbox_type.to_string();
|
||||
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, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
log::warn!("Security.allowDomain not implemented");
|
||||
Ok(Value::Undefined)
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ pub fn allow_insecure_domain<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
log::warn!("Security.allowInsecureDomain not implemented");
|
||||
Ok(Value::Undefined)
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ pub fn load_policy_file<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
log::warn!("Security.loadPolicyFile not implemented");
|
||||
Ok(Value::Undefined)
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ pub fn show_settings<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
log::warn!("Security.showSettings not implemented");
|
||||
Ok(Value::Undefined)
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ pub fn instance_init<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
activation.super_init(this, &[])?;
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ pub fn class_init<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Ok(Value::Undefined)
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,7 @@ pub fn font_name<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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| {
|
||||
activation
|
||||
.context
|
||||
|
@ -70,7 +70,7 @@ pub fn font_style<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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| {
|
||||
activation
|
||||
.context
|
||||
|
@ -101,7 +101,7 @@ pub fn font_type<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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| {
|
||||
activation
|
||||
.context
|
||||
|
@ -128,7 +128,7 @@ pub fn has_glyphs<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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| {
|
||||
activation
|
||||
.context
|
||||
|
@ -160,7 +160,7 @@ pub fn enumerate_fonts<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Err("Font.enumerateFonts is a stub".into())
|
||||
}
|
||||
|
||||
|
@ -169,7 +169,7 @@ pub fn register_font<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Err("Font.registerFont is a stub".into())
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ pub fn instance_init<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
activation.super_init(this, &[])?;
|
||||
|
||||
|
@ -42,7 +42,7 @@ pub fn class_init<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Ok(Value::Undefined)
|
||||
}
|
||||
|
||||
|
@ -50,7 +50,7 @@ pub fn autosize<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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())
|
||||
.and_then(|this| this.as_edit_text())
|
||||
|
@ -70,7 +70,7 @@ pub fn set_autosize<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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())
|
||||
.and_then(|this| this.as_edit_text())
|
||||
|
@ -101,7 +101,7 @@ pub fn background<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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())
|
||||
.and_then(|this| this.as_edit_text())
|
||||
|
@ -116,7 +116,7 @@ pub fn set_background<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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())
|
||||
.and_then(|this| this.as_edit_text())
|
||||
|
@ -136,7 +136,7 @@ pub fn background_color<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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())
|
||||
.and_then(|this| this.as_edit_text())
|
||||
|
@ -151,7 +151,7 @@ pub fn set_background_color<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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())
|
||||
.and_then(|this| this.as_edit_text())
|
||||
|
@ -171,7 +171,7 @@ pub fn border<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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())
|
||||
.and_then(|this| this.as_edit_text())
|
||||
|
@ -186,7 +186,7 @@ pub fn set_border<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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())
|
||||
.and_then(|this| this.as_edit_text())
|
||||
|
@ -206,7 +206,7 @@ pub fn border_color<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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())
|
||||
.and_then(|this| this.as_edit_text())
|
||||
|
@ -221,7 +221,7 @@ pub fn set_border_color<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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())
|
||||
.and_then(|this| this.as_edit_text())
|
||||
|
@ -241,7 +241,7 @@ pub fn default_text_format<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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())
|
||||
.and_then(|this| this.as_edit_text())
|
||||
|
@ -256,7 +256,7 @@ pub fn set_default_text_format<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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())
|
||||
.and_then(|this| this.as_edit_text())
|
||||
|
@ -277,7 +277,7 @@ pub fn display_as_password<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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())
|
||||
.and_then(|this| this.as_edit_text())
|
||||
|
@ -292,7 +292,7 @@ pub fn set_display_as_password<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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())
|
||||
.and_then(|this| this.as_edit_text())
|
||||
|
@ -313,7 +313,7 @@ pub fn embed_fonts<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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())
|
||||
.and_then(|this| this.as_edit_text())
|
||||
|
@ -328,7 +328,7 @@ pub fn set_embed_fonts<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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())
|
||||
.and_then(|this| this.as_edit_text())
|
||||
|
@ -349,7 +349,7 @@ pub fn html_text<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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())
|
||||
.and_then(|this| this.as_edit_text())
|
||||
|
@ -364,7 +364,7 @@ pub fn set_html_text<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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())
|
||||
.and_then(|this| this.as_edit_text())
|
||||
|
@ -385,7 +385,7 @@ pub fn length<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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())
|
||||
.and_then(|this| this.as_edit_text())
|
||||
|
@ -400,7 +400,7 @@ pub fn multiline<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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())
|
||||
.and_then(|this| this.as_edit_text())
|
||||
|
@ -415,7 +415,7 @@ pub fn set_multiline<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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())
|
||||
.and_then(|this| this.as_edit_text())
|
||||
|
@ -436,7 +436,7 @@ pub fn selectable<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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())
|
||||
.and_then(|this| this.as_edit_text())
|
||||
|
@ -451,7 +451,7 @@ pub fn set_selectable<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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())
|
||||
.and_then(|this| this.as_edit_text())
|
||||
|
@ -472,7 +472,7 @@ pub fn text<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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())
|
||||
.and_then(|this| this.as_edit_text())
|
||||
|
@ -487,7 +487,7 @@ pub fn set_text<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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())
|
||||
.and_then(|this| this.as_edit_text())
|
||||
|
@ -508,7 +508,7 @@ pub fn text_color<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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())
|
||||
.and_then(|this| this.as_edit_text())
|
||||
|
@ -527,7 +527,7 @@ pub fn set_text_color<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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())
|
||||
.and_then(|this| this.as_edit_text())
|
||||
|
@ -558,7 +558,7 @@ pub fn text_height<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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())
|
||||
.and_then(|this| this.as_edit_text())
|
||||
|
@ -574,7 +574,7 @@ pub fn text_width<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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())
|
||||
.and_then(|this| this.as_edit_text())
|
||||
|
@ -590,7 +590,7 @@ pub fn get_type<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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())
|
||||
.and_then(|this| this.as_edit_text())
|
||||
|
@ -608,7 +608,7 @@ pub fn set_type<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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())
|
||||
.and_then(|this| this.as_edit_text())
|
||||
|
@ -635,7 +635,7 @@ pub fn word_wrap<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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())
|
||||
.and_then(|this| this.as_edit_text())
|
||||
|
@ -650,7 +650,7 @@ pub fn set_word_wrap<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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())
|
||||
.and_then(|this| this.as_edit_text())
|
||||
|
@ -671,7 +671,7 @@ pub fn append_text<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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())
|
||||
.and_then(|this| this.as_edit_text())
|
||||
|
@ -698,7 +698,7 @@ pub fn get_text_format<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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())
|
||||
.and_then(|this| this.as_edit_text())
|
||||
|
@ -733,7 +733,7 @@ pub fn replace_selected_text<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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())
|
||||
.and_then(|this| this.as_edit_text())
|
||||
|
@ -762,7 +762,7 @@ pub fn replace_text<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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())
|
||||
.and_then(|this| this.as_edit_text())
|
||||
|
@ -798,7 +798,7 @@ pub fn set_selection<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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())
|
||||
.and_then(|this| this.as_edit_text())
|
||||
|
@ -830,7 +830,7 @@ pub fn set_text_format<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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())
|
||||
.and_then(|this| this.as_edit_text())
|
||||
|
@ -880,7 +880,7 @@ pub fn anti_alias_type<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
log::warn!("TextField.antiAliasType getter: not yet implemented");
|
||||
Ok(Value::Undefined)
|
||||
}
|
||||
|
@ -889,7 +889,7 @@ pub fn set_anti_alias_type<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
log::warn!("TextField.antiAliasType setter: not yet implemented");
|
||||
Ok(Value::Undefined)
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ pub fn instance_init<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
activation.super_init(this, &[])?;
|
||||
|
||||
|
@ -100,7 +100,7 @@ pub fn class_init<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Ok(Value::Undefined)
|
||||
}
|
||||
|
||||
|
@ -136,7 +136,7 @@ macro_rules! setter {
|
|||
fn align<'gc>(
|
||||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
text_format: &TextFormat,
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Ok(text_format
|
||||
.align
|
||||
.as_ref()
|
||||
|
@ -152,7 +152,7 @@ fn set_align<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
text_format: &mut TextFormat,
|
||||
value: &Value<'gc>,
|
||||
) -> Result<(), Error> {
|
||||
) -> Result<(), Error<'gc>> {
|
||||
let value = match value {
|
||||
Value::Undefined | Value::Null => {
|
||||
text_format.align = None;
|
||||
|
@ -181,7 +181,7 @@ fn set_align<'gc>(
|
|||
fn block_indent<'gc>(
|
||||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
text_format: &TextFormat,
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Ok(text_format
|
||||
.block_indent
|
||||
.as_ref()
|
||||
|
@ -192,7 +192,7 @@ fn set_block_indent<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
text_format: &mut TextFormat,
|
||||
value: &Value<'gc>,
|
||||
) -> Result<(), Error> {
|
||||
) -> Result<(), Error<'gc>> {
|
||||
text_format.block_indent = match value {
|
||||
Value::Undefined | Value::Null => None,
|
||||
value => Some(round_to_even(value.coerce_to_number(activation)?).into()),
|
||||
|
@ -203,7 +203,7 @@ fn set_block_indent<'gc>(
|
|||
fn bold<'gc>(
|
||||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
text_format: &TextFormat,
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Ok(text_format
|
||||
.bold
|
||||
.as_ref()
|
||||
|
@ -214,7 +214,7 @@ fn set_bold<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
text_format: &mut TextFormat,
|
||||
value: &Value<'gc>,
|
||||
) -> Result<(), Error> {
|
||||
) -> Result<(), Error<'gc>> {
|
||||
text_format.bold = match value {
|
||||
Value::Undefined | Value::Null => None,
|
||||
value => Some(value.coerce_to_boolean()),
|
||||
|
@ -225,7 +225,7 @@ fn set_bold<'gc>(
|
|||
fn bullet<'gc>(
|
||||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
text_format: &TextFormat,
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Ok(text_format
|
||||
.bullet
|
||||
.as_ref()
|
||||
|
@ -236,7 +236,7 @@ fn set_bullet<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
text_format: &mut TextFormat,
|
||||
value: &Value<'gc>,
|
||||
) -> Result<(), Error> {
|
||||
) -> Result<(), Error<'gc>> {
|
||||
text_format.bullet = match value {
|
||||
Value::Undefined | Value::Null => None,
|
||||
value => Some(value.coerce_to_boolean()),
|
||||
|
@ -247,7 +247,7 @@ fn set_bullet<'gc>(
|
|||
fn color<'gc>(
|
||||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
text_format: &TextFormat,
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Ok(text_format
|
||||
.color
|
||||
.as_ref()
|
||||
|
@ -258,7 +258,7 @@ fn set_color<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
text_format: &mut TextFormat,
|
||||
value: &Value<'gc>,
|
||||
) -> Result<(), Error> {
|
||||
) -> Result<(), Error<'gc>> {
|
||||
text_format.color = match value {
|
||||
Value::Undefined | Value::Null => None,
|
||||
value => Some(swf::Color::from_rgba(value.coerce_to_u32(activation)?)),
|
||||
|
@ -269,7 +269,7 @@ fn set_color<'gc>(
|
|||
fn font<'gc>(
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
text_format: &TextFormat,
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Ok(text_format.font.as_ref().map_or(Value::Null, |font| {
|
||||
AvmString::new(activation.context.gc_context, font.as_wstr()).into()
|
||||
}))
|
||||
|
@ -279,7 +279,7 @@ fn set_font<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
text_format: &mut TextFormat,
|
||||
value: &Value<'gc>,
|
||||
) -> Result<(), Error> {
|
||||
) -> Result<(), Error<'gc>> {
|
||||
text_format.font = match value {
|
||||
Value::Undefined | Value::Null => None,
|
||||
value => Some(value.coerce_to_string(activation)?.as_wstr().into()),
|
||||
|
@ -290,7 +290,7 @@ fn set_font<'gc>(
|
|||
fn indent<'gc>(
|
||||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
text_format: &TextFormat,
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Ok(text_format
|
||||
.indent
|
||||
.as_ref()
|
||||
|
@ -301,7 +301,7 @@ fn set_indent<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
text_format: &mut TextFormat,
|
||||
value: &Value<'gc>,
|
||||
) -> Result<(), Error> {
|
||||
) -> Result<(), Error<'gc>> {
|
||||
text_format.indent = match value {
|
||||
Value::Undefined | Value::Null => None,
|
||||
value => Some(round_to_even(value.coerce_to_number(activation)?).into()),
|
||||
|
@ -312,7 +312,7 @@ fn set_indent<'gc>(
|
|||
fn italic<'gc>(
|
||||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
text_format: &TextFormat,
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Ok(text_format
|
||||
.italic
|
||||
.as_ref()
|
||||
|
@ -323,7 +323,7 @@ fn set_italic<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
text_format: &mut TextFormat,
|
||||
value: &Value<'gc>,
|
||||
) -> Result<(), Error> {
|
||||
) -> Result<(), Error<'gc>> {
|
||||
text_format.italic = match value {
|
||||
Value::Undefined | Value::Null => None,
|
||||
value => Some(value.coerce_to_boolean()),
|
||||
|
@ -334,7 +334,7 @@ fn set_italic<'gc>(
|
|||
fn kerning<'gc>(
|
||||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
text_format: &TextFormat,
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Ok(text_format
|
||||
.kerning
|
||||
.as_ref()
|
||||
|
@ -345,7 +345,7 @@ fn set_kerning<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
text_format: &mut TextFormat,
|
||||
value: &Value<'gc>,
|
||||
) -> Result<(), Error> {
|
||||
) -> Result<(), Error<'gc>> {
|
||||
text_format.kerning = match value {
|
||||
Value::Undefined | Value::Null => None,
|
||||
value => Some(value.coerce_to_boolean()),
|
||||
|
@ -356,7 +356,7 @@ fn set_kerning<'gc>(
|
|||
fn leading<'gc>(
|
||||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
text_format: &TextFormat,
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Ok(text_format
|
||||
.leading
|
||||
.as_ref()
|
||||
|
@ -367,7 +367,7 @@ fn set_leading<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
text_format: &mut TextFormat,
|
||||
value: &Value<'gc>,
|
||||
) -> Result<(), Error> {
|
||||
) -> Result<(), Error<'gc>> {
|
||||
text_format.leading = match value {
|
||||
Value::Undefined | Value::Null => None,
|
||||
value => Some(round_to_even(value.coerce_to_number(activation)?).into()),
|
||||
|
@ -378,7 +378,7 @@ fn set_leading<'gc>(
|
|||
fn left_margin<'gc>(
|
||||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
text_format: &TextFormat,
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Ok(text_format
|
||||
.left_margin
|
||||
.as_ref()
|
||||
|
@ -389,7 +389,7 @@ fn set_left_margin<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
text_format: &mut TextFormat,
|
||||
value: &Value<'gc>,
|
||||
) -> Result<(), Error> {
|
||||
) -> Result<(), Error<'gc>> {
|
||||
text_format.left_margin = match value {
|
||||
Value::Undefined | Value::Null => None,
|
||||
value => Some(round_to_even(value.coerce_to_number(activation)?).into()),
|
||||
|
@ -400,7 +400,7 @@ fn set_left_margin<'gc>(
|
|||
fn letter_spacing<'gc>(
|
||||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
text_format: &TextFormat,
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Ok(text_format
|
||||
.letter_spacing
|
||||
.as_ref()
|
||||
|
@ -411,7 +411,7 @@ fn set_letter_spacing<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
text_format: &mut TextFormat,
|
||||
value: &Value<'gc>,
|
||||
) -> Result<(), Error> {
|
||||
) -> Result<(), Error<'gc>> {
|
||||
text_format.letter_spacing = match value {
|
||||
Value::Undefined | Value::Null => None,
|
||||
value => Some(value.coerce_to_number(activation)?),
|
||||
|
@ -422,7 +422,7 @@ fn set_letter_spacing<'gc>(
|
|||
fn right_margin<'gc>(
|
||||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
text_format: &TextFormat,
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Ok(text_format
|
||||
.right_margin
|
||||
.as_ref()
|
||||
|
@ -433,7 +433,7 @@ fn set_right_margin<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
text_format: &mut TextFormat,
|
||||
value: &Value<'gc>,
|
||||
) -> Result<(), Error> {
|
||||
) -> Result<(), Error<'gc>> {
|
||||
text_format.right_margin = match value {
|
||||
Value::Undefined | Value::Null => None,
|
||||
value => Some(round_to_even(value.coerce_to_number(activation)?).into()),
|
||||
|
@ -444,7 +444,7 @@ fn set_right_margin<'gc>(
|
|||
fn size<'gc>(
|
||||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
text_format: &TextFormat,
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Ok(text_format
|
||||
.size
|
||||
.as_ref()
|
||||
|
@ -455,7 +455,7 @@ fn set_size<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
text_format: &mut TextFormat,
|
||||
value: &Value<'gc>,
|
||||
) -> Result<(), Error> {
|
||||
) -> Result<(), Error<'gc>> {
|
||||
text_format.size = match value {
|
||||
Value::Undefined | Value::Null => None,
|
||||
value => Some(round_to_even(value.coerce_to_number(activation)?).into()),
|
||||
|
@ -466,7 +466,7 @@ fn set_size<'gc>(
|
|||
fn tab_stops<'gc>(
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
text_format: &TextFormat,
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
text_format
|
||||
.tab_stops
|
||||
.as_ref()
|
||||
|
@ -480,14 +480,14 @@ fn set_tab_stops<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
text_format: &mut TextFormat,
|
||||
value: &Value<'gc>,
|
||||
) -> Result<(), Error> {
|
||||
) -> Result<(), Error<'gc>> {
|
||||
text_format.tab_stops = match value {
|
||||
Value::Undefined | Value::Null => None,
|
||||
value => {
|
||||
let object = value.coerce_to_object(activation)?;
|
||||
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| {
|
||||
let element = object.get_property(
|
||||
&Multiname::public(AvmString::new_utf8(
|
||||
|
@ -508,7 +508,7 @@ fn set_tab_stops<'gc>(
|
|||
fn target<'gc>(
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
text_format: &TextFormat,
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Ok(text_format.target.as_ref().map_or(Value::Null, |target| {
|
||||
AvmString::new(activation.context.gc_context, target.as_wstr()).into()
|
||||
}))
|
||||
|
@ -518,7 +518,7 @@ fn set_target<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
text_format: &mut TextFormat,
|
||||
value: &Value<'gc>,
|
||||
) -> Result<(), Error> {
|
||||
) -> Result<(), Error<'gc>> {
|
||||
text_format.target = match value {
|
||||
Value::Undefined | Value::Null => None,
|
||||
value => Some(value.coerce_to_string(activation)?.as_wstr().into()),
|
||||
|
@ -529,7 +529,7 @@ fn set_target<'gc>(
|
|||
fn underline<'gc>(
|
||||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
text_format: &TextFormat,
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Ok(text_format
|
||||
.underline
|
||||
.as_ref()
|
||||
|
@ -540,7 +540,7 @@ fn set_underline<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
text_format: &mut TextFormat,
|
||||
value: &Value<'gc>,
|
||||
) -> Result<(), Error> {
|
||||
) -> Result<(), Error<'gc>> {
|
||||
text_format.underline = match value {
|
||||
Value::Undefined | Value::Null => None,
|
||||
value => Some(value.coerce_to_boolean()),
|
||||
|
@ -551,7 +551,7 @@ fn set_underline<'gc>(
|
|||
fn url<'gc>(
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
text_format: &TextFormat,
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Ok(text_format.url.as_ref().map_or(Value::Null, |url| {
|
||||
AvmString::new(activation.context.gc_context, url.as_wstr()).into()
|
||||
}))
|
||||
|
@ -561,7 +561,7 @@ fn set_url<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
text_format: &mut TextFormat,
|
||||
value: &Value<'gc>,
|
||||
) -> Result<(), Error> {
|
||||
) -> Result<(), Error<'gc>> {
|
||||
text_format.url = match value {
|
||||
Value::Undefined | Value::Null => None,
|
||||
value => Some(value.coerce_to_string(activation)?.as_wstr().into()),
|
||||
|
|
|
@ -7,7 +7,7 @@ pub fn hide_built_in_items<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
// TODO: replace this by a proper implementation.
|
||||
log::warn!("flash.ui.ContextMenu is a stub");
|
||||
activation
|
||||
|
|
|
@ -17,7 +17,7 @@ pub fn class_init<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Ok(Value::Undefined)
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,7 @@ pub fn instance_init<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Ok(Value::Undefined)
|
||||
}
|
||||
|
||||
|
@ -351,7 +351,7 @@ fn caps_lock<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
log::warn!("Keyboard.capsLock: not yet implemented");
|
||||
Ok(false.into())
|
||||
}
|
||||
|
@ -360,7 +360,7 @@ fn has_virtual_keyboard<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
log::warn!("Keyboard.hasVirtualKeyboard: not yet implemented");
|
||||
Ok(false.into())
|
||||
}
|
||||
|
@ -369,7 +369,7 @@ fn num_lock<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
log::warn!("Keyboard.numLock: not yet implemented");
|
||||
Ok(false.into())
|
||||
}
|
||||
|
@ -378,7 +378,7 @@ fn physical_keyboard_type<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
log::warn!("Keyboard.physicalKeyboardType: not yet implemented");
|
||||
Ok(AvmString::new_utf8(activation.context.gc_context, "alphanumeric").into())
|
||||
}
|
||||
|
@ -387,7 +387,7 @@ fn is_accessible<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
log::warn!("Keyboard.isAccessible: not yet implemented");
|
||||
Ok(true.into())
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ fn instance_init<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Err("The Mouse class cannot be constructed.".into())
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,7 @@ fn class_init<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Ok(Value::Undefined)
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,7 @@ fn hide<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
activation.context.ui.set_mouse_visible(false);
|
||||
Ok(Value::Undefined)
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ fn show<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
activation.context.ui.set_mouse_visible(true);
|
||||
Ok(Value::Undefined)
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ pub fn get_timer<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Ok((Instant::now()
|
||||
.duration_since(activation.context.start_time)
|
||||
.as_millis() as u32)
|
||||
|
@ -33,7 +33,7 @@ pub fn set_interval<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if args.len() < 2 {
|
||||
return Err(Error::from("setInterval: not enough arguments"));
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ pub fn clear_interval<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
let id = args
|
||||
.get(0)
|
||||
.ok_or("clearInterval: not enough arguments")?
|
||||
|
@ -76,7 +76,7 @@ pub fn set_timeout<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if args.len() < 2 {
|
||||
return Err(Error::from("setTimeout: not enough arguments"));
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ pub fn clear_timeout<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
let id = args
|
||||
.get(0)
|
||||
.ok_or("clearTimeout: not enough arguments")?
|
||||
|
@ -119,7 +119,7 @@ pub fn escape_multi_byte<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
let s = args
|
||||
.get(0)
|
||||
.unwrap_or(&Value::Undefined)
|
||||
|
@ -145,7 +145,7 @@ pub fn get_qualified_class_name<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
let obj = args
|
||||
.get(0)
|
||||
.unwrap_or(&Value::Undefined)
|
||||
|
@ -172,7 +172,7 @@ pub fn get_qualified_superclass_name<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
let obj = args
|
||||
.get(0)
|
||||
.unwrap_or(&Value::Undefined)
|
||||
|
@ -203,7 +203,7 @@ pub fn get_definition_by_name<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
let appdomain = activation.caller_domain();
|
||||
let name = args
|
||||
.get(0)
|
||||
|
|
|
@ -21,7 +21,7 @@ pub fn instance_init<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
activation.super_init(this, &[])?;
|
||||
|
||||
|
@ -55,7 +55,7 @@ pub fn class_init<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Ok(Value::Undefined)
|
||||
}
|
||||
|
||||
|
@ -64,7 +64,7 @@ pub fn write_byte<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(mut bytearray) = this.as_bytearray_mut(activation.context.gc_context) {
|
||||
let byte = args
|
||||
|
@ -84,7 +84,7 @@ pub fn write_bytes<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
let bytearray = args
|
||||
.get(0)
|
||||
|
@ -138,7 +138,7 @@ pub fn read_bytes<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
let bytearray = args
|
||||
.get(0)
|
||||
|
@ -186,7 +186,7 @@ pub fn write_utf<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(mut bytearray) = this.as_bytearray_mut(activation.context.gc_context) {
|
||||
if let Some(utf_string) = args.get(0) {
|
||||
|
@ -207,7 +207,7 @@ pub fn read_utf<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(bytearray) = this.as_bytearray() {
|
||||
return Ok(AvmString::new_utf8_bytes(
|
||||
|
@ -224,7 +224,7 @@ pub fn to_string<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(bytearray) = this.as_bytearray() {
|
||||
return Ok(
|
||||
|
@ -240,7 +240,7 @@ pub fn clear<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(mut bytearray) = this.as_bytearray_mut(activation.context.gc_context) {
|
||||
bytearray.clear();
|
||||
|
@ -255,7 +255,7 @@ pub fn position<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(bytearray) = this.as_bytearray() {
|
||||
return Ok(bytearray.position().into());
|
||||
|
@ -269,7 +269,7 @@ pub fn set_position<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(bytearray) = this.as_bytearray() {
|
||||
let num = args
|
||||
|
@ -287,7 +287,7 @@ pub fn bytes_available<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(bytearray) = this.as_bytearray() {
|
||||
return Ok(bytearray.bytes_available().into());
|
||||
|
@ -301,7 +301,7 @@ pub fn length<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(bytearray) = this.as_bytearray() {
|
||||
return Ok(bytearray.len().into());
|
||||
|
@ -315,7 +315,7 @@ pub fn set_length<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(mut bytearray) = this.as_bytearray_mut(activation.context.gc_context) {
|
||||
let len = args
|
||||
|
@ -333,7 +333,7 @@ pub fn endian<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(bytearray) = this.as_bytearray() {
|
||||
return Ok(match bytearray.endian() {
|
||||
|
@ -350,7 +350,7 @@ pub fn set_endian<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(mut bytearray) = this.as_bytearray_mut(activation.context.gc_context) {
|
||||
let endian = args
|
||||
|
@ -374,7 +374,7 @@ pub fn read_short<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(bytearray) = this.as_bytearray() {
|
||||
return Ok(bytearray.read_short()?.into());
|
||||
|
@ -388,7 +388,7 @@ pub fn read_unsigned_short<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(bytearray) = this.as_bytearray() {
|
||||
return Ok(bytearray.read_unsigned_short()?.into());
|
||||
|
@ -402,7 +402,7 @@ pub fn read_double<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(bytearray) = this.as_bytearray() {
|
||||
return Ok(bytearray.read_double()?.into());
|
||||
|
@ -416,7 +416,7 @@ pub fn read_float<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(bytearray) = this.as_bytearray() {
|
||||
return Ok(bytearray.read_float()?.into());
|
||||
|
@ -430,7 +430,7 @@ pub fn read_int<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(bytearray) = this.as_bytearray() {
|
||||
return Ok(bytearray.read_int()?.into());
|
||||
|
@ -444,7 +444,7 @@ pub fn read_unsigned_int<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(bytearray) = this.as_bytearray() {
|
||||
return Ok(bytearray.read_unsigned_int()?.into());
|
||||
|
@ -458,7 +458,7 @@ pub fn read_boolean<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(bytearray) = this.as_bytearray() {
|
||||
return Ok(bytearray.read_boolean()?.into());
|
||||
|
@ -472,7 +472,7 @@ pub fn read_byte<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(bytearray) = this.as_bytearray() {
|
||||
return Ok(bytearray.read_byte()?.into());
|
||||
|
@ -486,7 +486,7 @@ pub fn read_utf_bytes<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(bytearray) = this.as_bytearray() {
|
||||
let len = args
|
||||
|
@ -508,7 +508,7 @@ pub fn read_unsigned_byte<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(bytearray) = this.as_bytearray() {
|
||||
return Ok(bytearray.read_unsigned_byte()?.into());
|
||||
|
@ -522,7 +522,7 @@ pub fn write_float<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(mut bytearray) = this.as_bytearray_mut(activation.context.gc_context) {
|
||||
let num = args
|
||||
|
@ -540,7 +540,7 @@ pub fn write_double<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(mut bytearray) = this.as_bytearray_mut(activation.context.gc_context) {
|
||||
let num = args
|
||||
|
@ -558,7 +558,7 @@ pub fn write_boolean<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
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();
|
||||
|
@ -573,7 +573,7 @@ pub fn write_int<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(mut bytearray) = this.as_bytearray_mut(activation.context.gc_context) {
|
||||
let num = args
|
||||
|
@ -591,7 +591,7 @@ pub fn write_unsigned_int<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(mut bytearray) = this.as_bytearray_mut(activation.context.gc_context) {
|
||||
let num = args
|
||||
|
@ -609,7 +609,7 @@ pub fn write_short<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(mut bytearray) = this.as_bytearray_mut(activation.context.gc_context) {
|
||||
let num = args
|
||||
|
@ -627,7 +627,7 @@ pub fn write_multibyte<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(mut bytearray) = this.as_bytearray_mut(activation.context.gc_context) {
|
||||
let string = args
|
||||
|
@ -653,7 +653,7 @@ pub fn read_multibyte<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(bytearray) = this.as_bytearray() {
|
||||
let len = args
|
||||
|
@ -679,7 +679,7 @@ pub fn write_utf_bytes<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(mut bytearray) = this.as_bytearray_mut(activation.context.gc_context) {
|
||||
let string = args
|
||||
|
@ -697,7 +697,7 @@ pub fn compress<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(mut bytearray) = this.as_bytearray_mut(activation.context.gc_context) {
|
||||
let algorithm = args
|
||||
|
@ -717,7 +717,7 @@ pub fn uncompress<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(mut bytearray) = this.as_bytearray_mut(activation.context.gc_context) {
|
||||
let algorithm = args
|
||||
|
@ -737,7 +737,7 @@ pub fn deflate<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(mut bytearray) = this.as_bytearray_mut(activation.context.gc_context) {
|
||||
let buffer = bytearray.compress(CompressionAlgorithm::Deflate)?;
|
||||
|
@ -753,7 +753,7 @@ pub fn inflate<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(mut bytearray) = this.as_bytearray_mut(activation.context.gc_context) {
|
||||
let buffer = bytearray.decompress(CompressionAlgorithm::Deflate)?;
|
||||
|
@ -769,7 +769,7 @@ pub fn read_object<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(bytearray) = this.as_bytearray() {
|
||||
let bytes = bytearray.read_at(bytearray.bytes_available(), bytearray.position())?;
|
||||
|
@ -808,7 +808,7 @@ pub fn object_encoding<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(bytearray) = this.as_bytearray() {
|
||||
return Ok((bytearray.object_encoding() as u8).into());
|
||||
|
@ -822,7 +822,7 @@ pub fn set_object_encoding<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(mut bytearray) = this.as_bytearray_mut(activation.context.gc_context) {
|
||||
let new_encoding = args
|
||||
|
|
|
@ -16,7 +16,7 @@ pub fn instance_init<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
activation.super_init(this, &[])?;
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ pub fn class_init<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Ok(Value::Undefined)
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ pub fn instance_init<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Ok(Value::Undefined)
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,7 @@ pub fn class_init<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Ok(Value::Undefined)
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@ pub fn get_property<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Err("getproperty is not implemented for this Proxy".into())
|
||||
}
|
||||
|
||||
|
@ -42,7 +42,7 @@ pub fn set_property<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Err("setproperty is not implemented for this Proxy".into())
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,7 @@ pub fn delete_property<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Err("deleteproperty is not implemented for this Proxy".into())
|
||||
}
|
||||
|
||||
|
@ -60,7 +60,7 @@ pub fn call_property<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Err("callproperty is not implemented for this Proxy".into())
|
||||
}
|
||||
|
||||
|
@ -69,7 +69,7 @@ pub fn has_property<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Err("hasproperty is not implemented for this Proxy".into())
|
||||
}
|
||||
|
||||
|
@ -78,7 +78,7 @@ pub fn is_attribute<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Err("isattribute is not implemented for this Proxy".into())
|
||||
}
|
||||
|
||||
|
@ -87,7 +87,7 @@ pub fn get_descendants<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Err("getdescendants is not implemented for this Proxy".into())
|
||||
}
|
||||
|
||||
|
@ -96,7 +96,7 @@ pub fn next_name_index<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Err("hasnext/nextNameIndex is not implemented for this Proxy".into())
|
||||
}
|
||||
|
||||
|
@ -105,7 +105,7 @@ pub fn next_name<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Err("nextname is not implemented for this Proxy".into())
|
||||
}
|
||||
|
||||
|
@ -114,7 +114,7 @@ pub fn next_value<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Err("nextvalue is not implemented for this Proxy".into())
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ pub fn stop<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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 id = this
|
||||
.get_property(
|
||||
|
@ -40,7 +40,7 @@ pub fn start<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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 id = this
|
||||
.get_property(
|
||||
|
|
|
@ -17,7 +17,7 @@ pub fn instance_init<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
activation.super_init(this, &[])?;
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ pub fn class_init<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
let scope = activation.create_scopechain();
|
||||
let this_class = this.as_class_object().unwrap();
|
||||
|
@ -79,7 +79,7 @@ fn call<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
func: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
let this = args
|
||||
.get(0)
|
||||
.and_then(|v| v.coerce_to_object(activation).ok())
|
||||
|
@ -101,7 +101,7 @@ fn apply<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
func: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
let this = args
|
||||
.get(0)
|
||||
.and_then(|v| v.coerce_to_object(activation).ok())
|
||||
|
@ -137,7 +137,7 @@ fn prototype<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(function) = this.as_function_object() {
|
||||
if let Some(proto) = function.prototype() {
|
||||
|
@ -154,7 +154,7 @@ fn set_prototype<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(function) = this.as_function_object() {
|
||||
let new_proto = args
|
||||
|
|
|
@ -20,7 +20,7 @@ pub fn instance_init<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Ok(Value::Undefined)
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,7 @@ pub fn class_init<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Ok(Value::Undefined)
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ fn instance_init<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(mut prim) = this.as_primitive_mut(activation.context.gc_context) {
|
||||
if matches!(*prim, Value::Undefined | Value::Null) {
|
||||
|
@ -39,7 +39,7 @@ fn native_instance_init<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
activation.super_init(this, args)?;
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ fn class_init<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
let scope = activation.create_scopechain();
|
||||
let gc_context = activation.context.gc_context;
|
||||
|
@ -135,7 +135,7 @@ fn to_exponential<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(this) = this.as_primitive() {
|
||||
if let Value::Integer(number) = *this {
|
||||
|
@ -169,7 +169,7 @@ fn to_fixed<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(this) = this.as_primitive() {
|
||||
if let Value::Integer(number) = *this {
|
||||
|
@ -200,7 +200,7 @@ fn to_precision<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(this) = this.as_primitive() {
|
||||
if let Value::Integer(number) = *this {
|
||||
|
@ -227,7 +227,7 @@ fn to_string<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(this) = this.as_primitive() {
|
||||
if let Value::Integer(number) = *this {
|
||||
|
@ -254,7 +254,7 @@ fn value_of<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(this) = this.as_primitive() {
|
||||
return Ok(*this);
|
||||
|
|
|
@ -23,7 +23,7 @@ fn deserialize_json_inner<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
json: JsonValue,
|
||||
reviver: Option<Object<'gc>>,
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Ok(match json {
|
||||
JsonValue::Null => Value::Null,
|
||||
JsonValue::String(s) => AvmString::new_utf8(activation.context.gc_context, s).into(),
|
||||
|
@ -75,7 +75,7 @@ fn deserialize_json<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
json: JsonValue,
|
||||
reviver: Option<Object<'gc>>,
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
let val = deserialize_json_inner(activation, json, reviver)?;
|
||||
match reviver {
|
||||
None => Ok(val),
|
||||
|
@ -118,7 +118,7 @@ impl<'gc> AvmSerializer<'gc> {
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
key: impl Fn() -> AvmString<'gc>,
|
||||
value: Value<'gc>,
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
let (eval_key, value) = if value.is_primitive() {
|
||||
(None, value)
|
||||
} else {
|
||||
|
@ -149,7 +149,7 @@ impl<'gc> AvmSerializer<'gc> {
|
|||
&mut self,
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
obj: Object<'gc>,
|
||||
) -> Result<JsonValue, Error> {
|
||||
) -> Result<JsonValue, Error<'gc>> {
|
||||
let mut js_obj = JsonObject::new();
|
||||
// If the user supplied a PropList, we use that to find properties on the object.
|
||||
if let Some(Replacer::PropList(props)) = self.replacer {
|
||||
|
@ -194,7 +194,7 @@ impl<'gc> AvmSerializer<'gc> {
|
|||
&mut self,
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
iterable: Object<'gc>,
|
||||
) -> Result<JsonValue, Error> {
|
||||
) -> Result<JsonValue, Error<'gc>> {
|
||||
let mut js_arr = Vec::new();
|
||||
let mut iter = ArrayIter::new(activation, iterable)?;
|
||||
while let Some(r) = iter.next(activation) {
|
||||
|
@ -211,7 +211,7 @@ impl<'gc> AvmSerializer<'gc> {
|
|||
&mut self,
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
value: Value<'gc>,
|
||||
) -> Result<JsonValue, Error> {
|
||||
) -> Result<JsonValue, Error<'gc>> {
|
||||
Ok(match value {
|
||||
Value::Null => JsonValue::Null,
|
||||
Value::Undefined => JsonValue::Null,
|
||||
|
@ -247,7 +247,7 @@ impl<'gc> AvmSerializer<'gc> {
|
|||
&mut self,
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
value: Value<'gc>,
|
||||
) -> Result<JsonValue, Error> {
|
||||
) -> Result<JsonValue, Error<'gc>> {
|
||||
let mapped = self.map_value(activation, || "".into(), value)?;
|
||||
self.serialize_value(activation, mapped)
|
||||
}
|
||||
|
@ -258,7 +258,7 @@ pub fn instance_init<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Err("ArgumentError: Error #2012: JSON class cannot be instantiated.".into())
|
||||
}
|
||||
|
||||
|
@ -267,7 +267,7 @@ pub fn class_init<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Ok(Value::Undefined)
|
||||
}
|
||||
|
||||
|
@ -276,7 +276,7 @@ pub fn parse<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
let input = args
|
||||
.get(0)
|
||||
.unwrap_or(&Value::Undefined)
|
||||
|
@ -292,7 +292,7 @@ pub fn stringify<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
let val = args.get(0).unwrap_or(&Value::Undefined);
|
||||
let replacer = args.get(1).unwrap_or(&Value::Undefined).as_object();
|
||||
let spaces = args.get(2).unwrap_or(&Value::Undefined);
|
||||
|
|
|
@ -12,7 +12,7 @@ macro_rules! wrap_std {
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(input) = args.get(0) {
|
||||
Ok($std(input.coerce_to_number(activation)?).into())
|
||||
} else {
|
||||
|
@ -39,7 +39,7 @@ pub fn round<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(x) = args.get(0) {
|
||||
let x = x.coerce_to_number(activation)?;
|
||||
// Note that Flash Math.round always rounds toward infinity,
|
||||
|
@ -54,7 +54,7 @@ pub fn atan2<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
let y = args
|
||||
.get(0)
|
||||
.unwrap_or(&Value::Undefined)
|
||||
|
@ -70,7 +70,7 @@ pub fn max<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
let mut cur_max = f64::NEG_INFINITY;
|
||||
for arg in args {
|
||||
let val = arg.coerce_to_number(activation)?;
|
||||
|
@ -87,7 +87,7 @@ pub fn min<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
let mut cur_min = f64::INFINITY;
|
||||
for arg in args {
|
||||
let val = arg.coerce_to_number(activation)?;
|
||||
|
@ -104,7 +104,7 @@ pub fn pow<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
let n = args
|
||||
.get(0)
|
||||
.unwrap_or(&Value::Undefined)
|
||||
|
@ -120,6 +120,6 @@ pub fn random<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Ok(activation.context.rng.gen_range(0.0f64..1.0f64).into())
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ pub fn instance_init<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Err("Namespace constructor is a stub.".into())
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,7 @@ fn class_call<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Err("Namespace constructor is a stub.".into())
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@ pub fn native_instance_init<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
activation.super_init(this, args)?;
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ pub fn class_init<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Ok(Value::Undefined)
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ fn instance_init<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(mut prim) = this.as_primitive_mut(activation.context.gc_context) {
|
||||
if matches!(*prim, Value::Undefined | Value::Null) {
|
||||
|
@ -38,7 +38,7 @@ fn native_instance_init<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
activation.super_init(this, args)?;
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ fn class_init<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
let scope = activation.create_scopechain();
|
||||
let gc_context = activation.context.gc_context;
|
||||
|
@ -133,7 +133,7 @@ fn to_locale_string<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(this) = this.as_primitive() {
|
||||
return Ok(this.coerce_to_string(activation)?.into());
|
||||
|
@ -148,7 +148,7 @@ fn to_exponential<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(this) = this.as_primitive() {
|
||||
if let Value::Number(number) = *this {
|
||||
|
@ -182,7 +182,7 @@ fn to_fixed<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(this) = this.as_primitive() {
|
||||
if let Value::Number(number) = *this {
|
||||
|
@ -212,7 +212,7 @@ pub fn print_with_precision<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
number: f64,
|
||||
wanted_digits: usize,
|
||||
) -> Result<AvmString<'gc>, Error> {
|
||||
) -> Result<AvmString<'gc>, Error<'gc>> {
|
||||
let mut available_digits = number.abs().log10().floor();
|
||||
if available_digits.is_nan() || available_digits.is_infinite() {
|
||||
available_digits = 1.0;
|
||||
|
@ -244,7 +244,7 @@ fn to_precision<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(this) = this.as_primitive() {
|
||||
if let Value::Number(number) = *this {
|
||||
|
@ -270,7 +270,7 @@ pub fn print_with_radix<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
mut number: f64,
|
||||
radix: usize,
|
||||
) -> Result<AvmString<'gc>, Error> {
|
||||
) -> Result<AvmString<'gc>, Error<'gc>> {
|
||||
if radix == 10 {
|
||||
return Value::from(number).coerce_to_string(activation);
|
||||
}
|
||||
|
@ -313,7 +313,7 @@ fn to_string<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(this) = this.as_primitive() {
|
||||
if let Value::Number(number) = *this {
|
||||
|
@ -340,7 +340,7 @@ fn value_of<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(this) = this.as_primitive() {
|
||||
return Ok(*this);
|
||||
|
|
|
@ -17,7 +17,7 @@ pub fn instance_init<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Ok(Value::Undefined)
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@ fn class_call<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
let this_class = activation.subclass_object().unwrap();
|
||||
|
||||
if args.is_empty() {
|
||||
|
@ -43,7 +43,7 @@ pub fn class_init<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
let scope = activation.create_scopechain();
|
||||
let gc_context = activation.context.gc_context;
|
||||
|
@ -164,7 +164,7 @@ fn to_string<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
this.map(|t| t.to_string(activation))
|
||||
.unwrap_or(Ok(Value::Undefined))
|
||||
}
|
||||
|
@ -174,7 +174,7 @@ fn to_locale_string<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
this.map(|t| t.to_locale_string(activation))
|
||||
.unwrap_or(Ok(Value::Undefined))
|
||||
}
|
||||
|
@ -184,7 +184,7 @@ fn value_of<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
this.map(|t| t.value_of(activation.context.gc_context))
|
||||
.unwrap_or(Ok(Value::Undefined))
|
||||
}
|
||||
|
@ -194,10 +194,12 @@ pub fn has_own_property<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
let this: Result<Object<'gc>, Error> = this.ok_or_else(|| "No valid this parameter".into());
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
let this: Result<Object<'gc>, Error<'gc>> =
|
||||
this.ok_or_else(|| "No valid this parameter".into());
|
||||
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 multiname = Multiname::public(name);
|
||||
|
@ -209,8 +211,8 @@ pub fn is_prototype_of<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
let search_proto: Result<Object<'gc>, Error> =
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
let search_proto: Result<Object<'gc>, Error<'gc>> =
|
||||
this.ok_or_else(|| "No valid this parameter".into());
|
||||
let search_proto = search_proto?;
|
||||
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, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
let this: Result<Object<'gc>, Error> = this.ok_or_else(|| "No valid this parameter".into());
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
let this: Result<Object<'gc>, Error<'gc>> =
|
||||
this.ok_or_else(|| "No valid this parameter".into());
|
||||
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)?;
|
||||
|
||||
Ok(this.property_is_enumerable(name).into())
|
||||
|
@ -245,10 +249,12 @@ pub fn set_property_is_enumerable<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
let this: Result<Object<'gc>, Error> = this.ok_or_else(|| "No valid this parameter".into());
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
let this: Result<Object<'gc>, Error<'gc>> =
|
||||
this.ok_or_else(|| "No valid this parameter".into());
|
||||
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)?;
|
||||
|
||||
if let Some(Value::Bool(is_enum)) = args.get(1) {
|
||||
|
|
|
@ -16,7 +16,7 @@ pub fn instance_init<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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 this.qname().is_none() {
|
||||
let (namespace, local_arg) = if args.len() > 1 {
|
||||
|
@ -64,7 +64,7 @@ pub fn class_init<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
let this = this.unwrap();
|
||||
let scope = activation.create_scopechain();
|
||||
let this_class = this.as_class_object().unwrap();
|
||||
|
@ -115,7 +115,7 @@ pub fn local_name<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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(qname) = this.qname() {
|
||||
return Ok(qname.local_name().into());
|
||||
|
@ -130,7 +130,7 @@ pub fn uri<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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(qname) = this.qname() {
|
||||
return Ok(match qname.namespace() {
|
||||
|
@ -148,7 +148,7 @@ pub fn to_string<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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(qname) = this.qname() {
|
||||
return Ok(qname.as_uri(activation.context.gc_context).into());
|
||||
|
@ -163,7 +163,7 @@ pub fn value_of<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
return Ok(this.into());
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ pub fn instance_init<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
activation.super_init(this, &[])?;
|
||||
|
||||
|
@ -57,7 +57,7 @@ fn class_call<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
let this_class = activation.subclass_object().unwrap();
|
||||
|
||||
if args.len() == 1 {
|
||||
|
@ -74,7 +74,7 @@ pub fn class_init<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Ok(Value::Undefined)
|
||||
}
|
||||
|
||||
|
@ -83,7 +83,7 @@ pub fn dotall<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(regexp) = this.as_regexp() {
|
||||
return Ok(regexp.flags().contains(RegExpFlags::DOTALL).into());
|
||||
|
@ -98,7 +98,7 @@ pub fn extended<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(regexp) = this.as_regexp() {
|
||||
return Ok(regexp.flags().contains(RegExpFlags::EXTENDED).into());
|
||||
|
@ -113,7 +113,7 @@ pub fn global<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(regexp) = this.as_regexp() {
|
||||
return Ok(regexp.flags().contains(RegExpFlags::GLOBAL).into());
|
||||
|
@ -128,7 +128,7 @@ pub fn ignore_case<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(regexp) = this.as_regexp() {
|
||||
return Ok(regexp.flags().contains(RegExpFlags::IGNORE_CASE).into());
|
||||
|
@ -143,7 +143,7 @@ pub fn multiline<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(regexp) = this.as_regexp() {
|
||||
return Ok(regexp.flags().contains(RegExpFlags::MULTILINE).into());
|
||||
|
@ -158,7 +158,7 @@ pub fn last_index<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(re) = this.as_regexp() {
|
||||
return Ok(re.last_index().into());
|
||||
|
@ -173,7 +173,7 @@ pub fn set_last_index<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(mut re) = this.as_regexp_mut(activation.context.gc_context) {
|
||||
let i = args
|
||||
|
@ -192,7 +192,7 @@ pub fn source<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(re) = this.as_regexp() {
|
||||
return Ok(re.source().into());
|
||||
|
@ -207,7 +207,7 @@ pub fn exec<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(mut re) = this.as_regexp_mut(activation.context.gc_context) {
|
||||
let text = args
|
||||
|
@ -253,7 +253,7 @@ pub fn test<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(mut re) = this.as_regexp_mut(activation.context.gc_context) {
|
||||
let text = args
|
||||
|
|
|
@ -20,7 +20,7 @@ pub fn instance_init<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
activation.super_init(this, &[])?;
|
||||
|
||||
|
@ -43,7 +43,7 @@ pub fn class_init<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Ok(Value::Undefined)
|
||||
}
|
||||
|
||||
|
@ -52,7 +52,7 @@ fn length<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Value::String(s) = this.value_of(activation.context.gc_context)? {
|
||||
return Ok(s.len().into());
|
||||
|
@ -67,7 +67,7 @@ fn char_at<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
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.
|
||||
|
@ -97,7 +97,7 @@ fn char_code_at<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
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.
|
||||
|
@ -123,7 +123,7 @@ fn concat<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
let mut ret = WString::from(Value::from(this).coerce_to_string(activation)?.as_wstr());
|
||||
for arg in args {
|
||||
|
@ -141,7 +141,7 @@ fn from_char_code<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
let mut out = WString::with_capacity(args.len(), false);
|
||||
for arg in args {
|
||||
let i = arg.coerce_to_u32(activation)? as u16;
|
||||
|
@ -159,7 +159,7 @@ fn index_of<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
let this = Value::from(this).coerce_to_string(activation)?;
|
||||
let pattern = match args.get(0) {
|
||||
|
@ -187,7 +187,7 @@ fn last_index_of<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
let this = Value::from(this).coerce_to_string(activation)?;
|
||||
let pattern = match args.get(0) {
|
||||
|
@ -220,7 +220,7 @@ fn locale_compare<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
let this = Value::from(this).coerce_to_string(activation)?;
|
||||
let other = match args.get(0) {
|
||||
|
@ -254,7 +254,7 @@ fn match_s<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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)) {
|
||||
let this = Value::from(this).coerce_to_string(activation)?;
|
||||
|
||||
|
@ -321,7 +321,7 @@ fn replace<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
let this = Value::from(this).coerce_to_string(activation)?;
|
||||
let pattern = args.get(0).unwrap_or(&Value::Undefined);
|
||||
|
@ -368,7 +368,7 @@ fn search<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'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)) {
|
||||
let this = Value::from(this).coerce_to_string(activation)?;
|
||||
|
||||
|
@ -405,7 +405,7 @@ fn slice<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
let this = Value::from(this).coerce_to_string(activation)?;
|
||||
let start_index = match args.get(0) {
|
||||
|
@ -437,7 +437,7 @@ fn split<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
let delimiter = args.get(0).unwrap_or(&Value::Undefined);
|
||||
if matches!(delimiter, Value::Undefined) {
|
||||
|
@ -497,7 +497,7 @@ fn substr<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
let this_val = Value::from(this);
|
||||
let this = this_val.coerce_to_string(activation)?;
|
||||
|
@ -536,7 +536,7 @@ fn substring<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
let this_val = Value::from(this);
|
||||
let this = this_val.coerce_to_string(activation)?;
|
||||
|
@ -575,7 +575,7 @@ fn to_lower_case<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
let this_val = Value::from(this);
|
||||
let this = this_val.coerce_to_string(activation)?;
|
||||
|
@ -595,7 +595,7 @@ fn to_upper_case<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
let this_val = Value::from(this);
|
||||
let this = this_val.coerce_to_string(activation)?;
|
||||
|
|
|
@ -10,7 +10,7 @@ pub fn trace<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
match args {
|
||||
[] => activation.context.avm_trace(""),
|
||||
[arg] => {
|
||||
|
@ -34,7 +34,7 @@ pub fn is_finite<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(val) = args.get(0) {
|
||||
Ok(val.coerce_to_number(activation)?.is_finite().into())
|
||||
} else {
|
||||
|
@ -46,7 +46,7 @@ pub fn is_nan<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(val) = args.get(0) {
|
||||
Ok(val.coerce_to_number(activation)?.is_nan().into())
|
||||
} else {
|
||||
|
@ -58,7 +58,7 @@ pub fn parse_int<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
let string = match args.get(0).unwrap_or(&Value::Undefined) {
|
||||
Value::Undefined => "null".into(),
|
||||
value => value.coerce_to_string(activation)?,
|
||||
|
@ -77,7 +77,7 @@ pub fn parse_float<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(value) = args.get(0) {
|
||||
let string = value.coerce_to_string(activation)?;
|
||||
let swf_version = activation.context.swf.version();
|
||||
|
@ -93,7 +93,7 @@ pub fn escape<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
let value = match args.first() {
|
||||
None => return Ok("undefined".into()),
|
||||
Some(Value::Undefined) => return Ok("null".into()),
|
||||
|
|
|
@ -17,7 +17,7 @@ fn instance_init<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(mut prim) = this.as_primitive_mut(activation.context.gc_context) {
|
||||
if matches!(*prim, Value::Undefined | Value::Null) {
|
||||
|
@ -39,7 +39,7 @@ fn native_instance_init<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
activation.super_init(this, args)?;
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ fn class_init<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
let scope = activation.create_scopechain();
|
||||
let gc_context = activation.context.gc_context;
|
||||
|
@ -134,7 +134,7 @@ fn to_exponential<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(this) = this.as_primitive() {
|
||||
if let Value::Integer(number) = *this {
|
||||
|
@ -168,7 +168,7 @@ fn to_fixed<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(this) = this.as_primitive() {
|
||||
if let Value::Integer(number) = *this {
|
||||
|
@ -199,7 +199,7 @@ fn to_precision<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(this) = this.as_primitive() {
|
||||
if let Value::Integer(number) = *this {
|
||||
|
@ -226,7 +226,7 @@ fn to_string<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(this) = this.as_primitive() {
|
||||
if let Value::Integer(number) = *this {
|
||||
|
@ -253,7 +253,7 @@ fn value_of<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(this) = this.as_primitive() {
|
||||
return Ok(*this);
|
||||
|
|
|
@ -24,7 +24,7 @@ pub fn instance_init<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
activation.super_init(this, &[])?;
|
||||
|
||||
|
@ -52,7 +52,7 @@ fn class_call<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if args.len() != 1 {
|
||||
return Err("Argument count mismatch on class coercion".into());
|
||||
}
|
||||
|
@ -93,7 +93,7 @@ pub fn class_init<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
let mut globals = activation.global_scope().unwrap();
|
||||
let mut domain = activation.domain();
|
||||
|
@ -178,7 +178,7 @@ pub fn specialized_class_init<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
let mut proto = this
|
||||
.get_property(&Multiname::public("prototype"), activation)?
|
||||
|
@ -239,7 +239,7 @@ pub fn length<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(vector) = this.as_vector_storage() {
|
||||
return Ok(vector.length().into());
|
||||
|
@ -254,7 +254,7 @@ pub fn set_length<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(mut vector) = this.as_vector_storage_mut(activation.context.gc_context) {
|
||||
let new_length = args
|
||||
|
@ -275,7 +275,7 @@ pub fn fixed<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(vector) = this.as_vector_storage() {
|
||||
return Ok(vector.is_fixed().into());
|
||||
|
@ -290,7 +290,7 @@ pub fn set_fixed<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(mut vector) = this.as_vector_storage_mut(activation.context.gc_context) {
|
||||
let new_fixed = args
|
||||
|
@ -311,7 +311,7 @@ pub fn concat<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
let mut new_vector_storage = if let Some(vector) = this.as_vector_storage() {
|
||||
vector.clone()
|
||||
|
@ -378,9 +378,12 @@ fn join_inner<'gc, 'a, 'ctxt, C>(
|
|||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
mut conv: C,
|
||||
) -> Result<Value<'gc>, Error>
|
||||
) -> Result<Value<'gc>, Error<'gc>>
|
||||
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);
|
||||
if separator == Value::Undefined {
|
||||
|
@ -416,7 +419,7 @@ pub fn join<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
join_inner(activation, this, args, |v, _act| Ok(v))
|
||||
}
|
||||
|
||||
|
@ -425,7 +428,7 @@ pub fn to_string<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
join_inner(activation, this, &[",".into()], |v, _act| Ok(v))
|
||||
}
|
||||
|
||||
|
@ -434,7 +437,7 @@ pub fn to_locale_string<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
join_inner(activation, this, &[",".into()], |v, act| {
|
||||
if let Ok(o) = v.coerce_to_object(act) {
|
||||
o.call_property(&Multiname::public("toLocaleString"), &[], act)
|
||||
|
@ -449,7 +452,7 @@ pub fn every<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
let callback = args
|
||||
.get(0)
|
||||
|
@ -482,7 +485,7 @@ pub fn some<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
let callback = args
|
||||
.get(0)
|
||||
|
@ -515,7 +518,7 @@ pub fn filter<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
let callback = args
|
||||
.get(0)
|
||||
|
@ -556,7 +559,7 @@ pub fn for_each<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
let callback = args
|
||||
.get(0)
|
||||
|
@ -581,7 +584,7 @@ pub fn index_of<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
let search_for = args.get(0).cloned().unwrap_or(Value::Undefined);
|
||||
let from_index = args
|
||||
|
@ -618,7 +621,7 @@ pub fn last_index_of<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
let search_for = args.get(0).cloned().unwrap_or(Value::Undefined);
|
||||
let from_index = args
|
||||
|
@ -655,7 +658,7 @@ pub fn map<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
let callback = args
|
||||
.get(0)
|
||||
|
@ -693,7 +696,7 @@ pub fn pop<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(mut vs) = this.as_vector_storage_mut(activation.context.gc_context) {
|
||||
return vs.pop(activation);
|
||||
|
@ -708,7 +711,7 @@ pub fn push<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(mut vs) = this.as_vector_storage_mut(activation.context.gc_context) {
|
||||
let value_type = vs.value_type();
|
||||
|
@ -731,7 +734,7 @@ pub fn shift<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(mut vs) = this.as_vector_storage_mut(activation.context.gc_context) {
|
||||
return vs.shift(activation);
|
||||
|
@ -746,7 +749,7 @@ pub fn unshift<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(mut vs) = this.as_vector_storage_mut(activation.context.gc_context) {
|
||||
let value_type = vs.value_type();
|
||||
|
@ -769,7 +772,7 @@ pub fn insert_at<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(mut vs) = this.as_vector_storage_mut(activation.context.gc_context) {
|
||||
let index = args
|
||||
|
@ -796,7 +799,7 @@ pub fn remove_at<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(mut vs) = this.as_vector_storage_mut(activation.context.gc_context) {
|
||||
let index = args
|
||||
|
@ -817,7 +820,7 @@ pub fn reverse<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(mut vs) = this.as_vector_storage_mut(activation.context.gc_context) {
|
||||
vs.reverse();
|
||||
|
@ -834,7 +837,7 @@ pub fn slice<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(vs) = this.as_vector_storage_mut(activation.context.gc_context) {
|
||||
let from = args
|
||||
|
@ -874,7 +877,7 @@ pub fn sort<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
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);
|
||||
|
@ -961,7 +964,7 @@ pub fn splice<'gc>(
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if let Some(this) = this {
|
||||
if let Some(mut vs) = this.as_vector_storage_mut(activation.context.gc_context) {
|
||||
let start_len = args
|
||||
|
|
|
@ -16,7 +16,7 @@ pub fn instance_init<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Ok(Value::Undefined)
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@ pub fn class_init<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Ok(Value::Undefined)
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ pub fn instance_init<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Ok(Value::Undefined)
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@ pub fn class_init<'gc>(
|
|||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Ok(Value::Undefined)
|
||||
}
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ pub type NativeMethodImpl = for<'gc> fn(
|
|||
&mut Activation<'_, 'gc, '_>,
|
||||
Option<Object<'gc>>,
|
||||
&[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error>;
|
||||
) -> Result<Value<'gc>, Error<'gc>>;
|
||||
|
||||
/// Configuration of a single parameter of a method.
|
||||
#[derive(Clone, Collect, Debug)]
|
||||
|
@ -56,7 +56,7 @@ impl<'gc> ParamConfig<'gc> {
|
|||
config: &AbcMethodParam,
|
||||
txunit: TranslationUnit<'gc>,
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
) -> Result<Self, Error> {
|
||||
) -> Result<Self, Error<'gc>> {
|
||||
let param_name = if let Some(name) = &config.name {
|
||||
txunit.pool_string(name.0, activation.context.gc_context)?
|
||||
} else {
|
||||
|
@ -138,7 +138,7 @@ impl<'gc> BytecodeMethod<'gc> {
|
|||
abc_method: Index<AbcMethod>,
|
||||
is_function: bool,
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
) -> Result<Self, Error> {
|
||||
) -> Result<Self, Error<'gc>> {
|
||||
let abc = txunit.abc();
|
||||
let mut signature = Vec::new();
|
||||
|
||||
|
@ -348,7 +348,7 @@ impl<'gc> Method<'gc> {
|
|||
/// Access the bytecode of 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 {
|
||||
Method::Native { .. } => {
|
||||
Err("Attempted to unwrap a native method as a user-defined one".into())
|
||||
|
|
|
@ -106,7 +106,7 @@ impl<'gc> Multiname<'gc> {
|
|||
translation_unit: TranslationUnit<'gc>,
|
||||
namespace_set_index: Index<AbcNamespaceSet>,
|
||||
mc: MutationContext<'gc, '_>,
|
||||
) -> Result<NamespaceSet<'gc>, Error> {
|
||||
) -> Result<NamespaceSet<'gc>, Error<'gc>> {
|
||||
if namespace_set_index.0 == 0 {
|
||||
//TODO: What is namespace set zero?
|
||||
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 abc = translation_unit.abc();
|
||||
let ns_set: Result<_, Error> = abc
|
||||
let ns_set: Result<_, Error<'gc>> = abc
|
||||
.constant_pool
|
||||
.namespace_sets
|
||||
.get(actual_index)
|
||||
|
@ -143,7 +143,7 @@ impl<'gc> Multiname<'gc> {
|
|||
translation_unit: TranslationUnit<'gc>,
|
||||
multiname_index: Index<AbcMultiname>,
|
||||
mc: MutationContext<'gc, '_>,
|
||||
) -> Result<Self, Error> {
|
||||
) -> Result<Self, Error<'gc>> {
|
||||
let abc = translation_unit.abc();
|
||||
let abc_multiname = Self::resolve_multiname_index(&abc, multiname_index)?;
|
||||
|
||||
|
@ -223,7 +223,7 @@ impl<'gc> Multiname<'gc> {
|
|||
pub fn fill_with_runtime_params(
|
||||
&self,
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
) -> Result<Self, Error> {
|
||||
) -> Result<Self, Error<'gc>> {
|
||||
let name = if self.has_lazy_name() {
|
||||
Some(activation.avm2().pop().coerce_to_string(activation)?)
|
||||
} else {
|
||||
|
@ -251,8 +251,8 @@ impl<'gc> Multiname<'gc> {
|
|||
pub fn resolve_multiname_index(
|
||||
abc: &AbcFile,
|
||||
multiname_index: Index<AbcMultiname>,
|
||||
) -> Result<&AbcMultiname, Error> {
|
||||
let actual_index: Result<usize, Error> = (multiname_index.0 as usize)
|
||||
) -> Result<&AbcMultiname, Error<'gc>> {
|
||||
let actual_index: Result<usize, Error<'gc>> = (multiname_index.0 as usize)
|
||||
.checked_sub(1)
|
||||
.ok_or_else(|| "Attempted to resolve a multiname at index zero. This is a bug.".into());
|
||||
|
||||
|
|
|
@ -27,14 +27,14 @@ impl<'gc> Namespace<'gc> {
|
|||
translation_unit: TranslationUnit<'gc>,
|
||||
namespace_index: Index<AbcNamespace>,
|
||||
mc: MutationContext<'gc, '_>,
|
||||
) -> Result<Self, Error> {
|
||||
) -> Result<Self, Error<'gc>> {
|
||||
if namespace_index.0 == 0 {
|
||||
return Ok(Self::Any);
|
||||
}
|
||||
|
||||
let actual_index = namespace_index.0 as usize - 1;
|
||||
let abc = translation_unit.abc();
|
||||
let abc_namespace: Result<_, Error> = abc
|
||||
let abc_namespace: Result<_, Error<'gc>> = abc
|
||||
.constant_pool
|
||||
.namespaces
|
||||
.get(actual_index)
|
||||
|
|
|
@ -128,7 +128,7 @@ pub trait TObject<'gc>: 'gc + Collect + Debug + Into<Object<'gc>> + Clone + Copy
|
|||
self,
|
||||
name: &Multiname<'gc>,
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
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,
|
||||
multiname: &Multiname<'gc>,
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
match self.vtable().and_then(|vtable| vtable.get_trait(multiname)) {
|
||||
Some(Property::Slot { slot_id }) | Some(Property::ConstSlot { 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>,
|
||||
value: Value<'gc>,
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
) -> Result<(), Error> {
|
||||
) -> Result<(), Error<'gc>> {
|
||||
let mut base = self.base_mut(activation.context.gc_context);
|
||||
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>,
|
||||
value: Value<'gc>,
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
) -> Result<(), Error> {
|
||||
) -> Result<(), Error<'gc>> {
|
||||
match self.vtable().and_then(|vtable| vtable.get_trait(multiname)) {
|
||||
Some(Property::Slot { slot_id }) => {
|
||||
let value = self
|
||||
|
@ -238,7 +238,7 @@ pub trait TObject<'gc>: 'gc + Collect + Debug + Into<Object<'gc>> + Clone + Copy
|
|||
name: &Multiname<'gc>,
|
||||
value: Value<'gc>,
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
) -> Result<(), Error> {
|
||||
) -> Result<(), Error<'gc>> {
|
||||
let mut base = self.base_mut(activation.context.gc_context);
|
||||
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>,
|
||||
value: Value<'gc>,
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
) -> Result<(), Error> {
|
||||
) -> Result<(), Error<'gc>> {
|
||||
match self.vtable().and_then(|vtable| vtable.get_trait(multiname)) {
|
||||
Some(Property::Slot { slot_id }) | Some(Property::ConstSlot { slot_id }) => {
|
||||
let value = self
|
||||
|
@ -288,7 +288,7 @@ pub trait TObject<'gc>: 'gc + Collect + Debug + Into<Object<'gc>> + Clone + Copy
|
|||
multiname: &Multiname<'gc>,
|
||||
arguments: &[Value<'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
|
||||
// but because calling into ScriptObjectData borrows it for entire duration,
|
||||
// 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>,
|
||||
arguments: &[Value<'gc>],
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
match self.vtable().and_then(|vtable| vtable.get_trait(multiname)) {
|
||||
Some(Property::Slot { slot_id }) | Some(Property::ConstSlot { slot_id }) => {
|
||||
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.
|
||||
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();
|
||||
|
||||
base.get_slot(id)
|
||||
|
@ -384,7 +384,7 @@ pub trait TObject<'gc>: 'gc + Collect + Debug + Into<Object<'gc>> + Clone + Copy
|
|||
id: u32,
|
||||
value: Value<'gc>,
|
||||
mc: MutationContext<'gc, '_>,
|
||||
) -> Result<(), Error> {
|
||||
) -> Result<(), Error<'gc>> {
|
||||
let mut base = self.base_mut(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,
|
||||
value: Value<'gc>,
|
||||
mc: MutationContext<'gc, '_>,
|
||||
) -> Result<(), Error> {
|
||||
) -> Result<(), Error<'gc>> {
|
||||
let mut base = self.base_mut(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,
|
||||
arguments: &[Value<'gc>],
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if self.get_bound_method(id).is_none() {
|
||||
if let Some(vtable) = self.vtable() {
|
||||
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,
|
||||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
name: &Multiname<'gc>,
|
||||
) -> Result<bool, Error> {
|
||||
) -> Result<bool, Error<'gc>> {
|
||||
Ok(self.has_property(name))
|
||||
}
|
||||
|
||||
|
@ -472,7 +472,7 @@ pub trait TObject<'gc>: 'gc + Collect + Debug + Into<Object<'gc>> + Clone + Copy
|
|||
self,
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
name: &Multiname<'gc>,
|
||||
) -> Result<bool, Error> {
|
||||
) -> Result<bool, Error<'gc>> {
|
||||
let mut base = self.base_mut(activation.context.gc_context);
|
||||
|
||||
Ok(base.delete_property_local(name))
|
||||
|
@ -485,7 +485,7 @@ pub trait TObject<'gc>: 'gc + Collect + Debug + Into<Object<'gc>> + Clone + Copy
|
|||
&self,
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
multiname: &Multiname<'gc>,
|
||||
) -> Result<bool, Error> {
|
||||
) -> Result<bool, Error<'gc>> {
|
||||
match self.vtable().and_then(|vtable| vtable.get_trait(multiname)) {
|
||||
None => {
|
||||
if self
|
||||
|
@ -539,7 +539,7 @@ pub trait TObject<'gc>: 'gc + Collect + Debug + Into<Object<'gc>> + Clone + Copy
|
|||
self,
|
||||
last_index: u32,
|
||||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
) -> Result<Option<u32>, Error> {
|
||||
) -> Result<Option<u32>, Error<'gc>> {
|
||||
let base = self.base();
|
||||
|
||||
Ok(base.get_next_enumerant(last_index))
|
||||
|
@ -555,7 +555,7 @@ pub trait TObject<'gc>: 'gc + Collect + Debug + Into<Object<'gc>> + Clone + Copy
|
|||
self,
|
||||
index: u32,
|
||||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
let base = self.base();
|
||||
|
||||
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,
|
||||
index: u32,
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
let name = self
|
||||
.get_enumerant_name(index, 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>>,
|
||||
_arguments: &[Value<'gc>],
|
||||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Err("Object is not callable".into())
|
||||
}
|
||||
|
||||
|
@ -661,7 +661,7 @@ pub trait TObject<'gc>: 'gc + Collect + Debug + Into<Object<'gc>> + Clone + Copy
|
|||
self,
|
||||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Object<'gc>, Error> {
|
||||
) -> Result<Object<'gc>, Error<'gc>> {
|
||||
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>,
|
||||
args: &[Value<'gc>],
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
) -> Result<Object<'gc>, Error> {
|
||||
) -> Result<Object<'gc>, Error<'gc>> {
|
||||
let ctor = self.get_property(multiname, activation)?.as_callable(
|
||||
activation,
|
||||
Some(multiname),
|
||||
|
@ -702,7 +702,7 @@ pub trait TObject<'gc>: 'gc + Collect + Debug + Into<Object<'gc>> + Clone + Copy
|
|||
&self,
|
||||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_params: &[Value<'gc>],
|
||||
) -> Result<ClassObject<'gc>, Error> {
|
||||
) -> Result<ClassObject<'gc>, Error<'gc>> {
|
||||
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
|
||||
/// prototype; this is then picked up by the VM runtime when doing
|
||||
/// 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
|
||||
.instance_of_class_definition()
|
||||
.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(
|
||||
&self,
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
let class_name = self
|
||||
.instance_of_class_definition()
|
||||
.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
|
||||
/// 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.
|
||||
///
|
||||
|
@ -781,7 +784,7 @@ pub trait TObject<'gc>: 'gc + Collect + Debug + Into<Object<'gc>> + Clone + Copy
|
|||
&self,
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
class: Object<'gc>,
|
||||
) -> Result<bool, Error> {
|
||||
) -> Result<bool, Error<'gc>> {
|
||||
let type_proto = class
|
||||
.get_property(&Multiname::public("prototype"), activation)?
|
||||
.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
|
||||
/// 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();
|
||||
|
||||
//TODO: Is it a verification error to do `obj instanceof bare_object`?
|
||||
|
|
|
@ -15,7 +15,7 @@ use std::cell::{Ref, RefMut};
|
|||
pub fn array_allocator<'gc>(
|
||||
class: ClassObject<'gc>,
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
) -> Result<Object<'gc>, Error> {
|
||||
) -> Result<Object<'gc>, Error<'gc>> {
|
||||
let base = ScriptObjectData::new(class);
|
||||
|
||||
Ok(ArrayObject(GcCell::allocate(
|
||||
|
@ -45,7 +45,7 @@ pub struct ArrayObjectData<'gc> {
|
|||
|
||||
impl<'gc> ArrayObject<'gc> {
|
||||
/// 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))
|
||||
}
|
||||
|
||||
|
@ -55,7 +55,7 @@ impl<'gc> ArrayObject<'gc> {
|
|||
pub fn from_storage(
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
array: ArrayStorage<'gc>,
|
||||
) -> Result<Object<'gc>, Error> {
|
||||
) -> Result<Object<'gc>, Error<'gc>> {
|
||||
let class = activation.avm2().classes().array;
|
||||
let base = ScriptObjectData::new(class);
|
||||
|
||||
|
@ -89,7 +89,7 @@ impl<'gc> TObject<'gc> for ArrayObject<'gc> {
|
|||
self,
|
||||
name: &Multiname<'gc>,
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
let read = self.0.read();
|
||||
|
||||
if name.contains_public_namespace() {
|
||||
|
@ -110,7 +110,7 @@ impl<'gc> TObject<'gc> for ArrayObject<'gc> {
|
|||
name: &Multiname<'gc>,
|
||||
value: Value<'gc>,
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
) -> Result<(), Error> {
|
||||
) -> Result<(), Error<'gc>> {
|
||||
let mut write = self.0.write(activation.context.gc_context);
|
||||
|
||||
if name.contains_public_namespace() {
|
||||
|
@ -130,7 +130,7 @@ impl<'gc> TObject<'gc> for ArrayObject<'gc> {
|
|||
name: &Multiname<'gc>,
|
||||
value: Value<'gc>,
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
) -> Result<(), Error> {
|
||||
) -> Result<(), Error<'gc>> {
|
||||
let mut write = self.0.write(activation.context.gc_context);
|
||||
|
||||
if name.contains_public_namespace() {
|
||||
|
@ -149,7 +149,7 @@ impl<'gc> TObject<'gc> for ArrayObject<'gc> {
|
|||
self,
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
name: &Multiname<'gc>,
|
||||
) -> Result<bool, Error> {
|
||||
) -> Result<bool, Error<'gc>> {
|
||||
if name.contains_public_namespace() {
|
||||
if let Some(name) = name.local_name() {
|
||||
if let Ok(index) = name.parse::<usize>() {
|
||||
|
@ -185,7 +185,7 @@ impl<'gc> TObject<'gc> for ArrayObject<'gc> {
|
|||
self,
|
||||
mut last_index: u32,
|
||||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
) -> Result<Option<u32>, Error> {
|
||||
) -> Result<Option<u32>, Error<'gc>> {
|
||||
let read = self.0.read();
|
||||
let num_enumerants = read.base.num_enumerants();
|
||||
let array_length = read.array.length() as u32;
|
||||
|
@ -211,7 +211,7 @@ impl<'gc> TObject<'gc> for ArrayObject<'gc> {
|
|||
self,
|
||||
index: u32,
|
||||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
let arr_len = self.0.read().array.length() as u32;
|
||||
if arr_len >= index {
|
||||
Ok(index
|
||||
|
@ -233,11 +233,14 @@ impl<'gc> TObject<'gc> for ArrayObject<'gc> {
|
|||
|| 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)))
|
||||
}
|
||||
|
||||
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)))
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ use std::cell::{Ref, RefMut};
|
|||
pub fn bitmapdata_allocator<'gc>(
|
||||
class: ClassObject<'gc>,
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
) -> Result<Object<'gc>, Error> {
|
||||
) -> Result<Object<'gc>, Error<'gc>> {
|
||||
let base = ScriptObjectData::new(class);
|
||||
|
||||
Ok(BitmapDataObject(GcCell::allocate(
|
||||
|
@ -44,7 +44,7 @@ impl<'gc> BitmapDataObject<'gc> {
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
bitmap_data: GcCell<'gc, BitmapData<'gc>>,
|
||||
class: ClassObject<'gc>,
|
||||
) -> Result<Object<'gc>, Error> {
|
||||
) -> Result<Object<'gc>, Error<'gc>> {
|
||||
let mut instance = Self(GcCell::allocate(
|
||||
activation.context.gc_context,
|
||||
BitmapDataObjectData {
|
||||
|
@ -76,7 +76,7 @@ impl<'gc> TObject<'gc> for BitmapDataObject<'gc> {
|
|||
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)))
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ use std::cell::{Ref, RefMut};
|
|||
pub fn bytearray_allocator<'gc>(
|
||||
class: ClassObject<'gc>,
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
) -> Result<Object<'gc>, Error> {
|
||||
) -> Result<Object<'gc>, Error<'gc>> {
|
||||
let base = ScriptObjectData::new(class);
|
||||
|
||||
Ok(ByteArrayObject(GcCell::allocate(
|
||||
|
@ -42,7 +42,7 @@ impl<'gc> ByteArrayObject<'gc> {
|
|||
pub fn from_storage(
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
bytes: ByteArrayStorage,
|
||||
) -> Result<Object<'gc>, Error> {
|
||||
) -> Result<Object<'gc>, Error<'gc>> {
|
||||
let class = activation.avm2().classes().bytearray;
|
||||
let base = ScriptObjectData::new(class);
|
||||
|
||||
|
@ -79,7 +79,7 @@ impl<'gc> TObject<'gc> for ByteArrayObject<'gc> {
|
|||
self,
|
||||
name: &Multiname<'gc>,
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
let read = self.0.read();
|
||||
|
||||
if name.contains_public_namespace() {
|
||||
|
@ -102,7 +102,7 @@ impl<'gc> TObject<'gc> for ByteArrayObject<'gc> {
|
|||
name: &Multiname<'gc>,
|
||||
value: Value<'gc>,
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
) -> Result<(), Error> {
|
||||
) -> Result<(), Error<'gc>> {
|
||||
let mut write = self.0.write(activation.context.gc_context);
|
||||
|
||||
if name.contains_public_namespace() {
|
||||
|
@ -125,7 +125,7 @@ impl<'gc> TObject<'gc> for ByteArrayObject<'gc> {
|
|||
name: &Multiname<'gc>,
|
||||
value: Value<'gc>,
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
) -> Result<(), Error> {
|
||||
) -> Result<(), Error<'gc>> {
|
||||
let mut write = self.0.write(activation.context.gc_context);
|
||||
|
||||
if name.contains_public_namespace() {
|
||||
|
@ -147,7 +147,7 @@ impl<'gc> TObject<'gc> for ByteArrayObject<'gc> {
|
|||
self,
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
name: &Multiname<'gc>,
|
||||
) -> Result<bool, Error> {
|
||||
) -> Result<bool, Error<'gc>> {
|
||||
if name.contains_public_namespace() {
|
||||
if let Some(name) = name.local_name() {
|
||||
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)
|
||||
}
|
||||
|
||||
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)))
|
||||
}
|
||||
|
||||
|
|
|
@ -103,7 +103,7 @@ impl<'gc> ClassObject<'gc> {
|
|||
self,
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
superclass_object: Option<ClassObject<'gc>>,
|
||||
) -> Result<Object<'gc>, Error> {
|
||||
) -> Result<Object<'gc>, Error<'gc>> {
|
||||
let proto = activation
|
||||
.avm2()
|
||||
.classes()
|
||||
|
@ -130,7 +130,7 @@ impl<'gc> ClassObject<'gc> {
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
class: GcCell<'gc, Class<'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_proto = class_object.allocate_prototype(activation, superclass_object)?;
|
||||
|
||||
|
@ -159,7 +159,7 @@ impl<'gc> ClassObject<'gc> {
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
class: GcCell<'gc, Class<'gc>>,
|
||||
superclass_object: Option<ClassObject<'gc>>,
|
||||
) -> Result<Self, Error> {
|
||||
) -> Result<Self, Error<'gc>> {
|
||||
let scope = activation.create_scopechain();
|
||||
if let Some(base_class) = superclass_object.map(|b| b.inner_class_definition()) {
|
||||
if base_class.read().is_final() {
|
||||
|
@ -239,7 +239,7 @@ impl<'gc> ClassObject<'gc> {
|
|||
pub fn into_finished_class(
|
||||
mut self,
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
) -> Result<Self, Error> {
|
||||
) -> Result<Self, Error<'gc>> {
|
||||
let class = self.inner_class_definition();
|
||||
self.instance_of().ok_or(
|
||||
"Cannot finish initialization of core class without it being linked to a type!",
|
||||
|
@ -282,7 +282,7 @@ impl<'gc> ClassObject<'gc> {
|
|||
self,
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
class_proto: Object<'gc>,
|
||||
) -> Result<(), Error> {
|
||||
) -> Result<(), Error<'gc>> {
|
||||
self.0.write(activation.context.gc_context).prototype = Some(class_proto);
|
||||
class_proto.set_property_local(
|
||||
&Multiname::public("constructor"),
|
||||
|
@ -303,7 +303,10 @@ impl<'gc> ClassObject<'gc> {
|
|||
/// This should be done after all instance traits has been resolved, as
|
||||
/// instance traits will be resolved to their corresponding methods at this
|
||||
/// 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 class = write.class;
|
||||
let scope = write.class_scope;
|
||||
|
@ -392,7 +395,7 @@ impl<'gc> ClassObject<'gc> {
|
|||
pub fn run_class_initializer(
|
||||
self,
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
) -> Result<(), Error> {
|
||||
) -> Result<(), Error<'gc>> {
|
||||
let object: Object<'gc> = self.into();
|
||||
|
||||
let scope = self.0.read().class_scope;
|
||||
|
@ -466,7 +469,7 @@ impl<'gc> ClassObject<'gc> {
|
|||
receiver: Option<Object<'gc>>,
|
||||
arguments: &[Value<'gc>],
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
let scope = self.0.read().instance_scope;
|
||||
let constructor =
|
||||
Executable::from_method(self.0.read().constructor.clone(), scope, None, Some(self));
|
||||
|
@ -484,7 +487,7 @@ impl<'gc> ClassObject<'gc> {
|
|||
receiver: Option<Object<'gc>>,
|
||||
arguments: &[Value<'gc>],
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
let scope = self.0.read().instance_scope;
|
||||
let constructor = Executable::from_method(
|
||||
self.0.read().native_constructor.clone(),
|
||||
|
@ -526,7 +529,7 @@ impl<'gc> ClassObject<'gc> {
|
|||
reciever: Object<'gc>,
|
||||
arguments: &[Value<'gc>],
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
let property = self.instance_vtable().get_trait(multiname);
|
||||
if property.is_none() {
|
||||
return Err(format!(
|
||||
|
@ -585,7 +588,7 @@ impl<'gc> ClassObject<'gc> {
|
|||
multiname: &Multiname<'gc>,
|
||||
reciever: Object<'gc>,
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
let property = self.instance_vtable().get_trait(multiname);
|
||||
if property.is_none() {
|
||||
return Err(format!(
|
||||
|
@ -649,7 +652,7 @@ impl<'gc> ClassObject<'gc> {
|
|||
value: Value<'gc>,
|
||||
mut reciever: Object<'gc>,
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
) -> Result<(), Error> {
|
||||
) -> Result<(), Error<'gc>> {
|
||||
let property = self.instance_vtable().get_trait(multiname);
|
||||
if property.is_none() {
|
||||
return Err(format!(
|
||||
|
@ -773,7 +776,10 @@ impl<'gc> TObject<'gc> for ClassObject<'gc> {
|
|||
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(
|
||||
activation.context.gc_context,
|
||||
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(
|
||||
&self,
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
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)))
|
||||
}
|
||||
|
||||
|
@ -797,7 +803,7 @@ impl<'gc> TObject<'gc> for ClassObject<'gc> {
|
|||
receiver: Option<Object<'gc>>,
|
||||
arguments: &[Value<'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() {
|
||||
let scope = self.0.read().class_scope;
|
||||
let func = Executable::from_method(call_handler, scope, None, Some(self));
|
||||
|
@ -816,7 +822,7 @@ impl<'gc> TObject<'gc> for ClassObject<'gc> {
|
|||
self,
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
arguments: &[Value<'gc>],
|
||||
) -> Result<Object<'gc>, Error> {
|
||||
) -> Result<Object<'gc>, Error<'gc>> {
|
||||
let instance_allocator = self.0.read().instance_allocator.0;
|
||||
|
||||
let mut instance = instance_allocator(self, activation)?;
|
||||
|
@ -854,7 +860,7 @@ impl<'gc> TObject<'gc> for ClassObject<'gc> {
|
|||
&self,
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
nullable_params: &[Value<'gc>],
|
||||
) -> Result<ClassObject<'gc>, Error> {
|
||||
) -> Result<ClassObject<'gc>, Error<'gc>> {
|
||||
let self_class = self.inner_class_definition();
|
||||
|
||||
if !self_class.read().is_generic() {
|
||||
|
|
|
@ -11,7 +11,7 @@ use std::cell::{Ref, RefMut};
|
|||
pub fn date_allocator<'gc>(
|
||||
class: ClassObject<'gc>,
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
) -> Result<Object<'gc>, Error> {
|
||||
) -> Result<Object<'gc>, Error<'gc>> {
|
||||
let base = ScriptObjectData::new(class);
|
||||
|
||||
Ok(DateObject(GcCell::allocate(
|
||||
|
@ -64,7 +64,7 @@ impl<'gc> TObject<'gc> for DateObject<'gc> {
|
|||
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() {
|
||||
Ok((date.timestamp_millis() as f64).into())
|
||||
} else {
|
||||
|
|
|
@ -14,7 +14,7 @@ use std::cell::{Ref, RefMut};
|
|||
pub fn dictionary_allocator<'gc>(
|
||||
class: ClassObject<'gc>,
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
) -> Result<Object<'gc>, Error> {
|
||||
) -> Result<Object<'gc>, Error<'gc>> {
|
||||
let base = ScriptObjectData::new(class);
|
||||
|
||||
Ok(DictionaryObject(GcCell::allocate(
|
||||
|
@ -90,7 +90,7 @@ impl<'gc> TObject<'gc> for DictionaryObject<'gc> {
|
|||
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())
|
||||
}
|
||||
|
||||
|
@ -102,7 +102,7 @@ impl<'gc> TObject<'gc> for DictionaryObject<'gc> {
|
|||
self,
|
||||
last_index: u32,
|
||||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
) -> Result<Option<u32>, Error> {
|
||||
) -> Result<Option<u32>, Error<'gc>> {
|
||||
let read = self.0.read();
|
||||
let num_enumerants = read.base.num_enumerants();
|
||||
let object_space_length = read.object_space.keys().len() as u32;
|
||||
|
@ -118,7 +118,7 @@ impl<'gc> TObject<'gc> for DictionaryObject<'gc> {
|
|||
self,
|
||||
index: u32,
|
||||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
let read = self.0.read();
|
||||
let object_space_len = read.object_space.keys().len() as u32;
|
||||
if object_space_len >= index {
|
||||
|
|
|
@ -82,11 +82,11 @@ impl<'gc> TObject<'gc> for DispatchObject<'gc> {
|
|||
self,
|
||||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Object<'gc>, Error> {
|
||||
) -> Result<Object<'gc>, Error<'gc>> {
|
||||
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())
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ use std::cell::{Ref, RefMut};
|
|||
pub fn appdomain_allocator<'gc>(
|
||||
class: ClassObject<'gc>,
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
) -> Result<Object<'gc>, Error> {
|
||||
) -> Result<Object<'gc>, Error<'gc>> {
|
||||
let domain = activation.domain();
|
||||
let base = ScriptObjectData::new(class);
|
||||
|
||||
|
@ -46,7 +46,7 @@ impl<'gc> DomainObject<'gc> {
|
|||
pub fn from_domain(
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
domain: Domain<'gc>,
|
||||
) -> Result<Object<'gc>, Error> {
|
||||
) -> Result<Object<'gc>, Error<'gc>> {
|
||||
let class = activation.avm2().classes().application_domain;
|
||||
let base = ScriptObjectData::new(class);
|
||||
let mut this: Object<'gc> = DomainObject(GcCell::allocate(
|
||||
|
@ -79,7 +79,7 @@ impl<'gc> TObject<'gc> for DomainObject<'gc> {
|
|||
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);
|
||||
|
||||
Ok(this.into())
|
||||
|
|
|
@ -17,7 +17,7 @@ use std::cell::{Ref, RefMut};
|
|||
pub fn error_allocator<'gc>(
|
||||
class: ClassObject<'gc>,
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
) -> Result<Object<'gc>, Error> {
|
||||
) -> Result<Object<'gc>, Error<'gc>> {
|
||||
let base = ScriptObjectData::new(class);
|
||||
|
||||
Ok(ErrorObject(GcCell::allocate(
|
||||
|
@ -49,7 +49,7 @@ impl<'gc> ErrorObject<'gc> {
|
|||
pub fn display(
|
||||
&self,
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
) -> Result<AvmString<'gc>, Error> {
|
||||
) -> Result<AvmString<'gc>, Error<'gc>> {
|
||||
let name = self
|
||||
.get_property(&Multiname::public("name"), activation)?
|
||||
.coerce_to_string(activation)?;
|
||||
|
@ -70,7 +70,7 @@ impl<'gc> ErrorObject<'gc> {
|
|||
pub fn display_full(
|
||||
&self,
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
) -> Result<AvmString<'gc>, Error> {
|
||||
) -> Result<AvmString<'gc>, Error<'gc>> {
|
||||
let mut output = WString::new();
|
||||
output.push_str(&self.display(activation)?);
|
||||
self.call_stack().display(&mut output);
|
||||
|
@ -96,11 +96,14 @@ impl<'gc> TObject<'gc> for ErrorObject<'gc> {
|
|||
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)))
|
||||
}
|
||||
|
||||
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())
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ use std::fmt::Debug;
|
|||
pub fn event_allocator<'gc>(
|
||||
class: ClassObject<'gc>,
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
) -> Result<Object<'gc>, Error> {
|
||||
) -> Result<Object<'gc>, Error<'gc>> {
|
||||
let base = ScriptObjectData::new(class);
|
||||
|
||||
Ok(EventObject(GcCell::allocate(
|
||||
|
@ -157,7 +157,7 @@ impl<'gc> TObject<'gc> for EventObject<'gc> {
|
|||
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()))
|
||||
}
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ impl<'gc> FunctionObject<'gc> {
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
method: Method<'gc>,
|
||||
scope: ScopeChain<'gc>,
|
||||
) -> Result<FunctionObject<'gc>, Error> {
|
||||
) -> Result<FunctionObject<'gc>, Error<'gc>> {
|
||||
let this = Self::from_method(activation, method, scope, None, None);
|
||||
let es3_proto = ScriptObject::custom_object(
|
||||
activation.context.gc_context,
|
||||
|
@ -99,18 +99,21 @@ impl<'gc> TObject<'gc> for FunctionObject<'gc> {
|
|||
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())
|
||||
}
|
||||
|
||||
fn to_locale_string(
|
||||
&self,
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
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)))
|
||||
}
|
||||
|
||||
|
@ -127,7 +130,7 @@ impl<'gc> TObject<'gc> for FunctionObject<'gc> {
|
|||
receiver: Option<Object<'gc>>,
|
||||
arguments: &[Value<'gc>],
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
self.0
|
||||
.read()
|
||||
.exec
|
||||
|
@ -138,7 +141,7 @@ impl<'gc> TObject<'gc> for FunctionObject<'gc> {
|
|||
self,
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
arguments: &[Value<'gc>],
|
||||
) -> Result<Object<'gc>, Error> {
|
||||
) -> Result<Object<'gc>, Error<'gc>> {
|
||||
let prototype = self.prototype().unwrap();
|
||||
|
||||
let instance =
|
||||
|
|
|
@ -18,7 +18,7 @@ use std::sync::Arc;
|
|||
pub fn loaderinfo_allocator<'gc>(
|
||||
class: ClassObject<'gc>,
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
) -> Result<Object<'gc>, Error> {
|
||||
) -> Result<Object<'gc>, Error<'gc>> {
|
||||
let base = ScriptObjectData::new(class);
|
||||
|
||||
Ok(LoaderInfoObject(GcCell::allocate(
|
||||
|
@ -87,7 +87,7 @@ impl<'gc> LoaderInfoObject<'gc> {
|
|||
movie: Arc<SwfMovie>,
|
||||
root: DisplayObject<'gc>,
|
||||
loader: Option<Object<'gc>>,
|
||||
) -> Result<Object<'gc>, Error> {
|
||||
) -> Result<Object<'gc>, Error<'gc>> {
|
||||
let class = activation.avm2().classes().loaderinfo;
|
||||
let base = ScriptObjectData::new(class);
|
||||
let loaded_stream = Some(LoaderStream::Swf(movie, root));
|
||||
|
@ -120,7 +120,7 @@ impl<'gc> LoaderInfoObject<'gc> {
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
movie: Arc<SwfMovie>,
|
||||
loader: Option<Object<'gc>>,
|
||||
) -> Result<Object<'gc>, Error> {
|
||||
) -> Result<Object<'gc>, Error<'gc>> {
|
||||
let class = activation.avm2().classes().loaderinfo;
|
||||
let base = ScriptObjectData::new(class);
|
||||
|
||||
|
@ -210,7 +210,7 @@ impl<'gc> TObject<'gc> for LoaderInfoObject<'gc> {
|
|||
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()))
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ use std::cell::{Ref, RefMut};
|
|||
pub fn namespace_allocator<'gc>(
|
||||
class: ClassObject<'gc>,
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
) -> Result<Object<'gc>, Error> {
|
||||
) -> Result<Object<'gc>, Error<'gc>> {
|
||||
let base = ScriptObjectData::new(class);
|
||||
|
||||
Ok(NamespaceObject(GcCell::allocate(
|
||||
|
@ -46,7 +46,7 @@ impl<'gc> NamespaceObject<'gc> {
|
|||
pub fn from_namespace(
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
namespace: Namespace<'gc>,
|
||||
) -> Result<Object<'gc>, Error> {
|
||||
) -> Result<Object<'gc>, Error<'gc>> {
|
||||
let class = activation.avm2().classes().namespace;
|
||||
let base = ScriptObjectData::new(class);
|
||||
|
||||
|
@ -76,11 +76,14 @@ impl<'gc> TObject<'gc> for NamespaceObject<'gc> {
|
|||
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())
|
||||
}
|
||||
|
||||
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())
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ use gc_arena::{Collect, GcCell, MutationContext};
|
|||
pub fn primitive_allocator<'gc>(
|
||||
class: ClassObject<'gc>,
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
) -> Result<Object<'gc>, Error> {
|
||||
) -> Result<Object<'gc>, Error<'gc>> {
|
||||
let base = ScriptObjectData::new(class);
|
||||
|
||||
Ok(PrimitiveObject(GcCell::allocate(
|
||||
|
@ -53,7 +53,7 @@ impl<'gc> PrimitiveObject<'gc> {
|
|||
pub fn from_primitive(
|
||||
primitive: Value<'gc>,
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
) -> Result<Object<'gc>, Error> {
|
||||
) -> Result<Object<'gc>, Error<'gc>> {
|
||||
if !primitive.is_primitive() {
|
||||
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
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
fn to_locale_string(
|
||||
&self,
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
match self.0.read().primitive {
|
||||
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)
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ use std::cell::{Ref, RefMut};
|
|||
pub fn proxy_allocator<'gc>(
|
||||
class: ClassObject<'gc>,
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
) -> Result<Object<'gc>, Error> {
|
||||
) -> Result<Object<'gc>, Error<'gc>> {
|
||||
let base = ScriptObjectData::new(class);
|
||||
|
||||
Ok(ProxyObject(GcCell::allocate(
|
||||
|
@ -50,7 +50,7 @@ impl<'gc> TObject<'gc> for ProxyObject<'gc> {
|
|||
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())
|
||||
}
|
||||
|
||||
|
@ -58,7 +58,7 @@ impl<'gc> TObject<'gc> for ProxyObject<'gc> {
|
|||
self,
|
||||
multiname: &Multiname<'gc>,
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
// NOTE: This is incorrect behavior.
|
||||
// `QName` should instead store the whole multiname's namespace set,
|
||||
// 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>,
|
||||
value: Value<'gc>,
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
) -> Result<(), Error> {
|
||||
) -> Result<(), Error<'gc>> {
|
||||
// NOTE: This is incorrect behavior.
|
||||
// `QName` should instead store the whole multiname's namespace set,
|
||||
// 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())
|
||||
.unwrap_or(false)
|
||||
{
|
||||
let local_name: Result<AvmString<'gc>, Error> = multiname
|
||||
let local_name: Result<AvmString<'gc>, Error<'gc>> = multiname
|
||||
.local_name()
|
||||
.ok_or_else(|| "Cannot set undefined property using any name".into());
|
||||
let _ = local_name?;
|
||||
|
@ -136,7 +136,7 @@ impl<'gc> TObject<'gc> for ProxyObject<'gc> {
|
|||
multiname: &Multiname<'gc>,
|
||||
arguments: &[Value<'gc>],
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
// NOTE: This is incorrect behavior.
|
||||
// `QName` should instead store the whole multiname's namespace set,
|
||||
// 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,
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
multiname: &Multiname<'gc>,
|
||||
) -> Result<bool, Error> {
|
||||
) -> Result<bool, Error<'gc>> {
|
||||
// NOTE: This is incorrect behavior.
|
||||
// `QName` should instead store the whole multiname's namespace set,
|
||||
// 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,
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
name: &Multiname<'gc>,
|
||||
) -> Result<bool, Error> {
|
||||
) -> Result<bool, Error<'gc>> {
|
||||
Ok(self
|
||||
.call_property(
|
||||
&Multiname::new(Namespace::Namespace(NS_FLASH_PROXY.into()), "hasProperty"),
|
||||
|
@ -224,7 +224,7 @@ impl<'gc> TObject<'gc> for ProxyObject<'gc> {
|
|||
self,
|
||||
last_index: u32,
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
) -> Result<Option<u32>, Error> {
|
||||
) -> Result<Option<u32>, Error<'gc>> {
|
||||
Ok(Some(
|
||||
self.call_property(
|
||||
&Multiname::new(Namespace::Namespace(NS_FLASH_PROXY.into()), "nextNameIndex"),
|
||||
|
@ -239,7 +239,7 @@ impl<'gc> TObject<'gc> for ProxyObject<'gc> {
|
|||
self,
|
||||
index: u32,
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
self.call_property(
|
||||
&Multiname::new(Namespace::Namespace(NS_FLASH_PROXY.into()), "nextName"),
|
||||
&[index.into()],
|
||||
|
@ -251,7 +251,7 @@ impl<'gc> TObject<'gc> for ProxyObject<'gc> {
|
|||
self,
|
||||
index: u32,
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
self.call_property(
|
||||
&Multiname::new(Namespace::Namespace(NS_FLASH_PROXY.into()), "nextValue"),
|
||||
&[index.into()],
|
||||
|
|
|
@ -13,7 +13,7 @@ use std::cell::{Ref, RefMut};
|
|||
pub fn qname_allocator<'gc>(
|
||||
class: ClassObject<'gc>,
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
) -> Result<Object<'gc>, Error> {
|
||||
) -> Result<Object<'gc>, Error<'gc>> {
|
||||
let base = ScriptObjectData::new(class);
|
||||
|
||||
Ok(QNameObject(GcCell::allocate(
|
||||
|
@ -43,7 +43,7 @@ impl<'gc> QNameObject<'gc> {
|
|||
pub fn from_qname(
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
qname: QName<'gc>,
|
||||
) -> Result<Object<'gc>, Error> {
|
||||
) -> Result<Object<'gc>, Error<'gc>> {
|
||||
let class = activation.avm2().classes().qname;
|
||||
let base = ScriptObjectData::new(class);
|
||||
|
||||
|
@ -87,7 +87,7 @@ impl<'gc> TObject<'gc> for QNameObject<'gc> {
|
|||
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)))
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ use std::cell::{Ref, RefMut};
|
|||
pub fn regexp_allocator<'gc>(
|
||||
class: ClassObject<'gc>,
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
) -> Result<Object<'gc>, Error> {
|
||||
) -> Result<Object<'gc>, Error<'gc>> {
|
||||
let base = ScriptObjectData::new(class);
|
||||
|
||||
Ok(RegExpObject(GcCell::allocate(
|
||||
|
@ -44,7 +44,7 @@ impl<'gc> RegExpObject<'gc> {
|
|||
pub fn from_regexp(
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
regexp: RegExp<'gc>,
|
||||
) -> Result<Object<'gc>, Error> {
|
||||
) -> Result<Object<'gc>, Error<'gc>> {
|
||||
let class = activation.avm2().classes().regexp;
|
||||
let base = ScriptObjectData::new(class);
|
||||
|
||||
|
@ -74,11 +74,14 @@ impl<'gc> TObject<'gc> for RegExpObject<'gc> {
|
|||
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)))
|
||||
}
|
||||
|
||||
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 mut s = WString::new();
|
||||
s.push_byte(b'/');
|
||||
|
|
|
@ -17,7 +17,7 @@ use std::fmt::Debug;
|
|||
pub fn scriptobject_allocator<'gc>(
|
||||
class: ClassObject<'gc>,
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
) -> Result<Object<'gc>, Error> {
|
||||
) -> Result<Object<'gc>, Error<'gc>> {
|
||||
let base = ScriptObjectData::new(class);
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
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)))
|
||||
}
|
||||
}
|
||||
|
@ -145,7 +145,7 @@ impl<'gc> ScriptObjectData<'gc> {
|
|||
&self,
|
||||
multiname: &Multiname<'gc>,
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
if !multiname.contains_public_namespace() {
|
||||
return Err(format!(
|
||||
"Non-public property {} not found on Object",
|
||||
|
@ -205,7 +205,7 @@ impl<'gc> ScriptObjectData<'gc> {
|
|||
multiname: &Multiname<'gc>,
|
||||
value: Value<'gc>,
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
) -> Result<(), Error> {
|
||||
) -> Result<(), Error<'gc>> {
|
||||
if self
|
||||
.instance_of()
|
||||
.map(|cls| cls.inner_class_definition().read().is_sealed())
|
||||
|
@ -257,7 +257,7 @@ impl<'gc> ScriptObjectData<'gc> {
|
|||
multiname: &Multiname<'gc>,
|
||||
value: Value<'gc>,
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
) -> Result<(), Error> {
|
||||
) -> Result<(), Error<'gc>> {
|
||||
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
|
||||
.get(id as usize)
|
||||
.cloned()
|
||||
|
@ -287,7 +287,7 @@ impl<'gc> ScriptObjectData<'gc> {
|
|||
id: u32,
|
||||
value: Value<'gc>,
|
||||
_mc: MutationContext<'gc, '_>,
|
||||
) -> Result<(), Error> {
|
||||
) -> Result<(), Error<'gc>> {
|
||||
if let Some(slot) = self.slots.get_mut(id as usize) {
|
||||
*slot = value;
|
||||
Ok(())
|
||||
|
@ -302,7 +302,7 @@ impl<'gc> ScriptObjectData<'gc> {
|
|||
id: u32,
|
||||
value: Value<'gc>,
|
||||
_mc: MutationContext<'gc, '_>,
|
||||
) -> Result<(), Error> {
|
||||
) -> Result<(), Error<'gc>> {
|
||||
if let Some(slot) = self.slots.get_mut(id as usize) {
|
||||
*slot = value;
|
||||
Ok(())
|
||||
|
|
|
@ -13,7 +13,7 @@ use std::cell::{Ref, RefMut};
|
|||
pub fn sound_allocator<'gc>(
|
||||
class: ClassObject<'gc>,
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
) -> Result<Object<'gc>, Error> {
|
||||
) -> Result<Object<'gc>, Error<'gc>> {
|
||||
let base = ScriptObjectData::new(class);
|
||||
|
||||
Ok(SoundObject(GcCell::allocate(
|
||||
|
@ -48,7 +48,7 @@ impl<'gc> SoundObject<'gc> {
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
class: ClassObject<'gc>,
|
||||
sound: SoundHandle,
|
||||
) -> Result<Object<'gc>, Error> {
|
||||
) -> Result<Object<'gc>, Error<'gc>> {
|
||||
let base = ScriptObjectData::new(class);
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
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())
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ use std::cell::{Ref, RefMut};
|
|||
pub fn soundchannel_allocator<'gc>(
|
||||
class: ClassObject<'gc>,
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
) -> Result<Object<'gc>, Error> {
|
||||
) -> Result<Object<'gc>, Error<'gc>> {
|
||||
let base = ScriptObjectData::new(class);
|
||||
|
||||
Ok(SoundChannelObject(GcCell::allocate(
|
||||
|
@ -50,7 +50,7 @@ impl<'gc> SoundChannelObject<'gc> {
|
|||
pub fn from_sound_instance(
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
sound: SoundInstanceHandle,
|
||||
) -> Result<Self, Error> {
|
||||
) -> Result<Self, Error<'gc>> {
|
||||
let class = activation.avm2().classes().soundchannel;
|
||||
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)
|
||||
}
|
||||
|
||||
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())
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ use std::fmt::Debug;
|
|||
pub fn stage_allocator<'gc>(
|
||||
class: ClassObject<'gc>,
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
) -> Result<Object<'gc>, Error> {
|
||||
) -> Result<Object<'gc>, Error<'gc>> {
|
||||
let base = ScriptObjectData::new(class);
|
||||
|
||||
Ok(StageObject(GcCell::allocate(
|
||||
|
@ -56,7 +56,7 @@ impl<'gc> StageObject<'gc> {
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
display_object: DisplayObject<'gc>,
|
||||
class: ClassObject<'gc>,
|
||||
) -> Result<Self, Error> {
|
||||
) -> Result<Self, Error<'gc>> {
|
||||
let mut instance = Self(GcCell::allocate(
|
||||
activation.context.gc_context,
|
||||
StageObjectData {
|
||||
|
@ -78,7 +78,7 @@ impl<'gc> StageObject<'gc> {
|
|||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
display_object: DisplayObject<'gc>,
|
||||
class: ClassObject<'gc>,
|
||||
) -> Result<Self, Error> {
|
||||
) -> Result<Self, Error<'gc>> {
|
||||
let this = Self::for_display_object(activation, display_object, class)?;
|
||||
|
||||
class.call_native_init(Some(this.into()), &[], activation)?;
|
||||
|
@ -90,7 +90,7 @@ impl<'gc> StageObject<'gc> {
|
|||
pub fn graphics(
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
display_object: DisplayObject<'gc>,
|
||||
) -> Result<Self, Error> {
|
||||
) -> Result<Self, Error<'gc>> {
|
||||
let class = activation.avm2().classes().graphics;
|
||||
let mut this = Self(GcCell::allocate(
|
||||
activation.context.gc_context,
|
||||
|
@ -128,7 +128,7 @@ impl<'gc> TObject<'gc> for StageObject<'gc> {
|
|||
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)))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ use std::cell::{Ref, RefMut};
|
|||
pub fn textformat_allocator<'gc>(
|
||||
class: ClassObject<'gc>,
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
) -> Result<Object<'gc>, Error> {
|
||||
) -> Result<Object<'gc>, Error<'gc>> {
|
||||
let base = ScriptObjectData::new(class);
|
||||
|
||||
Ok(TextFormatObject(GcCell::allocate(
|
||||
|
@ -43,7 +43,7 @@ impl<'gc> TextFormatObject<'gc> {
|
|||
pub fn from_text_format(
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
text_format: TextFormat,
|
||||
) -> Result<Object<'gc>, Error> {
|
||||
) -> Result<Object<'gc>, Error<'gc>> {
|
||||
let class = activation.avm2().classes().textformat;
|
||||
let base = ScriptObjectData::new(class);
|
||||
|
||||
|
@ -71,7 +71,7 @@ impl<'gc> TObject<'gc> for TextFormatObject<'gc> {
|
|||
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)))
|
||||
}
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue