From 5ba242122531487a9e957a97d76bf6a865da50b3 Mon Sep 17 00:00:00 2001 From: David Wendt Date: Fri, 17 Sep 2021 00:44:27 -0400 Subject: [PATCH] avm2: Add private instance slots for `Scene`'s properties --- core/src/avm2/globals/flash/display/scene.rs | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/core/src/avm2/globals/flash/display/scene.rs b/core/src/avm2/globals/flash/display/scene.rs index c9b4dd84a..c9fd67e9d 100644 --- a/core/src/avm2/globals/flash/display/scene.rs +++ b/core/src/avm2/globals/flash/display/scene.rs @@ -2,6 +2,7 @@ use crate::avm2::activation::Activation; use crate::avm2::class::Class; +use crate::avm2::globals::NS_RUFFLE_INTERNAL; use crate::avm2::method::{Method, NativeMethodImpl}; use crate::avm2::names::{Namespace, QName}; use crate::avm2::object::{Object, TObject}; @@ -32,19 +33,19 @@ pub fn instance_init<'gc>( this.set_property( this, - &QName::new(Namespace::Private("ruffle".into()), "name"), + &QName::new(Namespace::Private(NS_RUFFLE_INTERNAL.into()), "name").into(), name.into(), activation, )?; this.set_property( this, - &QName::new(Namespace::Private("ruffle".into()), "labels"), + &QName::new(Namespace::Private(NS_RUFFLE_INTERNAL.into()), "labels").into(), labels, activation, )?; this.set_property( this, - &QName::new(Namespace::Private("ruffle".into()), "numFrames"), + &QName::new(Namespace::Private(NS_RUFFLE_INTERNAL.into()), "numFrames").into(), num_frames.into(), activation, )?; @@ -71,7 +72,7 @@ pub fn labels<'gc>( if let Some(this) = this { this.get_property( this, - &QName::new(Namespace::Private("ruffle".into()), "labels"), + &QName::new(Namespace::Private(NS_RUFFLE_INTERNAL.into()), "labels").into(), activation, ) } else { @@ -88,7 +89,7 @@ pub fn name<'gc>( if let Some(this) = this { this.get_property( this, - &QName::new(Namespace::Private("ruffle".into()), "name"), + &QName::new(Namespace::Private(NS_RUFFLE_INTERNAL.into()), "name").into(), activation, ) } else { @@ -105,7 +106,7 @@ pub fn num_frames<'gc>( if let Some(this) = this { this.get_property( this, - &QName::new(Namespace::Private("ruffle".into()), "numFrames"), + &QName::new(Namespace::Private(NS_RUFFLE_INTERNAL.into()), "numFrames").into(), activation, ) } else { @@ -136,5 +137,12 @@ pub fn create_class<'gc>(mc: MutationContext<'gc, '_>) -> GcCell<'gc, Class<'gc> ]; write.define_public_builtin_instance_properties(mc, PUBLIC_INSTANCE_PROPERTIES); + const PRIVATE_INSTANCE_SLOTS: &[(&str, &str, &str, &str)] = &[ + (NS_RUFFLE_INTERNAL, "name", "", "String"), + (NS_RUFFLE_INTERNAL, "labels", "", "Array"), + (NS_RUFFLE_INTERNAL, "numFrames", "", "int"), + ]; + write.define_private_slot_instance_traits(PRIVATE_INSTANCE_SLOTS); + class }