From 1577f517304008099523ceee2a306998ba62a7a2 Mon Sep 17 00:00:00 2001 From: David Wendt Date: Fri, 27 Dec 2019 20:13:48 -0700 Subject: [PATCH] Expose elided objects as pointers when debugging XML nodes --- core/src/xml/tree.rs | 75 ++++++++++++++++++++++++++++++++++++++------ 1 file changed, 65 insertions(+), 10 deletions(-) diff --git a/core/src/xml/tree.rs b/core/src/xml/tree.rs index 76a0048fc..71343125e 100644 --- a/core/src/xml/tree.rs +++ b/core/src/xml/tree.rs @@ -992,37 +992,92 @@ impl<'gc> XMLNode<'gc> { impl<'gc> fmt::Debug for XMLNode<'gc> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match &*self.0.read() { - XMLNodeData::Text { contents, .. } => f + XMLNodeData::Text { + script_object, + contents, + parent, + .. + } => f .debug_struct("XMLNodeData::Text") - .field("script_object", &"".to_string()) + .field("0", &self.0.as_ptr()) + .field( + "script_object", + &script_object + .map(|p| format!("{:p}", p.as_ptr())) + .unwrap_or_else(|| "None".to_string()), + ) .field("document", &"".to_string()) - .field("parent", &"".to_string()) + .field( + "parent", + &parent + .map(|p| format!("{:p}", p.0.as_ptr())) + .unwrap_or_else(|| "None".to_string()), + ) .field("contents", contents) .finish(), - XMLNodeData::Comment { contents, .. } => f + XMLNodeData::Comment { + script_object, + contents, + parent, + .. + } => f .debug_struct("XMLNodeData::Comment") - .field("script_object", &"".to_string()) + .field("0", &self.0.as_ptr()) + .field( + "script_object", + &script_object + .map(|p| format!("{:p}", p.as_ptr())) + .unwrap_or_else(|| "None".to_string()), + ) .field("document", &"".to_string()) - .field("parent", &"".to_string()) + .field( + "parent", + &parent + .map(|p| format!("{:p}", p.0.as_ptr())) + .unwrap_or_else(|| "None".to_string()), + ) .field("contents", contents) .finish(), XMLNodeData::Element { + script_object, tag_name, attributes, children, + parent, .. } => f .debug_struct("XMLNodeData::Element") - .field("script_object", &"".to_string()) + .field("0", &self.0.as_ptr()) + .field( + "script_object", + &script_object + .map(|p| format!("{:p}", p.as_ptr())) + .unwrap_or_else(|| "None".to_string()), + ) .field("document", &"".to_string()) - .field("parent", &"".to_string()) + .field( + "parent", + &parent + .map(|p| format!("{:p}", p.0.as_ptr())) + .unwrap_or_else(|| "None".to_string()), + ) .field("tag_name", tag_name) .field("attributes", attributes) .field("children", children) .finish(), - XMLNodeData::DocumentRoot { children, .. } => f + XMLNodeData::DocumentRoot { + script_object, + children, + .. + } => f .debug_struct("XMLNodeData::DocumentRoot") - .field("script_object", &"".to_string()) + .field("0", &self.0.as_ptr()) + .field( + "script_object", + &script_object + .map(|p| format!("{:p}", p.as_ptr())) + .unwrap_or_else(|| "None".to_string()), + ) .field("document", &"".to_string()) .field("children", children) .finish(),