2020-02-12 19:58:33 +00:00
|
|
|
//! Global scope built-ins
|
|
|
|
|
2020-07-04 21:18:41 +00:00
|
|
|
use crate::avm2::activation::Activation;
|
2020-07-07 04:24:16 +00:00
|
|
|
use crate::avm2::class::Class;
|
2020-09-24 03:35:11 +00:00
|
|
|
use crate::avm2::domain::Domain;
|
2021-06-19 01:49:40 +00:00
|
|
|
use crate::avm2::method::{Method, NativeMethodImpl};
|
2020-02-19 03:26:08 +00:00
|
|
|
use crate::avm2::names::{Namespace, QName};
|
2021-09-07 06:29:07 +00:00
|
|
|
use crate::avm2::object::{ClassObject, FunctionObject, Object, ScriptObject, TObject};
|
2021-09-07 22:17:38 +00:00
|
|
|
use crate::avm2::scope::{Scope, ScopeChain};
|
2020-09-24 03:35:11 +00:00
|
|
|
use crate::avm2::script::Script;
|
2020-02-23 02:27:03 +00:00
|
|
|
use crate::avm2::value::Value;
|
2020-07-04 21:18:41 +00:00
|
|
|
use crate::avm2::Error;
|
2021-09-12 10:20:51 +00:00
|
|
|
use crate::string::AvmString;
|
2020-07-07 04:24:16 +00:00
|
|
|
use gc_arena::{Collect, GcCell, MutationContext};
|
2020-02-12 19:58:33 +00:00
|
|
|
|
2020-08-26 03:10:59 +00:00
|
|
|
mod array;
|
2020-07-17 02:33:26 +00:00
|
|
|
mod boolean;
|
2020-03-09 01:53:33 +00:00
|
|
|
mod class;
|
2021-07-27 23:58:13 +00:00
|
|
|
mod date;
|
2020-02-23 00:12:33 +00:00
|
|
|
mod flash;
|
2020-02-19 03:26:08 +00:00
|
|
|
mod function;
|
2020-09-22 00:37:22 +00:00
|
|
|
mod global_scope;
|
2020-07-17 02:33:26 +00:00
|
|
|
mod int;
|
2020-11-10 23:43:44 +00:00
|
|
|
mod math;
|
2020-07-17 02:33:26 +00:00
|
|
|
mod namespace;
|
|
|
|
mod number;
|
2020-02-19 03:26:08 +00:00
|
|
|
mod object;
|
2021-09-29 03:15:44 +00:00
|
|
|
mod qname;
|
2021-02-11 07:56:21 +00:00
|
|
|
mod regexp;
|
2020-07-17 02:33:26 +00:00
|
|
|
mod string;
|
|
|
|
mod r#uint;
|
2021-03-13 03:24:20 +00:00
|
|
|
mod vector;
|
2021-01-15 22:35:10 +00:00
|
|
|
mod xml;
|
|
|
|
mod xml_list;
|
2020-02-19 03:26:08 +00:00
|
|
|
|
2020-12-22 04:43:32 +00:00
|
|
|
const NS_RUFFLE_INTERNAL: &str = "https://ruffle.rs/AS3/impl/";
|
2021-03-16 22:45:38 +00:00
|
|
|
const NS_VECTOR: &str = "__AS3__.vec";
|
2020-12-22 04:43:32 +00:00
|
|
|
|
2020-02-23 02:27:03 +00:00
|
|
|
fn trace<'gc>(
|
2020-06-24 03:34:06 +00:00
|
|
|
activation: &mut Activation<'_, 'gc, '_>,
|
2020-02-24 03:11:02 +00:00
|
|
|
_this: Option<Object<'gc>>,
|
2020-02-23 02:27:03 +00:00
|
|
|
args: &[Value<'gc>],
|
2020-07-04 21:18:41 +00:00
|
|
|
) -> Result<Value<'gc>, Error> {
|
2020-11-11 00:30:01 +00:00
|
|
|
let mut message = String::new();
|
|
|
|
if !args.is_empty() {
|
|
|
|
message.push_str(&args[0].clone().coerce_to_string(activation)?);
|
|
|
|
for arg in &args[1..] {
|
|
|
|
message.push(' ');
|
|
|
|
message.push_str(&arg.clone().coerce_to_string(activation)?);
|
|
|
|
}
|
2020-02-23 02:27:03 +00:00
|
|
|
}
|
|
|
|
|
2020-11-11 00:30:01 +00:00
|
|
|
activation.context.log.avm_trace(&message);
|
|
|
|
|
2020-07-04 21:18:41 +00:00
|
|
|
Ok(Value::Undefined)
|
2020-02-23 02:27:03 +00:00
|
|
|
}
|
|
|
|
|
2020-12-28 05:30:11 +00:00
|
|
|
fn is_finite<'gc>(
|
|
|
|
activation: &mut Activation<'_, 'gc, '_>,
|
|
|
|
_this: Option<Object<'gc>>,
|
|
|
|
args: &[Value<'gc>],
|
|
|
|
) -> Result<Value<'gc>, Error> {
|
|
|
|
if let Some(val) = args.get(0) {
|
|
|
|
Ok(val.coerce_to_number(activation)?.is_finite().into())
|
|
|
|
} else {
|
|
|
|
Ok(false.into())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-12-28 04:40:47 +00:00
|
|
|
fn is_nan<'gc>(
|
|
|
|
activation: &mut Activation<'_, 'gc, '_>,
|
|
|
|
_this: Option<Object<'gc>>,
|
|
|
|
args: &[Value<'gc>],
|
|
|
|
) -> Result<Value<'gc>, Error> {
|
|
|
|
if let Some(val) = args.get(0) {
|
|
|
|
Ok(val.coerce_to_number(activation)?.is_nan().into())
|
|
|
|
} else {
|
|
|
|
Ok(true.into())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-19 03:26:08 +00:00
|
|
|
/// This structure represents all system builtins' prototypes.
|
|
|
|
#[derive(Clone, Collect)]
|
|
|
|
#[collect(no_drop)]
|
|
|
|
pub struct SystemPrototypes<'gc> {
|
|
|
|
pub object: Object<'gc>,
|
|
|
|
pub function: Object<'gc>,
|
2020-03-09 01:53:33 +00:00
|
|
|
pub class: Object<'gc>,
|
2020-09-22 00:37:22 +00:00
|
|
|
pub global: Object<'gc>,
|
2020-07-17 02:33:26 +00:00
|
|
|
pub string: Object<'gc>,
|
|
|
|
pub boolean: Object<'gc>,
|
|
|
|
pub number: Object<'gc>,
|
|
|
|
pub int: Object<'gc>,
|
|
|
|
pub uint: Object<'gc>,
|
|
|
|
pub namespace: Object<'gc>,
|
2020-08-26 03:10:59 +00:00
|
|
|
pub array: Object<'gc>,
|
2020-10-06 01:21:13 +00:00
|
|
|
pub movieclip: Object<'gc>,
|
2020-09-18 00:58:36 +00:00
|
|
|
pub framelabel: Object<'gc>,
|
2020-09-19 02:05:16 +00:00
|
|
|
pub scene: Object<'gc>,
|
2020-09-27 00:21:11 +00:00
|
|
|
pub application_domain: Object<'gc>,
|
2020-12-09 01:48:11 +00:00
|
|
|
pub event: Object<'gc>,
|
2021-01-05 03:14:14 +00:00
|
|
|
pub video: Object<'gc>,
|
2021-01-15 22:35:10 +00:00
|
|
|
pub xml: Object<'gc>,
|
|
|
|
pub xml_list: Object<'gc>,
|
2021-01-22 01:16:23 +00:00
|
|
|
pub display_object: Object<'gc>,
|
2021-02-09 03:40:22 +00:00
|
|
|
pub shape: Object<'gc>,
|
2021-03-18 19:03:04 +00:00
|
|
|
pub point: Object<'gc>,
|
2021-08-13 16:05:11 +00:00
|
|
|
pub rectangle: Object<'gc>,
|
2021-02-14 03:53:29 +00:00
|
|
|
pub textfield: Object<'gc>,
|
2021-02-26 00:04:25 +00:00
|
|
|
pub textformat: Object<'gc>,
|
2021-02-11 00:25:27 +00:00
|
|
|
pub graphics: Object<'gc>,
|
2021-03-20 02:25:11 +00:00
|
|
|
pub loaderinfo: Object<'gc>,
|
2021-03-22 22:35:43 +00:00
|
|
|
pub bytearray: Object<'gc>,
|
2021-04-17 20:03:19 +00:00
|
|
|
pub stage: Object<'gc>,
|
2021-04-24 00:35:55 +00:00
|
|
|
pub sprite: Object<'gc>,
|
2021-04-24 01:15:37 +00:00
|
|
|
pub simplebutton: Object<'gc>,
|
2021-06-01 02:19:36 +00:00
|
|
|
pub regexp: Object<'gc>,
|
2021-03-27 02:58:56 +00:00
|
|
|
pub vector: Object<'gc>,
|
2021-08-14 22:33:01 +00:00
|
|
|
pub soundtransform: Object<'gc>,
|
2021-08-16 23:16:25 +00:00
|
|
|
pub soundchannel: Object<'gc>,
|
2021-08-31 02:54:42 +00:00
|
|
|
pub bitmap: Object<'gc>,
|
2021-08-31 04:14:47 +00:00
|
|
|
pub bitmapdata: Object<'gc>,
|
2021-07-27 23:58:13 +00:00
|
|
|
pub date: Object<'gc>,
|
2021-09-29 03:15:44 +00:00
|
|
|
pub qname: Object<'gc>,
|
2020-02-19 03:26:08 +00:00
|
|
|
}
|
|
|
|
|
2020-08-05 03:00:17 +00:00
|
|
|
impl<'gc> SystemPrototypes<'gc> {
|
|
|
|
/// Construct a minimal set of system prototypes necessary for
|
|
|
|
/// bootstrapping player globals.
|
|
|
|
///
|
|
|
|
/// All other system prototypes aside from the three given here will be set
|
|
|
|
/// to the empty object also handed to this function. It is the caller's
|
|
|
|
/// responsibility to instantiate each class and replace the empty object
|
|
|
|
/// with that.
|
|
|
|
fn new(
|
|
|
|
object: Object<'gc>,
|
|
|
|
function: Object<'gc>,
|
|
|
|
class: Object<'gc>,
|
|
|
|
empty: Object<'gc>,
|
|
|
|
) -> Self {
|
|
|
|
SystemPrototypes {
|
|
|
|
object,
|
|
|
|
function,
|
|
|
|
class,
|
2020-09-22 00:37:22 +00:00
|
|
|
global: empty,
|
2020-08-05 03:00:17 +00:00
|
|
|
string: empty,
|
|
|
|
boolean: empty,
|
|
|
|
number: empty,
|
|
|
|
int: empty,
|
|
|
|
uint: empty,
|
|
|
|
namespace: empty,
|
2020-08-26 03:10:59 +00:00
|
|
|
array: empty,
|
2020-10-06 01:21:13 +00:00
|
|
|
movieclip: empty,
|
2020-09-18 00:58:36 +00:00
|
|
|
framelabel: empty,
|
2020-09-19 02:05:16 +00:00
|
|
|
scene: empty,
|
2020-09-27 00:21:11 +00:00
|
|
|
application_domain: empty,
|
2020-12-09 01:48:11 +00:00
|
|
|
event: empty,
|
2021-01-05 03:14:14 +00:00
|
|
|
video: empty,
|
2021-01-15 22:35:10 +00:00
|
|
|
xml: empty,
|
|
|
|
xml_list: empty,
|
2021-01-22 01:16:23 +00:00
|
|
|
display_object: empty,
|
2021-02-09 03:40:22 +00:00
|
|
|
shape: empty,
|
2021-03-18 19:03:04 +00:00
|
|
|
point: empty,
|
2021-08-13 16:05:11 +00:00
|
|
|
rectangle: empty,
|
2021-02-14 03:53:29 +00:00
|
|
|
textfield: empty,
|
2021-02-26 00:04:25 +00:00
|
|
|
textformat: empty,
|
2021-02-11 00:25:27 +00:00
|
|
|
graphics: empty,
|
2021-03-20 02:25:11 +00:00
|
|
|
loaderinfo: empty,
|
2021-03-22 22:35:43 +00:00
|
|
|
bytearray: empty,
|
2021-04-17 20:03:19 +00:00
|
|
|
stage: empty,
|
2021-04-24 00:35:55 +00:00
|
|
|
sprite: empty,
|
2021-04-24 01:15:37 +00:00
|
|
|
simplebutton: empty,
|
2021-06-01 02:19:36 +00:00
|
|
|
regexp: empty,
|
2021-03-27 02:58:56 +00:00
|
|
|
vector: empty,
|
2021-08-14 22:33:01 +00:00
|
|
|
soundtransform: empty,
|
2021-08-16 23:16:25 +00:00
|
|
|
soundchannel: empty,
|
2021-08-31 02:54:42 +00:00
|
|
|
bitmap: empty,
|
2021-08-31 04:14:47 +00:00
|
|
|
bitmapdata: empty,
|
2021-07-27 23:58:13 +00:00
|
|
|
date: empty,
|
2021-09-29 03:15:44 +00:00
|
|
|
qname: empty,
|
2020-08-05 03:00:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-19 23:07:55 +00:00
|
|
|
/// This structure represents all system builtin classes.
|
2021-05-28 02:22:38 +00:00
|
|
|
#[derive(Clone, Collect)]
|
|
|
|
#[collect(no_drop)]
|
2021-06-18 22:11:37 +00:00
|
|
|
pub struct SystemClasses<'gc> {
|
2021-09-24 20:54:36 +00:00
|
|
|
pub object: ClassObject<'gc>,
|
|
|
|
pub function: ClassObject<'gc>,
|
|
|
|
pub class: ClassObject<'gc>,
|
|
|
|
pub global: ClassObject<'gc>,
|
|
|
|
pub string: ClassObject<'gc>,
|
|
|
|
pub boolean: ClassObject<'gc>,
|
|
|
|
pub number: ClassObject<'gc>,
|
|
|
|
pub int: ClassObject<'gc>,
|
|
|
|
pub uint: ClassObject<'gc>,
|
|
|
|
pub namespace: ClassObject<'gc>,
|
|
|
|
pub array: ClassObject<'gc>,
|
|
|
|
pub movieclip: ClassObject<'gc>,
|
|
|
|
pub framelabel: ClassObject<'gc>,
|
|
|
|
pub scene: ClassObject<'gc>,
|
|
|
|
pub application_domain: ClassObject<'gc>,
|
|
|
|
pub event: ClassObject<'gc>,
|
|
|
|
pub video: ClassObject<'gc>,
|
|
|
|
pub xml: ClassObject<'gc>,
|
|
|
|
pub xml_list: ClassObject<'gc>,
|
|
|
|
pub display_object: ClassObject<'gc>,
|
|
|
|
pub shape: ClassObject<'gc>,
|
|
|
|
pub point: ClassObject<'gc>,
|
|
|
|
pub rectangle: ClassObject<'gc>,
|
|
|
|
pub textfield: ClassObject<'gc>,
|
|
|
|
pub textformat: ClassObject<'gc>,
|
|
|
|
pub graphics: ClassObject<'gc>,
|
|
|
|
pub loaderinfo: ClassObject<'gc>,
|
|
|
|
pub bytearray: ClassObject<'gc>,
|
|
|
|
pub stage: ClassObject<'gc>,
|
|
|
|
pub sprite: ClassObject<'gc>,
|
|
|
|
pub simplebutton: ClassObject<'gc>,
|
|
|
|
pub regexp: ClassObject<'gc>,
|
|
|
|
pub vector: ClassObject<'gc>,
|
|
|
|
pub soundtransform: ClassObject<'gc>,
|
|
|
|
pub soundchannel: ClassObject<'gc>,
|
|
|
|
pub bitmap: ClassObject<'gc>,
|
|
|
|
pub bitmapdata: ClassObject<'gc>,
|
|
|
|
pub date: ClassObject<'gc>,
|
2021-09-29 03:15:44 +00:00
|
|
|
pub qname: ClassObject<'gc>,
|
2021-05-28 02:22:38 +00:00
|
|
|
}
|
|
|
|
|
2021-06-18 22:11:37 +00:00
|
|
|
impl<'gc> SystemClasses<'gc> {
|
2021-06-19 23:07:55 +00:00
|
|
|
/// Construct a minimal set of system classes necessary for bootstrapping
|
|
|
|
/// player globals.
|
2021-05-28 02:22:38 +00:00
|
|
|
///
|
2021-06-19 23:07:55 +00:00
|
|
|
/// All other system classes aside from the three given here will be set to
|
|
|
|
/// the empty object also handed to this function. It is the caller's
|
2021-05-28 02:22:38 +00:00
|
|
|
/// responsibility to instantiate each class and replace the empty object
|
|
|
|
/// with that.
|
2021-09-24 20:54:36 +00:00
|
|
|
fn new(object: ClassObject<'gc>, function: ClassObject<'gc>, class: ClassObject<'gc>) -> Self {
|
2021-06-18 22:11:37 +00:00
|
|
|
SystemClasses {
|
2021-05-28 02:22:38 +00:00
|
|
|
object,
|
|
|
|
function,
|
|
|
|
class,
|
2021-09-24 20:54:36 +00:00
|
|
|
// temporary initialization
|
|
|
|
global: object,
|
|
|
|
string: object,
|
|
|
|
boolean: object,
|
|
|
|
number: object,
|
|
|
|
int: object,
|
|
|
|
uint: object,
|
|
|
|
namespace: object,
|
|
|
|
array: object,
|
|
|
|
movieclip: object,
|
|
|
|
framelabel: object,
|
|
|
|
scene: object,
|
|
|
|
application_domain: object,
|
|
|
|
event: object,
|
|
|
|
video: object,
|
|
|
|
xml: object,
|
|
|
|
xml_list: object,
|
|
|
|
display_object: object,
|
|
|
|
shape: object,
|
|
|
|
point: object,
|
|
|
|
rectangle: object,
|
|
|
|
textfield: object,
|
|
|
|
textformat: object,
|
|
|
|
graphics: object,
|
|
|
|
loaderinfo: object,
|
|
|
|
bytearray: object,
|
|
|
|
stage: object,
|
|
|
|
sprite: object,
|
|
|
|
simplebutton: object,
|
|
|
|
regexp: object,
|
|
|
|
vector: object,
|
|
|
|
soundtransform: object,
|
|
|
|
soundchannel: object,
|
|
|
|
bitmap: object,
|
|
|
|
bitmapdata: object,
|
|
|
|
date: object,
|
2021-09-29 03:15:44 +00:00
|
|
|
qname: object,
|
2021-05-28 02:22:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-23 02:27:03 +00:00
|
|
|
/// Add a free-function builtin to the global scope.
|
|
|
|
fn function<'gc>(
|
2021-09-21 21:50:06 +00:00
|
|
|
activation: &mut Activation<'_, 'gc, '_>,
|
2020-07-14 02:21:18 +00:00
|
|
|
package: impl Into<AvmString<'gc>>,
|
2021-06-13 04:03:41 +00:00
|
|
|
name: &'static str,
|
2021-06-19 01:49:40 +00:00
|
|
|
nf: NativeMethodImpl,
|
2020-10-09 01:54:51 +00:00
|
|
|
script: Script<'gc>,
|
2021-09-07 06:29:07 +00:00
|
|
|
scope: ScopeChain<'gc>,
|
2020-09-24 03:35:11 +00:00
|
|
|
) -> Result<(), Error> {
|
2021-09-07 06:29:07 +00:00
|
|
|
let (_, _, mut domain) = script.init();
|
2021-09-21 21:50:06 +00:00
|
|
|
let mc = activation.context.gc_context;
|
2021-06-13 04:03:41 +00:00
|
|
|
let qname = QName::new(Namespace::package(package), name);
|
2021-06-19 20:28:04 +00:00
|
|
|
let method = Method::from_builtin(nf, name, mc);
|
2021-09-07 06:29:07 +00:00
|
|
|
let as3fn = FunctionObject::from_method(activation, method, scope, None).into();
|
2021-06-13 04:03:41 +00:00
|
|
|
domain.export_definition(qname.clone(), script, mc)?;
|
2020-09-24 03:35:11 +00:00
|
|
|
script
|
2020-10-09 01:54:51 +00:00
|
|
|
.init()
|
|
|
|
.1
|
2021-06-13 04:03:41 +00:00
|
|
|
.install_dynamic_property(mc, qname, as3fn)
|
2020-09-24 03:35:11 +00:00
|
|
|
.unwrap();
|
|
|
|
|
|
|
|
Ok(())
|
2020-02-23 02:27:03 +00:00
|
|
|
}
|
|
|
|
|
2021-06-19 23:07:55 +00:00
|
|
|
/// Add a fully-formed class object builtin to the global scope.
|
2020-08-05 03:00:17 +00:00
|
|
|
///
|
2021-06-19 23:07:55 +00:00
|
|
|
/// This allows the caller to pre-populate the class's prototype with dynamic
|
|
|
|
/// properties, if necessary.
|
2020-08-05 03:00:17 +00:00
|
|
|
fn dynamic_class<'gc>(
|
2020-02-23 00:39:12 +00:00
|
|
|
mc: MutationContext<'gc, '_>,
|
2021-09-24 20:54:36 +00:00
|
|
|
class_object: ClassObject<'gc>,
|
2020-10-09 01:54:51 +00:00
|
|
|
script: Script<'gc>,
|
2020-09-24 03:35:11 +00:00
|
|
|
) -> Result<(), Error> {
|
2021-09-07 06:29:07 +00:00
|
|
|
let (_, mut global, mut domain) = script.init();
|
2021-09-24 20:54:36 +00:00
|
|
|
let class = class_object.inner_class_definition();
|
2020-09-24 03:35:11 +00:00
|
|
|
let name = class.read().name().clone();
|
2020-08-05 03:00:17 +00:00
|
|
|
|
2021-09-07 06:29:07 +00:00
|
|
|
global.install_const(mc, name.clone(), 0, class_object.into(), false);
|
2020-10-09 01:54:51 +00:00
|
|
|
domain.export_definition(name, script, mc)
|
2020-02-23 00:39:12 +00:00
|
|
|
}
|
|
|
|
|
2020-07-07 04:24:16 +00:00
|
|
|
/// Add a class builtin to the global scope.
|
2020-08-05 03:00:17 +00:00
|
|
|
///
|
2021-06-19 19:12:35 +00:00
|
|
|
/// This function returns the class object and class prototype as a pair, which
|
|
|
|
/// may be stored in `SystemClasses` and `SystemPrototypes`, respectively.
|
2021-05-16 02:36:11 +00:00
|
|
|
fn class<'gc>(
|
2020-07-07 04:24:16 +00:00
|
|
|
activation: &mut Activation<'_, 'gc, '_>,
|
|
|
|
class_def: GcCell<'gc, Class<'gc>>,
|
2020-10-09 01:54:51 +00:00
|
|
|
script: Script<'gc>,
|
2021-09-07 06:29:07 +00:00
|
|
|
scope: ScopeChain<'gc>,
|
2021-09-24 20:54:36 +00:00
|
|
|
) -> Result<(ClassObject<'gc>, Object<'gc>), Error> {
|
2021-09-07 06:29:07 +00:00
|
|
|
let (_, mut global, mut domain) = script.init();
|
2020-08-26 03:10:59 +00:00
|
|
|
|
|
|
|
let class_read = class_def.read();
|
|
|
|
let super_class = if let Some(sc_name) = class_read.super_class_name() {
|
|
|
|
let super_class: Result<Object<'gc>, Error> = global
|
2021-09-16 23:17:56 +00:00
|
|
|
.get_property(global, sc_name, activation)?
|
2020-08-26 03:10:59 +00:00
|
|
|
.coerce_to_object(activation)
|
|
|
|
.map_err(|_e| {
|
2021-09-17 04:47:02 +00:00
|
|
|
format!(
|
|
|
|
"Could not resolve superclass {:?} when defining global class {:?}",
|
2021-09-16 23:17:56 +00:00
|
|
|
sc_name.local_name(),
|
2021-09-17 04:47:02 +00:00
|
|
|
class_read.name().local_name()
|
|
|
|
)
|
|
|
|
.into()
|
2020-08-26 03:10:59 +00:00
|
|
|
});
|
2021-09-24 20:54:36 +00:00
|
|
|
let super_class = super_class?
|
|
|
|
.as_class_object()
|
|
|
|
.ok_or_else(|| Error::from("Base class of a global class is not a class"))?;
|
2020-08-26 03:10:59 +00:00
|
|
|
|
2021-09-24 20:54:36 +00:00
|
|
|
Some(super_class)
|
2020-08-26 03:10:59 +00:00
|
|
|
} else {
|
|
|
|
None
|
|
|
|
};
|
|
|
|
|
2021-05-31 20:34:46 +00:00
|
|
|
let class_name = class_read.name().clone();
|
|
|
|
drop(class_read);
|
|
|
|
|
2021-09-07 06:29:07 +00:00
|
|
|
let class_object = ClassObject::from_class(activation, class_def, super_class, scope)?;
|
2020-08-26 03:10:59 +00:00
|
|
|
global.install_const(
|
|
|
|
activation.context.gc_context,
|
2021-05-31 20:34:46 +00:00
|
|
|
class_name.clone(),
|
2020-08-26 03:10:59 +00:00
|
|
|
0,
|
2021-06-19 23:07:55 +00:00
|
|
|
class_object.into(),
|
2021-06-08 22:21:00 +00:00
|
|
|
false,
|
2020-08-26 03:10:59 +00:00
|
|
|
);
|
2021-05-31 20:34:46 +00:00
|
|
|
domain.export_definition(class_name, script, activation.context.gc_context)?;
|
2020-07-07 04:24:16 +00:00
|
|
|
|
2021-06-19 23:07:55 +00:00
|
|
|
let proto = class_object
|
2020-08-05 03:00:17 +00:00
|
|
|
.get_property(
|
2021-09-24 20:54:36 +00:00
|
|
|
class_object.into(),
|
2021-09-16 23:17:56 +00:00
|
|
|
&QName::new(Namespace::public(), "prototype").into(),
|
2020-08-05 03:00:17 +00:00
|
|
|
activation,
|
|
|
|
)?
|
2021-05-28 02:22:38 +00:00
|
|
|
.coerce_to_object(activation)?;
|
|
|
|
|
2021-06-19 23:07:55 +00:00
|
|
|
Ok((class_object, proto))
|
2020-07-07 04:24:16 +00:00
|
|
|
}
|
|
|
|
|
2020-03-09 03:09:30 +00:00
|
|
|
/// Add a builtin constant to the global scope.
|
|
|
|
fn constant<'gc>(
|
|
|
|
mc: MutationContext<'gc, '_>,
|
2020-07-14 02:21:18 +00:00
|
|
|
package: impl Into<AvmString<'gc>>,
|
|
|
|
name: impl Into<AvmString<'gc>>,
|
2020-03-09 03:09:30 +00:00
|
|
|
value: Value<'gc>,
|
2020-10-09 01:54:51 +00:00
|
|
|
script: Script<'gc>,
|
2020-09-24 03:35:11 +00:00
|
|
|
) -> Result<(), Error> {
|
2021-09-07 06:29:07 +00:00
|
|
|
let (_, mut global, mut domain) = script.init();
|
2020-09-24 03:35:11 +00:00
|
|
|
let name = QName::new(Namespace::package(package), name);
|
2020-10-09 01:54:51 +00:00
|
|
|
domain.export_definition(name.clone(), script, mc)?;
|
2021-09-07 06:29:07 +00:00
|
|
|
global.install_const(mc, name, 0, value, false);
|
2020-09-24 03:35:11 +00:00
|
|
|
|
|
|
|
Ok(())
|
2020-03-09 03:09:30 +00:00
|
|
|
}
|
|
|
|
|
2021-05-28 02:22:38 +00:00
|
|
|
macro_rules! avm2_system_class {
|
2021-09-07 06:29:07 +00:00
|
|
|
($field:ident, $activation:ident, $class:expr, $script:expr, $scope:expr) => {
|
|
|
|
let (class_object, proto) = class($activation, $class, $script, $scope)?;
|
2021-05-28 02:22:38 +00:00
|
|
|
|
2021-06-18 22:11:37 +00:00
|
|
|
let sc = $activation.avm2().system_classes.as_mut().unwrap();
|
2021-06-19 23:07:55 +00:00
|
|
|
sc.$field = class_object;
|
2021-05-28 02:22:38 +00:00
|
|
|
|
|
|
|
let sp = $activation.avm2().system_prototypes.as_mut().unwrap();
|
|
|
|
sp.$field = proto;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2020-09-24 03:35:11 +00:00
|
|
|
/// Initialize the player global domain.
|
2020-07-07 04:24:16 +00:00
|
|
|
///
|
2020-08-05 03:00:17 +00:00
|
|
|
/// This should be called only once, to construct the global scope of the
|
|
|
|
/// player. It will return a list of prototypes it has created, which should be
|
2020-09-24 03:35:11 +00:00
|
|
|
/// stored on the AVM. All relevant declarations will also be attached to the
|
|
|
|
/// given domain.
|
|
|
|
pub fn load_player_globals<'gc>(
|
|
|
|
activation: &mut Activation<'_, 'gc, '_>,
|
2020-10-09 01:54:51 +00:00
|
|
|
domain: Domain<'gc>,
|
2020-09-24 03:35:11 +00:00
|
|
|
) -> Result<(), Error> {
|
|
|
|
let mc = activation.context.gc_context;
|
2021-09-07 06:29:07 +00:00
|
|
|
|
|
|
|
let globals = ScriptObject::bare_object(activation.context.gc_context);
|
2021-09-07 22:17:38 +00:00
|
|
|
let gs = ScopeChain::new(domain).chain(mc, &[Scope::new(globals)]);
|
2021-09-07 06:29:07 +00:00
|
|
|
let script = Script::empty_script(mc, globals, domain);
|
2020-02-19 03:26:08 +00:00
|
|
|
|
2020-02-23 00:39:12 +00:00
|
|
|
// public / root package
|
2021-05-16 02:36:11 +00:00
|
|
|
//
|
2021-09-21 21:50:06 +00:00
|
|
|
// This part of global initialization is very complicated, because
|
|
|
|
// everything has to circularly reference everything else:
|
|
|
|
//
|
|
|
|
// - Object is an instance of itself, as well as it's prototype
|
|
|
|
// - All other types are instances of Class, which is an instance of
|
|
|
|
// itself
|
|
|
|
// - Function's prototype is an instance of itself
|
|
|
|
// - All methods created by the above-mentioned classes are also instances
|
|
|
|
// of Function
|
|
|
|
//
|
|
|
|
// Hence, this ridiculously complicated dance of classdef, type allocation,
|
|
|
|
// and partial initialization.
|
|
|
|
let object_classdef = object::create_class(mc);
|
2021-09-07 06:29:07 +00:00
|
|
|
let object_class = ClassObject::from_class_partial(activation, object_classdef, None, gs)?;
|
2021-09-21 21:50:06 +00:00
|
|
|
let object_proto = ScriptObject::bare_object(mc);
|
2020-02-23 00:39:12 +00:00
|
|
|
|
2021-09-21 21:50:06 +00:00
|
|
|
let fn_classdef = function::create_class(mc);
|
2021-09-24 20:54:36 +00:00
|
|
|
let fn_class =
|
2021-09-07 06:29:07 +00:00
|
|
|
ClassObject::from_class_partial(activation, fn_classdef, Some(object_class.into()), gs)?;
|
2021-09-21 21:50:06 +00:00
|
|
|
let fn_proto = ScriptObject::object(mc, object_proto);
|
2021-05-16 02:36:11 +00:00
|
|
|
|
2021-09-21 21:50:06 +00:00
|
|
|
let class_classdef = class::create_class(mc);
|
2021-09-07 06:29:07 +00:00
|
|
|
let class_class =
|
|
|
|
ClassObject::from_class_partial(activation, class_classdef, Some(object_class.into()), gs)?;
|
2021-09-21 21:50:06 +00:00
|
|
|
let class_proto = ScriptObject::object(mc, object_proto);
|
2020-02-19 03:26:08 +00:00
|
|
|
|
2021-09-21 21:50:06 +00:00
|
|
|
// Now to weave the Gordian knot...
|
|
|
|
object_class.link_prototype(activation, object_proto)?;
|
2021-09-24 20:54:36 +00:00
|
|
|
object_class.link_type(activation, class_proto, class_class);
|
2021-09-21 21:50:06 +00:00
|
|
|
|
|
|
|
fn_class.link_prototype(activation, fn_proto)?;
|
2021-09-24 20:54:36 +00:00
|
|
|
fn_class.link_type(activation, class_proto, class_class);
|
2021-09-21 21:50:06 +00:00
|
|
|
|
|
|
|
class_class.link_prototype(activation, class_proto)?;
|
2021-09-24 20:54:36 +00:00
|
|
|
class_class.link_type(activation, class_proto, class_class);
|
2020-08-05 03:00:17 +00:00
|
|
|
|
|
|
|
// At this point, we need at least a partial set of system prototypes in
|
|
|
|
// order to continue initializing the player. The rest of the prototypes
|
|
|
|
// are set to a bare object until we have a chance to initialize them.
|
|
|
|
activation.context.avm2.system_prototypes = Some(SystemPrototypes::new(
|
2020-02-23 00:39:12 +00:00
|
|
|
object_proto,
|
|
|
|
fn_proto,
|
2020-08-05 03:00:17 +00:00
|
|
|
class_proto,
|
2020-09-24 03:35:11 +00:00
|
|
|
ScriptObject::bare_object(mc),
|
2020-08-05 03:00:17 +00:00
|
|
|
));
|
|
|
|
|
2021-09-24 20:54:36 +00:00
|
|
|
activation.context.avm2.system_classes =
|
|
|
|
Some(SystemClasses::new(object_class, fn_class, class_class));
|
2021-05-28 02:22:38 +00:00
|
|
|
|
2021-09-21 21:50:06 +00:00
|
|
|
// Our activation environment is now functional enough to finish
|
|
|
|
// initializing the core class weave. The order of initialization shouldn't
|
|
|
|
// matter here, as long as all the initialization machinery can see and
|
|
|
|
// link the various system types together correctly.
|
|
|
|
let object_class = object_class.into_finished_class(activation)?;
|
|
|
|
let fn_class = fn_class.into_finished_class(activation)?;
|
|
|
|
let class_class = class_class.into_finished_class(activation)?;
|
2021-06-08 00:53:24 +00:00
|
|
|
|
2021-09-07 06:29:07 +00:00
|
|
|
dynamic_class(mc, object_class, script)?;
|
|
|
|
dynamic_class(mc, fn_class, script)?;
|
|
|
|
dynamic_class(mc, class_class, script)?;
|
2021-09-21 21:50:06 +00:00
|
|
|
|
|
|
|
// After this point, it is safe to initialize any other classes.
|
|
|
|
// Make sure to initialize superclasses *before* their subclasses!
|
2020-08-05 03:00:17 +00:00
|
|
|
|
2021-05-28 02:22:38 +00:00
|
|
|
avm2_system_class!(
|
|
|
|
global,
|
|
|
|
activation,
|
|
|
|
global_scope::create_class(mc),
|
2021-09-07 06:29:07 +00:00
|
|
|
script,
|
|
|
|
gs
|
2021-05-28 02:22:38 +00:00
|
|
|
);
|
2021-09-21 21:50:06 +00:00
|
|
|
|
|
|
|
// Oh, one more small hitch: the domain everything gets put into was
|
|
|
|
// actually made *before* the core class weave, so let's fix that up now
|
|
|
|
// that the global class actually exists.
|
2021-09-07 06:29:07 +00:00
|
|
|
globals.set_proto(mc, activation.avm2().prototypes().global);
|
|
|
|
globals.set_instance_of(mc, activation.avm2().classes().global);
|
|
|
|
|
|
|
|
avm2_system_class!(string, activation, string::create_class(mc), script, gs);
|
|
|
|
avm2_system_class!(boolean, activation, boolean::create_class(mc), script, gs);
|
|
|
|
avm2_system_class!(number, activation, number::create_class(mc), script, gs);
|
|
|
|
avm2_system_class!(int, activation, int::create_class(mc), script, gs);
|
|
|
|
avm2_system_class!(uint, activation, uint::create_class(mc), script, gs);
|
2021-05-28 02:22:38 +00:00
|
|
|
avm2_system_class!(
|
|
|
|
namespace,
|
|
|
|
activation,
|
|
|
|
namespace::create_class(mc),
|
2021-09-07 06:29:07 +00:00
|
|
|
script,
|
|
|
|
gs
|
2021-05-28 02:22:38 +00:00
|
|
|
);
|
2021-09-07 06:29:07 +00:00
|
|
|
avm2_system_class!(qname, activation, qname::create_class(mc), script, gs);
|
|
|
|
avm2_system_class!(array, activation, array::create_class(mc), script, gs);
|
|
|
|
|
|
|
|
function(activation, "", "trace", trace, script, gs)?;
|
|
|
|
function(activation, "", "isFinite", is_finite, script, gs)?;
|
|
|
|
function(activation, "", "isNaN", is_nan, script, gs)?;
|
|
|
|
constant(mc, "", "undefined", Value::Undefined, script)?;
|
|
|
|
constant(mc, "", "null", Value::Null, script)?;
|
|
|
|
constant(mc, "", "NaN", f64::NAN.into(), script)?;
|
|
|
|
constant(mc, "", "Infinity", f64::INFINITY.into(), script)?;
|
|
|
|
|
|
|
|
class(activation, math::create_class(mc), script, gs)?;
|
|
|
|
avm2_system_class!(regexp, activation, regexp::create_class(mc), script, gs);
|
|
|
|
avm2_system_class!(vector, activation, vector::create_class(mc), script, gs);
|
|
|
|
avm2_system_class!(xml, activation, xml::create_class(mc), script, gs);
|
|
|
|
avm2_system_class!(xml_list, activation, xml_list::create_class(mc), script, gs);
|
2021-01-15 22:35:10 +00:00
|
|
|
|
2021-09-07 06:29:07 +00:00
|
|
|
avm2_system_class!(date, activation, date::create_class(mc), script, gs);
|
2021-07-27 23:58:13 +00:00
|
|
|
|
2020-09-27 00:21:11 +00:00
|
|
|
// package `flash.system`
|
2021-05-28 02:22:38 +00:00
|
|
|
avm2_system_class!(
|
|
|
|
application_domain,
|
2020-09-27 00:21:11 +00:00
|
|
|
activation,
|
|
|
|
flash::system::application_domain::create_class(mc),
|
2021-09-07 06:29:07 +00:00
|
|
|
script,
|
|
|
|
gs
|
2021-05-28 02:22:38 +00:00
|
|
|
);
|
2021-07-18 02:18:03 +00:00
|
|
|
class(
|
|
|
|
activation,
|
|
|
|
flash::system::capabilities::create_class(mc),
|
|
|
|
script,
|
2021-09-07 06:29:07 +00:00
|
|
|
gs,
|
2021-07-18 02:18:03 +00:00
|
|
|
)?;
|
2021-08-25 18:05:37 +00:00
|
|
|
class(
|
|
|
|
activation,
|
|
|
|
flash::system::security::create_class(mc),
|
|
|
|
script,
|
2021-09-07 06:29:07 +00:00
|
|
|
gs,
|
2021-08-25 18:05:37 +00:00
|
|
|
)?;
|
2021-01-16 23:28:49 +00:00
|
|
|
class(
|
|
|
|
activation,
|
|
|
|
flash::system::system::create_class(mc),
|
|
|
|
script,
|
2021-09-07 06:29:07 +00:00
|
|
|
gs,
|
2021-01-16 23:28:49 +00:00
|
|
|
)?;
|
2020-09-27 00:21:11 +00:00
|
|
|
|
2020-07-07 04:24:16 +00:00
|
|
|
// package `flash.events`
|
2021-05-28 02:22:38 +00:00
|
|
|
avm2_system_class!(
|
|
|
|
event,
|
2020-12-08 02:37:43 +00:00
|
|
|
activation,
|
|
|
|
flash::events::event::create_class(mc),
|
2021-09-07 06:29:07 +00:00
|
|
|
script,
|
|
|
|
gs
|
2021-05-28 02:22:38 +00:00
|
|
|
);
|
2020-07-11 22:09:51 +00:00
|
|
|
class(
|
|
|
|
activation,
|
2020-09-24 03:35:11 +00:00
|
|
|
flash::events::ieventdispatcher::create_interface(mc),
|
|
|
|
script,
|
2021-09-07 06:29:07 +00:00
|
|
|
gs,
|
2020-07-11 22:09:51 +00:00
|
|
|
)?;
|
2020-02-23 00:39:12 +00:00
|
|
|
class(
|
2020-07-07 04:24:16 +00:00
|
|
|
activation,
|
2020-09-24 03:35:11 +00:00
|
|
|
flash::events::eventdispatcher::create_class(mc),
|
|
|
|
script,
|
2021-09-07 06:29:07 +00:00
|
|
|
gs,
|
2020-07-07 04:24:16 +00:00
|
|
|
)?;
|
2021-08-20 23:26:34 +00:00
|
|
|
class(
|
|
|
|
activation,
|
|
|
|
flash::events::mouseevent::create_class(mc),
|
|
|
|
script,
|
2021-09-07 06:29:07 +00:00
|
|
|
gs,
|
2021-08-20 23:26:34 +00:00
|
|
|
)?;
|
2021-09-04 21:18:22 +00:00
|
|
|
class(
|
|
|
|
activation,
|
|
|
|
flash::events::keyboardevent::create_class(mc),
|
|
|
|
script,
|
2021-09-07 06:29:07 +00:00
|
|
|
gs,
|
2021-09-04 21:18:22 +00:00
|
|
|
)?;
|
|
|
|
class(
|
|
|
|
activation,
|
|
|
|
flash::events::progressevent::create_class(mc),
|
|
|
|
script,
|
2021-09-07 06:29:07 +00:00
|
|
|
gs,
|
2021-09-04 21:18:22 +00:00
|
|
|
)?;
|
2021-03-05 23:01:02 +00:00
|
|
|
// package `flash.utils`
|
2021-05-28 02:22:38 +00:00
|
|
|
avm2_system_class!(
|
|
|
|
bytearray,
|
2021-03-05 23:01:02 +00:00
|
|
|
activation,
|
|
|
|
flash::utils::bytearray::create_class(mc),
|
2021-09-07 06:29:07 +00:00
|
|
|
script,
|
|
|
|
gs
|
2021-05-28 02:22:38 +00:00
|
|
|
);
|
|
|
|
|
2021-09-07 06:29:07 +00:00
|
|
|
domain.init_default_domain_memory(activation)?;
|
2021-03-05 23:01:02 +00:00
|
|
|
|
|
|
|
class(
|
|
|
|
activation,
|
|
|
|
flash::utils::endian::create_class(mc),
|
|
|
|
script,
|
2021-09-07 06:29:07 +00:00
|
|
|
gs,
|
2021-03-05 23:01:02 +00:00
|
|
|
)?;
|
2020-02-23 00:39:12 +00:00
|
|
|
|
2021-06-22 08:26:27 +00:00
|
|
|
class(
|
|
|
|
activation,
|
|
|
|
flash::utils::compression_algorithm::create_class(mc),
|
|
|
|
script,
|
2021-09-07 06:29:07 +00:00
|
|
|
gs,
|
2021-06-22 08:26:27 +00:00
|
|
|
)?;
|
|
|
|
|
2021-09-25 02:45:07 +00:00
|
|
|
class(
|
|
|
|
activation,
|
|
|
|
flash::utils::dictionary::create_class(mc),
|
|
|
|
script,
|
2021-09-07 06:29:07 +00:00
|
|
|
gs,
|
2021-09-25 02:45:07 +00:00
|
|
|
)?;
|
|
|
|
|
2021-03-27 16:59:56 +00:00
|
|
|
function(
|
2021-09-21 21:50:06 +00:00
|
|
|
activation,
|
2021-03-27 16:59:56 +00:00
|
|
|
"flash.utils",
|
|
|
|
"getTimer",
|
|
|
|
flash::utils::get_timer,
|
|
|
|
script,
|
2021-09-07 06:29:07 +00:00
|
|
|
gs,
|
2021-03-27 16:59:56 +00:00
|
|
|
)?;
|
|
|
|
|
2021-08-26 07:46:39 +00:00
|
|
|
function(
|
2021-09-21 21:50:06 +00:00
|
|
|
activation,
|
2021-08-26 07:46:39 +00:00
|
|
|
"flash.utils",
|
|
|
|
"getQualifiedClassName",
|
|
|
|
flash::utils::get_qualified_class_name,
|
|
|
|
script,
|
2021-09-07 06:29:07 +00:00
|
|
|
gs,
|
2021-08-26 07:46:39 +00:00
|
|
|
)?;
|
|
|
|
|
|
|
|
function(
|
2021-09-21 21:50:06 +00:00
|
|
|
activation,
|
2021-08-26 07:46:39 +00:00
|
|
|
"flash.utils",
|
|
|
|
"getQualifiedSuperclassName",
|
|
|
|
flash::utils::get_qualified_super_class_name,
|
|
|
|
script,
|
2021-09-07 06:29:07 +00:00
|
|
|
gs,
|
2021-08-26 07:46:39 +00:00
|
|
|
)?;
|
|
|
|
|
|
|
|
function(
|
2021-09-21 21:50:06 +00:00
|
|
|
activation,
|
2021-08-26 07:46:39 +00:00
|
|
|
"flash.utils",
|
|
|
|
"getDefinitionByName",
|
|
|
|
flash::utils::get_definition_by_name,
|
|
|
|
script,
|
2021-09-07 06:29:07 +00:00
|
|
|
gs,
|
2021-08-26 07:46:39 +00:00
|
|
|
)?;
|
|
|
|
|
2020-02-23 00:39:12 +00:00
|
|
|
// package `flash.display`
|
2021-09-11 21:58:27 +00:00
|
|
|
class(
|
|
|
|
activation,
|
|
|
|
flash::display::ibitmapdrawable::create_interface(mc),
|
|
|
|
script,
|
2021-09-07 06:29:07 +00:00
|
|
|
gs,
|
2021-09-11 21:58:27 +00:00
|
|
|
)?;
|
2021-05-28 02:22:38 +00:00
|
|
|
avm2_system_class!(
|
|
|
|
display_object,
|
2020-07-07 04:24:16 +00:00
|
|
|
activation,
|
2020-09-24 03:35:11 +00:00
|
|
|
flash::display::displayobject::create_class(mc),
|
2021-09-07 06:29:07 +00:00
|
|
|
script,
|
|
|
|
gs
|
2021-05-28 02:22:38 +00:00
|
|
|
);
|
|
|
|
avm2_system_class!(
|
|
|
|
shape,
|
2021-02-09 03:40:22 +00:00
|
|
|
activation,
|
|
|
|
flash::display::shape::create_class(mc),
|
2021-09-07 06:29:07 +00:00
|
|
|
script,
|
|
|
|
gs
|
2021-05-28 02:22:38 +00:00
|
|
|
);
|
2020-02-23 00:39:12 +00:00
|
|
|
class(
|
2020-07-07 04:24:16 +00:00
|
|
|
activation,
|
2020-09-24 03:35:11 +00:00
|
|
|
flash::display::interactiveobject::create_class(mc),
|
|
|
|
script,
|
2021-09-07 06:29:07 +00:00
|
|
|
gs,
|
2020-07-07 04:24:16 +00:00
|
|
|
)?;
|
2021-05-28 02:22:38 +00:00
|
|
|
avm2_system_class!(
|
|
|
|
simplebutton,
|
2021-04-24 01:15:37 +00:00
|
|
|
activation,
|
|
|
|
flash::display::simplebutton::create_class(mc),
|
2021-09-07 06:29:07 +00:00
|
|
|
script,
|
|
|
|
gs
|
2021-05-28 02:22:38 +00:00
|
|
|
);
|
2020-02-23 00:39:12 +00:00
|
|
|
class(
|
2020-07-07 04:24:16 +00:00
|
|
|
activation,
|
2020-09-24 03:35:11 +00:00
|
|
|
flash::display::displayobjectcontainer::create_class(mc),
|
|
|
|
script,
|
2021-09-07 06:29:07 +00:00
|
|
|
gs,
|
2020-07-07 04:24:16 +00:00
|
|
|
)?;
|
2021-05-28 02:22:38 +00:00
|
|
|
avm2_system_class!(
|
|
|
|
sprite,
|
2020-07-07 04:24:16 +00:00
|
|
|
activation,
|
2020-09-24 03:35:11 +00:00
|
|
|
flash::display::sprite::create_class(mc),
|
2021-09-07 06:29:07 +00:00
|
|
|
script,
|
|
|
|
gs
|
2021-05-28 02:22:38 +00:00
|
|
|
);
|
|
|
|
avm2_system_class!(
|
|
|
|
movieclip,
|
2020-07-07 04:24:16 +00:00
|
|
|
activation,
|
2020-09-24 03:35:11 +00:00
|
|
|
flash::display::movieclip::create_class(mc),
|
2021-09-07 06:29:07 +00:00
|
|
|
script,
|
|
|
|
gs
|
2021-05-28 02:22:38 +00:00
|
|
|
);
|
|
|
|
avm2_system_class!(
|
|
|
|
framelabel,
|
2020-09-17 01:32:00 +00:00
|
|
|
activation,
|
2020-09-24 03:35:11 +00:00
|
|
|
flash::display::framelabel::create_class(mc),
|
2021-09-07 06:29:07 +00:00
|
|
|
script,
|
|
|
|
gs
|
2021-05-28 02:22:38 +00:00
|
|
|
);
|
|
|
|
avm2_system_class!(
|
|
|
|
scene,
|
2020-09-18 01:56:48 +00:00
|
|
|
activation,
|
2020-09-24 03:35:11 +00:00
|
|
|
flash::display::scene::create_class(mc),
|
2021-09-07 06:29:07 +00:00
|
|
|
script,
|
|
|
|
gs
|
2021-05-28 02:22:38 +00:00
|
|
|
);
|
|
|
|
avm2_system_class!(
|
|
|
|
graphics,
|
2021-02-11 00:25:27 +00:00
|
|
|
activation,
|
|
|
|
flash::display::graphics::create_class(mc),
|
2021-09-07 06:29:07 +00:00
|
|
|
script,
|
|
|
|
gs
|
2021-05-28 02:22:38 +00:00
|
|
|
);
|
2021-02-11 22:28:07 +00:00
|
|
|
class(
|
|
|
|
activation,
|
|
|
|
flash::display::jointstyle::create_class(mc),
|
|
|
|
script,
|
2021-09-07 06:29:07 +00:00
|
|
|
gs,
|
2021-02-11 22:28:07 +00:00
|
|
|
)?;
|
2021-02-11 22:34:32 +00:00
|
|
|
class(
|
|
|
|
activation,
|
|
|
|
flash::display::linescalemode::create_class(mc),
|
|
|
|
script,
|
2021-09-07 06:29:07 +00:00
|
|
|
gs,
|
2021-02-11 22:34:32 +00:00
|
|
|
)?;
|
2021-02-11 22:37:18 +00:00
|
|
|
class(
|
|
|
|
activation,
|
|
|
|
flash::display::capsstyle::create_class(mc),
|
2021-03-24 23:42:37 +00:00
|
|
|
script,
|
2021-09-07 06:29:07 +00:00
|
|
|
gs,
|
2021-03-20 02:01:44 +00:00
|
|
|
)?;
|
2021-05-28 02:22:38 +00:00
|
|
|
avm2_system_class!(
|
|
|
|
loaderinfo,
|
2021-03-20 02:01:44 +00:00
|
|
|
activation,
|
|
|
|
flash::display::loaderinfo::create_class(mc),
|
2021-09-07 06:29:07 +00:00
|
|
|
script,
|
|
|
|
gs
|
2021-05-28 02:22:38 +00:00
|
|
|
);
|
2021-03-20 03:12:14 +00:00
|
|
|
class(
|
|
|
|
activation,
|
|
|
|
flash::display::actionscriptversion::create_class(mc),
|
|
|
|
script,
|
2021-09-07 06:29:07 +00:00
|
|
|
gs,
|
2021-03-20 03:12:14 +00:00
|
|
|
)?;
|
2021-03-22 22:48:35 +00:00
|
|
|
class(
|
|
|
|
activation,
|
|
|
|
flash::display::swfversion::create_class(mc),
|
|
|
|
script,
|
2021-09-07 06:29:07 +00:00
|
|
|
gs,
|
2021-03-22 22:48:35 +00:00
|
|
|
)?;
|
2021-05-28 02:22:38 +00:00
|
|
|
avm2_system_class!(
|
|
|
|
stage,
|
2021-04-17 20:03:19 +00:00
|
|
|
activation,
|
|
|
|
flash::display::stage::create_class(mc),
|
2021-09-07 06:29:07 +00:00
|
|
|
script,
|
|
|
|
gs
|
2021-05-28 02:22:38 +00:00
|
|
|
);
|
2021-04-25 22:19:02 +00:00
|
|
|
class(
|
|
|
|
activation,
|
|
|
|
flash::display::stagescalemode::create_class(mc),
|
|
|
|
script,
|
2021-09-07 06:29:07 +00:00
|
|
|
gs,
|
2021-04-25 22:19:02 +00:00
|
|
|
)?;
|
2021-04-18 03:46:00 +00:00
|
|
|
class(
|
|
|
|
activation,
|
|
|
|
flash::display::stagealign::create_class(mc),
|
|
|
|
script,
|
2021-09-07 06:29:07 +00:00
|
|
|
gs,
|
2021-04-18 03:46:00 +00:00
|
|
|
)?;
|
2021-04-20 01:47:02 +00:00
|
|
|
class(
|
|
|
|
activation,
|
|
|
|
flash::display::stagedisplaystate::create_class(mc),
|
|
|
|
script,
|
2021-09-07 06:29:07 +00:00
|
|
|
gs,
|
2021-04-20 01:47:02 +00:00
|
|
|
)?;
|
2021-04-21 22:21:22 +00:00
|
|
|
class(
|
|
|
|
activation,
|
|
|
|
flash::display::stagequality::create_class(mc),
|
|
|
|
script,
|
2021-09-07 06:29:07 +00:00
|
|
|
gs,
|
2021-04-21 22:21:22 +00:00
|
|
|
)?;
|
2021-08-31 02:54:42 +00:00
|
|
|
avm2_system_class!(
|
|
|
|
bitmap,
|
|
|
|
activation,
|
|
|
|
flash::display::bitmap::create_class(mc),
|
2021-09-07 06:29:07 +00:00
|
|
|
script,
|
|
|
|
gs
|
2021-08-31 02:54:42 +00:00
|
|
|
);
|
2021-08-31 04:14:47 +00:00
|
|
|
avm2_system_class!(
|
|
|
|
bitmapdata,
|
|
|
|
activation,
|
|
|
|
flash::display::bitmapdata::create_class(mc),
|
2021-09-07 06:29:07 +00:00
|
|
|
script,
|
|
|
|
gs
|
2021-08-31 04:14:47 +00:00
|
|
|
);
|
2020-02-12 19:58:33 +00:00
|
|
|
|
2021-03-18 19:03:04 +00:00
|
|
|
// package `flash.geom`
|
2021-05-28 02:22:38 +00:00
|
|
|
avm2_system_class!(
|
|
|
|
point,
|
2021-03-18 19:03:04 +00:00
|
|
|
activation,
|
|
|
|
flash::geom::point::create_class(mc),
|
2021-09-07 06:29:07 +00:00
|
|
|
script,
|
|
|
|
gs
|
2021-05-28 02:22:38 +00:00
|
|
|
);
|
2021-08-13 16:05:11 +00:00
|
|
|
avm2_system_class!(
|
|
|
|
rectangle,
|
|
|
|
activation,
|
|
|
|
flash::geom::rectangle::create_class(mc),
|
2021-09-07 06:29:07 +00:00
|
|
|
script,
|
|
|
|
gs
|
2021-08-13 16:05:11 +00:00
|
|
|
);
|
2021-03-18 19:03:04 +00:00
|
|
|
|
2021-01-05 03:14:14 +00:00
|
|
|
// package `flash.media`
|
2021-05-28 02:22:38 +00:00
|
|
|
avm2_system_class!(
|
|
|
|
video,
|
2021-01-05 03:14:14 +00:00
|
|
|
activation,
|
|
|
|
flash::media::video::create_class(mc),
|
2021-09-07 06:29:07 +00:00
|
|
|
script,
|
|
|
|
gs
|
2021-05-28 02:22:38 +00:00
|
|
|
);
|
2021-08-11 01:05:11 +00:00
|
|
|
class(
|
|
|
|
activation,
|
|
|
|
flash::media::sound::create_class(mc),
|
|
|
|
script,
|
2021-09-07 06:29:07 +00:00
|
|
|
gs,
|
2021-08-11 01:05:11 +00:00
|
|
|
)?;
|
2021-08-14 22:33:01 +00:00
|
|
|
avm2_system_class!(
|
|
|
|
soundtransform,
|
2021-08-14 03:34:51 +00:00
|
|
|
activation,
|
|
|
|
flash::media::soundtransform::create_class(mc),
|
2021-09-07 06:29:07 +00:00
|
|
|
script,
|
|
|
|
gs
|
2021-08-14 22:33:01 +00:00
|
|
|
);
|
2021-08-14 23:36:14 +00:00
|
|
|
class(
|
|
|
|
activation,
|
|
|
|
flash::media::soundmixer::create_class(mc),
|
|
|
|
script,
|
2021-09-07 06:29:07 +00:00
|
|
|
gs,
|
2021-08-14 23:36:14 +00:00
|
|
|
)?;
|
2021-08-16 23:16:25 +00:00
|
|
|
avm2_system_class!(
|
|
|
|
soundchannel,
|
|
|
|
activation,
|
|
|
|
flash::media::soundchannel::create_class(mc),
|
2021-09-07 06:29:07 +00:00
|
|
|
script,
|
|
|
|
gs
|
2021-08-16 23:16:25 +00:00
|
|
|
);
|
2021-01-05 03:14:14 +00:00
|
|
|
|
2021-02-13 01:32:13 +00:00
|
|
|
// package `flash.text`
|
2021-05-28 02:22:38 +00:00
|
|
|
avm2_system_class!(
|
|
|
|
textfield,
|
2021-02-13 01:32:13 +00:00
|
|
|
activation,
|
|
|
|
flash::text::textfield::create_class(mc),
|
2021-09-07 06:29:07 +00:00
|
|
|
script,
|
|
|
|
gs
|
2021-05-28 02:22:38 +00:00
|
|
|
);
|
|
|
|
avm2_system_class!(
|
|
|
|
textformat,
|
2021-02-18 02:40:01 +00:00
|
|
|
activation,
|
|
|
|
flash::text::textformat::create_class(mc),
|
2021-09-07 06:29:07 +00:00
|
|
|
script,
|
|
|
|
gs
|
2021-05-28 02:22:38 +00:00
|
|
|
);
|
2021-02-19 03:00:49 +00:00
|
|
|
class(
|
|
|
|
activation,
|
|
|
|
flash::text::textfieldautosize::create_class(mc),
|
|
|
|
script,
|
2021-09-07 06:29:07 +00:00
|
|
|
gs,
|
2021-02-19 03:00:49 +00:00
|
|
|
)?;
|
2021-02-25 23:07:48 +00:00
|
|
|
class(
|
|
|
|
activation,
|
|
|
|
flash::text::textformatalign::create_class(mc),
|
|
|
|
script,
|
2021-09-07 06:29:07 +00:00
|
|
|
gs,
|
2021-02-25 23:07:48 +00:00
|
|
|
)?;
|
2021-02-27 00:07:07 +00:00
|
|
|
class(
|
|
|
|
activation,
|
|
|
|
flash::text::textfieldtype::create_class(mc),
|
2021-08-30 00:09:47 +00:00
|
|
|
script,
|
2021-09-07 06:29:07 +00:00
|
|
|
gs,
|
2021-08-30 00:09:47 +00:00
|
|
|
)?;
|
2021-09-07 06:29:07 +00:00
|
|
|
class(activation, flash::text::font::create_class(mc), script, gs)?;
|
2021-02-13 01:32:13 +00:00
|
|
|
|
2021-07-21 08:09:48 +00:00
|
|
|
// package `flash.crypto`
|
|
|
|
function(
|
2021-09-21 21:50:06 +00:00
|
|
|
activation,
|
2021-07-21 08:09:48 +00:00
|
|
|
"flash.crypto",
|
|
|
|
"generateRandomBytes",
|
|
|
|
flash::crypto::generate_random_bytes,
|
|
|
|
script,
|
2021-09-07 06:29:07 +00:00
|
|
|
gs,
|
2021-07-21 08:09:48 +00:00
|
|
|
)?;
|
|
|
|
|
2020-07-07 04:24:16 +00:00
|
|
|
Ok(())
|
2020-02-12 19:58:33 +00:00
|
|
|
}
|