diff --git a/core/build_playerglobal/src/lib.rs b/core/build_playerglobal/src/lib.rs index eb6589747d92..a9054c7db356 100644 --- a/core/build_playerglobal/src/lib.rs +++ b/core/build_playerglobal/src/lib.rs @@ -519,7 +519,7 @@ fn write_native_table(data: &[u8], out_dir: &Path) -> Result, Box { rust_instance_allocators[class_id as usize] = { - let path = "crate::avm2::globals::class::abstract_class_allocator"; + let path = "crate::avm2::object::abstract_class_allocator"; let path_tokens = TokenStream::from_str(&path).unwrap(); let flash_method_path = "unused".to_string(); quote! { Some((#flash_method_path, #path_tokens)) } diff --git a/core/src/avm2/globals/class.rs b/core/src/avm2/globals/class.rs index cb5f3fc0fec1..f624a6a67943 100644 --- a/core/src/avm2/globals/class.rs +++ b/core/src/avm2/globals/class.rs @@ -2,28 +2,13 @@ use crate::avm2::activation::Activation; use crate::avm2::class::{Class, ClassAttributes}; -use crate::avm2::error::{argument_error, type_error}; +use crate::avm2::error::type_error; use crate::avm2::method::{Method, NativeMethodImpl}; use crate::avm2::object::{ClassObject, Object, TObject}; use crate::avm2::value::Value; use crate::avm2::Error; use crate::avm2::QName; -/// Implements a custom allocator for classes that are not constructible. -/// (but their derived classes can be) -pub fn abstract_class_allocator<'gc>( - class: ClassObject<'gc>, - activation: &mut Activation<'_, 'gc>, -) -> Result, Error<'gc>> { - let class_name = class.instance_class().name().local_name(); - - return Err(Error::AvmError(argument_error( - activation, - &format!("Error #2012: {class_name} class cannot be instantiated."), - 2012, - )?)); -} - pub fn class_allocator<'gc>( _class: ClassObject<'gc>, activation: &mut Activation<'_, 'gc>, diff --git a/core/src/avm2/object.rs b/core/src/avm2/object.rs index 7cec700eb979..e30426be0b8f 100644 --- a/core/src/avm2/object.rs +++ b/core/src/avm2/object.rs @@ -1529,3 +1529,18 @@ impl<'gc> WeakObject<'gc> { }) } } + +/// Implements a custom allocator for classes that are not constructible. +/// (but their derived classes can be) +pub fn abstract_class_allocator<'gc>( + class: ClassObject<'gc>, + activation: &mut Activation<'_, 'gc>, +) -> Result, Error<'gc>> { + let class_name = class.instance_class().name().local_name(); + + return Err(Error::AvmError(error::argument_error( + activation, + &format!("Error #2012: {class_name} class cannot be instantiated."), + 2012, + )?)); +}