Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

avm2: Improve XML set_property_local implementation #13041

Merged
merged 9 commits into from
Sep 14, 2023

Conversation

sleepycatcoding
Copy link
Member

@sleepycatcoding sleepycatcoding commented Sep 2, 2023

This is a draft as it currently makes test xml_namespaced_property fail.
Also requires #12993 (merged)

Fixes #12162
Fixes #12910

@@ -244,6 +244,57 @@ impl<'gc> E4XNode<'gc> {
node
}

/// Returns the amount of children in this node if this node is of Element kind, otherwise returns [None].
pub fn length(&self) -> Option<usize> {
let E4XNodeKind::Element { children, .. } = &*self.kind() else {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I'd say do it the other way around?

it let E4XNodeKind::Element { children, .. } = &*self.kind() {
    Some(children.len())
} else {
    None
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can cleanup in follow up PR.

let E4XNodeKind::Element { children, .. } = &mut *kind else {
// 7. Let isValidName be the result of calling the function isXMLName (section 13.1.2.1) with argument n
let is_valid_name = name.local_name().map_or(Ok(false), |x| {
crate::avm2::e4x::is_xml_name(activation, x.into())
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(in retrospect, maybe passing an AvmString to is_xml_name would have been a nicer design, so it wouldn't need a Result here)

Copy link
Member Author

@sleepycatcoding sleepycatcoding Sep 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I also realized this myself, I should have left the null and undefined handling in AS3 isXMLName function. Can cleanup in follow up PR.

@adrian17 adrian17 enabled auto-merge (squash) September 14, 2023 21:11
@adrian17 adrian17 merged commit ecbf325 into ruffle-rs:master Sep 14, 2023
13 checks passed
@Lord-McSweeney Lord-McSweeney removed the waiting-on-review Waiting on review from a Ruffle team member label Sep 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Laser Cannon 2 can't push to start.... Cannot set an XML/XMLList object as an element yet
3 participants