avm2: Unify NativeMethod and GenericNativeMethod
This commit is contained in:
parent
46ddb9be82
commit
faa0e50e89
|
@ -1,6 +1,6 @@
|
||||||
//! AVM2 classes
|
//! AVM2 classes
|
||||||
|
|
||||||
use crate::avm2::method::{GenericNativeMethod, Method};
|
use crate::avm2::method::{Method, NativeMethod};
|
||||||
use crate::avm2::names::{Multiname, Namespace, QName};
|
use crate::avm2::names::{Multiname, Namespace, QName};
|
||||||
use crate::avm2::script::TranslationUnit;
|
use crate::avm2::script::TranslationUnit;
|
||||||
use crate::avm2::string::AvmString;
|
use crate::avm2::string::AvmString;
|
||||||
|
@ -378,7 +378,7 @@ impl<'gc> Class<'gc> {
|
||||||
#[inline(never)]
|
#[inline(never)]
|
||||||
pub fn define_public_builtin_instance_methods(
|
pub fn define_public_builtin_instance_methods(
|
||||||
&mut self,
|
&mut self,
|
||||||
items: &[(&'static str, GenericNativeMethod)],
|
items: &[(&'static str, NativeMethod)],
|
||||||
) {
|
) {
|
||||||
for &(name, value) in items {
|
for &(name, value) in items {
|
||||||
self.define_instance_trait(Trait::from_method(
|
self.define_instance_trait(Trait::from_method(
|
||||||
|
@ -388,10 +388,7 @@ impl<'gc> Class<'gc> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#[inline(never)]
|
#[inline(never)]
|
||||||
pub fn define_as3_builtin_instance_methods(
|
pub fn define_as3_builtin_instance_methods(&mut self, items: &[(&'static str, NativeMethod)]) {
|
||||||
&mut self,
|
|
||||||
items: &[(&'static str, GenericNativeMethod)],
|
|
||||||
) {
|
|
||||||
for &(name, value) in items {
|
for &(name, value) in items {
|
||||||
self.define_instance_trait(Trait::from_method(
|
self.define_instance_trait(Trait::from_method(
|
||||||
QName::new(Namespace::as3_namespace(), name),
|
QName::new(Namespace::as3_namespace(), name),
|
||||||
|
@ -400,10 +397,7 @@ impl<'gc> Class<'gc> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#[inline(never)]
|
#[inline(never)]
|
||||||
pub fn define_public_builtin_class_methods(
|
pub fn define_public_builtin_class_methods(&mut self, items: &[(&'static str, NativeMethod)]) {
|
||||||
&mut self,
|
|
||||||
items: &[(&'static str, GenericNativeMethod)],
|
|
||||||
) {
|
|
||||||
for &(name, value) in items {
|
for &(name, value) in items {
|
||||||
self.define_class_trait(Trait::from_method(
|
self.define_class_trait(Trait::from_method(
|
||||||
QName::new(Namespace::public(), name),
|
QName::new(Namespace::public(), name),
|
||||||
|
@ -414,11 +408,7 @@ impl<'gc> Class<'gc> {
|
||||||
#[inline(never)]
|
#[inline(never)]
|
||||||
pub fn define_public_builtin_instance_properties(
|
pub fn define_public_builtin_instance_properties(
|
||||||
&mut self,
|
&mut self,
|
||||||
items: &[(
|
items: &[(&'static str, Option<NativeMethod>, Option<NativeMethod>)],
|
||||||
&'static str,
|
|
||||||
Option<GenericNativeMethod>,
|
|
||||||
Option<GenericNativeMethod>,
|
|
||||||
)],
|
|
||||||
) {
|
) {
|
||||||
for &(name, getter, setter) in items {
|
for &(name, getter, setter) in items {
|
||||||
if let Some(getter) = getter {
|
if let Some(getter) = getter {
|
||||||
|
@ -444,7 +434,6 @@ impl<'gc> Class<'gc> {
|
||||||
self.class_traits.push(my_trait);
|
self.class_traits.push(my_trait);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// Given a name, append class traits matching the name to a list of known
|
/// Given a name, append class traits matching the name to a list of known
|
||||||
/// traits.
|
/// traits.
|
||||||
///
|
///
|
||||||
|
|
|
@ -33,7 +33,7 @@ pub enum Executable<'gc> {
|
||||||
/// Code defined in Ruffle's binary.
|
/// Code defined in Ruffle's binary.
|
||||||
///
|
///
|
||||||
/// The second parameter stores the bound receiver for this function.
|
/// The second parameter stores the bound receiver for this function.
|
||||||
Native(NativeMethod<'gc>, Option<Object<'gc>>),
|
Native(NativeMethod, Option<Object<'gc>>),
|
||||||
|
|
||||||
/// Code defined in a loaded ABC file.
|
/// Code defined in a loaded ABC file.
|
||||||
Action(Gc<'gc, BytecodeExecutable<'gc>>),
|
Action(Gc<'gc, BytecodeExecutable<'gc>>),
|
||||||
|
|
|
@ -164,7 +164,7 @@ fn function<'gc>(
|
||||||
mc: MutationContext<'gc, '_>,
|
mc: MutationContext<'gc, '_>,
|
||||||
package: impl Into<AvmString<'gc>>,
|
package: impl Into<AvmString<'gc>>,
|
||||||
name: impl Into<AvmString<'gc>>,
|
name: impl Into<AvmString<'gc>>,
|
||||||
nf: NativeMethod<'gc>,
|
nf: NativeMethod,
|
||||||
fn_proto: Object<'gc>,
|
fn_proto: Object<'gc>,
|
||||||
mut domain: Domain<'gc>,
|
mut domain: Domain<'gc>,
|
||||||
script: Script<'gc>,
|
script: Script<'gc>,
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
use crate::avm2::activation::Activation;
|
use crate::avm2::activation::Activation;
|
||||||
use crate::avm2::array::ArrayStorage;
|
use crate::avm2::array::ArrayStorage;
|
||||||
use crate::avm2::class::Class;
|
use crate::avm2::class::Class;
|
||||||
use crate::avm2::method::{GenericNativeMethod, Method};
|
use crate::avm2::method::{Method, NativeMethod};
|
||||||
use crate::avm2::names::{Namespace, QName};
|
use crate::avm2::names::{Namespace, QName};
|
||||||
use crate::avm2::object::{ArrayObject, Object, TObject};
|
use crate::avm2::object::{ArrayObject, Object, TObject};
|
||||||
use crate::avm2::string::AvmString;
|
use crate::avm2::string::AvmString;
|
||||||
|
@ -1229,7 +1229,7 @@ pub fn create_class<'gc>(mc: MutationContext<'gc, '_>) -> GcCell<'gc, Class<'gc>
|
||||||
|
|
||||||
let mut write = class.write(mc);
|
let mut write = class.write(mc);
|
||||||
|
|
||||||
const PUBLIC_INSTANCE_METHODS: &[(&'static str, GenericNativeMethod)] = &[
|
const PUBLIC_INSTANCE_METHODS: &[(&'static str, NativeMethod)] = &[
|
||||||
("toString", to_string),
|
("toString", to_string),
|
||||||
("toLocaleString", to_locale_string),
|
("toLocaleString", to_locale_string),
|
||||||
("valueOf", value_of),
|
("valueOf", value_of),
|
||||||
|
@ -1238,12 +1238,12 @@ pub fn create_class<'gc>(mc: MutationContext<'gc, '_>) -> GcCell<'gc, Class<'gc>
|
||||||
|
|
||||||
const PUBLIC_INSTANCE_PROPERTIES: &[(
|
const PUBLIC_INSTANCE_PROPERTIES: &[(
|
||||||
&'static str,
|
&'static str,
|
||||||
Option<GenericNativeMethod>,
|
Option<NativeMethod>,
|
||||||
Option<GenericNativeMethod>,
|
Option<NativeMethod>,
|
||||||
)] = &[("length", Some(length), Some(set_length))];
|
)] = &[("length", Some(length), Some(set_length))];
|
||||||
write.define_public_builtin_instance_properties(PUBLIC_INSTANCE_PROPERTIES);
|
write.define_public_builtin_instance_properties(PUBLIC_INSTANCE_PROPERTIES);
|
||||||
|
|
||||||
const AS3_INSTANCE_METHODS: &[(&'static str, GenericNativeMethod)] = &[
|
const AS3_INSTANCE_METHODS: &[(&'static str, NativeMethod)] = &[
|
||||||
("concat", concat),
|
("concat", concat),
|
||||||
("join", join),
|
("join", join),
|
||||||
("forEach", for_each),
|
("forEach", for_each),
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
use crate::avm2::activation::Activation;
|
use crate::avm2::activation::Activation;
|
||||||
use crate::avm2::class::Class;
|
use crate::avm2::class::Class;
|
||||||
use crate::avm2::method::{GenericNativeMethod, Method};
|
use crate::avm2::method::{Method, NativeMethod};
|
||||||
use crate::avm2::names::{Namespace, QName};
|
use crate::avm2::names::{Namespace, QName};
|
||||||
use crate::avm2::object::{LoaderInfoObject, Object, TObject};
|
use crate::avm2::object::{LoaderInfoObject, Object, TObject};
|
||||||
use crate::avm2::string::AvmString;
|
use crate::avm2::string::AvmString;
|
||||||
|
@ -599,8 +599,8 @@ pub fn create_class<'gc>(mc: MutationContext<'gc, '_>) -> GcCell<'gc, Class<'gc>
|
||||||
|
|
||||||
const PUBLIC_INSTANCE_PROPERTIES: &[(
|
const PUBLIC_INSTANCE_PROPERTIES: &[(
|
||||||
&'static str,
|
&'static str,
|
||||||
Option<GenericNativeMethod>,
|
Option<NativeMethod>,
|
||||||
Option<GenericNativeMethod>,
|
Option<NativeMethod>,
|
||||||
)] = &[
|
)] = &[
|
||||||
("alpha", Some(alpha), Some(set_alpha)),
|
("alpha", Some(alpha), Some(set_alpha)),
|
||||||
("height", Some(height), Some(set_height)),
|
("height", Some(height), Some(set_height)),
|
||||||
|
@ -621,7 +621,7 @@ pub fn create_class<'gc>(mc: MutationContext<'gc, '_>) -> GcCell<'gc, Class<'gc>
|
||||||
];
|
];
|
||||||
write.define_public_builtin_instance_properties(PUBLIC_INSTANCE_PROPERTIES);
|
write.define_public_builtin_instance_properties(PUBLIC_INSTANCE_PROPERTIES);
|
||||||
|
|
||||||
const PUBLIC_INSTANCE_METHODS: &[(&'static str, GenericNativeMethod)] = &[
|
const PUBLIC_INSTANCE_METHODS: &[(&'static str, NativeMethod)] = &[
|
||||||
("hitTestPoint", hit_test_point),
|
("hitTestPoint", hit_test_point),
|
||||||
("hitTestObject", hit_test_object),
|
("hitTestObject", hit_test_object),
|
||||||
];
|
];
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
use crate::avm2::activation::Activation;
|
use crate::avm2::activation::Activation;
|
||||||
use crate::avm2::class::Class;
|
use crate::avm2::class::Class;
|
||||||
use crate::avm2::method::{GenericNativeMethod, Method};
|
use crate::avm2::method::{Method, NativeMethod};
|
||||||
use crate::avm2::names::{Namespace, QName};
|
use crate::avm2::names::{Namespace, QName};
|
||||||
use crate::avm2::object::{Object, TObject};
|
use crate::avm2::object::{Object, TObject};
|
||||||
use crate::avm2::value::Value;
|
use crate::avm2::value::Value;
|
||||||
|
@ -587,12 +587,12 @@ pub fn create_class<'gc>(mc: MutationContext<'gc, '_>) -> GcCell<'gc, Class<'gc>
|
||||||
|
|
||||||
const PUBLIC_INSTANCE_PROPERTIES: &[(
|
const PUBLIC_INSTANCE_PROPERTIES: &[(
|
||||||
&'static str,
|
&'static str,
|
||||||
Option<GenericNativeMethod>,
|
Option<NativeMethod>,
|
||||||
Option<GenericNativeMethod>,
|
Option<NativeMethod>,
|
||||||
)] = &[("numChildren", Some(num_children), None)];
|
)] = &[("numChildren", Some(num_children), None)];
|
||||||
write.define_public_builtin_instance_properties(PUBLIC_INSTANCE_PROPERTIES);
|
write.define_public_builtin_instance_properties(PUBLIC_INSTANCE_PROPERTIES);
|
||||||
|
|
||||||
const PUBLIC_INSTANCE_METHODS: &[(&'static str, GenericNativeMethod)] = &[
|
const PUBLIC_INSTANCE_METHODS: &[(&'static str, NativeMethod)] = &[
|
||||||
("getChildAt", get_child_at),
|
("getChildAt", get_child_at),
|
||||||
("getChildByName", get_child_by_name),
|
("getChildByName", get_child_by_name),
|
||||||
("addChild", add_child),
|
("addChild", add_child),
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
use crate::avm2::activation::Activation;
|
use crate::avm2::activation::Activation;
|
||||||
use crate::avm2::class::Class;
|
use crate::avm2::class::Class;
|
||||||
use crate::avm2::method::{GenericNativeMethod, Method};
|
use crate::avm2::method::{Method, NativeMethod};
|
||||||
use crate::avm2::names::{Namespace, QName};
|
use crate::avm2::names::{Namespace, QName};
|
||||||
use crate::avm2::object::{Object, TObject};
|
use crate::avm2::object::{Object, TObject};
|
||||||
use crate::avm2::value::Value;
|
use crate::avm2::value::Value;
|
||||||
|
@ -103,8 +103,8 @@ pub fn create_class<'gc>(mc: MutationContext<'gc, '_>) -> GcCell<'gc, Class<'gc>
|
||||||
|
|
||||||
const PUBLIC_INSTANCE_PROPERTIES: &[(
|
const PUBLIC_INSTANCE_PROPERTIES: &[(
|
||||||
&'static str,
|
&'static str,
|
||||||
Option<GenericNativeMethod>,
|
Option<NativeMethod>,
|
||||||
Option<GenericNativeMethod>,
|
Option<NativeMethod>,
|
||||||
)] = &[("name", Some(name), None), ("frame", Some(frame), None)];
|
)] = &[("name", Some(name), None), ("frame", Some(frame), None)];
|
||||||
write.define_public_builtin_instance_properties(PUBLIC_INSTANCE_PROPERTIES);
|
write.define_public_builtin_instance_properties(PUBLIC_INSTANCE_PROPERTIES);
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
use crate::avm2::activation::Activation;
|
use crate::avm2::activation::Activation;
|
||||||
use crate::avm2::class::{Class, ClassAttributes};
|
use crate::avm2::class::{Class, ClassAttributes};
|
||||||
use crate::avm2::method::{GenericNativeMethod, Method};
|
use crate::avm2::method::{Method, NativeMethod};
|
||||||
use crate::avm2::names::{Namespace, QName};
|
use crate::avm2::names::{Namespace, QName};
|
||||||
use crate::avm2::object::{Object, TObject};
|
use crate::avm2::object::{Object, TObject};
|
||||||
use crate::avm2::value::Value;
|
use crate::avm2::value::Value;
|
||||||
|
@ -365,7 +365,7 @@ pub fn create_class<'gc>(mc: MutationContext<'gc, '_>) -> GcCell<'gc, Class<'gc>
|
||||||
|
|
||||||
write.set_attributes(ClassAttributes::SEALED);
|
write.set_attributes(ClassAttributes::SEALED);
|
||||||
|
|
||||||
const PUBLIC_INSTANCE_METHODS: &[(&'static str, GenericNativeMethod)] = &[
|
const PUBLIC_INSTANCE_METHODS: &[(&'static str, NativeMethod)] = &[
|
||||||
("beginFill", begin_fill),
|
("beginFill", begin_fill),
|
||||||
("clear", clear),
|
("clear", clear),
|
||||||
("curveTo", curve_to),
|
("curveTo", curve_to),
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
use crate::avm2::activation::Activation;
|
use crate::avm2::activation::Activation;
|
||||||
use crate::avm2::bytearray::Endian;
|
use crate::avm2::bytearray::Endian;
|
||||||
use crate::avm2::class::{Class, ClassAttributes};
|
use crate::avm2::class::{Class, ClassAttributes};
|
||||||
use crate::avm2::method::{GenericNativeMethod, Method};
|
use crate::avm2::method::{Method, NativeMethod};
|
||||||
use crate::avm2::names::{Namespace, QName};
|
use crate::avm2::names::{Namespace, QName};
|
||||||
use crate::avm2::object::{
|
use crate::avm2::object::{
|
||||||
ByteArrayObject, DomainObject, LoaderInfoObject, LoaderStream, Object, ScriptObject, TObject,
|
ByteArrayObject, DomainObject, LoaderInfoObject, LoaderStream, Object, ScriptObject, TObject,
|
||||||
|
@ -435,8 +435,8 @@ pub fn create_class<'gc>(mc: MutationContext<'gc, '_>) -> GcCell<'gc, Class<'gc>
|
||||||
|
|
||||||
const PUBLIC_INSTANCE_PROPERTIES: &[(
|
const PUBLIC_INSTANCE_PROPERTIES: &[(
|
||||||
&'static str,
|
&'static str,
|
||||||
Option<GenericNativeMethod>,
|
Option<NativeMethod>,
|
||||||
Option<GenericNativeMethod>,
|
Option<NativeMethod>,
|
||||||
)] = &[
|
)] = &[
|
||||||
("actionScriptVersion", Some(action_script_version), None),
|
("actionScriptVersion", Some(action_script_version), None),
|
||||||
("applicationDomain", Some(application_domain), None),
|
("applicationDomain", Some(application_domain), None),
|
||||||
|
|
|
@ -4,7 +4,7 @@ use crate::avm2::activation::Activation;
|
||||||
use crate::avm2::array::ArrayStorage;
|
use crate::avm2::array::ArrayStorage;
|
||||||
use crate::avm2::class::Class;
|
use crate::avm2::class::Class;
|
||||||
use crate::avm2::globals::flash::display::{framelabel, scene};
|
use crate::avm2::globals::flash::display::{framelabel, scene};
|
||||||
use crate::avm2::method::{GenericNativeMethod, Method};
|
use crate::avm2::method::{Method, NativeMethod};
|
||||||
use crate::avm2::names::{Namespace, QName};
|
use crate::avm2::names::{Namespace, QName};
|
||||||
use crate::avm2::object::{ArrayObject, Object, TObject};
|
use crate::avm2::object::{ArrayObject, Object, TObject};
|
||||||
use crate::avm2::string::AvmString;
|
use crate::avm2::string::AvmString;
|
||||||
|
@ -548,8 +548,8 @@ pub fn create_class<'gc>(mc: MutationContext<'gc, '_>) -> GcCell<'gc, Class<'gc>
|
||||||
|
|
||||||
const PUBLIC_INSTANCE_PROPERTIES: &[(
|
const PUBLIC_INSTANCE_PROPERTIES: &[(
|
||||||
&'static str,
|
&'static str,
|
||||||
Option<GenericNativeMethod>,
|
Option<NativeMethod>,
|
||||||
Option<GenericNativeMethod>,
|
Option<NativeMethod>,
|
||||||
)] = &[
|
)] = &[
|
||||||
("currentFrame", Some(current_frame), None),
|
("currentFrame", Some(current_frame), None),
|
||||||
("currentFrameLabel", Some(current_frame_label), None),
|
("currentFrameLabel", Some(current_frame_label), None),
|
||||||
|
@ -563,7 +563,7 @@ pub fn create_class<'gc>(mc: MutationContext<'gc, '_>) -> GcCell<'gc, Class<'gc>
|
||||||
];
|
];
|
||||||
write.define_public_builtin_instance_properties(PUBLIC_INSTANCE_PROPERTIES);
|
write.define_public_builtin_instance_properties(PUBLIC_INSTANCE_PROPERTIES);
|
||||||
|
|
||||||
const PUBLIC_INSTANCE_METHODS: &[(&'static str, GenericNativeMethod)] = &[
|
const PUBLIC_INSTANCE_METHODS: &[(&'static str, NativeMethod)] = &[
|
||||||
("addFrameScript", add_frame_script),
|
("addFrameScript", add_frame_script),
|
||||||
("gotoAndPlay", goto_and_play),
|
("gotoAndPlay", goto_and_play),
|
||||||
("gotoAndStop", goto_and_stop),
|
("gotoAndStop", goto_and_stop),
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
use crate::avm2::activation::Activation;
|
use crate::avm2::activation::Activation;
|
||||||
use crate::avm2::class::Class;
|
use crate::avm2::class::Class;
|
||||||
use crate::avm2::method::{GenericNativeMethod, Method};
|
use crate::avm2::method::{Method, NativeMethod};
|
||||||
use crate::avm2::names::{Namespace, QName};
|
use crate::avm2::names::{Namespace, QName};
|
||||||
use crate::avm2::object::{Object, TObject};
|
use crate::avm2::object::{Object, TObject};
|
||||||
use crate::avm2::value::Value;
|
use crate::avm2::value::Value;
|
||||||
|
@ -127,8 +127,8 @@ pub fn create_class<'gc>(mc: MutationContext<'gc, '_>) -> GcCell<'gc, Class<'gc>
|
||||||
|
|
||||||
const PUBLIC_INSTANCE_PROPERTIES: &[(
|
const PUBLIC_INSTANCE_PROPERTIES: &[(
|
||||||
&'static str,
|
&'static str,
|
||||||
Option<GenericNativeMethod>,
|
Option<NativeMethod>,
|
||||||
Option<GenericNativeMethod>,
|
Option<NativeMethod>,
|
||||||
)] = &[
|
)] = &[
|
||||||
("labels", Some(labels), None),
|
("labels", Some(labels), None),
|
||||||
("name", Some(name), None),
|
("name", Some(name), None),
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
use crate::avm2::activation::Activation;
|
use crate::avm2::activation::Activation;
|
||||||
use crate::avm2::class::Class;
|
use crate::avm2::class::Class;
|
||||||
use crate::avm2::globals::NS_RUFFLE_INTERNAL;
|
use crate::avm2::globals::NS_RUFFLE_INTERNAL;
|
||||||
use crate::avm2::method::{GenericNativeMethod, Method};
|
use crate::avm2::method::{Method, NativeMethod};
|
||||||
use crate::avm2::names::{Namespace, QName};
|
use crate::avm2::names::{Namespace, QName};
|
||||||
use crate::avm2::object::{Object, StageObject, TObject};
|
use crate::avm2::object::{Object, StageObject, TObject};
|
||||||
use crate::avm2::traits::Trait;
|
use crate::avm2::traits::Trait;
|
||||||
|
@ -99,8 +99,8 @@ pub fn create_class<'gc>(mc: MutationContext<'gc, '_>) -> GcCell<'gc, Class<'gc>
|
||||||
|
|
||||||
const PUBLIC_INSTANCE_PROPERTIES: &[(
|
const PUBLIC_INSTANCE_PROPERTIES: &[(
|
||||||
&'static str,
|
&'static str,
|
||||||
Option<GenericNativeMethod>,
|
Option<NativeMethod>,
|
||||||
Option<GenericNativeMethod>,
|
Option<NativeMethod>,
|
||||||
)] = &[("graphics", Some(graphics), None)];
|
)] = &[("graphics", Some(graphics), None)];
|
||||||
write.define_public_builtin_instance_properties(PUBLIC_INSTANCE_PROPERTIES);
|
write.define_public_builtin_instance_properties(PUBLIC_INSTANCE_PROPERTIES);
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
use crate::avm2::activation::Activation;
|
use crate::avm2::activation::Activation;
|
||||||
use crate::avm2::class::{Class, ClassAttributes};
|
use crate::avm2::class::{Class, ClassAttributes};
|
||||||
use crate::avm2::globals::NS_RUFFLE_INTERNAL;
|
use crate::avm2::globals::NS_RUFFLE_INTERNAL;
|
||||||
use crate::avm2::method::{GenericNativeMethod, Method};
|
use crate::avm2::method::{Method, NativeMethod};
|
||||||
use crate::avm2::names::{Namespace, QName};
|
use crate::avm2::names::{Namespace, QName};
|
||||||
use crate::avm2::object::{Object, StageObject, TObject};
|
use crate::avm2::object::{Object, StageObject, TObject};
|
||||||
use crate::avm2::traits::Trait;
|
use crate::avm2::traits::Trait;
|
||||||
|
@ -93,8 +93,8 @@ pub fn create_class<'gc>(mc: MutationContext<'gc, '_>) -> GcCell<'gc, Class<'gc>
|
||||||
|
|
||||||
const PUBLIC_INSTANCE_PROPERTIES: &[(
|
const PUBLIC_INSTANCE_PROPERTIES: &[(
|
||||||
&'static str,
|
&'static str,
|
||||||
Option<GenericNativeMethod>,
|
Option<NativeMethod>,
|
||||||
Option<GenericNativeMethod>,
|
Option<NativeMethod>,
|
||||||
)] = &[("graphics", Some(graphics), None)];
|
)] = &[("graphics", Some(graphics), None)];
|
||||||
write.define_public_builtin_instance_properties(PUBLIC_INSTANCE_PROPERTIES);
|
write.define_public_builtin_instance_properties(PUBLIC_INSTANCE_PROPERTIES);
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
use crate::avm2::activation::Activation;
|
use crate::avm2::activation::Activation;
|
||||||
use crate::avm2::class::{Class, ClassAttributes};
|
use crate::avm2::class::{Class, ClassAttributes};
|
||||||
use crate::avm2::method::{GenericNativeMethod, Method};
|
use crate::avm2::method::{Method, NativeMethod};
|
||||||
use crate::avm2::names::{Namespace, QName};
|
use crate::avm2::names::{Namespace, QName};
|
||||||
use crate::avm2::object::{Object, TObject};
|
use crate::avm2::object::{Object, TObject};
|
||||||
use crate::avm2::string::AvmString;
|
use crate::avm2::string::AvmString;
|
||||||
|
@ -616,8 +616,8 @@ pub fn create_class<'gc>(mc: MutationContext<'gc, '_>) -> GcCell<'gc, Class<'gc>
|
||||||
|
|
||||||
const PUBLIC_OVERRIDE_INSTANCE_PROPERTIES: &[(
|
const PUBLIC_OVERRIDE_INSTANCE_PROPERTIES: &[(
|
||||||
&'static str,
|
&'static str,
|
||||||
Option<GenericNativeMethod>,
|
Option<NativeMethod>,
|
||||||
Option<GenericNativeMethod>,
|
Option<NativeMethod>,
|
||||||
)] = &[
|
)] = &[
|
||||||
(
|
(
|
||||||
"accessibilityProperties",
|
"accessibilityProperties",
|
||||||
|
@ -670,8 +670,8 @@ pub fn create_class<'gc>(mc: MutationContext<'gc, '_>) -> GcCell<'gc, Class<'gc>
|
||||||
|
|
||||||
const PUBLIC_INSTANCE_PROPERTIES: &[(
|
const PUBLIC_INSTANCE_PROPERTIES: &[(
|
||||||
&'static str,
|
&'static str,
|
||||||
Option<GenericNativeMethod>,
|
Option<NativeMethod>,
|
||||||
Option<GenericNativeMethod>,
|
Option<NativeMethod>,
|
||||||
)] = &[
|
)] = &[
|
||||||
("align", Some(align), Some(set_align)),
|
("align", Some(align), Some(set_align)),
|
||||||
("browserZoomFactor", Some(browser_zoom_factor), None),
|
("browserZoomFactor", Some(browser_zoom_factor), None),
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
use crate::avm2::activation::Activation;
|
use crate::avm2::activation::Activation;
|
||||||
use crate::avm2::class::{Class, ClassAttributes};
|
use crate::avm2::class::{Class, ClassAttributes};
|
||||||
use crate::avm2::method::{GenericNativeMethod, Method};
|
use crate::avm2::method::{Method, NativeMethod};
|
||||||
use crate::avm2::names::{Namespace, QName};
|
use crate::avm2::names::{Namespace, QName};
|
||||||
use crate::avm2::object::{EventObject, Object, TObject};
|
use crate::avm2::object::{EventObject, Object, TObject};
|
||||||
use crate::avm2::scope::Scope;
|
use crate::avm2::scope::Scope;
|
||||||
|
@ -275,8 +275,8 @@ pub fn create_class<'gc>(mc: MutationContext<'gc, '_>) -> GcCell<'gc, Class<'gc>
|
||||||
|
|
||||||
const PUBLIC_INSTANCE_PROPERTIES: &[(
|
const PUBLIC_INSTANCE_PROPERTIES: &[(
|
||||||
&'static str,
|
&'static str,
|
||||||
Option<GenericNativeMethod>,
|
Option<NativeMethod>,
|
||||||
Option<GenericNativeMethod>,
|
Option<NativeMethod>,
|
||||||
)] = &[
|
)] = &[
|
||||||
("bubbles", Some(bubbles), None),
|
("bubbles", Some(bubbles), None),
|
||||||
("cancelable", Some(cancelable), None),
|
("cancelable", Some(cancelable), None),
|
||||||
|
@ -287,7 +287,7 @@ pub fn create_class<'gc>(mc: MutationContext<'gc, '_>) -> GcCell<'gc, Class<'gc>
|
||||||
];
|
];
|
||||||
write.define_public_builtin_instance_properties(PUBLIC_INSTANCE_PROPERTIES);
|
write.define_public_builtin_instance_properties(PUBLIC_INSTANCE_PROPERTIES);
|
||||||
|
|
||||||
const PUBLIC_INSTANCE_METHODS: &[(&'static str, GenericNativeMethod)] = &[
|
const PUBLIC_INSTANCE_METHODS: &[(&'static str, NativeMethod)] = &[
|
||||||
("clone", clone),
|
("clone", clone),
|
||||||
("formatToString", format_to_string),
|
("formatToString", format_to_string),
|
||||||
("isDefaultPrevented", is_default_prevented),
|
("isDefaultPrevented", is_default_prevented),
|
||||||
|
|
|
@ -6,7 +6,7 @@ use crate::avm2::events::{
|
||||||
dispatch_event as dispatch_event_internal, parent_of, NS_EVENT_DISPATCHER,
|
dispatch_event as dispatch_event_internal, parent_of, NS_EVENT_DISPATCHER,
|
||||||
};
|
};
|
||||||
use crate::avm2::globals::NS_RUFFLE_INTERNAL;
|
use crate::avm2::globals::NS_RUFFLE_INTERNAL;
|
||||||
use crate::avm2::method::{GenericNativeMethod, Method};
|
use crate::avm2::method::{Method, NativeMethod};
|
||||||
use crate::avm2::names::{Namespace, QName};
|
use crate::avm2::names::{Namespace, QName};
|
||||||
use crate::avm2::object::{DispatchObject, Object, TObject};
|
use crate::avm2::object::{DispatchObject, Object, TObject};
|
||||||
use crate::avm2::traits::Trait;
|
use crate::avm2::traits::Trait;
|
||||||
|
@ -253,7 +253,7 @@ pub fn create_class<'gc>(mc: MutationContext<'gc, '_>) -> GcCell<'gc, Class<'gc>
|
||||||
|
|
||||||
write.implements(QName::new(Namespace::package("flash.events"), "IEventDispatcher").into());
|
write.implements(QName::new(Namespace::package("flash.events"), "IEventDispatcher").into());
|
||||||
|
|
||||||
const PUBLIC_INSTANCE_METHODS: &[(&'static str, GenericNativeMethod)] = &[
|
const PUBLIC_INSTANCE_METHODS: &[(&'static str, NativeMethod)] = &[
|
||||||
("addEventListener", add_event_listener),
|
("addEventListener", add_event_listener),
|
||||||
("removeEventListener", remove_event_listener),
|
("removeEventListener", remove_event_listener),
|
||||||
("hasEventListener", has_event_listener),
|
("hasEventListener", has_event_listener),
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
use crate::avm2::activation::Activation;
|
use crate::avm2::activation::Activation;
|
||||||
use crate::avm2::class::{Class, ClassAttributes};
|
use crate::avm2::class::{Class, ClassAttributes};
|
||||||
use crate::avm2::method::{GenericNativeMethod, Method};
|
use crate::avm2::method::{Method, NativeMethod};
|
||||||
use crate::avm2::names::{Namespace, QName};
|
use crate::avm2::names::{Namespace, QName};
|
||||||
use crate::avm2::object::Object;
|
use crate::avm2::object::Object;
|
||||||
use crate::avm2::value::Value;
|
use crate::avm2::value::Value;
|
||||||
|
@ -41,7 +41,7 @@ pub fn create_interface<'gc>(mc: MutationContext<'gc, '_>) -> GcCell<'gc, Class<
|
||||||
|
|
||||||
write.set_attributes(ClassAttributes::INTERFACE);
|
write.set_attributes(ClassAttributes::INTERFACE);
|
||||||
|
|
||||||
const PUBLIC_INSTANCE_METHODS: &[(&'static str, GenericNativeMethod)] = &[
|
const PUBLIC_INSTANCE_METHODS: &[(&'static str, NativeMethod)] = &[
|
||||||
("addEventListener", bodiless_method),
|
("addEventListener", bodiless_method),
|
||||||
("dispatchEvent", bodiless_method),
|
("dispatchEvent", bodiless_method),
|
||||||
("hasEventListener", bodiless_method),
|
("hasEventListener", bodiless_method),
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
use crate::avm1::AvmString;
|
use crate::avm1::AvmString;
|
||||||
use crate::avm2::class::{Class, ClassAttributes};
|
use crate::avm2::class::{Class, ClassAttributes};
|
||||||
use crate::avm2::method::{GenericNativeMethod, Method};
|
use crate::avm2::method::{Method, NativeMethod};
|
||||||
use crate::avm2::{Activation, Error, Namespace, Object, QName, TObject, Value};
|
use crate::avm2::{Activation, Error, Namespace, Object, QName, TObject, Value};
|
||||||
use gc_arena::{GcCell, MutationContext};
|
use gc_arena::{GcCell, MutationContext};
|
||||||
|
|
||||||
|
@ -343,19 +343,19 @@ pub fn create_class<'gc>(mc: MutationContext<'gc, '_>) -> GcCell<'gc, Class<'gc>
|
||||||
|
|
||||||
const PUBLIC_INSTANCE_PROPERTIES: &[(
|
const PUBLIC_INSTANCE_PROPERTIES: &[(
|
||||||
&'static str,
|
&'static str,
|
||||||
Option<GenericNativeMethod>,
|
Option<NativeMethod>,
|
||||||
Option<GenericNativeMethod>,
|
Option<NativeMethod>,
|
||||||
)] = &[("length", Some(length), None)];
|
)] = &[("length", Some(length), None)];
|
||||||
write.define_public_builtin_instance_properties(PUBLIC_INSTANCE_PROPERTIES);
|
write.define_public_builtin_instance_properties(PUBLIC_INSTANCE_PROPERTIES);
|
||||||
|
|
||||||
const PUBLIC_CLASS_METHODS: &[(&'static str, GenericNativeMethod)] = &[
|
const PUBLIC_CLASS_METHODS: &[(&'static str, NativeMethod)] = &[
|
||||||
("distance", distance),
|
("distance", distance),
|
||||||
("interpolate", interpolate),
|
("interpolate", interpolate),
|
||||||
("polar", polar),
|
("polar", polar),
|
||||||
];
|
];
|
||||||
write.define_public_builtin_class_methods(PUBLIC_CLASS_METHODS);
|
write.define_public_builtin_class_methods(PUBLIC_CLASS_METHODS);
|
||||||
|
|
||||||
const PUBLIC_INSTANCE_METHODS: &[(&'static str, GenericNativeMethod)] = &[
|
const PUBLIC_INSTANCE_METHODS: &[(&'static str, NativeMethod)] = &[
|
||||||
("add", add),
|
("add", add),
|
||||||
("clone", clone),
|
("clone", clone),
|
||||||
("copyFrom", copy_from),
|
("copyFrom", copy_from),
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
use crate::avm2::activation::Activation;
|
use crate::avm2::activation::Activation;
|
||||||
use crate::avm2::class::Class;
|
use crate::avm2::class::Class;
|
||||||
use crate::avm2::method::{GenericNativeMethod, Method};
|
use crate::avm2::method::{Method, NativeMethod};
|
||||||
use crate::avm2::names::{Namespace, QName};
|
use crate::avm2::names::{Namespace, QName};
|
||||||
use crate::avm2::object::{DomainObject, Object, TObject};
|
use crate::avm2::object::{DomainObject, Object, TObject};
|
||||||
use crate::avm2::value::Value;
|
use crate::avm2::value::Value;
|
||||||
|
@ -160,7 +160,7 @@ pub fn create_class<'gc>(mc: MutationContext<'gc, '_>) -> GcCell<'gc, Class<'gc>
|
||||||
|
|
||||||
let mut write = class.write(mc);
|
let mut write = class.write(mc);
|
||||||
|
|
||||||
const PUBLIC_CLASS_METHODS: &[(&'static str, GenericNativeMethod)] = &[
|
const PUBLIC_CLASS_METHODS: &[(&'static str, NativeMethod)] = &[
|
||||||
("currentDomain", current_domain),
|
("currentDomain", current_domain),
|
||||||
("parentDomain", parent_domain),
|
("parentDomain", parent_domain),
|
||||||
("getDefinition", get_definition),
|
("getDefinition", get_definition),
|
||||||
|
@ -170,8 +170,8 @@ pub fn create_class<'gc>(mc: MutationContext<'gc, '_>) -> GcCell<'gc, Class<'gc>
|
||||||
|
|
||||||
const PUBLIC_INSTANCE_PROPERTIES: &[(
|
const PUBLIC_INSTANCE_PROPERTIES: &[(
|
||||||
&'static str,
|
&'static str,
|
||||||
Option<GenericNativeMethod>,
|
Option<NativeMethod>,
|
||||||
Option<GenericNativeMethod>,
|
Option<NativeMethod>,
|
||||||
)] = &[("domainMemory", Some(domain_memory), Some(set_domain_memory))];
|
)] = &[("domainMemory", Some(domain_memory), Some(set_domain_memory))];
|
||||||
write.define_public_builtin_instance_properties(PUBLIC_INSTANCE_PROPERTIES);
|
write.define_public_builtin_instance_properties(PUBLIC_INSTANCE_PROPERTIES);
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
use crate::avm2::activation::Activation;
|
use crate::avm2::activation::Activation;
|
||||||
use crate::avm2::class::Class;
|
use crate::avm2::class::Class;
|
||||||
use crate::avm2::method::{GenericNativeMethod, Method};
|
use crate::avm2::method::{Method, NativeMethod};
|
||||||
use crate::avm2::names::{Namespace, QName};
|
use crate::avm2::names::{Namespace, QName};
|
||||||
use crate::avm2::object::Object;
|
use crate::avm2::object::Object;
|
||||||
use crate::avm2::value::Value;
|
use crate::avm2::value::Value;
|
||||||
|
@ -52,7 +52,7 @@ pub fn create_class<'gc>(mc: MutationContext<'gc, '_>) -> GcCell<'gc, Class<'gc>
|
||||||
|
|
||||||
let mut write = class.write(mc);
|
let mut write = class.write(mc);
|
||||||
|
|
||||||
const PUBLIC_CLASS_METHODS: &[(&'static str, GenericNativeMethod)] = &[("gc", gc)];
|
const PUBLIC_CLASS_METHODS: &[(&'static str, NativeMethod)] = &[("gc", gc)];
|
||||||
write.define_public_builtin_class_methods(PUBLIC_CLASS_METHODS);
|
write.define_public_builtin_class_methods(PUBLIC_CLASS_METHODS);
|
||||||
|
|
||||||
class
|
class
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
use crate::avm2::activation::Activation;
|
use crate::avm2::activation::Activation;
|
||||||
use crate::avm2::class::{Class, ClassAttributes};
|
use crate::avm2::class::{Class, ClassAttributes};
|
||||||
use crate::avm2::method::{GenericNativeMethod, Method};
|
use crate::avm2::method::{Method, NativeMethod};
|
||||||
use crate::avm2::names::{Namespace, QName};
|
use crate::avm2::names::{Namespace, QName};
|
||||||
use crate::avm2::object::{Object, TObject};
|
use crate::avm2::object::{Object, TObject};
|
||||||
use crate::avm2::string::AvmString;
|
use crate::avm2::string::AvmString;
|
||||||
|
@ -867,8 +867,8 @@ pub fn create_class<'gc>(mc: MutationContext<'gc, '_>) -> GcCell<'gc, Class<'gc>
|
||||||
|
|
||||||
const PUBLIC_INSTANCE_PROPERTIES: &[(
|
const PUBLIC_INSTANCE_PROPERTIES: &[(
|
||||||
&'static str,
|
&'static str,
|
||||||
Option<GenericNativeMethod>,
|
Option<NativeMethod>,
|
||||||
Option<GenericNativeMethod>,
|
Option<NativeMethod>,
|
||||||
)] = &[
|
)] = &[
|
||||||
("autoSize", Some(autosize), Some(set_autosize)),
|
("autoSize", Some(autosize), Some(set_autosize)),
|
||||||
(
|
(
|
||||||
|
@ -902,7 +902,7 @@ pub fn create_class<'gc>(mc: MutationContext<'gc, '_>) -> GcCell<'gc, Class<'gc>
|
||||||
];
|
];
|
||||||
write.define_public_builtin_instance_properties(PUBLIC_INSTANCE_PROPERTIES);
|
write.define_public_builtin_instance_properties(PUBLIC_INSTANCE_PROPERTIES);
|
||||||
|
|
||||||
const PUBLIC_INSTANCE_METHODS: &[(&'static str, GenericNativeMethod)] = &[
|
const PUBLIC_INSTANCE_METHODS: &[(&'static str, NativeMethod)] = &[
|
||||||
("appendText", append_text),
|
("appendText", append_text),
|
||||||
("getTextFormat", get_text_format),
|
("getTextFormat", get_text_format),
|
||||||
("replaceSelectedText", replace_selected_text),
|
("replaceSelectedText", replace_selected_text),
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use crate::avm2::activation::Activation;
|
use crate::avm2::activation::Activation;
|
||||||
use crate::avm2::bytearray::Endian;
|
use crate::avm2::bytearray::Endian;
|
||||||
use crate::avm2::class::{Class, ClassAttributes};
|
use crate::avm2::class::{Class, ClassAttributes};
|
||||||
use crate::avm2::method::{GenericNativeMethod, Method};
|
use crate::avm2::method::{Method, NativeMethod};
|
||||||
use crate::avm2::names::{Namespace, QName};
|
use crate::avm2::names::{Namespace, QName};
|
||||||
use crate::avm2::object::{Object, TObject};
|
use crate::avm2::object::{Object, TObject};
|
||||||
use crate::avm2::string::AvmString;
|
use crate::avm2::string::AvmString;
|
||||||
|
@ -743,7 +743,7 @@ pub fn create_class<'gc>(mc: MutationContext<'gc, '_>) -> GcCell<'gc, Class<'gc>
|
||||||
|
|
||||||
write.set_attributes(ClassAttributes::SEALED);
|
write.set_attributes(ClassAttributes::SEALED);
|
||||||
|
|
||||||
const PUBLIC_INSTANCE_METHODS: &[(&'static str, GenericNativeMethod)] = &[
|
const PUBLIC_INSTANCE_METHODS: &[(&'static str, NativeMethod)] = &[
|
||||||
("writeByte", write_byte),
|
("writeByte", write_byte),
|
||||||
("writeBytes", write_bytes),
|
("writeBytes", write_bytes),
|
||||||
("readBytes", read_bytes),
|
("readBytes", read_bytes),
|
||||||
|
@ -779,8 +779,8 @@ pub fn create_class<'gc>(mc: MutationContext<'gc, '_>) -> GcCell<'gc, Class<'gc>
|
||||||
|
|
||||||
const PUBLIC_INSTANCE_PROPERTIES: &[(
|
const PUBLIC_INSTANCE_PROPERTIES: &[(
|
||||||
&'static str,
|
&'static str,
|
||||||
Option<GenericNativeMethod>,
|
Option<NativeMethod>,
|
||||||
Option<GenericNativeMethod>,
|
Option<NativeMethod>,
|
||||||
)] = &[
|
)] = &[
|
||||||
("bytesAvailable", Some(bytes_available), None),
|
("bytesAvailable", Some(bytes_available), None),
|
||||||
("length", Some(length), Some(set_length)),
|
("length", Some(length), Some(set_length)),
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
use crate::avm2::activation::Activation;
|
use crate::avm2::activation::Activation;
|
||||||
use crate::avm2::class::{Class, ClassAttributes};
|
use crate::avm2::class::{Class, ClassAttributes};
|
||||||
use crate::avm2::method::{GenericNativeMethod, Method};
|
use crate::avm2::method::{Method, NativeMethod};
|
||||||
use crate::avm2::names::{Namespace, QName};
|
use crate::avm2::names::{Namespace, QName};
|
||||||
use crate::avm2::object::Object;
|
use crate::avm2::object::Object;
|
||||||
use crate::avm2::value::Value;
|
use crate::avm2::value::Value;
|
||||||
|
@ -67,7 +67,7 @@ pub fn create_class<'gc>(mc: MutationContext<'gc, '_>) -> GcCell<'gc, Class<'gc>
|
||||||
];
|
];
|
||||||
write.define_public_constant_number_class_traits(CONSTANTS);
|
write.define_public_constant_number_class_traits(CONSTANTS);
|
||||||
|
|
||||||
const PUBLIC_CLASS_METHODS: &[(&'static str, GenericNativeMethod)] = &[
|
const PUBLIC_CLASS_METHODS: &[(&'static str, NativeMethod)] = &[
|
||||||
("atan2", atan2),
|
("atan2", atan2),
|
||||||
("max", max),
|
("max", max),
|
||||||
("min", min),
|
("min", min),
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
//! `RegExp` impl
|
//! `RegExp` impl
|
||||||
|
|
||||||
use crate::avm2::class::Class;
|
use crate::avm2::class::Class;
|
||||||
use crate::avm2::method::{GenericNativeMethod, Method};
|
use crate::avm2::method::{Method, NativeMethod};
|
||||||
use crate::avm2::names::{Namespace, QName};
|
use crate::avm2::names::{Namespace, QName};
|
||||||
use crate::avm2::object::{ArrayObject, Object, RegExpObject, TObject};
|
use crate::avm2::object::{ArrayObject, Object, RegExpObject, TObject};
|
||||||
use crate::avm2::scope::Scope;
|
use crate::avm2::scope::Scope;
|
||||||
|
@ -276,8 +276,8 @@ pub fn create_class<'gc>(mc: MutationContext<'gc, '_>) -> GcCell<'gc, Class<'gc>
|
||||||
|
|
||||||
const PUBLIC_INSTANCE_PROPERTIES: &[(
|
const PUBLIC_INSTANCE_PROPERTIES: &[(
|
||||||
&'static str,
|
&'static str,
|
||||||
Option<GenericNativeMethod>,
|
Option<NativeMethod>,
|
||||||
Option<GenericNativeMethod>,
|
Option<NativeMethod>,
|
||||||
)] = &[
|
)] = &[
|
||||||
("dotall", Some(dotall), None),
|
("dotall", Some(dotall), None),
|
||||||
("extended", Some(extended), None),
|
("extended", Some(extended), None),
|
||||||
|
@ -289,8 +289,7 @@ pub fn create_class<'gc>(mc: MutationContext<'gc, '_>) -> GcCell<'gc, Class<'gc>
|
||||||
];
|
];
|
||||||
write.define_public_builtin_instance_properties(PUBLIC_INSTANCE_PROPERTIES);
|
write.define_public_builtin_instance_properties(PUBLIC_INSTANCE_PROPERTIES);
|
||||||
|
|
||||||
const AS3_INSTANCE_METHODS: &[(&'static str, GenericNativeMethod)] =
|
const AS3_INSTANCE_METHODS: &[(&'static str, NativeMethod)] = &[("exec", exec), ("test", test)];
|
||||||
&[("exec", exec), ("test", test)];
|
|
||||||
write.define_as3_builtin_instance_methods(AS3_INSTANCE_METHODS);
|
write.define_as3_builtin_instance_methods(AS3_INSTANCE_METHODS);
|
||||||
|
|
||||||
class
|
class
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
use crate::avm2::activation::Activation;
|
use crate::avm2::activation::Activation;
|
||||||
use crate::avm2::class::{Class, ClassAttributes};
|
use crate::avm2::class::{Class, ClassAttributes};
|
||||||
use crate::avm2::method::{GenericNativeMethod, Method};
|
use crate::avm2::method::{Method, NativeMethod};
|
||||||
use crate::avm2::names::{Namespace, QName};
|
use crate::avm2::names::{Namespace, QName};
|
||||||
use crate::avm2::object::{Object, TObject};
|
use crate::avm2::object::{Object, TObject};
|
||||||
use crate::avm2::string::AvmString;
|
use crate::avm2::string::AvmString;
|
||||||
|
@ -131,12 +131,12 @@ pub fn create_class<'gc>(mc: MutationContext<'gc, '_>) -> GcCell<'gc, Class<'gc>
|
||||||
|
|
||||||
const PUBLIC_INSTANCE_PROPERTIES: &[(
|
const PUBLIC_INSTANCE_PROPERTIES: &[(
|
||||||
&'static str,
|
&'static str,
|
||||||
Option<GenericNativeMethod>,
|
Option<NativeMethod>,
|
||||||
Option<GenericNativeMethod>,
|
Option<NativeMethod>,
|
||||||
)] = &[("length", Some(length), None)];
|
)] = &[("length", Some(length), None)];
|
||||||
write.define_public_builtin_instance_properties(PUBLIC_INSTANCE_PROPERTIES);
|
write.define_public_builtin_instance_properties(PUBLIC_INSTANCE_PROPERTIES);
|
||||||
|
|
||||||
const AS3_INSTANCE_METHODS: &[(&'static str, GenericNativeMethod)] =
|
const AS3_INSTANCE_METHODS: &[(&'static str, NativeMethod)] =
|
||||||
&[("charAt", char_at), ("charCodeAt", char_code_at)];
|
&[("charAt", char_at), ("charCodeAt", char_code_at)];
|
||||||
write.define_as3_builtin_instance_methods(AS3_INSTANCE_METHODS);
|
write.define_as3_builtin_instance_methods(AS3_INSTANCE_METHODS);
|
||||||
|
|
||||||
|
|
|
@ -25,13 +25,8 @@ use swf::avm2::types::{AbcFile, Index, Method as AbcMethod, MethodBody as AbcMet
|
||||||
/// resolve on the AVM stack, as if you had called a non-native function. If
|
/// resolve on the AVM stack, as if you had called a non-native function. If
|
||||||
/// your function yields `None`, you must ensure that the top-most activation
|
/// your function yields `None`, you must ensure that the top-most activation
|
||||||
/// in the AVM1 runtime will return with the value of this function.
|
/// in the AVM1 runtime will return with the value of this function.
|
||||||
pub type NativeMethod<'gc> = fn(
|
|
||||||
&mut Activation<'_, 'gc, '_>,
|
|
||||||
Option<Object<'gc>>,
|
|
||||||
&[Value<'gc>],
|
|
||||||
) -> Result<Value<'gc>, Error>;
|
|
||||||
|
|
||||||
pub type GenericNativeMethod = for<'gc> fn(
|
pub type NativeMethod = for<'gc> fn(
|
||||||
&mut Activation<'_, 'gc, '_>,
|
&mut Activation<'_, 'gc, '_>,
|
||||||
Option<Object<'gc>>,
|
Option<Object<'gc>>,
|
||||||
&[Value<'gc>],
|
&[Value<'gc>],
|
||||||
|
@ -125,7 +120,7 @@ impl<'gc> BytecodeMethod<'gc> {
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub enum Method<'gc> {
|
pub enum Method<'gc> {
|
||||||
/// A native method.
|
/// A native method.
|
||||||
Native(NativeMethod<'gc>),
|
Native(NativeMethod),
|
||||||
|
|
||||||
/// An ABC-provided method entry.
|
/// An ABC-provided method entry.
|
||||||
Entry(Gc<'gc, BytecodeMethod<'gc>>),
|
Entry(Gc<'gc, BytecodeMethod<'gc>>),
|
||||||
|
@ -152,8 +147,8 @@ impl<'gc> fmt::Debug for Method<'gc> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'gc> From<NativeMethod<'gc>> for Method<'gc> {
|
impl<'gc> From<NativeMethod> for Method<'gc> {
|
||||||
fn from(nf: NativeMethod<'gc>) -> Self {
|
fn from(nf: NativeMethod) -> Self {
|
||||||
Self::Native(nf)
|
Self::Native(nf)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -167,7 +162,7 @@ impl<'gc> From<Gc<'gc, BytecodeMethod<'gc>>> for Method<'gc> {
|
||||||
impl<'gc> Method<'gc> {
|
impl<'gc> Method<'gc> {
|
||||||
/// Builtin method constructor, because for some reason `nf.into()` just
|
/// Builtin method constructor, because for some reason `nf.into()` just
|
||||||
/// causes odd lifetime mismatches.
|
/// causes odd lifetime mismatches.
|
||||||
pub fn from_builtin(nf: NativeMethod<'gc>) -> Self {
|
pub fn from_builtin(nf: NativeMethod) -> Self {
|
||||||
Self::Native(nf)
|
Self::Native(nf)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -227,7 +227,7 @@ impl<'gc> FunctionObject<'gc> {
|
||||||
/// Construct a builtin function object from a Rust function.
|
/// Construct a builtin function object from a Rust function.
|
||||||
pub fn from_builtin(
|
pub fn from_builtin(
|
||||||
mc: MutationContext<'gc, '_>,
|
mc: MutationContext<'gc, '_>,
|
||||||
nf: NativeMethod<'gc>,
|
nf: NativeMethod,
|
||||||
fn_proto: Object<'gc>,
|
fn_proto: Object<'gc>,
|
||||||
) -> Object<'gc> {
|
) -> Object<'gc> {
|
||||||
FunctionObject(GcCell::allocate(
|
FunctionObject(GcCell::allocate(
|
||||||
|
@ -243,7 +243,7 @@ impl<'gc> FunctionObject<'gc> {
|
||||||
/// Construct a builtin type from a Rust constructor and prototype.
|
/// Construct a builtin type from a Rust constructor and prototype.
|
||||||
pub fn from_builtin_constr(
|
pub fn from_builtin_constr(
|
||||||
mc: MutationContext<'gc, '_>,
|
mc: MutationContext<'gc, '_>,
|
||||||
constr: NativeMethod<'gc>,
|
constr: NativeMethod,
|
||||||
mut prototype: Object<'gc>,
|
mut prototype: Object<'gc>,
|
||||||
fn_proto: Object<'gc>,
|
fn_proto: Object<'gc>,
|
||||||
) -> Result<Object<'gc>, Error> {
|
) -> Result<Object<'gc>, Error> {
|
||||||
|
|
Loading…
Reference in New Issue