core: xml_to_xml_string is now infallible

This commit is contained in:
Nathan Adams 2023-08-12 12:50:32 +02:00
parent 5d9c73cbb1
commit af1cb4ebd9
4 changed files with 5 additions and 11 deletions

View File

@ -112,10 +112,7 @@ pub fn serialize_value<'gc>(
} else if let Some(xml) = o.as_xml_object() {
// `is_string` is `true` for the AS3 XML class
Some(AmfValue::XML(
xml.node()
.xml_to_xml_string(activation)
.expect("Failed to stringify XML")
.to_string(),
xml.node().xml_to_xml_string(activation).to_string(),
true,
))
} else if let Some(bytearray) = o.as_bytearray() {

View File

@ -653,11 +653,8 @@ impl<'gc> E4XNode<'gc> {
}
}
pub fn xml_to_xml_string(
&self,
activation: &mut Activation<'_, 'gc>,
) -> Result<AvmString<'gc>, Error<'gc>> {
return Ok(to_xml_string(E4XOrXml::E4X(*self), activation));
pub fn xml_to_xml_string(&self, activation: &mut Activation<'_, 'gc>) -> AvmString<'gc> {
return to_xml_string(E4XOrXml::E4X(*self), activation);
}
pub fn kind(&self) -> Ref<'_, E4XNodeKind<'gc>> {

View File

@ -118,7 +118,7 @@ pub fn to_xml_string<'gc>(
) -> Result<Value<'gc>, Error<'gc>> {
let xml = this.as_xml_object().unwrap();
let node = xml.node();
Ok(Value::String(node.xml_to_xml_string(activation)?))
Ok(Value::String(node.xml_to_xml_string(activation)))
}
pub fn child<'gc>(

View File

@ -142,7 +142,7 @@ pub fn to_xml_string<'gc>(
if i != 0 {
out.push_char('\n');
}
out.push_str(child.node().xml_to_xml_string(activation)?.as_wstr())
out.push_str(child.node().xml_to_xml_string(activation).as_wstr())
}
Ok(AvmString::new(activation.context.gc_context, out).into())
}