avm2: Stub `flash.display.SimpleButton`
This commit is contained in:
parent
cffa739a54
commit
22eac776be
|
@ -111,6 +111,7 @@ pub struct SystemPrototypes<'gc> {
|
|||
pub bytearray: Object<'gc>,
|
||||
pub stage: Object<'gc>,
|
||||
pub sprite: Object<'gc>,
|
||||
pub simplebutton: Object<'gc>,
|
||||
}
|
||||
|
||||
impl<'gc> SystemPrototypes<'gc> {
|
||||
|
@ -157,6 +158,7 @@ impl<'gc> SystemPrototypes<'gc> {
|
|||
bytearray: empty,
|
||||
stage: empty,
|
||||
sprite: empty,
|
||||
simplebutton: empty,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -640,6 +642,19 @@ pub fn load_player_globals<'gc>(
|
|||
domain,
|
||||
script,
|
||||
)?;
|
||||
activation
|
||||
.context
|
||||
.avm2
|
||||
.system_prototypes
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
.simplebutton = class(
|
||||
activation,
|
||||
flash::display::simplebutton::create_class(mc),
|
||||
implicit_deriver,
|
||||
domain,
|
||||
script,
|
||||
)?;
|
||||
class(
|
||||
activation,
|
||||
flash::display::displayobjectcontainer::create_class(mc),
|
||||
|
|
|
@ -13,6 +13,7 @@ pub mod loaderinfo;
|
|||
pub mod movieclip;
|
||||
pub mod scene;
|
||||
pub mod shape;
|
||||
pub mod simplebutton;
|
||||
pub mod sprite;
|
||||
pub mod stage;
|
||||
pub mod stagealign;
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
//! `flash.display.SimpleButton` 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.display.SimpleButton`'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.display.SimpleButton`'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 `SimpleButton`'s class.
|
||||
pub fn create_class<'gc>(mc: MutationContext<'gc, '_>) -> GcCell<'gc, Class<'gc>> {
|
||||
let class = Class::new(
|
||||
QName::new(Namespace::package("flash.display"), "SimpleButton"),
|
||||
Some(QName::new(Namespace::package("flash.display"), "InteractiveObject").into()),
|
||||
Method::from_builtin(instance_init),
|
||||
Method::from_builtin(class_init),
|
||||
mc,
|
||||
);
|
||||
|
||||
let mut write = class.write(mc);
|
||||
|
||||
write.set_attributes(ClassAttributes::SEALED);
|
||||
|
||||
class
|
||||
}
|
Loading…
Reference in New Issue