avm2: Get rid of `RufflePrivate` and just use regular private namespaces scoped to our own domain.
This commit is contained in:
parent
30d8dc21be
commit
b848e4c5ff
|
@ -31,6 +31,8 @@ mod object;
|
|||
mod string;
|
||||
mod r#uint;
|
||||
|
||||
const NS_RUFFLE_INTERNAL: &str = "https://ruffle.rs/AS3/impl/";
|
||||
|
||||
fn trace<'gc>(
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
use crate::avm2::activation::Activation;
|
||||
use crate::avm2::class::{Class, ClassAttributes};
|
||||
use crate::avm2::events::EventPhase;
|
||||
use crate::avm2::globals::NS_RUFFLE_INTERNAL;
|
||||
use crate::avm2::method::Method;
|
||||
use crate::avm2::names::{Namespace, QName};
|
||||
use crate::avm2::object::{DispatchObject, Object, TObject};
|
||||
|
@ -12,6 +13,8 @@ use crate::avm2::Error;
|
|||
use crate::display_object::TDisplayObject;
|
||||
use gc_arena::{GcCell, MutationContext};
|
||||
|
||||
const NS_EVENT_DISPATCHER: &str = "https://ruffle.rs/AS3/impl/EventDispatcher/";
|
||||
|
||||
/// Implements `flash.events.EventDispatcher`'s instance constructor.
|
||||
pub fn instance_init<'gc>(
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
|
@ -26,16 +29,13 @@ pub fn instance_init<'gc>(
|
|||
|
||||
this.init_property(
|
||||
this,
|
||||
&QName::new(Namespace::ruffle_private("EventDispatcher"), "target"),
|
||||
&QName::new(Namespace::private(NS_EVENT_DISPATCHER), "target"),
|
||||
target,
|
||||
activation,
|
||||
)?;
|
||||
this.init_property(
|
||||
this,
|
||||
&QName::new(
|
||||
Namespace::ruffle_private("EventDispatcher"),
|
||||
"dispatch_list",
|
||||
),
|
||||
&QName::new(Namespace::private(NS_EVENT_DISPATCHER), "dispatch_list"),
|
||||
dispatch_list.into(),
|
||||
activation,
|
||||
)?;
|
||||
|
@ -54,10 +54,7 @@ pub fn add_event_listener<'gc>(
|
|||
let dispatch_list = this
|
||||
.get_property(
|
||||
this,
|
||||
&QName::new(
|
||||
Namespace::ruffle_private("EventDispatcher"),
|
||||
"dispatch_list",
|
||||
),
|
||||
&QName::new(Namespace::private(NS_EVENT_DISPATCHER), "dispatch_list"),
|
||||
activation,
|
||||
)?
|
||||
.coerce_to_object(activation)?;
|
||||
|
@ -102,10 +99,7 @@ pub fn remove_event_listener<'gc>(
|
|||
let dispatch_list = this
|
||||
.get_property(
|
||||
this,
|
||||
&QName::new(
|
||||
Namespace::ruffle_private("EventDispatcher"),
|
||||
"dispatch_list",
|
||||
),
|
||||
&QName::new(Namespace::private(NS_EVENT_DISPATCHER), "dispatch_list"),
|
||||
activation,
|
||||
)?
|
||||
.coerce_to_object(activation)?;
|
||||
|
@ -144,10 +138,7 @@ pub fn has_event_listener<'gc>(
|
|||
let dispatch_list = this
|
||||
.get_property(
|
||||
this,
|
||||
&QName::new(
|
||||
Namespace::ruffle_private("EventDispatcher"),
|
||||
"dispatch_list",
|
||||
),
|
||||
&QName::new(Namespace::private(NS_EVENT_DISPATCHER), "dispatch_list"),
|
||||
activation,
|
||||
)?
|
||||
.coerce_to_object(activation)?;
|
||||
|
@ -195,10 +186,7 @@ pub fn will_trigger<'gc>(
|
|||
let dispatch_list = this
|
||||
.get_property(
|
||||
this,
|
||||
&QName::new(
|
||||
Namespace::ruffle_private("EventDispatcher"),
|
||||
"dispatch_list",
|
||||
),
|
||||
&QName::new(Namespace::private(NS_EVENT_DISPATCHER), "dispatch_list"),
|
||||
activation,
|
||||
)?
|
||||
.coerce_to_object(activation)?;
|
||||
|
@ -219,7 +207,7 @@ pub fn will_trigger<'gc>(
|
|||
let target = this
|
||||
.get_property(
|
||||
this,
|
||||
&QName::new(Namespace::ruffle_private("EventDispatcher"), "target"),
|
||||
&QName::new(Namespace::private(NS_EVENT_DISPATCHER), "target"),
|
||||
activation,
|
||||
)?
|
||||
.coerce_to_object(activation)
|
||||
|
@ -248,10 +236,7 @@ pub fn dispatch_event_to_target<'gc>(
|
|||
let dispatch_list = target
|
||||
.get_property(
|
||||
target,
|
||||
&QName::new(
|
||||
Namespace::ruffle_private("EventDispatcher"),
|
||||
"dispatch_list",
|
||||
),
|
||||
&QName::new(Namespace::private(NS_EVENT_DISPATCHER), "dispatch_list"),
|
||||
activation,
|
||||
)?
|
||||
.coerce_to_object(activation)?;
|
||||
|
@ -310,7 +295,7 @@ pub fn dispatch_event<'gc>(
|
|||
let target = this
|
||||
.get_property(
|
||||
this,
|
||||
&QName::new(Namespace::ruffle_private("EventDispatcher"), "target"),
|
||||
&QName::new(Namespace::private(NS_EVENT_DISPATCHER), "target"),
|
||||
activation,
|
||||
)?
|
||||
.coerce_to_object(activation)
|
||||
|
@ -416,16 +401,13 @@ pub fn create_class<'gc>(mc: MutationContext<'gc, '_>) -> GcCell<'gc, Class<'gc>
|
|||
));
|
||||
|
||||
write.define_instance_trait(Trait::from_slot(
|
||||
QName::new(Namespace::ruffle_private("EventDispatcher"), "target"),
|
||||
QName::new(Namespace::ruffle_private(""), "BareObject").into(),
|
||||
QName::new(Namespace::private(NS_EVENT_DISPATCHER), "target"),
|
||||
QName::new(Namespace::private(NS_RUFFLE_INTERNAL), "BareObject").into(),
|
||||
None,
|
||||
));
|
||||
write.define_instance_trait(Trait::from_slot(
|
||||
QName::new(
|
||||
Namespace::ruffle_private("EventDispatcher"),
|
||||
"dispatch_list",
|
||||
),
|
||||
QName::new(Namespace::ruffle_private(""), "BareObject").into(),
|
||||
QName::new(Namespace::private(NS_EVENT_DISPATCHER), "dispatch_list"),
|
||||
QName::new(Namespace::private(NS_RUFFLE_INTERNAL), "BareObject").into(),
|
||||
None,
|
||||
));
|
||||
|
||||
|
|
|
@ -21,7 +21,6 @@ pub enum Namespace<'gc> {
|
|||
StaticProtected(AvmString<'gc>),
|
||||
Private(AvmString<'gc>),
|
||||
Any,
|
||||
RufflePrivate(AvmString<'gc>),
|
||||
}
|
||||
|
||||
impl<'gc> Namespace<'gc> {
|
||||
|
@ -75,10 +74,8 @@ impl<'gc> Namespace<'gc> {
|
|||
Namespace::Package(package_name.into())
|
||||
}
|
||||
|
||||
/// Construct a Ruffle-only namespace that user code cannot access, name,
|
||||
/// or enumerate.
|
||||
pub fn ruffle_private(name: impl Into<AvmString<'gc>>) -> Self {
|
||||
Namespace::RufflePrivate(name.into())
|
||||
pub fn private(name: impl Into<AvmString<'gc>>) -> Self {
|
||||
Namespace::Private(name.into())
|
||||
}
|
||||
|
||||
pub fn is_public(&self) -> bool {
|
||||
|
@ -90,7 +87,7 @@ impl<'gc> Namespace<'gc> {
|
|||
}
|
||||
|
||||
pub fn is_private(&self) -> bool {
|
||||
matches!(self, Self::Private(_)) || matches!(self, Self::RufflePrivate(_))
|
||||
matches!(self, Self::Private(_))
|
||||
}
|
||||
|
||||
pub fn is_dynamic(&self) -> bool {
|
||||
|
@ -110,7 +107,6 @@ impl<'gc> Namespace<'gc> {
|
|||
Self::StaticProtected(s) => *s,
|
||||
Self::Private(s) => *s,
|
||||
Self::Any => "".into(),
|
||||
Self::RufflePrivate(_) => "".into(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue