diff --git a/core/src/avm2/class.rs b/core/src/avm2/class.rs index 8024503cc..2b885c552 100644 --- a/core/src/avm2/class.rs +++ b/core/src/avm2/class.rs @@ -34,19 +34,19 @@ bitflags! { /// A function that can be used to allocate instances of a class. /// -/// By default, the `implicit_deriver` is used, which attempts to use the base -/// class's deriver, and defaults to `ScriptObject` otherwise. Custom derivers -/// anywhere in the class inheritance chain can change the representation of -/// all subtypes that use the implicit deriver. +/// By default, the `implicit_allocator` is used, which attempts to use the base +/// class's allocator, and defaults to `ScriptObject` otherwise. Custom +/// allocators anywhere in the class inheritance chain can change the +/// representation of all subclasses that use the implicit allocator. /// -/// Parameters for the deriver are: +/// Parameters for the allocator are: /// /// * `class` - The class object that is being allocated. This must be the /// current class (using a superclass will cause the wrong class to be /// read for traits). /// * `proto` - The prototype attached to the class object. /// * `activation` - The current AVM2 activation. -pub type DeriverFn = for<'gc> fn( +pub type AllocatorFn = for<'gc> fn( Object<'gc>, Object<'gc>, &mut Activation<'_, 'gc, '_>, @@ -54,34 +54,34 @@ pub type DeriverFn = for<'gc> fn( #[derive(Clone, Collect)] #[collect(require_static)] -pub struct Deriver(pub DeriverFn); +pub struct Allocator(pub AllocatorFn); -impl fmt::Debug for Deriver { +impl fmt::Debug for Allocator { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.debug_tuple("Deriver") + f.debug_tuple("Allocator") .field(&"".to_string()) .finish() } } -/// The implicit deriver for new classes. +/// The implicit allocator for new classes. /// -/// This attempts to use the parent type's deriver, and if such a deriver does -/// not exist, we default to `ScriptObject`. -pub fn implicit_deriver<'gc>( +/// This attempts to use the parent type's allocator, and if such an allocator +/// does not exist, we default to allocating a `ScriptObject`. +pub fn implicit_allocator<'gc>( mut class_object: Object<'gc>, proto: Object<'gc>, activation: &mut Activation<'_, 'gc, '_>, ) -> Result, Error> { let mut base_class_object = Some(class_object); let mut base_class = class_object.as_class(); - let mut instance_deriver = None; + let mut instance_allocator = None; while let (Some(b_class_object), Some(b_class)) = (base_class_object, base_class) { - let base_deriver = b_class.read().instance_deriver(); + let base_allocator = b_class.read().instance_allocator(); - if base_deriver as usize != implicit_deriver as usize { - instance_deriver = Some(base_deriver); + if base_allocator as usize != implicit_allocator as usize { + instance_allocator = Some(base_allocator); break; } @@ -89,8 +89,8 @@ pub fn implicit_deriver<'gc>( base_class = base_class_object.and_then(|c| c.as_class()); } - if let Some(base_deriver) = instance_deriver { - base_deriver(class_object, proto, activation) + if let Some(base_allocator) = instance_allocator { + base_allocator(class_object, proto, activation) } else { let base_proto = class_object .get_property( @@ -128,8 +128,8 @@ pub struct Class<'gc> { /// The list of interfaces this class implements. interfaces: Vec>, - /// The instance deriver for this class. - instance_deriver: Deriver, + /// The instance allocator for this class. + instance_allocator: Allocator, /// The instance initializer for this class. /// @@ -258,7 +258,7 @@ impl<'gc> Class<'gc> { attributes: ClassAttributes::empty(), protected_namespace: None, interfaces: Vec::new(), - instance_deriver: Deriver(implicit_deriver), + instance_allocator: Allocator(implicit_allocator), instance_init, native_instance_init, instance_traits: Vec::new(), @@ -354,7 +354,7 @@ impl<'gc> Class<'gc> { attributes, protected_namespace, interfaces, - instance_deriver: Deriver(implicit_deriver), + instance_allocator: Allocator(implicit_allocator), instance_init, native_instance_init, instance_traits: Vec::new(), @@ -436,7 +436,7 @@ impl<'gc> Class<'gc> { attributes: ClassAttributes::empty(), protected_namespace: None, interfaces: Vec::new(), - instance_deriver: Deriver(implicit_deriver), + instance_allocator: Allocator(implicit_allocator), instance_init: Method::from_builtin( |_, _, _| Ok(Value::Undefined), "", @@ -708,14 +708,14 @@ impl<'gc> Class<'gc> { None } - /// Get this class's instance deriver. - pub fn instance_deriver(&self) -> DeriverFn { - self.instance_deriver.0 + /// Get this class's instance allocator. + pub fn instance_allocator(&self) -> AllocatorFn { + self.instance_allocator.0 } - /// Set this class's instance deriver. - pub fn set_instance_deriver(&mut self, deriver: DeriverFn) { - self.instance_deriver.0 = deriver; + /// Set this class's instance allocator. + pub fn set_instance_allocator(&mut self, alloc: AllocatorFn) { + self.instance_allocator.0 = alloc; } /// Get this class's instance initializer. diff --git a/core/src/avm2/globals/array.rs b/core/src/avm2/globals/array.rs index 7d5243d47..77730277b 100644 --- a/core/src/avm2/globals/array.rs +++ b/core/src/avm2/globals/array.rs @@ -5,7 +5,7 @@ use crate::avm2::array::ArrayStorage; use crate::avm2::class::Class; use crate::avm2::method::{Method, NativeMethodImpl}; use crate::avm2::names::{Namespace, QName}; -use crate::avm2::object::{array_deriver, ArrayObject, Object, TObject}; +use crate::avm2::object::{array_allocator, ArrayObject, Object, TObject}; use crate::avm2::string::AvmString; use crate::avm2::value::Value; use crate::avm2::Error; @@ -1215,7 +1215,7 @@ pub fn create_class<'gc>(mc: MutationContext<'gc, '_>) -> GcCell<'gc, Class<'gc> let mut write = class.write(mc); - write.set_instance_deriver(array_deriver); + write.set_instance_allocator(array_allocator); const PUBLIC_INSTANCE_METHODS: &[(&str, NativeMethodImpl)] = &[ ("toString", to_string), diff --git a/core/src/avm2/globals/boolean.rs b/core/src/avm2/globals/boolean.rs index ebfc30116..9c1217813 100644 --- a/core/src/avm2/globals/boolean.rs +++ b/core/src/avm2/globals/boolean.rs @@ -4,7 +4,7 @@ use crate::avm2::activation::Activation; use crate::avm2::class::Class; use crate::avm2::method::Method; use crate::avm2::names::{Namespace, QName}; -use crate::avm2::object::{primitive_deriver, Object}; +use crate::avm2::object::{primitive_allocator, Object}; use crate::avm2::value::Value; use crate::avm2::Error; use gc_arena::{GcCell, MutationContext}; @@ -51,7 +51,7 @@ pub fn create_class<'gc>(mc: MutationContext<'gc, '_>) -> GcCell<'gc, Class<'gc> ); let mut write = class.write(mc); - write.set_instance_deriver(primitive_deriver); + write.set_instance_allocator(primitive_allocator); write.set_native_instance_init(Method::from_builtin( native_instance_init, "", diff --git a/core/src/avm2/globals/flash/display/displayobject.rs b/core/src/avm2/globals/flash/display/displayobject.rs index c294e1d1e..d6fb55e5c 100644 --- a/core/src/avm2/globals/flash/display/displayobject.rs +++ b/core/src/avm2/globals/flash/display/displayobject.rs @@ -4,7 +4,7 @@ use crate::avm2::activation::Activation; use crate::avm2::class::Class; use crate::avm2::method::{Method, NativeMethodImpl}; use crate::avm2::names::{Namespace, QName}; -use crate::avm2::object::{stage_deriver, LoaderInfoObject, Object, TObject}; +use crate::avm2::object::{stage_allocator, LoaderInfoObject, Object, TObject}; use crate::avm2::string::AvmString; use crate::avm2::value::Value; use crate::avm2::Error; @@ -597,7 +597,7 @@ pub fn create_class<'gc>(mc: MutationContext<'gc, '_>) -> GcCell<'gc, Class<'gc> let mut write = class.write(mc); - write.set_instance_deriver(stage_deriver); + write.set_instance_allocator(stage_allocator); write.set_native_instance_init(Method::from_builtin( native_instance_init, "", diff --git a/core/src/avm2/globals/flash/display/graphics.rs b/core/src/avm2/globals/flash/display/graphics.rs index 491a19306..c86e7e60b 100644 --- a/core/src/avm2/globals/flash/display/graphics.rs +++ b/core/src/avm2/globals/flash/display/graphics.rs @@ -4,7 +4,7 @@ use crate::avm2::activation::Activation; use crate::avm2::class::{Class, ClassAttributes}; use crate::avm2::method::{Method, NativeMethodImpl}; use crate::avm2::names::{Namespace, QName}; -use crate::avm2::object::{stage_deriver, Object, TObject}; +use crate::avm2::object::{stage_allocator, Object, TObject}; use crate::avm2::value::Value; use crate::avm2::Error; use crate::display_object::TDisplayObject; @@ -377,7 +377,7 @@ pub fn create_class<'gc>(mc: MutationContext<'gc, '_>) -> GcCell<'gc, Class<'gc> let mut write = class.write(mc); write.set_attributes(ClassAttributes::SEALED); - write.set_instance_deriver(stage_deriver); + write.set_instance_allocator(stage_allocator); write.set_native_instance_init(Method::from_builtin( native_instance_init, "", diff --git a/core/src/avm2/globals/flash/display/loaderinfo.rs b/core/src/avm2/globals/flash/display/loaderinfo.rs index fe8dd0dea..107e9d22b 100644 --- a/core/src/avm2/globals/flash/display/loaderinfo.rs +++ b/core/src/avm2/globals/flash/display/loaderinfo.rs @@ -5,7 +5,7 @@ use crate::avm2::bytearray::Endian; use crate::avm2::class::{Class, ClassAttributes}; use crate::avm2::method::{Method, NativeMethodImpl}; use crate::avm2::names::{Namespace, QName}; -use crate::avm2::object::{loaderinfo_deriver, DomainObject, LoaderStream, Object, TObject}; +use crate::avm2::object::{loaderinfo_allocator, DomainObject, LoaderStream, Object, TObject}; use crate::avm2::value::Value; use crate::avm2::{AvmString, Error}; use crate::display_object::TDisplayObject; @@ -416,7 +416,7 @@ pub fn create_class<'gc>(mc: MutationContext<'gc, '_>) -> GcCell<'gc, Class<'gc> let mut write = class.write(mc); write.set_attributes(ClassAttributes::SEALED); - write.set_instance_deriver(loaderinfo_deriver); + write.set_instance_allocator(loaderinfo_allocator); write.set_native_instance_init(Method::from_builtin( native_instance_init, "", diff --git a/core/src/avm2/globals/flash/events/event.rs b/core/src/avm2/globals/flash/events/event.rs index 73a82987b..fc9be65d7 100644 --- a/core/src/avm2/globals/flash/events/event.rs +++ b/core/src/avm2/globals/flash/events/event.rs @@ -4,7 +4,7 @@ use crate::avm2::activation::Activation; use crate::avm2::class::{Class, ClassAttributes}; use crate::avm2::method::{Method, NativeMethodImpl}; use crate::avm2::names::{Namespace, QName}; -use crate::avm2::object::{event_deriver, EventObject, Object, TObject}; +use crate::avm2::object::{event_allocator, EventObject, Object, TObject}; use crate::avm2::string::AvmString; use crate::avm2::value::Value; use crate::avm2::Error; @@ -274,7 +274,7 @@ pub fn create_class<'gc>(mc: MutationContext<'gc, '_>) -> GcCell<'gc, Class<'gc> let mut write = class.write(mc); write.set_attributes(ClassAttributes::SEALED); - write.set_instance_deriver(event_deriver); + write.set_instance_allocator(event_allocator); const PUBLIC_INSTANCE_PROPERTIES: &[( &str, diff --git a/core/src/avm2/globals/flash/system/application_domain.rs b/core/src/avm2/globals/flash/system/application_domain.rs index 11b0de6a8..6e69c9532 100644 --- a/core/src/avm2/globals/flash/system/application_domain.rs +++ b/core/src/avm2/globals/flash/system/application_domain.rs @@ -4,7 +4,7 @@ use crate::avm2::activation::Activation; use crate::avm2::class::Class; use crate::avm2::method::{Method, NativeMethodImpl}; use crate::avm2::names::{Namespace, QName}; -use crate::avm2::object::{appdomain_deriver, DomainObject, Object, TObject}; +use crate::avm2::object::{appdomain_allocator, DomainObject, Object, TObject}; use crate::avm2::value::Value; use crate::avm2::Error; use gc_arena::{GcCell, MutationContext}; @@ -154,7 +154,7 @@ pub fn create_class<'gc>(mc: MutationContext<'gc, '_>) -> GcCell<'gc, Class<'gc> ); let mut write = class.write(mc); - write.set_instance_deriver(appdomain_deriver); + write.set_instance_allocator(appdomain_allocator); const PUBLIC_CLASS_METHODS: &[(&str, NativeMethodImpl)] = &[ ("currentDomain", current_domain), diff --git a/core/src/avm2/globals/flash/utils/bytearray.rs b/core/src/avm2/globals/flash/utils/bytearray.rs index 28336363b..d974ba864 100644 --- a/core/src/avm2/globals/flash/utils/bytearray.rs +++ b/core/src/avm2/globals/flash/utils/bytearray.rs @@ -3,7 +3,7 @@ use crate::avm2::bytearray::{CompressionAlgorithm, Endian}; use crate::avm2::class::{Class, ClassAttributes}; use crate::avm2::method::{Method, NativeMethodImpl}; use crate::avm2::names::{Namespace, QName}; -use crate::avm2::object::{bytearray_deriver, Object, TObject}; +use crate::avm2::object::{bytearray_allocator, Object, TObject}; use crate::avm2::string::AvmString; use crate::avm2::value::Value; use crate::avm2::Error; @@ -728,7 +728,7 @@ pub fn create_class<'gc>(mc: MutationContext<'gc, '_>) -> GcCell<'gc, Class<'gc> let mut write = class.write(mc); write.set_attributes(ClassAttributes::SEALED); - write.set_instance_deriver(bytearray_deriver); + write.set_instance_allocator(bytearray_allocator); const PUBLIC_INSTANCE_METHODS: &[(&str, NativeMethodImpl)] = &[ ("writeByte", write_byte), diff --git a/core/src/avm2/globals/int.rs b/core/src/avm2/globals/int.rs index 4977e8089..1e96cddab 100644 --- a/core/src/avm2/globals/int.rs +++ b/core/src/avm2/globals/int.rs @@ -4,7 +4,7 @@ use crate::avm2::activation::Activation; use crate::avm2::class::Class; use crate::avm2::method::Method; use crate::avm2::names::{Namespace, QName}; -use crate::avm2::object::{primitive_deriver, Object}; +use crate::avm2::object::{primitive_allocator, Object}; use crate::avm2::value::Value; use crate::avm2::Error; use gc_arena::{GcCell, MutationContext}; @@ -51,7 +51,7 @@ pub fn create_class<'gc>(mc: MutationContext<'gc, '_>) -> GcCell<'gc, Class<'gc> ); let mut write = class.write(mc); - write.set_instance_deriver(primitive_deriver); + write.set_instance_allocator(primitive_allocator); write.set_native_instance_init(Method::from_builtin( native_instance_init, "", diff --git a/core/src/avm2/globals/namespace.rs b/core/src/avm2/globals/namespace.rs index 734773113..e775c3de0 100644 --- a/core/src/avm2/globals/namespace.rs +++ b/core/src/avm2/globals/namespace.rs @@ -4,7 +4,7 @@ use crate::avm2::activation::Activation; use crate::avm2::class::Class; use crate::avm2::method::Method; use crate::avm2::names::{Namespace, QName}; -use crate::avm2::object::{namespace_deriver, Object}; +use crate::avm2::object::{namespace_allocator, Object}; use crate::avm2::value::Value; use crate::avm2::Error; use gc_arena::{GcCell, MutationContext}; @@ -51,7 +51,7 @@ pub fn create_class<'gc>(mc: MutationContext<'gc, '_>) -> GcCell<'gc, Class<'gc> ); let mut write = class.write(mc); - write.set_instance_deriver(namespace_deriver); + write.set_instance_allocator(namespace_allocator); write.set_native_instance_init(Method::from_builtin( native_instance_init, "", diff --git a/core/src/avm2/globals/number.rs b/core/src/avm2/globals/number.rs index 79e2a67bf..c915a28fe 100644 --- a/core/src/avm2/globals/number.rs +++ b/core/src/avm2/globals/number.rs @@ -4,7 +4,7 @@ use crate::avm2::activation::Activation; use crate::avm2::class::Class; use crate::avm2::method::Method; use crate::avm2::names::{Namespace, QName}; -use crate::avm2::object::{primitive_deriver, Object}; +use crate::avm2::object::{primitive_allocator, Object}; use crate::avm2::value::Value; use crate::avm2::Error; use gc_arena::{GcCell, MutationContext}; @@ -51,7 +51,7 @@ pub fn create_class<'gc>(mc: MutationContext<'gc, '_>) -> GcCell<'gc, Class<'gc> ); let mut write = class.write(mc); - write.set_instance_deriver(primitive_deriver); + write.set_instance_allocator(primitive_allocator); write.set_native_instance_init(Method::from_builtin( native_instance_init, "", diff --git a/core/src/avm2/globals/regexp.rs b/core/src/avm2/globals/regexp.rs index ff371a03e..e2daf9915 100644 --- a/core/src/avm2/globals/regexp.rs +++ b/core/src/avm2/globals/regexp.rs @@ -3,7 +3,7 @@ use crate::avm2::class::Class; use crate::avm2::method::{Method, NativeMethodImpl, ParamConfig}; use crate::avm2::names::{Namespace, QName}; -use crate::avm2::object::{regexp_deriver, ArrayObject, Object, TObject}; +use crate::avm2::object::{regexp_allocator, ArrayObject, Object, TObject}; use crate::avm2::string::AvmString; use crate::avm2::value::Value; use crate::avm2::Error; @@ -275,7 +275,7 @@ pub fn create_class<'gc>(mc: MutationContext<'gc, '_>) -> GcCell<'gc, Class<'gc> ); let mut write = class.write(mc); - write.set_instance_deriver(regexp_deriver); + write.set_instance_allocator(regexp_allocator); const PUBLIC_INSTANCE_PROPERTIES: &[( &str, diff --git a/core/src/avm2/globals/string.rs b/core/src/avm2/globals/string.rs index f744ab0ad..00c9b17d3 100644 --- a/core/src/avm2/globals/string.rs +++ b/core/src/avm2/globals/string.rs @@ -4,7 +4,7 @@ use crate::avm2::activation::Activation; use crate::avm2::class::{Class, ClassAttributes}; use crate::avm2::method::{Method, NativeMethodImpl}; use crate::avm2::names::{Namespace, QName}; -use crate::avm2::object::{primitive_deriver, Object, TObject}; +use crate::avm2::object::{primitive_allocator, Object, TObject}; use crate::avm2::string::AvmString; use crate::avm2::value::Value; use crate::avm2::Error; @@ -130,7 +130,7 @@ pub fn create_class<'gc>(mc: MutationContext<'gc, '_>) -> GcCell<'gc, Class<'gc> let mut write = class.write(mc); write.set_attributes(ClassAttributes::FINAL | ClassAttributes::SEALED); - write.set_instance_deriver(primitive_deriver); + write.set_instance_allocator(primitive_allocator); const PUBLIC_INSTANCE_PROPERTIES: &[( &str, diff --git a/core/src/avm2/globals/uint.rs b/core/src/avm2/globals/uint.rs index 1ef325baa..e67cb8a89 100644 --- a/core/src/avm2/globals/uint.rs +++ b/core/src/avm2/globals/uint.rs @@ -4,7 +4,7 @@ use crate::avm2::activation::Activation; use crate::avm2::class::Class; use crate::avm2::method::{Method, ParamConfig}; use crate::avm2::names::{Namespace, QName}; -use crate::avm2::object::{primitive_deriver, Object}; +use crate::avm2::object::{primitive_allocator, Object}; use crate::avm2::value::Value; use crate::avm2::Error; use gc_arena::{GcCell, MutationContext}; @@ -60,7 +60,7 @@ pub fn create_class<'gc>(mc: MutationContext<'gc, '_>) -> GcCell<'gc, Class<'gc> ); let mut write = class.write(mc); - write.set_instance_deriver(primitive_deriver); + write.set_instance_allocator(primitive_allocator); write.set_native_instance_init(Method::from_builtin_and_params( native_instance_init, "", diff --git a/core/src/avm2/globals/xml.rs b/core/src/avm2/globals/xml.rs index 6f5737890..988093389 100644 --- a/core/src/avm2/globals/xml.rs +++ b/core/src/avm2/globals/xml.rs @@ -4,7 +4,7 @@ use crate::avm2::activation::Activation; use crate::avm2::class::Class; use crate::avm2::method::{Method, ParamConfig}; use crate::avm2::names::{Namespace, QName}; -use crate::avm2::object::{xml_deriver, Object}; +use crate::avm2::object::{xml_allocator, Object}; use crate::avm2::value::Value; use crate::avm2::Error; use gc_arena::{GcCell, MutationContext}; @@ -47,7 +47,7 @@ pub fn create_class<'gc>(mc: MutationContext<'gc, '_>) -> GcCell<'gc, Class<'gc> ); let mut write = class.write(mc); - write.set_instance_deriver(xml_deriver); + write.set_instance_allocator(xml_allocator); class } diff --git a/core/src/avm2/globals/xml_list.rs b/core/src/avm2/globals/xml_list.rs index 98bf7d832..d6d6c2fba 100644 --- a/core/src/avm2/globals/xml_list.rs +++ b/core/src/avm2/globals/xml_list.rs @@ -4,7 +4,7 @@ use crate::avm2::activation::Activation; use crate::avm2::class::Class; use crate::avm2::method::{Method, ParamConfig}; use crate::avm2::names::{Namespace, QName}; -use crate::avm2::object::{xml_deriver, Object}; +use crate::avm2::object::{xml_allocator, Object}; use crate::avm2::value::Value; use crate::avm2::Error; use gc_arena::{GcCell, MutationContext}; @@ -47,7 +47,7 @@ pub fn create_class<'gc>(mc: MutationContext<'gc, '_>) -> GcCell<'gc, Class<'gc> ); let mut write = class.write(mc); - write.set_instance_deriver(xml_deriver); + write.set_instance_allocator(xml_allocator); class } diff --git a/core/src/avm2/object.rs b/core/src/avm2/object.rs index b8825fe6f..f612b870d 100644 --- a/core/src/avm2/object.rs +++ b/core/src/avm2/object.rs @@ -37,22 +37,22 @@ mod script_object; mod stage_object; mod xml_object; -pub use crate::avm2::object::array_object::{array_deriver, ArrayObject}; -pub use crate::avm2::object::bytearray_object::{bytearray_deriver, ByteArrayObject}; +pub use crate::avm2::object::array_object::{array_allocator, ArrayObject}; +pub use crate::avm2::object::bytearray_object::{bytearray_allocator, ByteArrayObject}; pub use crate::avm2::object::class_object::ClassObject; pub use crate::avm2::object::dispatch_object::DispatchObject; -pub use crate::avm2::object::domain_object::{appdomain_deriver, DomainObject}; -pub use crate::avm2::object::event_object::{event_deriver, EventObject}; +pub use crate::avm2::object::domain_object::{appdomain_allocator, DomainObject}; +pub use crate::avm2::object::event_object::{event_allocator, EventObject}; pub use crate::avm2::object::function_object::FunctionObject; pub use crate::avm2::object::loaderinfo_object::{ - loaderinfo_deriver, LoaderInfoObject, LoaderStream, + loaderinfo_allocator, LoaderInfoObject, LoaderStream, }; -pub use crate::avm2::object::namespace_object::{namespace_deriver, NamespaceObject}; -pub use crate::avm2::object::primitive_object::{primitive_deriver, PrimitiveObject}; -pub use crate::avm2::object::regexp_object::{regexp_deriver, RegExpObject}; +pub use crate::avm2::object::namespace_object::{namespace_allocator, NamespaceObject}; +pub use crate::avm2::object::primitive_object::{primitive_allocator, PrimitiveObject}; +pub use crate::avm2::object::regexp_object::{regexp_allocator, RegExpObject}; pub use crate::avm2::object::script_object::ScriptObject; -pub use crate::avm2::object::stage_object::{stage_deriver, StageObject}; -pub use crate::avm2::object::xml_object::{xml_deriver, XmlObject}; +pub use crate::avm2::object::stage_object::{stage_allocator, StageObject}; +pub use crate::avm2::object::xml_object::{xml_allocator, XmlObject}; /// Represents an object that can be directly interacted with by the AVM2 /// runtime. @@ -824,7 +824,7 @@ pub trait TObject<'gc>: 'gc + Collect + Debug + Into> + Clone + Copy /// constructor is then expected to perform the following steps, in order: /// /// 1. Allocate the instance object. For ES4 classes, the class's instance - /// deriver is used to allocate the object. ES3-style classes use the + /// allocator is used to allocate the object. ES3-style classes use the /// prototype to derive instances. /// 2. Associate the instance object with the class's explicit `prototype`. /// 3. If the class has instance traits, install them at this time. diff --git a/core/src/avm2/object/array_object.rs b/core/src/avm2/object/array_object.rs index 3d516f0fa..a3ffd8c8d 100644 --- a/core/src/avm2/object/array_object.rs +++ b/core/src/avm2/object/array_object.rs @@ -14,8 +14,8 @@ use crate::impl_avm2_custom_object; use gc_arena::{Collect, GcCell, MutationContext}; use std::cell::{Ref, RefMut}; -/// A class instance deriver that constructs array objects. -pub fn array_deriver<'gc>( +/// A class instance allocator that allocates array objects. +pub fn array_allocator<'gc>( class: Object<'gc>, proto: Object<'gc>, activation: &mut Activation<'_, 'gc, '_>, diff --git a/core/src/avm2/object/bytearray_object.rs b/core/src/avm2/object/bytearray_object.rs index d83dc0538..8817b2308 100644 --- a/core/src/avm2/object/bytearray_object.rs +++ b/core/src/avm2/object/bytearray_object.rs @@ -12,8 +12,8 @@ use crate::impl_avm2_custom_object; use gc_arena::{Collect, GcCell, MutationContext}; use std::cell::{Ref, RefMut}; -/// A class instance deriver that constructs ByteArray objects. -pub fn bytearray_deriver<'gc>( +/// A class instance allocator that allocates ByteArray objects. +pub fn bytearray_allocator<'gc>( class: Object<'gc>, proto: Object<'gc>, activation: &mut Activation<'_, 'gc, '_>, diff --git a/core/src/avm2/object/class_object.rs b/core/src/avm2/object/class_object.rs index 3c31ea031..da4230b18 100644 --- a/core/src/avm2/object/class_object.rs +++ b/core/src/avm2/object/class_object.rs @@ -79,7 +79,8 @@ impl<'gc> ClassObject<'gc> { } //TODO: Class prototypes are *not* instances of their class and should - //not be allocated by a deriver, but instead should be regular objects + //not be allocated by the class allocator, but instead should be + //regular objects let mut class_proto = if let Some(mut superclass_object) = superclass_object { let base_proto = superclass_object .get_property( @@ -88,8 +89,8 @@ impl<'gc> ClassObject<'gc> { activation, )? .coerce_to_object(activation)?; - let derive = class.read().instance_deriver(); - derive(superclass_object, base_proto, activation)? + let allocate = class.read().instance_allocator(); + allocate(superclass_object, base_proto, activation)? } else { ScriptObject::bare_object(activation.context.gc_context) }; @@ -369,7 +370,7 @@ impl<'gc> TObject<'gc> for ClassObject<'gc> { arguments: &[Value<'gc>], ) -> Result, Error> { let class = self.as_class().ok_or("Cannot construct classless class!")?; - let deriver = class.read().instance_deriver(); + let allocator = class.read().instance_allocator(); let class_object: Object<'gc> = self.into(); let prototype = self .get_property( @@ -379,7 +380,7 @@ impl<'gc> TObject<'gc> for ClassObject<'gc> { )? .coerce_to_object(activation)?; - let mut instance = deriver(class_object, prototype, activation)?; + let mut instance = allocator(class_object, prototype, activation)?; instance.install_instance_traits(activation, class_object)?; diff --git a/core/src/avm2/object/domain_object.rs b/core/src/avm2/object/domain_object.rs index 220d2017e..a5b2f818f 100644 --- a/core/src/avm2/object/domain_object.rs +++ b/core/src/avm2/object/domain_object.rs @@ -13,8 +13,8 @@ use crate::avm2::Error; use crate::{impl_avm2_custom_object, impl_avm2_custom_object_properties}; use gc_arena::{Collect, GcCell, MutationContext}; -/// A class instance deriver that constructs AppDomain objects. -pub fn appdomain_deriver<'gc>( +/// A class instance allocator that allocates AppDomain objects. +pub fn appdomain_allocator<'gc>( class: Object<'gc>, proto: Object<'gc>, activation: &mut Activation<'_, 'gc, '_>, @@ -136,6 +136,6 @@ impl<'gc> TObject<'gc> for DomainObject<'gc> { )? .coerce_to_object(activation)?; - appdomain_deriver(constr, this, activation) + appdomain_allocator(constr, this, activation) } } diff --git a/core/src/avm2/object/event_object.rs b/core/src/avm2/object/event_object.rs index 22de4eb38..84884461b 100644 --- a/core/src/avm2/object/event_object.rs +++ b/core/src/avm2/object/event_object.rs @@ -14,8 +14,8 @@ use crate::{impl_avm2_custom_object, impl_avm2_custom_object_properties}; use gc_arena::{Collect, GcCell, MutationContext}; use std::cell::{Ref, RefMut}; -/// A class instance deriver that constructs Event objects. -pub fn event_deriver<'gc>( +/// A class instance allocator that allocates Event objects. +pub fn event_allocator<'gc>( class: Object<'gc>, proto: Object<'gc>, activation: &mut Activation<'_, 'gc, '_>, diff --git a/core/src/avm2/object/loaderinfo_object.rs b/core/src/avm2/object/loaderinfo_object.rs index 2c670a52a..19d84345f 100644 --- a/core/src/avm2/object/loaderinfo_object.rs +++ b/core/src/avm2/object/loaderinfo_object.rs @@ -16,8 +16,8 @@ use gc_arena::{Collect, GcCell, MutationContext}; use std::cell::Ref; use std::sync::Arc; -/// A class instance deriver that constructs LoaderInfo objects. -pub fn loaderinfo_deriver<'gc>( +/// A class instance allocator that allocates LoaderInfo objects. +pub fn loaderinfo_allocator<'gc>( class: Object<'gc>, proto: Object<'gc>, activation: &mut Activation<'_, 'gc, '_>, diff --git a/core/src/avm2/object/namespace_object.rs b/core/src/avm2/object/namespace_object.rs index f4be93558..ca81539b7 100644 --- a/core/src/avm2/object/namespace_object.rs +++ b/core/src/avm2/object/namespace_object.rs @@ -13,8 +13,8 @@ use crate::{impl_avm2_custom_object, impl_avm2_custom_object_properties}; use gc_arena::{Collect, GcCell, MutationContext}; use std::cell::Ref; -/// A class instance deriver that constructs namespace objects. -pub fn namespace_deriver<'gc>( +/// A class instance allocator that allocates namespace objects. +pub fn namespace_allocator<'gc>( class: Object<'gc>, proto: Object<'gc>, activation: &mut Activation<'_, 'gc, '_>, diff --git a/core/src/avm2/object/primitive_object.rs b/core/src/avm2/object/primitive_object.rs index 908e6b611..68d10099e 100644 --- a/core/src/avm2/object/primitive_object.rs +++ b/core/src/avm2/object/primitive_object.rs @@ -14,8 +14,8 @@ use crate::avm2::Error; use crate::{impl_avm2_custom_object, impl_avm2_custom_object_properties}; use gc_arena::{Collect, GcCell, MutationContext}; -/// A class instance deriver that constructs primitive objects. -pub fn primitive_deriver<'gc>( +/// A class instance allocator that allocates primitive objects. +pub fn primitive_allocator<'gc>( class: Object<'gc>, proto: Object<'gc>, activation: &mut Activation<'_, 'gc, '_>, diff --git a/core/src/avm2/object/regexp_object.rs b/core/src/avm2/object/regexp_object.rs index 1fec9a076..858bcff52 100644 --- a/core/src/avm2/object/regexp_object.rs +++ b/core/src/avm2/object/regexp_object.rs @@ -14,8 +14,8 @@ use crate::{impl_avm2_custom_object, impl_avm2_custom_object_properties}; use gc_arena::{Collect, GcCell, MutationContext}; use std::cell::{Ref, RefMut}; -/// A class instance deriver that constructs RegExp objects. -pub fn regexp_deriver<'gc>( +/// A class instance allocator that allocates RegExp objects. +pub fn regexp_allocator<'gc>( class: Object<'gc>, proto: Object<'gc>, activation: &mut Activation<'_, 'gc, '_>, diff --git a/core/src/avm2/object/stage_object.rs b/core/src/avm2/object/stage_object.rs index 17c80371e..2cccf2d42 100644 --- a/core/src/avm2/object/stage_object.rs +++ b/core/src/avm2/object/stage_object.rs @@ -13,8 +13,8 @@ use crate::avm2::Error; use crate::display_object::DisplayObject; use gc_arena::{Collect, GcCell, MutationContext}; -/// A class instance deriver that constructs Stage objects. -pub fn stage_deriver<'gc>( +/// A class instance allocator that allocates Stage objects. +pub fn stage_allocator<'gc>( class: Object<'gc>, proto: Object<'gc>, activation: &mut Activation<'_, 'gc, '_>, diff --git a/core/src/avm2/object/xml_object.rs b/core/src/avm2/object/xml_object.rs index 03d1ce96c..21cf66938 100644 --- a/core/src/avm2/object/xml_object.rs +++ b/core/src/avm2/object/xml_object.rs @@ -12,8 +12,8 @@ use crate::avm2::Error; use crate::{impl_avm2_custom_object, impl_avm2_custom_object_properties}; use gc_arena::{Collect, GcCell, MutationContext}; -/// A class instance deriver that constructs XML objects. -pub fn xml_deriver<'gc>( +/// A class instance allocator that allocates XML objects. +pub fn xml_allocator<'gc>( class: Object<'gc>, proto: Object<'gc>, activation: &mut Activation<'_, 'gc, '_>,