avm2: Replace `deriver` language with `allocator` language

This commit is contained in:
David Wendt 2021-06-19 20:05:40 -04:00
parent 8af0481a23
commit b469ef8a3f
29 changed files with 100 additions and 99 deletions

View File

@ -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(&"<native code>".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<Object<'gc>, 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<Multiname<'gc>>,
/// 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),
"<Activation object constructor>",
@ -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.

View File

@ -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),

View File

@ -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,
"<Boolean native instance initializer>",

View File

@ -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,
"<DisplayObject native instance initializer>",

View File

@ -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,
"<Graphics native instance initializer>",

View File

@ -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,
"<LoaderInfo native instance initializer>",

View File

@ -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,

View File

@ -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),

View File

@ -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),

View File

@ -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,
"<int native instance initializer>",

View File

@ -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,
"<Namespace native instance initializer>",

View File

@ -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,
"<Number native instance initializer>",

View File

@ -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,

View File

@ -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,

View File

@ -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,
"<uint native instance initializer>",

View File

@ -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
}

View File

@ -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
}

View File

@ -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<Object<'gc>> + 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.

View File

@ -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, '_>,

View File

@ -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, '_>,

View File

@ -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<Object<'gc>, 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)?;

View File

@ -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)
}
}

View File

@ -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, '_>,

View File

@ -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, '_>,

View File

@ -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, '_>,

View File

@ -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, '_>,

View File

@ -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, '_>,

View File

@ -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, '_>,

View File

@ -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, '_>,