avm2: Port `flash.display.InterpolationMethod` to ActionScript

This commit is contained in:
relrelb 2022-06-24 16:53:19 +03:00 committed by relrelb
parent 7c992b4664
commit 6779e406ce
5 changed files with 7 additions and 61 deletions

View File

@ -785,11 +785,6 @@ pub fn load_player_globals<'gc>(
flash::display::spreadmethod::create_class(mc),
script,
)?;
class(
activation,
flash::display::interpolationmethod::create_class(mc),
script,
)?;
class(activation, flash::display::loader::create_class(mc), script)?;
avm2_system_class!(
loaderinfo,

View File

@ -8,7 +8,6 @@ pub mod framelabel;
pub mod graphics;
pub mod ibitmapdrawable;
pub mod interactiveobject;
pub mod interpolationmethod;
pub mod jointstyle;
pub mod linescalemode;
pub mod loader;

View File

@ -0,0 +1,6 @@
package flash.display {
public final class InterpolationMethod {
public static const RGB: String = "rgb";
public static const LINEAR_RGB: String = "linearRGB";
}
}

View File

@ -1,55 +0,0 @@
//! `flash.display.InterpolationMethod` 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.InterpolationMethod`'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.InterpolationMethod`'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 `InterpolationMethod`'s class.
pub fn create_class<'gc>(mc: MutationContext<'gc, '_>) -> GcCell<'gc, Class<'gc>> {
let class = Class::new(
QName::new(Namespace::package("flash.display"), "InterpolationMethod"),
Some(QName::new(Namespace::public(), "Object").into()),
Method::from_builtin(
instance_init,
"<InterpolationMethod instance initializer>",
mc,
),
Method::from_builtin(class_init, "<InterpolationMethod class initializer>", mc),
mc,
);
let mut write = class.write(mc);
write.set_attributes(ClassAttributes::SEALED);
const CONSTANTS: &[(&str, &str)] = &[("LINEAR_RGB", "linearRGB"), ("RGB", "rgb")];
write.define_public_constant_string_class_traits(CONSTANTS);
class
}

View File

@ -11,6 +11,7 @@ include "flash/display/FocusDirection.as"
include "flash/display/GradientType.as"
include "flash/display/GraphicsPathCommand.as"
include "flash/display/GraphicsPathWinding.as"
include "flash/display/InterpolationMethod.as"
include "flash/geom/ColorTransform.as"
include "flash/geom/Orientation3D.as"
include "flash/geom/Point.as"