Skip to content

Commit

Permalink
avm2:Move abstract_class_allocator to object.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
adrian17 committed Nov 19, 2024
1 parent ebf3f99 commit 71b39aa
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion core/build_playerglobal/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ fn write_native_table(data: &[u8], out_dir: &Path) -> Result<Vec<u8>, Box<dyn st
}
(None, METADATA_ABSTRACT) if !is_versioning => {
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)) }
Expand Down
17 changes: 1 addition & 16 deletions core/src/avm2/globals/class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Object<'gc>, 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>,
Expand Down
15 changes: 15 additions & 0 deletions core/src/avm2/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Object<'gc>, 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,
)?));
}

0 comments on commit 71b39aa

Please sign in to comment.