avm2: Replaced stubs in namespace with new format (but still err as I don't know what to return otherwise)

This commit is contained in:
Nathan Adams 2023-01-31 18:15:56 +01:00
parent 8f53f5414c
commit 10ec9a1a74
3 changed files with 37 additions and 10 deletions

View File

@ -9,22 +9,25 @@ use crate::avm2::Error;
use crate::avm2::Multiname;
use crate::avm2::Namespace;
use crate::avm2::QName;
use crate::avm2_stub_constructor;
use gc_arena::{GcCell, MutationContext};
/// Implements `Namespace`'s instance initializer.
pub fn instance_init<'gc>(
_activation: &mut Activation<'_, 'gc>,
activation: &mut Activation<'_, 'gc>,
_this: Option<Object<'gc>>,
_args: &[Value<'gc>],
) -> Result<Value<'gc>, Error<'gc>> {
avm2_stub_constructor!(activation, "Namespace");
Err("Namespace constructor is a stub.".into())
}
fn class_call<'gc>(
_activation: &mut Activation<'_, 'gc>,
activation: &mut Activation<'_, 'gc>,
_this: Option<Object<'gc>>,
_args: &[Value<'gc>],
) -> Result<Value<'gc>, Error<'gc>> {
avm2_stub_constructor!(activation, "Namespace");
Err("Namespace constructor is a stub.".into())
}

View File

@ -26,16 +26,28 @@ macro_rules! avm2_stub_method {
};
}
#[macro_export]
macro_rules! avm2_stub_constructor {
($activation: ident, $class: literal) => {
#[cfg_attr(
feature = "known_stubs",
linkme::distributed_slice($crate::stub::KNOWN_STUBS)
)]
static STUB: $crate::stub::Stub = $crate::stub::Stub::Avm2Constructor { class: $class };
$activation.context.stub_tracker.encounter(&STUB);
};
}
#[macro_export]
macro_rules! avm2_stub_getter {
($activation: ident, $class: literal, $method: literal) => {
($activation: ident, $class: literal, $property: literal) => {
#[cfg_attr(
feature = "known_stubs",
linkme::distributed_slice($crate::stub::KNOWN_STUBS)
)]
static STUB: $crate::stub::Stub = $crate::stub::Stub::Avm2Getter {
class: $class,
field: $method,
property: $property,
};
$activation.context.stub_tracker.encounter(&STUB);
};
@ -43,14 +55,14 @@ macro_rules! avm2_stub_getter {
#[macro_export]
macro_rules! avm2_stub_setter {
($activation: ident, $class: literal, $method: literal) => {
($activation: ident, $class: literal, $property: literal) => {
#[cfg_attr(
feature = "known_stubs",
linkme::distributed_slice($crate::stub::KNOWN_STUBS)
)]
static STUB: $crate::stub::Stub = $crate::stub::Stub::Avm2Setter {
class: $class,
field: $method,
property: $property,
};
$activation.context.stub_tracker.encounter(&STUB);
};

View File

@ -16,11 +16,14 @@ pub enum Stub {
},
Avm2Getter {
class: &'static str,
field: &'static str,
property: &'static str,
},
Avm2Setter {
class: &'static str,
field: &'static str,
property: &'static str,
},
Avm2Constructor {
class: &'static str,
},
Other(Cow<'static, str>),
}
@ -42,12 +45,21 @@ impl Display for Stub {
} => {
write!(f, "AVM1 {class}.{method}() {specifics}")
}
Stub::Avm2Getter { class, field } => {
Stub::Avm2Getter {
class,
property: field,
} => {
write!(f, "AVM2 {class}.{field} getter")
}
Stub::Avm2Setter { class, field } => {
Stub::Avm2Setter {
class,
property: field,
} => {
write!(f, "AVM2 {class}.{field} setter")
}
Stub::Avm2Constructor { class } => {
write!(f, "AVM2 {class} constructor")
}
Stub::Other(text) => write!(f, "{text}"),
}
}