avm2: Implement QName call handler

This commit is contained in:
sleepycatcoding 2023-10-19 00:50:22 +03:00 committed by Nathan Adams
parent fd4d6921d8
commit 5da09c137e
5 changed files with 28 additions and 3 deletions

View File

@ -1,5 +1,6 @@
package { package {
[Ruffle(InstanceAllocator)] [Ruffle(InstanceAllocator)]
[Ruffle(CallHandler)]
public final class QName { public final class QName {
public static const length = 2; public static const length = 2;

View File

@ -8,6 +8,33 @@ use crate::avm2::Namespace;
pub use crate::avm2::object::q_name_allocator; pub use crate::avm2::object::q_name_allocator;
pub fn call_handler<'gc>(
activation: &mut Activation<'_, 'gc>,
_this: Object<'gc>,
args: &[Value<'gc>],
) -> Result<Value<'gc>, Error<'gc>> {
if args.len() == 1 {
// 1. If Namespace is not specified and Type(Name) is Object and Name.[[Class]] == “QName”
if args[0]
.as_object()
.and_then(|x| x.as_qname_object())
.is_some()
{
// 1.a. Return Name
return Ok(args[0]);
}
}
// 2. Create and return a new QName object exactly as if the QName constructor had been called with the
// same arguments (section 13.3.2).
Ok(activation
.avm2()
.classes()
.qname
.construct(activation, args)?
.into())
}
/// Implements `QName`'s `init` method, which is called from the constructor. /// Implements `QName`'s `init` method, which is called from the constructor.
pub fn init<'gc>( pub fn init<'gc>(
activation: &mut Activation<'_, 'gc>, activation: &mut Activation<'_, 'gc>,

View File

@ -1,2 +1 @@
num_ticks = 1 num_ticks = 1
known_failure = true # https://github.com/ruffle-rs/ruffle/issues/12356

View File

@ -1,2 +1 @@
num_ticks = 1 num_ticks = 1
known_failure = true

View File

@ -1,2 +1 @@
num_ticks = 1 num_ticks = 1
known_failure = true