avm2: Implement `flash.display.PixelSnapping` (#5718)
* Add flash.display.PixelSnapping enum class * Run 'cargo format --all' * Add 'final' class attribute
This commit is contained in:
parent
9701b817f5
commit
7c87f35d8d
|
@ -816,6 +816,11 @@ pub fn load_player_globals<'gc>(
|
||||||
flash::display::bitmapdata::create_class(mc),
|
flash::display::bitmapdata::create_class(mc),
|
||||||
script
|
script
|
||||||
);
|
);
|
||||||
|
class(
|
||||||
|
activation,
|
||||||
|
flash::display::pixelsnapping::create_class(mc),
|
||||||
|
script,
|
||||||
|
)?;
|
||||||
|
|
||||||
// package `flash.geom`
|
// package `flash.geom`
|
||||||
avm2_system_class!(
|
avm2_system_class!(
|
||||||
|
|
|
@ -14,6 +14,7 @@ pub mod jointstyle;
|
||||||
pub mod linescalemode;
|
pub mod linescalemode;
|
||||||
pub mod loaderinfo;
|
pub mod loaderinfo;
|
||||||
pub mod movieclip;
|
pub mod movieclip;
|
||||||
|
pub mod pixelsnapping;
|
||||||
pub mod scene;
|
pub mod scene;
|
||||||
pub mod shape;
|
pub mod shape;
|
||||||
pub mod simplebutton;
|
pub mod simplebutton;
|
||||||
|
|
|
@ -0,0 +1,53 @@
|
||||||
|
//! `flash.display.PixelSnapping` 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.PixelSnapping`'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.PixelSnapping`'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 `PixelSnapping`'s class.
|
||||||
|
pub fn create_class<'gc>(mc: MutationContext<'gc, '_>) -> GcCell<'gc, Class<'gc>> {
|
||||||
|
let class = Class::new(
|
||||||
|
QName::new(Namespace::package("flash.display"), "PixelSnapping"),
|
||||||
|
Some(QName::new(Namespace::public(), "Object").into()),
|
||||||
|
Method::from_builtin(instance_init, "<PixelSnapping instance initializer>", mc),
|
||||||
|
Method::from_builtin(class_init, "<PixelSnapping class initializer>", mc),
|
||||||
|
mc,
|
||||||
|
);
|
||||||
|
|
||||||
|
let mut write = class.write(mc);
|
||||||
|
|
||||||
|
write.set_attributes(ClassAttributes::SEALED | ClassAttributes::FINAL);
|
||||||
|
|
||||||
|
const CONSTANTS: &[(&str, &str)] =
|
||||||
|
&[("ALWAYS", "always"), ("AUTO", "auto"), ("NEVER", "never")];
|
||||||
|
write.define_public_constant_string_class_traits(CONSTANTS);
|
||||||
|
|
||||||
|
class
|
||||||
|
}
|
Loading…
Reference in New Issue