Skip to content

Commit

Permalink
avm1: Implement strict array conversion for AVM1, too.
Browse files Browse the repository at this point in the history
  • Loading branch information
kmeisthax committed Nov 29, 2023
1 parent 0a4d144 commit 204bdbf
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion core/src/avm1/flv.rs
Original file line number Diff line number Diff line change
@@ -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};

Expand All @@ -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<FlvValue>,
) -> 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>;
}
Expand All @@ -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()
}
Expand Down

0 comments on commit 204bdbf

Please sign in to comment.