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:
parent
8f53f5414c
commit
10ec9a1a74
|
@ -9,22 +9,25 @@ use crate::avm2::Error;
|
||||||
use crate::avm2::Multiname;
|
use crate::avm2::Multiname;
|
||||||
use crate::avm2::Namespace;
|
use crate::avm2::Namespace;
|
||||||
use crate::avm2::QName;
|
use crate::avm2::QName;
|
||||||
|
use crate::avm2_stub_constructor;
|
||||||
use gc_arena::{GcCell, MutationContext};
|
use gc_arena::{GcCell, MutationContext};
|
||||||
|
|
||||||
/// Implements `Namespace`'s instance initializer.
|
/// Implements `Namespace`'s instance initializer.
|
||||||
pub fn instance_init<'gc>(
|
pub fn instance_init<'gc>(
|
||||||
_activation: &mut Activation<'_, 'gc>,
|
activation: &mut Activation<'_, 'gc>,
|
||||||
_this: Option<Object<'gc>>,
|
_this: Option<Object<'gc>>,
|
||||||
_args: &[Value<'gc>],
|
_args: &[Value<'gc>],
|
||||||
) -> Result<Value<'gc>, Error<'gc>> {
|
) -> Result<Value<'gc>, Error<'gc>> {
|
||||||
|
avm2_stub_constructor!(activation, "Namespace");
|
||||||
Err("Namespace constructor is a stub.".into())
|
Err("Namespace constructor is a stub.".into())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn class_call<'gc>(
|
fn class_call<'gc>(
|
||||||
_activation: &mut Activation<'_, 'gc>,
|
activation: &mut Activation<'_, 'gc>,
|
||||||
_this: Option<Object<'gc>>,
|
_this: Option<Object<'gc>>,
|
||||||
_args: &[Value<'gc>],
|
_args: &[Value<'gc>],
|
||||||
) -> Result<Value<'gc>, Error<'gc>> {
|
) -> Result<Value<'gc>, Error<'gc>> {
|
||||||
|
avm2_stub_constructor!(activation, "Namespace");
|
||||||
Err("Namespace constructor is a stub.".into())
|
Err("Namespace constructor is a stub.".into())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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_export]
|
||||||
macro_rules! avm2_stub_getter {
|
macro_rules! avm2_stub_getter {
|
||||||
($activation: ident, $class: literal, $method: literal) => {
|
($activation: ident, $class: literal, $property: literal) => {
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
feature = "known_stubs",
|
feature = "known_stubs",
|
||||||
linkme::distributed_slice($crate::stub::KNOWN_STUBS)
|
linkme::distributed_slice($crate::stub::KNOWN_STUBS)
|
||||||
)]
|
)]
|
||||||
static STUB: $crate::stub::Stub = $crate::stub::Stub::Avm2Getter {
|
static STUB: $crate::stub::Stub = $crate::stub::Stub::Avm2Getter {
|
||||||
class: $class,
|
class: $class,
|
||||||
field: $method,
|
property: $property,
|
||||||
};
|
};
|
||||||
$activation.context.stub_tracker.encounter(&STUB);
|
$activation.context.stub_tracker.encounter(&STUB);
|
||||||
};
|
};
|
||||||
|
@ -43,14 +55,14 @@ macro_rules! avm2_stub_getter {
|
||||||
|
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! avm2_stub_setter {
|
macro_rules! avm2_stub_setter {
|
||||||
($activation: ident, $class: literal, $method: literal) => {
|
($activation: ident, $class: literal, $property: literal) => {
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
feature = "known_stubs",
|
feature = "known_stubs",
|
||||||
linkme::distributed_slice($crate::stub::KNOWN_STUBS)
|
linkme::distributed_slice($crate::stub::KNOWN_STUBS)
|
||||||
)]
|
)]
|
||||||
static STUB: $crate::stub::Stub = $crate::stub::Stub::Avm2Setter {
|
static STUB: $crate::stub::Stub = $crate::stub::Stub::Avm2Setter {
|
||||||
class: $class,
|
class: $class,
|
||||||
field: $method,
|
property: $property,
|
||||||
};
|
};
|
||||||
$activation.context.stub_tracker.encounter(&STUB);
|
$activation.context.stub_tracker.encounter(&STUB);
|
||||||
};
|
};
|
||||||
|
|
|
@ -16,11 +16,14 @@ pub enum Stub {
|
||||||
},
|
},
|
||||||
Avm2Getter {
|
Avm2Getter {
|
||||||
class: &'static str,
|
class: &'static str,
|
||||||
field: &'static str,
|
property: &'static str,
|
||||||
},
|
},
|
||||||
Avm2Setter {
|
Avm2Setter {
|
||||||
class: &'static str,
|
class: &'static str,
|
||||||
field: &'static str,
|
property: &'static str,
|
||||||
|
},
|
||||||
|
Avm2Constructor {
|
||||||
|
class: &'static str,
|
||||||
},
|
},
|
||||||
Other(Cow<'static, str>),
|
Other(Cow<'static, str>),
|
||||||
}
|
}
|
||||||
|
@ -42,12 +45,21 @@ impl Display for Stub {
|
||||||
} => {
|
} => {
|
||||||
write!(f, "AVM1 {class}.{method}() {specifics}")
|
write!(f, "AVM1 {class}.{method}() {specifics}")
|
||||||
}
|
}
|
||||||
Stub::Avm2Getter { class, field } => {
|
Stub::Avm2Getter {
|
||||||
|
class,
|
||||||
|
property: field,
|
||||||
|
} => {
|
||||||
write!(f, "AVM2 {class}.{field} getter")
|
write!(f, "AVM2 {class}.{field} getter")
|
||||||
}
|
}
|
||||||
Stub::Avm2Setter { class, field } => {
|
Stub::Avm2Setter {
|
||||||
|
class,
|
||||||
|
property: field,
|
||||||
|
} => {
|
||||||
write!(f, "AVM2 {class}.{field} setter")
|
write!(f, "AVM2 {class}.{field} setter")
|
||||||
}
|
}
|
||||||
|
Stub::Avm2Constructor { class } => {
|
||||||
|
write!(f, "AVM2 {class} constructor")
|
||||||
|
}
|
||||||
Stub::Other(text) => write!(f, "{text}"),
|
Stub::Other(text) => write!(f, "{text}"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue