fixed warnings in mers, but one warning in parse.rs will stay

This commit is contained in:
Dummi26 2023-04-14 17:10:54 +02:00
parent c526912ecb
commit dfd83fa581
4 changed files with 19 additions and 8 deletions

View File

@ -2,7 +2,7 @@ pub mod inlib;
pub mod path;
use std::{
collections::{HashMap, HashSet},
collections::HashMap,
io::{self, BufRead, BufReader, Read, Write},
path::PathBuf,
process::{Child, ChildStdin, ChildStdout, Command, Stdio},
@ -55,11 +55,24 @@ sending data: (all ints are encoded so that the most significant data is sent FI
#[derive(Debug)]
pub struct Lib {
name: String,
process: Child,
stdin: Arc<Mutex<ChildStdin>>,
stdout: Arc<Mutex<BufReader<ChildStdout>>>,
pub registered_fns: Vec<(String, Vec<VType>, VType)>,
}
impl Drop for Lib {
fn drop(&mut self) {
if self.process.try_wait().is_err() {
if let Err(e) = self.process.kill() {
eprint!(
"Warn: tried to kill lib process for library \"{}\", but failed: {e:?}",
self.name
);
}
}
}
}
impl Lib {
pub fn launch(
mut exec: Command,
@ -131,6 +144,7 @@ impl Lib {
}
writeln!(stdin, "init_finished").unwrap();
Ok(Self {
name: name.to_string(),
process: handle,
stdin: Arc::new(Mutex::new(stdin)),
stdout: Arc::new(Mutex::new(stdout)),

View File

@ -1,8 +1,4 @@
use std::{
fs,
sync::{Arc, Mutex},
time::Instant,
};
use std::{fs, sync::Arc, time::Instant};
use notify::Watcher as FsWatcher;
@ -10,6 +6,8 @@ pub mod libs;
pub mod parse;
pub mod script;
// necessary because the lib target in Cargo.toml also points here. TODO: update Cargo.toml to have a lib target that is separate from the bin one (=> doesn't point to main)
#[allow(unused)]
fn main() {
let args: Vec<_> = std::env::args().skip(1).collect();
let path = std::env::args().nth(1).unwrap();

View File

@ -8,7 +8,7 @@ use std::{
use crate::libs;
use self::to_runnable::{GInfo, ToRunnableError};
use self::to_runnable::ToRunnableError;
use super::{
builtins::BuiltinFunction,

View File

@ -2,4 +2,3 @@ pub mod block;
pub mod builtins;
pub mod val_data;
pub mod val_type;
pub mod value;