avm2: Implement call handler for XMLList

This delegates to the XMLList constructor, just as
the XML call handler delegates to the XML constructor.
This commit is contained in:
Aaron Hill 2023-06-13 16:44:44 -05:00
parent 61f1cf88a5
commit 40318f905e
5 changed files with 20 additions and 0 deletions

View File

@ -1,5 +1,6 @@
package { package {
[Ruffle(InstanceAllocator)] [Ruffle(InstanceAllocator)]
[Ruffle(CallHandler)]
public final dynamic class XMLList { public final dynamic class XMLList {
public function XMLList(value:* = undefined) { public function XMLList(value:* = undefined) {

View File

@ -56,6 +56,19 @@ pub fn init<'gc>(
Ok(Value::Undefined) Ok(Value::Undefined)
} }
pub fn call_handler<'gc>(
activation: &mut Activation<'_, 'gc>,
_this: Option<Object<'gc>>,
args: &[Value<'gc>],
) -> Result<Value<'gc>, Error<'gc>> {
Ok(activation
.avm2()
.classes()
.xml_list
.construct(activation, args)?
.into())
}
pub fn has_complex_content<'gc>( pub fn has_complex_content<'gc>(
_activation: &mut Activation<'_, 'gc>, _activation: &mut Activation<'_, 'gc>,
this: Option<Object<'gc>>, this: Option<Object<'gc>>,

View File

@ -10,6 +10,9 @@
trace("From complex string:") trace("From complex string:")
trace(complexXML.children().length()); trace(complexXML.children().length());
trace(complexXML.name()); trace(complexXML.name());
trace("XMLList from string:");
trace(XMLList("<p>First element</p><p>Second element</p>"));
} }
} }
} }

View File

@ -4,3 +4,6 @@ Some string
From complex string: From complex string:
1 1
outer outer
XMLList from string:
<p>First element</p>
<p>Second element</p>