add more types to detach

This commit is contained in:
Michael Sippel 2024-08-23 13:57:10 +02:00
parent fb796cda04
commit b3d0e4f03c
Signed by: senvas
GPG key ID: F96CF119C34B64A6

View file

@ -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}}
};
//<<<<>>>><<>><><<>><<<*>>><<>><><<>><<<<>>>>
@ -241,23 +241,70 @@ impl ReprTree {
leaf.attach_to(src_port);
self.leaf = Some(leaf);
} else {
} else {
self.leaf = Some(ReprLeaf::from_view(src_port));
}
}
}
}
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") {
leaf.detach::<dyn SingletonView<Item = char>>();
if self.type_tag ==
TypeTerm::TypeID(TYPEID_edittree)
{
leaf.detach::< dyn SingletonView<
Item = Arc<RwLock< crate::edit_tree::EditTree >>
> >();
}
if self.type_tag == Context::parse(&ctx, "<Vec Char>") {
leaf.detach_vec::<char>();
else if self.type_tag ==
TypeTerm::TypeID(TYPEID_char)
{
leaf.detach::< dyn SingletonView<Item = char> >();
}
if self.type_tag == Context::parse(&ctx, "<List Char>") {
leaf.detach::<dyn ListView<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 >();
}
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));
}
}