avm2: Implement `flash.events.EventPhase`.
This commit is contained in:
parent
6d02248ea5
commit
7b6f8aef06
|
@ -594,6 +594,12 @@ pub fn load_player_globals<'gc>(
|
|||
flash::events::fullscreenevent::create_class(mc),
|
||||
script
|
||||
);
|
||||
class(
|
||||
activation,
|
||||
flash::events::eventphase::create_class(mc),
|
||||
script,
|
||||
)?;
|
||||
|
||||
// package `flash.utils`
|
||||
avm2_system_class!(
|
||||
bytearray,
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
pub mod activityevent;
|
||||
pub mod event;
|
||||
pub mod eventdispatcher;
|
||||
pub mod eventphase;
|
||||
pub mod fullscreenevent;
|
||||
pub mod ieventdispatcher;
|
||||
pub mod keyboardevent;
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
//! `flash.events.EventPhase` builtin/prototype
|
||||
|
||||
use crate::avm2::activation::Activation;
|
||||
use crate::avm2::class::{Class, ClassAttributes};
|
||||
use crate::avm2::method::Method;
|
||||
use crate::avm2::names::{Namespace, QName};
|
||||
use crate::avm2::object::Object;
|
||||
use crate::avm2::value::Value;
|
||||
use crate::avm2::Error;
|
||||
use gc_arena::{GcCell, MutationContext};
|
||||
|
||||
/// Implements `flash.events.EventPhase`'s instance constructor.
|
||||
pub fn instance_init<'gc>(
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
if let Some(this) = this {
|
||||
activation.super_init(this, &[])?;
|
||||
}
|
||||
|
||||
Ok(Value::Undefined)
|
||||
}
|
||||
|
||||
/// Implements `flash.events.EventPhase`'s class constructor.
|
||||
pub fn class_init<'gc>(
|
||||
_activation: &mut Activation<'_, 'gc, '_>,
|
||||
_this: Option<Object<'gc>>,
|
||||
_args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error> {
|
||||
Ok(Value::Undefined)
|
||||
}
|
||||
|
||||
/// Construct `EventPhase`'s class.
|
||||
pub fn create_class<'gc>(mc: MutationContext<'gc, '_>) -> GcCell<'gc, Class<'gc>> {
|
||||
let class = Class::new(
|
||||
QName::new(Namespace::package("flash.events"), "EventPhase"),
|
||||
Some(QName::new(Namespace::public(), "Object").into()),
|
||||
Method::from_builtin(instance_init, "<EventPhase instance initializer>", mc),
|
||||
Method::from_builtin(class_init, "<EventPhase class initializer>", mc),
|
||||
mc,
|
||||
);
|
||||
|
||||
let mut write = class.write(mc);
|
||||
|
||||
write.set_attributes(ClassAttributes::SEALED);
|
||||
write.set_attributes(ClassAttributes::FINAL);
|
||||
|
||||
const CONSTANTS: &[(&str, u32)] = &[
|
||||
("CAPTURING_PHASE", 1),
|
||||
("AT_TARGET", 2),
|
||||
("BUBBLING_PHASE", 3),
|
||||
];
|
||||
write.define_public_constant_uint_class_traits(CONSTANTS);
|
||||
|
||||
class
|
||||
}
|
Loading…
Reference in New Issue