fix warnings
This commit is contained in:
parent
5ec4773eb1
commit
c6717e0e75
20 changed files with 87 additions and 147 deletions
|
@ -31,28 +31,28 @@ interface (Sequence ℕ) 0 1");
|
||||||
|
|
||||||
let mut f0 = unsafe { File::from_raw_fd(0) };
|
let mut f0 = unsafe { File::from_raw_fd(0) };
|
||||||
eprintln!("
|
eprintln!("
|
||||||
> 0: n
|
>0: n
|
||||||
( ℕ )
|
( ℕ )
|
||||||
( MachineInt )
|
( MachineInt )
|
||||||
( MachineWord )
|
( MachineWord )
|
||||||
( Pipe Shot MachineWord )
|
( Stream MachineSyllab )
|
||||||
");
|
");
|
||||||
|
|
||||||
let mut f1 = unsafe { File::from_raw_fd(1) };
|
let mut f1 = unsafe { File::from_raw_fd(1) };
|
||||||
eprintln!("
|
eprintln!("
|
||||||
< 1: n'th fibonacci number
|
<1: n'th fibonacci number
|
||||||
( ℕ )
|
( ℕ )
|
||||||
( MachineInt )
|
( MachineInt )
|
||||||
( MachineWord )
|
( MachineWord )
|
||||||
( Pipe Shot MachineWord )
|
( Stream MachineSyllab )
|
||||||
");
|
");
|
||||||
|
|
||||||
nested::magic_header();
|
nested::magic_header();
|
||||||
|
|
||||||
let mut bytes = [0 as u8; 8];
|
let mut bytes = [0 as u8; 8];
|
||||||
f0.read_exact(&mut bytes);
|
f0.read_exact(&mut bytes).expect("");
|
||||||
let n = u64::from_le_bytes(bytes);
|
let n = u64::from_le_bytes(bytes);
|
||||||
bytes = fib(n).to_le_bytes();
|
bytes = fib(n).to_le_bytes();
|
||||||
f1.write(&bytes);
|
f1.write(&bytes).expect("");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
|
|
||||||
use std::{
|
use std::{
|
||||||
fs::File,
|
fs::File,
|
||||||
io::{Read, Write},
|
io::{Read},
|
||||||
os::unix::io::FromRawFd
|
os::unix::io::FromRawFd
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ fn main() {
|
||||||
nested::magic_header();
|
nested::magic_header();
|
||||||
|
|
||||||
let mut bytes = [0 as u8; 8];
|
let mut bytes = [0 as u8; 8];
|
||||||
f0.read_exact(&mut bytes);
|
f0.read_exact(&mut bytes).expect("");
|
||||||
println!("{}", u64::from_le_bytes(bytes));
|
println!("{}", u64::from_le_bytes(bytes));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,18 +1,11 @@
|
||||||
|
|
||||||
use {
|
use {
|
||||||
std::sync::{Arc, RwLock},
|
|
||||||
nested::{
|
nested::{
|
||||||
core::{
|
core::{
|
||||||
View,
|
|
||||||
ViewPort,
|
ViewPort,
|
||||||
Observer,
|
|
||||||
ObserverBroadcast,
|
|
||||||
InnerViewPort,
|
|
||||||
OuterViewPort,
|
|
||||||
TypeTerm,
|
|
||||||
TypeDict
|
TypeDict
|
||||||
},
|
},
|
||||||
sequence::{SequenceView, VecBuffer},
|
sequence::{VecBuffer},
|
||||||
integer::{RadixProjection}
|
integer::{RadixProjection}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -102,7 +95,7 @@ async fn main() {
|
||||||
|
|
||||||
let mut src_digits = VecBuffer::<usize>::new(src_digits_port.inner());
|
let mut src_digits = VecBuffer::<usize>::new(src_digits_port.inner());
|
||||||
|
|
||||||
let proj = RadixProjection::new(
|
let _proj = RadixProjection::new(
|
||||||
src_radix,
|
src_radix,
|
||||||
dst_radix,
|
dst_radix,
|
||||||
src_digits_port.outer().to_sequence(),
|
src_digits_port.outer().to_sequence(),
|
||||||
|
@ -110,10 +103,8 @@ async fn main() {
|
||||||
);
|
);
|
||||||
|
|
||||||
// output dst digits
|
// output dst digits
|
||||||
let writer = {
|
let _writer = {
|
||||||
use std::{
|
use std::{
|
||||||
fs::File,
|
|
||||||
io::{Read, Write},
|
|
||||||
os::unix::io::FromRawFd
|
os::unix::io::FromRawFd
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -123,8 +114,6 @@ async fn main() {
|
||||||
// start reading src digits
|
// start reading src digits
|
||||||
{
|
{
|
||||||
use async_std::{
|
use async_std::{
|
||||||
fs::File,
|
|
||||||
io::{Read, Write},
|
|
||||||
os::unix::io::FromRawFd
|
os::unix::io::FromRawFd
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -46,15 +46,15 @@ $1: radix
|
||||||
args.next().expect("Arg $0 missing!");
|
args.next().expect("Arg $0 missing!");
|
||||||
|
|
||||||
let radix_str = args.next().expect("Arg $1 required!");
|
let radix_str = args.next().expect("Arg $1 required!");
|
||||||
|
|
||||||
let radix = u32::from_str_radix(&radix_str, 10).expect("could not parse radix");
|
let radix = u32::from_str_radix(&radix_str, 10).expect("could not parse radix");
|
||||||
if radix > 16 {
|
if radix > 16 {
|
||||||
panic!("invalid radix! (radix<=16 required)");
|
panic!("invalid radix! (radix<=16 required)");
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut chars = Vec::new();
|
let mut chars = Vec::new();
|
||||||
f0.read_to_end(&mut chars);
|
f0.read_to_end(&mut chars).expect("");
|
||||||
chars.retain(|c| (*c as char).is_alphanumeric());
|
chars.retain(|c| (*c as char).is_alphanumeric());
|
||||||
f1.write(&u64::from_str_radix(&String::from_utf8_lossy(&chars), radix).unwrap().to_le_bytes());
|
f1.write(&u64::from_str_radix(&String::from_utf8_lossy(&chars), radix).unwrap().to_le_bytes()).expect("");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,11 @@
|
||||||
use {
|
use {
|
||||||
std::{
|
std::{
|
||||||
collections::HashMap,
|
collections::HashMap,
|
||||||
sync::{Arc, RwLock},
|
sync::{Arc, RwLock}
|
||||||
any::Any
|
|
||||||
},
|
},
|
||||||
crate::{
|
crate::{
|
||||||
core::{
|
core::{
|
||||||
type_term::{
|
type_term::{
|
||||||
TypeID,
|
|
||||||
TypeTerm,
|
TypeTerm,
|
||||||
TypeDict
|
TypeDict
|
||||||
},
|
},
|
||||||
|
@ -194,8 +192,8 @@ impl Object {
|
||||||
// replace with higher-level type in which self is a repr branch
|
// replace with higher-level type in which self is a repr branch
|
||||||
pub fn epi_cast<'a>(
|
pub fn epi_cast<'a>(
|
||||||
&self,
|
&self,
|
||||||
type_ladder: impl Iterator<Item = TypeTerm>,
|
_type_ladder: impl Iterator<Item = TypeTerm>,
|
||||||
morphism_constructors: &HashMap<MorphismType, Box<dyn Fn(Object) -> Object>>
|
_morphism_constructors: &HashMap<MorphismType, Box<dyn Fn(Object) -> Object>>
|
||||||
) {
|
) {
|
||||||
// todo
|
// todo
|
||||||
}
|
}
|
||||||
|
@ -288,7 +286,6 @@ impl Context {
|
||||||
type_tag,
|
type_tag,
|
||||||
repr: Arc::new(RwLock::new(ReprTree::new()))
|
repr: Arc::new(RwLock::new(ReprTree::new()))
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -341,8 +338,8 @@ impl Context {
|
||||||
typename: &str
|
typename: &str
|
||||||
) {
|
) {
|
||||||
let dst_type = self.type_dict.type_term_from_str(typename).unwrap();
|
let dst_type = self.type_dict.type_term_from_str(typename).unwrap();
|
||||||
let mut old_obj = self.objects.get(&name.to_string()).unwrap().clone();
|
let old_obj = self.objects.get(&name.to_string()).unwrap().clone();
|
||||||
let mut new_obj =
|
let new_obj =
|
||||||
if let Some(ctor) = self.morphism_constructors.get(
|
if let Some(ctor) = self.morphism_constructors.get(
|
||||||
&MorphismType {
|
&MorphismType {
|
||||||
mode: MorphismMode::Epi,
|
mode: MorphismMode::Epi,
|
||||||
|
@ -387,29 +384,6 @@ impl Context {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
pub fn _default_repr<'a>(
|
|
||||||
&mut self,
|
|
||||||
name: &String,
|
|
||||||
type_ladder: impl Iterator<Item = &'a str>
|
|
||||||
) -> AnyOuterViewPort {
|
|
||||||
for (i, type_term) in type_ladder.rev().enumerate() {
|
|
||||||
match i {
|
|
||||||
0 => {
|
|
||||||
if let Some(constructor) = self.default_constructors.get(&type_term) {
|
|
||||||
self.add_repr()
|
|
||||||
} else {
|
|
||||||
panic!("cannot find matching default constructor!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_n => {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//<<<<>>>><<>><><<>><<<*>>><<>><><<>><<<<>>>>
|
//<<<<>>>><<>><><<>><<<*>>><<>><><<>><<<<>>>>
|
||||||
|
|
|
@ -1,10 +1,6 @@
|
||||||
use {
|
use {
|
||||||
std::{
|
std::{
|
||||||
sync::Arc,
|
collections::HashMap
|
||||||
any::Any,
|
|
||||||
ops::Deref,
|
|
||||||
collections::HashMap,
|
|
||||||
iter::Peekable
|
|
||||||
},
|
},
|
||||||
crate::{
|
crate::{
|
||||||
bimap::Bimap,
|
bimap::Bimap,
|
||||||
|
@ -32,7 +28,7 @@ impl TypeTerm {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn arg(&mut self, t: TypeTerm) -> &mut Self {
|
pub fn arg(&mut self, t: TypeTerm) -> &mut Self {
|
||||||
if let TypeTerm::Type{ id, args } = self {
|
if let TypeTerm::Type{ id: _, args } = self {
|
||||||
args.push(t);
|
args.push(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,7 +50,7 @@ impl TypeTerm {
|
||||||
")" => {
|
")" => {
|
||||||
let t = term_stack.pop().unwrap();
|
let t = term_stack.pop().unwrap();
|
||||||
if term_stack.len() > 0 {
|
if term_stack.len() > 0 {
|
||||||
let mut f = term_stack.last_mut().unwrap();
|
let f = term_stack.last_mut().unwrap();
|
||||||
if let Some(f) = f {
|
if let Some(f) = f {
|
||||||
f.arg(t.unwrap());
|
f.arg(t.unwrap());
|
||||||
} else {
|
} else {
|
||||||
|
@ -65,7 +61,7 @@ impl TypeTerm {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
atom => {
|
atom => {
|
||||||
let mut f = term_stack.last_mut().unwrap();
|
let f = term_stack.last_mut().unwrap();
|
||||||
|
|
||||||
match f {
|
match f {
|
||||||
Some(f) =>
|
Some(f) =>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use {
|
use {
|
||||||
std::sync::{Arc, RwLock},
|
std::sync::{Arc, RwLock},
|
||||||
crate::{
|
crate::{
|
||||||
core::{InnerViewPort, OuterViewPort, ObserverBroadcast},
|
core::{InnerViewPort, OuterViewPort},
|
||||||
sequence::{SequenceView, VecBuffer},
|
sequence::{SequenceView, VecBuffer},
|
||||||
projection::ProjectionHelper
|
projection::ProjectionHelper
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ pub struct Add {
|
||||||
a: Arc<dyn SequenceView<Item = usize>>, // PosInt, Little Endian
|
a: Arc<dyn SequenceView<Item = usize>>, // PosInt, Little Endian
|
||||||
b: Arc<dyn SequenceView<Item = usize>>, // PosInt, Little Endian
|
b: Arc<dyn SequenceView<Item = usize>>, // PosInt, Little Endian
|
||||||
c: VecBuffer<usize>,
|
c: VecBuffer<usize>,
|
||||||
proj_helper: ProjectionHelper<Self>
|
_proj_helper: ProjectionHelper<Self>
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Add {
|
impl Add {
|
||||||
|
@ -60,7 +60,7 @@ impl Add {
|
||||||
a: proj_helper.new_sequence_arg(a, |s: &mut Self, _digit_idx| s.update()),
|
a: proj_helper.new_sequence_arg(a, |s: &mut Self, _digit_idx| s.update()),
|
||||||
b: proj_helper.new_sequence_arg(b, |s: &mut Self, _digit_idx| s.update()),
|
b: proj_helper.new_sequence_arg(b, |s: &mut Self, _digit_idx| s.update()),
|
||||||
c: VecBuffer::new(c),
|
c: VecBuffer::new(c),
|
||||||
proj_helper
|
_proj_helper: proj_helper
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
add
|
add
|
||||||
|
|
|
@ -2,10 +2,7 @@ use {
|
||||||
std::sync::{Arc, RwLock},
|
std::sync::{Arc, RwLock},
|
||||||
crate::{
|
crate::{
|
||||||
core::{
|
core::{
|
||||||
View,
|
|
||||||
ViewPort,
|
|
||||||
Observer,
|
Observer,
|
||||||
ObserverBroadcast,
|
|
||||||
InnerViewPort,
|
InnerViewPort,
|
||||||
OuterViewPort
|
OuterViewPort
|
||||||
},
|
},
|
||||||
|
@ -63,7 +60,7 @@ impl RadixProjection {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update_dst_digit(&mut self, idx: usize) {
|
fn _update_dst_digit(&mut self, _idx: usize) {
|
||||||
/*
|
/*
|
||||||
let v = 0; // calculate new digit value
|
let v = 0; // calculate new digit value
|
||||||
|
|
||||||
|
@ -85,7 +82,7 @@ impl Observer<dyn SequenceView<Item = usize>> for RadixProjection {
|
||||||
self.src_digits = view;
|
self.src_digits = view;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn notify(&self, idx: &usize) {
|
fn notify(&self, _idx: &usize) {
|
||||||
// todo:
|
// todo:
|
||||||
// src digit i changed.
|
// src digit i changed.
|
||||||
// which dst-digits does it affect?
|
// which dst-digits does it affect?
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
use {
|
use {
|
||||||
std::{
|
std::{
|
||||||
sync::{Arc},
|
sync::{Arc}
|
||||||
collections::HashSet
|
|
||||||
},
|
},
|
||||||
std::sync::RwLock,
|
std::sync::RwLock,
|
||||||
cgmath::Point2,
|
cgmath::Point2,
|
||||||
|
@ -9,7 +8,7 @@ use {
|
||||||
core::{ViewPort, Observer, ObserverExt, ObserverBroadcast, InnerViewPort, OuterViewPort},
|
core::{ViewPort, Observer, ObserverExt, ObserverBroadcast, InnerViewPort, OuterViewPort},
|
||||||
index::{ImplIndexView},
|
index::{ImplIndexView},
|
||||||
terminal::{TerminalAtom, TerminalView, TerminalStyle},
|
terminal::{TerminalAtom, TerminalView, TerminalStyle},
|
||||||
projection::{ProjectionHelper, ProjectionArg}
|
projection::{ProjectionHelper}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
#![feature(trait_alias)]
|
#![feature(trait_alias)]
|
||||||
#![feature(non_ascii_idents)]
|
|
||||||
|
|
||||||
pub mod core;
|
pub mod core;
|
||||||
pub mod projection;
|
pub mod projection;
|
||||||
|
|
|
@ -9,7 +9,16 @@ use {
|
||||||
},
|
},
|
||||||
std::sync::RwLock,
|
std::sync::RwLock,
|
||||||
crate::{
|
crate::{
|
||||||
core::{View, Observer, ObserverExt, OuterViewPort, channel::{channel, ChannelData, ChannelSender, ChannelReceiver}},
|
core::{
|
||||||
|
View,
|
||||||
|
Observer, ObserverExt,
|
||||||
|
OuterViewPort,
|
||||||
|
channel::{
|
||||||
|
channel,
|
||||||
|
ChannelData,
|
||||||
|
ChannelSender
|
||||||
|
}
|
||||||
|
},
|
||||||
singleton::{SingletonView},
|
singleton::{SingletonView},
|
||||||
sequence::{SequenceView},
|
sequence::{SequenceView},
|
||||||
index::{IndexView}
|
index::{IndexView}
|
||||||
|
@ -90,14 +99,7 @@ impl<P: Send + Sync + 'static> ProjectionHelper<P> {
|
||||||
async_std::task::spawn(async move {
|
async_std::task::spawn(async move {
|
||||||
while let Some(msg) = rx.next().await {
|
while let Some(msg) = rx.next().await {
|
||||||
if let Some(proj) = proj.read().unwrap().upgrade() {
|
if let Some(proj) = proj.read().unwrap().upgrade() {
|
||||||
loop {
|
notify(&mut *proj.write().unwrap(), &msg);
|
||||||
if let Ok(p) = proj.try_write().as_mut() {
|
|
||||||
notify(&mut *p, &msg);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
async_std::task::yield_now();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
use {
|
use {
|
||||||
async_std::stream::StreamExt,
|
async_std::stream::StreamExt,
|
||||||
std::{
|
std::{
|
||||||
sync::{Arc, Weak},
|
sync::{Arc},
|
||||||
collections::{HashMap, HashSet}
|
collections::{HashMap, HashSet}
|
||||||
},
|
},
|
||||||
std::sync::RwLock,
|
std::sync::RwLock,
|
||||||
crate::{
|
crate::{
|
||||||
core::{
|
core::{
|
||||||
View, Observer, ObserverExt, ObserverBroadcast,
|
View, Observer, ObserverBroadcast, ObserverExt,
|
||||||
ViewPort, InnerViewPort, OuterViewPort,
|
ViewPort, InnerViewPort, OuterViewPort,
|
||||||
channel::{ChannelSender, ChannelReceiver}
|
channel::{ChannelSender, ChannelReceiver}
|
||||||
},
|
},
|
||||||
|
@ -34,7 +34,7 @@ where V1: SequenceView<Item = OuterViewPort<V2>> + ?Sized + 'static,
|
||||||
top: Arc<RwLock<TopObserver<V1, V2>>>,
|
top: Arc<RwLock<TopObserver<V1, V2>>>,
|
||||||
chunks: HashMap<usize, Arc<RwLock<BotObserver<V2>>>>,
|
chunks: HashMap<usize, Arc<RwLock<BotObserver<V2>>>>,
|
||||||
|
|
||||||
cast: Arc<RwLock<ObserverBroadcast<dyn SequenceView<Item = V2::Item>>>>
|
_cast: Arc<RwLock<ObserverBroadcast<dyn SequenceView<Item = V2::Item>>>>
|
||||||
}
|
}
|
||||||
|
|
||||||
struct TopObserver<V1, V2>
|
struct TopObserver<V1, V2>
|
||||||
|
@ -130,7 +130,7 @@ where V1: SequenceView<Item = OuterViewPort<V2>> + ?Sized + 'static,
|
||||||
length: 0,
|
length: 0,
|
||||||
top: top_obs.clone(),
|
top: top_obs.clone(),
|
||||||
chunks: HashMap::new(),
|
chunks: HashMap::new(),
|
||||||
cast: out_port.get_broadcast()
|
_cast: out_port.get_broadcast()
|
||||||
}));
|
}));
|
||||||
|
|
||||||
let f = flat.clone();
|
let f = flat.clone();
|
||||||
|
|
|
@ -5,7 +5,7 @@ use {
|
||||||
sequence::{SequenceView},
|
sequence::{SequenceView},
|
||||||
core::{
|
core::{
|
||||||
Observer, ObserverExt, ObserverBroadcast,
|
Observer, ObserverExt, ObserverBroadcast,
|
||||||
View, ViewPort, InnerViewPort, OuterViewPort
|
View, ViewPort, OuterViewPort
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -7,7 +7,7 @@ use {
|
||||||
std::sync::RwLock,
|
std::sync::RwLock,
|
||||||
async_std::{
|
async_std::{
|
||||||
io::{Read, ReadExt},
|
io::{Read, ReadExt},
|
||||||
stream::{Stream, StreamExt}
|
stream::{StreamExt}
|
||||||
},
|
},
|
||||||
serde::{Serialize, Deserialize, de::DeserializeOwned},
|
serde::{Serialize, Deserialize, de::DeserializeOwned},
|
||||||
crate::{
|
crate::{
|
||||||
|
@ -101,24 +101,24 @@ where T: Clone + Serialize + Send + Sync + 'static,
|
||||||
self.data = view;
|
self.data = view;
|
||||||
let mut out = self.out.write().unwrap();
|
let mut out = self.out.write().unwrap();
|
||||||
|
|
||||||
out.write(&bincode::serialized_size(&VecDiff::<T>::Clear).unwrap().to_le_bytes());
|
out.write(&bincode::serialized_size(&VecDiff::<T>::Clear).unwrap().to_le_bytes()).expect("");
|
||||||
out.write(&bincode::serialize(&VecDiff::<T>::Clear).unwrap());
|
out.write(&bincode::serialize(&VecDiff::<T>::Clear).unwrap()).expect("");
|
||||||
|
|
||||||
if let Some(data) = self.data.as_ref() {
|
if let Some(data) = self.data.as_ref() {
|
||||||
for x in data.read().unwrap().iter() {
|
for x in data.read().unwrap().iter() {
|
||||||
out.write(&bincode::serialized_size(&VecDiff::Push(x)).unwrap().to_le_bytes());
|
out.write(&bincode::serialized_size(&VecDiff::Push(x)).unwrap().to_le_bytes()).expect("");
|
||||||
out.write(&bincode::serialize(&VecDiff::Push(x)).unwrap());
|
out.write(&bincode::serialize(&VecDiff::Push(x)).unwrap()).expect("");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
out.flush();
|
out.flush().expect("");
|
||||||
}
|
}
|
||||||
|
|
||||||
fn notify(&self, diff: &VecDiff<T>) {
|
fn notify(&self, diff: &VecDiff<T>) {
|
||||||
let mut out = self.out.write().unwrap();
|
let mut out = self.out.write().unwrap();
|
||||||
out.write(&bincode::serialized_size(diff).unwrap().to_le_bytes());
|
out.write(&bincode::serialized_size(diff).unwrap().to_le_bytes()).expect("");
|
||||||
out.write(&bincode::serialize(diff).unwrap());
|
out.write(&bincode::serialize(diff).unwrap()).expect("");
|
||||||
out.flush();
|
out.flush().expect("");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,23 +129,23 @@ where T: Clone + Serialize + Send + Sync + 'static,
|
||||||
fn reset(&mut self, view: Option<Arc<RwLock<Vec<T>>>>) {
|
fn reset(&mut self, view: Option<Arc<RwLock<Vec<T>>>>) {
|
||||||
self.data = view;
|
self.data = view;
|
||||||
|
|
||||||
self.out.write().unwrap().write(&serde_json::to_string(&VecDiff::<T>::Clear).unwrap().as_bytes());
|
self.out.write().unwrap().write(&serde_json::to_string(&VecDiff::<T>::Clear).unwrap().as_bytes()).expect("");
|
||||||
self.out.write().unwrap().write(b"\n");
|
self.out.write().unwrap().write(b"\n").expect("");
|
||||||
|
|
||||||
if let Some(data) = self.data.as_ref() {
|
if let Some(data) = self.data.as_ref() {
|
||||||
for x in data.read().unwrap().iter() {
|
for x in data.read().unwrap().iter() {
|
||||||
self.out.write().unwrap().write(&serde_json::to_string(&VecDiff::Push(x)).unwrap().as_bytes());
|
self.out.write().unwrap().write(&serde_json::to_string(&VecDiff::Push(x)).unwrap().as_bytes()).expect("");
|
||||||
self.out.write().unwrap().write(b"\n");
|
self.out.write().unwrap().write(b"\n").expect("");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self.out.write().unwrap().flush();
|
self.out.write().unwrap().flush().expect("");
|
||||||
}
|
}
|
||||||
|
|
||||||
fn notify(&self, diff: &VecDiff<T>) {
|
fn notify(&self, diff: &VecDiff<T>) {
|
||||||
self.out.write().unwrap().write(serde_json::to_string(diff).unwrap().as_bytes());
|
self.out.write().unwrap().write(serde_json::to_string(diff).unwrap().as_bytes()).expect("");
|
||||||
self.out.write().unwrap().write(b"\n");
|
self.out.write().unwrap().write(b"\n").expect("");
|
||||||
self.out.write().unwrap().flush();
|
self.out.write().unwrap().flush().expect("");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,21 +52,14 @@ where V::Item: Default{
|
||||||
|
|
||||||
//<<<<>>>><<>><><<>><<<*>>><<>><><<>><<<<>>>>
|
//<<<<>>>><<>><><<>><<<*>>><<>><><<>><<<<>>>>
|
||||||
/*
|
/*
|
||||||
pub trait ImplSingletonView : Send + Sync {
|
impl<T> OuterViewPort<dyn SingletonView<Item = T>> {
|
||||||
type Item;
|
pub fn get(&self) -> T {
|
||||||
|
self.get_view().unrwap().read().unwrap().get();
|
||||||
|
}
|
||||||
|
|
||||||
fn get(&self) -> Self::Item;
|
pub fn map<U: Send + Sync + 'static>(&self, f: impl Fn(T) -> U) -> OuterViewPort<dyn SingletonView<Item = U>> {
|
||||||
}
|
|
||||||
|
|
||||||
impl<V: ImplSingletonView> View for V {
|
|
||||||
type Msg = ();
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<V: ImplSingletonView> SingletonView for V {
|
|
||||||
type Item = V::Item;
|
|
||||||
|
|
||||||
fn get(&self) -> Self::Item {
|
|
||||||
(self as &V).get()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
@ -100,9 +100,7 @@ pub mod insert_view {
|
||||||
use {
|
use {
|
||||||
std::{
|
std::{
|
||||||
sync::Arc,
|
sync::Arc,
|
||||||
cmp::{min, max},
|
cmp::{min, max}
|
||||||
any::Any,
|
|
||||||
collections::HashSet
|
|
||||||
},
|
},
|
||||||
cgmath::Point2,
|
cgmath::Point2,
|
||||||
std::sync::RwLock,
|
std::sync::RwLock,
|
||||||
|
@ -113,7 +111,7 @@ pub mod insert_view {
|
||||||
singleton::{SingletonView},
|
singleton::{SingletonView},
|
||||||
sequence::{SequenceView},
|
sequence::{SequenceView},
|
||||||
index::{IndexView},
|
index::{IndexView},
|
||||||
projection::{ProjectionHelper, ProjectionArg},
|
projection::{ProjectionHelper},
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -144,7 +142,7 @@ pub mod insert_view {
|
||||||
if i < self.cur_pos {
|
if i < self.cur_pos {
|
||||||
TerminalAtom::from(data.get(&i)?)
|
TerminalAtom::from(data.get(&i)?)
|
||||||
} else if i == self.cur_pos {
|
} else if i == self.cur_pos {
|
||||||
TerminalAtom::new('|', TerminalStyle::fg_color((200, 0, 0)))
|
TerminalAtom::new('|', TerminalStyle::fg_color((0, 200, 0)))
|
||||||
} else {
|
} else {
|
||||||
TerminalAtom::from(data.get(&(i - 1))?)
|
TerminalAtom::from(data.get(&(i - 1))?)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
use {
|
use {
|
||||||
std::{
|
std::{
|
||||||
sync::{Arc, Weak},
|
sync::{Arc}
|
||||||
collections::HashMap
|
|
||||||
},
|
},
|
||||||
std::sync::RwLock,
|
std::sync::RwLock,
|
||||||
cgmath::Point2,
|
cgmath::Point2,
|
||||||
crate::{
|
crate::{
|
||||||
core::{InnerViewPort, OuterViewPort, Observer, ObserverExt, ObserverBroadcast},
|
core::{InnerViewPort, OuterViewPort, Observer, ObserverBroadcast},
|
||||||
index::{ImplIndexView},
|
index::{ImplIndexView},
|
||||||
terminal::{TerminalAtom, TerminalView},
|
terminal::{TerminalAtom, TerminalView},
|
||||||
projection::ProjectionHelper
|
projection::ProjectionHelper
|
||||||
|
|
|
@ -127,7 +127,8 @@ impl Observer<dyn TerminalView> for TermOutObserver {
|
||||||
if let Some(view) = view {
|
if let Some(view) = view {
|
||||||
for pos in view.area().unwrap_or(
|
for pos in view.area().unwrap_or(
|
||||||
GridWindowIterator::from(
|
GridWindowIterator::from(
|
||||||
Point2::new(0, 0) .. Point2::new(w as i16, h as i16)).collect()
|
Point2::new(0, 0) .. Point2::new(w as i16, h as i16)
|
||||||
|
).collect()
|
||||||
) {
|
) {
|
||||||
self.dirty_pos_tx.send(pos);
|
self.dirty_pos_tx.send(pos);
|
||||||
}
|
}
|
||||||
|
@ -148,7 +149,7 @@ pub struct TermOutWriter {
|
||||||
impl TermOutWriter {
|
impl TermOutWriter {
|
||||||
fn reset(&self) {
|
fn reset(&self) {
|
||||||
let mut out = self.out.write().unwrap();
|
let mut out = self.out.write().unwrap();
|
||||||
write!(out, "{}", termion::clear::All).ok();
|
write!(out, "{}", termion::clear::All).ok();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ use {
|
||||||
std::{
|
std::{
|
||||||
fs::File,
|
fs::File,
|
||||||
os::unix::io::FromRawFd,
|
os::unix::io::FromRawFd,
|
||||||
io::{Read, Write, stdin, stdout}
|
io::{Read, Write, stdin}
|
||||||
},
|
},
|
||||||
nested::{
|
nested::{
|
||||||
terminal::{
|
terminal::{
|
||||||
|
@ -39,7 +39,7 @@ struct PerfAtom {
|
||||||
|
|
||||||
impl PerfAtom {
|
impl PerfAtom {
|
||||||
fn write_atom(&mut self, pos: Point2<i16>, atom: Option<TerminalAtom>) {
|
fn write_atom(&mut self, pos: Point2<i16>, atom: Option<TerminalAtom>) {
|
||||||
self.out.write(&bincode::serialize(&(pos, atom)).unwrap());
|
self.out.write(&bincode::serialize(&(pos, atom)).unwrap()).expect("");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
use {
|
use {
|
||||||
std::{
|
std::{
|
||||||
fs::File,
|
|
||||||
os::unix::io::FromRawFd,
|
|
||||||
io::{Read, Write, stdout}
|
io::{Read, Write, stdout}
|
||||||
},
|
},
|
||||||
nested::terminal::{
|
nested::terminal::{
|
||||||
|
@ -22,12 +20,7 @@ fn main() {
|
||||||
let mut cur_pos = Point2::<i16>::new(0, 0);
|
let mut cur_pos = Point2::<i16>::new(0, 0);
|
||||||
let mut cur_style = TerminalStyle::default();
|
let mut cur_style = TerminalStyle::default();
|
||||||
|
|
||||||
let mut f = unsafe { File::from_raw_fd(0) };
|
|
||||||
let mut bytes = [0 as u8; 0xe];
|
|
||||||
|
|
||||||
|
|
||||||
let mut input = std::io::stdin();
|
let mut input = std::io::stdin();
|
||||||
let mut buf = [0; 2048];
|
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
match bincode::deserialize_from::<_, (Point2<i16>, Option<TerminalAtom>)>(input.by_ref()) {
|
match bincode::deserialize_from::<_, (Point2<i16>, Option<TerminalAtom>)>(input.by_ref()) {
|
||||||
|
@ -39,12 +32,12 @@ fn main() {
|
||||||
if let Some(atom) = atom {
|
if let Some(atom) = atom {
|
||||||
if cur_style != atom.style {
|
if cur_style != atom.style {
|
||||||
cur_style = atom.style;
|
cur_style = atom.style;
|
||||||
write!(out, "{}", atom.style);
|
write!(out, "{}", atom.style).expect("");
|
||||||
}
|
}
|
||||||
|
|
||||||
write!(out, "{}", atom.c.unwrap_or(' '));
|
write!(out, "{}", atom.c.unwrap_or(' ')).expect("");
|
||||||
} else {
|
} else {
|
||||||
write!(out, "{} ", termion::style::Reset);
|
write!(out, "{} ", termion::style::Reset).expect("");
|
||||||
cur_style = TerminalStyle::default();
|
cur_style = TerminalStyle::default();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,11 +47,11 @@ fn main() {
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
match *err {
|
match *err {
|
||||||
bincode::ErrorKind::Io(io_error) => {
|
bincode::ErrorKind::Io(_io_error) => {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
err => {
|
err => {
|
||||||
eprintln!("deserialization error: {:?}\n{:?}", bytes, err);
|
eprintln!("deserialization error\n{:?}", err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue