Skip to content

Commit ce5bf55

Browse files
relrelbHerschel
authored andcommitted
avm2: ExternalValue::from_avm2 is infallible
1 parent c2e78ff commit ce5bf55

File tree

2 files changed

+9
-13
lines changed

2 files changed

+9
-13
lines changed

core/src/avm2/globals/flash/external/externalinterface.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ pub fn call<'gc>(
4343
{
4444
let mut external_args = Vec::with_capacity(args.len() - 1);
4545
for arg in &args[1..] {
46-
external_args.push(ExternalValue::from_avm2(arg.to_owned())?);
46+
external_args.push(ExternalValue::from_avm2(arg.to_owned()));
4747
}
4848
Ok(method
4949
.call(&mut activation.context, &external_args)

core/src/external.rs

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ use crate::avm1::{
1010
use crate::avm2::activation::Activation as Avm2Activation;
1111
use crate::avm2::object::TObject as _;
1212
use crate::avm2::Value as Avm2Value;
13-
use crate::avm2::{ArrayObject as Avm2ArrayObject, Error as Avm2Error, Object as Avm2Object};
14-
13+
use crate::avm2::{ArrayObject as Avm2ArrayObject, Object as Avm2Object};
1514
use crate::context::UpdateContext;
1615
use crate::string::AvmString;
1716
use gc_arena::Collect;
@@ -183,8 +182,8 @@ impl Value {
183182
}
184183
}
185184

186-
pub fn from_avm2(value: Avm2Value) -> Result<Value, Avm2Error> {
187-
Ok(match value {
185+
pub fn from_avm2(value: Avm2Value) -> Value {
186+
match value {
188187
Avm2Value::Undefined | Avm2Value::Null => Value::Null,
189188
Avm2Value::Bool(value) => value.into(),
190189
Avm2Value::Number(value) => value.into(),
@@ -194,20 +193,20 @@ impl Value {
194193
Avm2Value::Object(object) => {
195194
if let Some(array) = object.as_array_storage() {
196195
let length = array.length();
197-
let values: Result<Vec<_>, Avm2Error> = (0..length)
196+
let values = (0..length)
198197
.map(|i| {
199198
// FIXME - is this right?
200199
let element = array.get(i).unwrap_or(Avm2Value::Null);
201200
Value::from_avm2(element)
202201
})
203202
.collect();
204-
Value::List(values?)
203+
Value::List(values)
205204
} else {
206205
log::warn!("from_avm2 needs to be implemented for Avm2Value::Object");
207206
Value::Null
208207
}
209208
}
210-
})
209+
}
211210
}
212211

213212
pub fn into_avm2<'gc>(self, activation: &mut Avm2Activation<'_, 'gc, '_>) -> Avm2Value<'gc> {
@@ -284,11 +283,8 @@ impl<'gc> Callback<'gc> {
284283
.into_iter()
285284
.map(|v| v.into_avm2(&mut activation))
286285
.collect();
287-
if let Ok(result) = method
288-
.call(None, &args, &mut activation)
289-
.and_then(Value::from_avm2)
290-
{
291-
result
286+
if let Ok(result) = method.call(None, &args, &mut activation) {
287+
Value::from_avm2(result)
292288
} else {
293289
Value::Null
294290
}

0 commit comments

Comments
 (0)