avm2: Allow setting XML methods as properties

This commit is contained in:
Tom Schuster 2023-04-30 23:04:07 +02:00 committed by Aaron Hill
parent 58d786b869
commit f6c0685992
4 changed files with 17 additions and 0 deletions

View File

@ -183,6 +183,7 @@ pub trait TObject<'gc>: 'gc + Collect + Debug + Into<Object<'gc>> + Clone + Copy
{
return self.get_property_local(multiname, activation);
}
if let Some(bound_method) = self.get_bound_method(disp_id) {
return Ok(bound_method.into());
}
@ -278,6 +279,13 @@ pub trait TObject<'gc>: 'gc + Collect + Debug + Into<Object<'gc>> + Clone + Copy
)
}
Some(Property::Method { .. }) => {
// Similar to the get_property special case for XML/XMLList.
if (self.as_xml_object().is_some() || self.as_xml_list_object().is_some())
&& multiname.contains_public_namespace()
{
return self.set_property_local(multiname, value, activation);
}
return Err(error::make_reference_error(
activation,
error::ReferenceErrorCode::AssignToMethod,

View File

@ -34,3 +34,9 @@ var xml = <a>xxx<foo>yyy</foo>zzz</a>;
trace("before: " + xml.toXMLString());
xml.b = "abc";
trace("after: " + xml.toXMLString());
var xml = <a/>;
trace("before: " + xml.toXMLString());
xml.name = "abc";
trace("xml.name: " + xml.name);
trace("after: " + xml.toXMLString());

View File

@ -10,3 +10,6 @@ before: <a><b x="1"/></a>
after: <a><b x="1">abc</b></a>
before: <a>xxx<foo>yyy</foo>zzz</a>
after: <a>xxx<foo>yyy</foo>zzz<b>abc</b></a>
before: <a/>
xml.name: abc
after: <a><name>abc</name></a>