delete recursive function
This commit is contained in:
parent
206bb01c1a
commit
3f15d2f5a8
27
src/main.rs
27
src/main.rs
@ -11,15 +11,16 @@ fn class_is_a(class: &str, superclass: &str) -> bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
fn recursive_collect_scripts(scripts: &mut std::vec::Vec<rbx_dom_weak::types::Ref>,dom: &rbx_dom_weak::WeakDom, instance: &rbx_dom_weak::Instance){
|
fn get_scripts(dom:rbx_dom_weak::WeakDom) -> Vec<rbx_dom_weak::Instance>{
|
||||||
for &referent in instance.children() {
|
let mut scripts = std::vec::Vec::<rbx_dom_weak::Instance>::new();
|
||||||
if let Some(c) = dom.get_by_ref(referent) {
|
|
||||||
if class_is_a(c.class.as_str(), "LuaSourceContainer") {
|
let (_,mut instances) = dom.into_raw();
|
||||||
scripts.push(c.referent());//copy ref
|
for (_,instance) in instances.drain() {
|
||||||
}
|
if class_is_a(instance.class.as_str(), "LuaSourceContainer") {
|
||||||
recursive_collect_scripts(scripts,dom,c);
|
scripts.push(instance);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
scripts
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
@ -34,13 +35,13 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
allowed.insert(std::fs::read_to_string(entry?.path())?);
|
allowed.insert(std::fs::read_to_string(entry?.path())?);
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut scripts = std::vec::Vec::<rbx_dom_weak::types::Ref>::new();
|
|
||||||
recursive_collect_scripts(&mut scripts, &dom, dom.root());
|
|
||||||
|
|
||||||
//check scribb
|
|
||||||
let mut any_failed=false;
|
let scripts = get_scripts(dom);
|
||||||
for (i,&referent) in scripts.iter().enumerate() {
|
|
||||||
if let Some(script) = dom.get_by_ref(referent) {
|
//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 let Some(rbx_dom_weak::types::Variant::String(s)) = script.properties.get("Source") {
|
||||||
if allowed.contains(s) {
|
if allowed.contains(s) {
|
||||||
println!("pass");
|
println!("pass");
|
||||||
|
Loading…
Reference in New Issue
Block a user