add more types to detach
This commit is contained in:
parent
fb796cda04
commit
b3d0e4f03c
1 changed files with 58 additions and 11 deletions
|
@ -19,7 +19,7 @@ use {
|
|||
sync::{Arc, RwLock},
|
||||
any::Any
|
||||
},
|
||||
super::{Context, ReprLeaf, ReprTreeExt, context::{TYPEID_vec, TYPEID_char, TYPEID_u64, TYPEID_edittree}}
|
||||
super::{Context, ReprLeaf, ReprTreeExt, context::{TYPEID_list, TYPEID_vec, TYPEID_char, TYPEID_u64, TYPEID_edittree}}
|
||||
};
|
||||
|
||||
//<<<<>>>><<>><><<>><<<*>>><<>><><<>><<<<>>>>
|
||||
|
@ -248,17 +248,64 @@ impl ReprTree {
|
|||
}
|
||||
|
||||
pub fn detach(&mut self, ctx: &Arc<RwLock<Context>>) {
|
||||
// eprintln!("DETACH {:?}", self.get_type());
|
||||
if let Some(leaf) = self.leaf.as_mut() {
|
||||
if self.type_tag == Context::parse(&ctx, "Char") {
|
||||
if self.type_tag ==
|
||||
TypeTerm::TypeID(TYPEID_edittree)
|
||||
{
|
||||
leaf.detach::< dyn SingletonView<
|
||||
Item = Arc<RwLock< crate::edit_tree::EditTree >>
|
||||
> >();
|
||||
}
|
||||
else if self.type_tag ==
|
||||
TypeTerm::TypeID(TYPEID_char)
|
||||
{
|
||||
leaf.detach::< dyn SingletonView<Item = char> >();
|
||||
}
|
||||
if self.type_tag == Context::parse(&ctx, "<Vec Char>") {
|
||||
else if self.type_tag == TypeTerm::TypeID(TYPEID_u64)
|
||||
{
|
||||
leaf.detach::< dyn SingletonView<Item = u64> >();
|
||||
}
|
||||
else if self.type_tag == TypeTerm::App(vec![
|
||||
TypeTerm::TypeID(TYPEID_vec),
|
||||
TypeTerm::TypeID(TYPEID_edittree),
|
||||
]) {
|
||||
leaf.detach_vec::<
|
||||
Arc<RwLock< crate::edit_tree::EditTree >>
|
||||
>();
|
||||
}
|
||||
else if self.type_tag == TypeTerm::App(vec![
|
||||
TypeTerm::TypeID(TYPEID_vec),
|
||||
TypeTerm::TypeID(TYPEID_char),
|
||||
]) {
|
||||
leaf.detach_vec::< char >();
|
||||
}
|
||||
if self.type_tag == Context::parse(&ctx, "<List Char>") {
|
||||
else if self.type_tag == TypeTerm::App(vec![
|
||||
TypeTerm::TypeID(TYPEID_vec),
|
||||
TypeTerm::TypeID(TYPEID_u64),
|
||||
]) {
|
||||
leaf.detach_vec::< u64 >();
|
||||
}
|
||||
else if self.type_tag == TypeTerm::App(vec![
|
||||
TypeTerm::TypeID(TYPEID_list),
|
||||
TypeTerm::TypeID(TYPEID_edittree),
|
||||
]) {
|
||||
leaf.detach::< dyn ListView<Arc<RwLock<crate::edit_tree::EditTree>>> >();
|
||||
}
|
||||
else if self.type_tag == TypeTerm::App(vec![
|
||||
TypeTerm::TypeID(TYPEID_list),
|
||||
TypeTerm::TypeID(TYPEID_char),
|
||||
]) {
|
||||
leaf.detach::< dyn ListView<char> >();
|
||||
}
|
||||
else if self.type_tag == TypeTerm::App(vec![
|
||||
TypeTerm::TypeID(TYPEID_list),
|
||||
TypeTerm::TypeID(TYPEID_u64),
|
||||
]) {
|
||||
leaf.detach::< dyn ListView<u64> >();
|
||||
}
|
||||
else {
|
||||
eprintln!("cant detach type {}", ctx.read().unwrap().type_term_to_str(&self.type_tag));
|
||||
}
|
||||
}
|
||||
|
||||
for (t,b) in self.branches.iter_mut() {
|
||||
|
|
Loading…
Reference in a new issue