generalize recursive_collect
This commit is contained in:
parent
81e4a201bd
commit
6efa811eb6
10
src/main.rs
10
src/main.rs
@ -48,13 +48,13 @@ 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 recursive_collect_superclass(objects: &mut std::vec::Vec<rbx_dom_weak::types::Ref>,dom: &rbx_dom_weak::WeakDom, instance: &rbx_dom_weak::Instance, superclass: &str){
|
||||||
for &referent in instance.children() {
|
for &referent in instance.children() {
|
||||||
if let Some(c) = dom.get_by_ref(referent) {
|
if let Some(c) = dom.get_by_ref(referent) {
|
||||||
if class_is_a(c.class.as_str(), "LuaSourceContainer") {
|
if class_is_a(c.class.as_str(), superclass) {
|
||||||
scripts.push(c.referent());//copy ref
|
objects.push(c.referent());//copy ref
|
||||||
}
|
}
|
||||||
recursive_collect_scripts(scripts,dom,c);
|
recursive_collect_superclass(objects,dom,c,superclass);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -89,7 +89,7 @@ fn get_full_name(dom:&rbx_dom_weak::WeakDom,instance:&rbx_dom_weak::Instance) ->
|
|||||||
|
|
||||||
fn get_script_refs(dom:&rbx_dom_weak::WeakDom) -> Vec<rbx_dom_weak::types::Ref>{
|
fn get_script_refs(dom:&rbx_dom_weak::WeakDom) -> Vec<rbx_dom_weak::types::Ref>{
|
||||||
let mut scripts = std::vec::Vec::new();
|
let mut scripts = std::vec::Vec::new();
|
||||||
recursive_collect_scripts(&mut scripts, dom, dom.root());
|
recursive_collect_superclass(&mut scripts, dom, dom.root(),"LuaSourceContainer");
|
||||||
scripts
|
scripts
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user