diff --git a/CHANGELOG.md b/CHANGELOG.md index 15bfad4..3fab754 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,5 @@ -0.2.3 (unreleased) -================= +0.3.0 (2019-09-13) +================== * Incompatible Change: Removed :wref and :ref definition labels in favor of proper $&&, $& and $\* reference handling. Added `wl:weaken` and `wl:set_ref` and diff --git a/Cargo.toml b/Cargo.toml index f6ff72b..76292ad 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "wlambda" -version = "0.2.2" +version = "0.3.0" authors = ["Weird Constructor "] license = "GPL-3.0-or-later" edition = "2018" diff --git a/examples/random_syntax_stuff.wl b/examples/random_syntax_stuff.wl index df917ed..6a3f494 100644 --- a/examples/random_syntax_stuff.wl +++ b/examples/random_syntax_stuff.wl @@ -23,12 +23,12 @@ $q" fefei fwof w " -feoofw@fe(fei) +feoofw@fe[fei] _d :foo :ba@fo_- :"fo @ [] \xFFAA { \u39f9e \t \r \n \" \0 \x00 } fe" -$e foobar [ 120 3 ] +$e foobar ( 120 3 ) panic "foobar" $t $true 3023 403.439 -32 +32 $n $nul $b"feofeo" while foo diff --git a/src/prelude.rs b/src/prelude.rs index 032764c..1730f48 100644 --- a/src/prelude.rs +++ b/src/prelude.rs @@ -1092,9 +1092,9 @@ pub fn create_wlamba_prelude() -> GlobalEnvRef { Ok(VVal::new_byt( s.chars() .map(|c| - match c { '0'..='9' => ( 9 - (('9' as u8) - (c as u8))) as i16, - 'a'..='f' => (15 - (('f' as u8) - (c as u8))) as i16, - 'A'..='F' => (15 - (('F' as u8) - (c as u8))) as i16, + match c { '0'..='9' => ( 9 - (b'9' - (c as u8))) as i16, + 'a'..='f' => (15 - (b'f' - (c as u8))) as i16, + 'A'..='F' => (15 - (b'F' - (c as u8))) as i16, _ => -1 }) .fold((256, out), |(last, mut out), c: i16| if c == -1 { (last, out) } diff --git a/src/threads.rs b/src/threads.rs index fdaf263..130e32b 100644 --- a/src/threads.rs +++ b/src/threads.rs @@ -248,10 +248,13 @@ enum RecvState { Return, } +type RecvData = (RecvState, String, Vec, bool, VecDeque<(String, Vec)>); +type RecvMutex = Mutex; + #[derive(Debug)] #[cfg(feature="rmp-serde")] pub struct Receiver { - mx: Mutex<(RecvState, String, Vec, bool, VecDeque<(String, Vec)>)>, + mx: RecvMutex, cv: Condvar, } @@ -271,7 +274,7 @@ impl Receiver { } #[cfg(feature="rmp-serde")] -fn mx_recv_error(mx: &mut (RecvState, String, Vec, bool, VecDeque<(String, Vec)>), s: &str) { +fn mx_recv_error(mx: &mut RecvData, s: &str) { mx.0 = RecvState::Return; mx.2 = VVal::err_msg(&format!("return value serialization error: {}", s)) @@ -281,7 +284,7 @@ fn mx_recv_error(mx: &mut (RecvState, String, Vec, bool, VecDeque<(String, V } #[cfg(feature="rmp-serde")] -fn mx_return(mx: &mut (RecvState, String, Vec, bool, VecDeque<(String, Vec)>), v: &VVal) { +fn mx_return(mx: &mut RecvData, v: &VVal) { mx.0 = RecvState::Return; match v.to_msgpack() { Ok(s) => { @@ -394,7 +397,7 @@ impl MsgHandle { std::mem::drop(mx); loop { let mut mx = r.mx.lock().unwrap(); - if mx.4.len() <= 0 { + if mx.4.is_empty() { mx.0 = RecvState::Open; break; } @@ -429,6 +432,12 @@ impl MsgHandle { } } +impl Default for MsgHandle { + fn default() -> Self { + Self::new() + } +} + #[cfg(test)] mod tests { #[cfg(feature="rmp-serde")] diff --git a/src/vval.rs b/src/vval.rs index 67279e2..dc12951 100644 --- a/src/vval.rs +++ b/src/vval.rs @@ -503,6 +503,7 @@ impl VValFun { /// assert_eq!( /// r.s(), "$[98,$]", "Userdata implementation works"); ///``` +#[allow(clippy::borrowed_box)] pub trait VValUserData { /// This method should return a human readable syntax representation /// of your VValUserData. @@ -961,7 +962,7 @@ impl VVal { VVal::Byt(s) => { if let VVal::Byt(s2) = v { s.borrow()[..] == s2.borrow()[..] } else { false } }, VVal::Usr(u) => { if let VVal::Usr(u2) = v { - u.eqv(u2) + u.eqv(&u2) } else { false } @@ -1129,6 +1130,8 @@ impl VVal { self } + pub fn is_empty(&self) -> bool { self.len() == 0 } + pub fn len(&self) -> usize { match self { VVal::Lst(l) => l.borrow().len(),