From 204bdbf74c10a365bf02e832eb079fc04970c1aa Mon Sep 17 00:00:00 2001 From: David Wendt Date: Sun, 26 Nov 2023 20:39:48 -0500 Subject: [PATCH] avm1: Implement strict array conversion for AVM1, too. --- core/src/avm1/flv.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/core/src/avm1/flv.rs b/core/src/avm1/flv.rs index 16148525784b..9a637de9130a 100644 --- a/core/src/avm1/flv.rs +++ b/core/src/avm1/flv.rs @@ -1,4 +1,4 @@ -use crate::avm1::{Activation, ScriptObject, TObject as _, Value as Avm1Value}; +use crate::avm1::{Activation, ArrayObject, ScriptObject, TObject as _, Value as Avm1Value}; use crate::string::AvmString; use flv_rs::{Value as FlvValue, Variable as FlvVariable}; @@ -24,6 +24,18 @@ fn avm1_object_from_flv_variables<'gc>( info_object.into() } +fn avm1_array_from_flv_values<'gc>( + activation: &mut Activation<'_, 'gc>, + values: Vec, +) -> Avm1Value<'gc> { + ArrayObject::new( + activation.context.gc_context, + activation.context.avm1.prototypes().array, + values.iter().map(|v| v.clone().to_avm1_value(activation)), + ) + .into() +} + pub trait FlvValueAvm1Ext<'gc> { fn to_avm1_value(self, activation: &mut Activation<'_, 'gc>) -> Avm1Value<'gc>; } @@ -32,6 +44,7 @@ impl<'gc> FlvValueAvm1Ext<'gc> for FlvValue<'_> { fn to_avm1_value(self, activation: &mut Activation<'_, 'gc>) -> Avm1Value<'gc> { match self { FlvValue::EcmaArray(values) => avm1_object_from_flv_variables(activation, values), + FlvValue::StrictArray(values) => avm1_array_from_flv_values(activation, values), FlvValue::String(string_data) | FlvValue::LongString(string_data) => { AvmString::new_utf8_bytes(activation.context.gc_context, string_data).into() }