avm2: Add private instance slots for `Scene`'s properties

This commit is contained in:
David Wendt 2021-09-17 00:44:27 -04:00 committed by kmeisthax
parent 97924d20ad
commit 5ba2421225
1 changed files with 14 additions and 6 deletions

View File

@ -2,6 +2,7 @@
use crate::avm2::activation::Activation; use crate::avm2::activation::Activation;
use crate::avm2::class::Class; use crate::avm2::class::Class;
use crate::avm2::globals::NS_RUFFLE_INTERNAL;
use crate::avm2::method::{Method, NativeMethodImpl}; use crate::avm2::method::{Method, NativeMethodImpl};
use crate::avm2::names::{Namespace, QName}; use crate::avm2::names::{Namespace, QName};
use crate::avm2::object::{Object, TObject}; use crate::avm2::object::{Object, TObject};
@ -32,19 +33,19 @@ pub fn instance_init<'gc>(
this.set_property( this.set_property(
this, this,
&QName::new(Namespace::Private("ruffle".into()), "name"), &QName::new(Namespace::Private(NS_RUFFLE_INTERNAL.into()), "name").into(),
name.into(), name.into(),
activation, activation,
)?; )?;
this.set_property( this.set_property(
this, this,
&QName::new(Namespace::Private("ruffle".into()), "labels"), &QName::new(Namespace::Private(NS_RUFFLE_INTERNAL.into()), "labels").into(),
labels, labels,
activation, activation,
)?; )?;
this.set_property( this.set_property(
this, this,
&QName::new(Namespace::Private("ruffle".into()), "numFrames"), &QName::new(Namespace::Private(NS_RUFFLE_INTERNAL.into()), "numFrames").into(),
num_frames.into(), num_frames.into(),
activation, activation,
)?; )?;
@ -71,7 +72,7 @@ pub fn labels<'gc>(
if let Some(this) = this { if let Some(this) = this {
this.get_property( this.get_property(
this, this,
&QName::new(Namespace::Private("ruffle".into()), "labels"), &QName::new(Namespace::Private(NS_RUFFLE_INTERNAL.into()), "labels").into(),
activation, activation,
) )
} else { } else {
@ -88,7 +89,7 @@ pub fn name<'gc>(
if let Some(this) = this { if let Some(this) = this {
this.get_property( this.get_property(
this, this,
&QName::new(Namespace::Private("ruffle".into()), "name"), &QName::new(Namespace::Private(NS_RUFFLE_INTERNAL.into()), "name").into(),
activation, activation,
) )
} else { } else {
@ -105,7 +106,7 @@ pub fn num_frames<'gc>(
if let Some(this) = this { if let Some(this) = this {
this.get_property( this.get_property(
this, this,
&QName::new(Namespace::Private("ruffle".into()), "numFrames"), &QName::new(Namespace::Private(NS_RUFFLE_INTERNAL.into()), "numFrames").into(),
activation, activation,
) )
} else { } 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); 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 class
} }