diff --git a/src/main.rs b/src/main.rs index 65d54ba..93ac7c0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -11,15 +11,16 @@ fn class_is_a(class: &str, superclass: &str) -> bool { return false } -fn recursive_collect_scripts(scripts: &mut std::vec::Vec,dom: &rbx_dom_weak::WeakDom, instance: &rbx_dom_weak::Instance){ - for &referent in instance.children() { - if let Some(c) = dom.get_by_ref(referent) { - if class_is_a(c.class.as_str(), "LuaSourceContainer") { - scripts.push(c.referent());//copy ref - } - recursive_collect_scripts(scripts,dom,c); +fn get_scripts(dom:rbx_dom_weak::WeakDom) -> Vec{ + let mut scripts = std::vec::Vec::::new(); + + let (_,mut instances) = dom.into_raw(); + for (_,instance) in instances.drain() { + if class_is_a(instance.class.as_str(), "LuaSourceContainer") { + scripts.push(instance); } } + scripts } fn main() -> Result<(), Box> { @@ -34,13 +35,13 @@ fn main() -> Result<(), Box> { allowed.insert(std::fs::read_to_string(entry?.path())?); } - let mut scripts = std::vec::Vec::::new(); - recursive_collect_scripts(&mut scripts, &dom, dom.root()); - //check scribb - let mut any_failed=false; - for (i,&referent) in scripts.iter().enumerate() { - if let Some(script) = dom.get_by_ref(referent) { + + let scripts = get_scripts(dom); + + //check scribb + let mut any_failed=false; + for script in scripts.iter() { if let Some(rbx_dom_weak::types::Variant::String(s)) = script.properties.get("Source") { if allowed.contains(s) { println!("pass");