diff --git a/bin/darkwallet/pydrk/api.py b/bin/darkwallet/pydrk/api.py index 2e6730399..d8e4d1dd2 100644 --- a/bin/darkwallet/pydrk/api.py +++ b/bin/darkwallet/pydrk/api.py @@ -113,6 +113,7 @@ class PropertyStatus: OK = 0 UNSET = 1 NULL = 2 + EXPR = 3 class ErrorCode: INVALID_SCENE_PATH = 1 @@ -429,6 +430,8 @@ class Api: match prop_status: case PropertyStatus.NULL: return None + case PropertyStatus.EXPR: + return None case PropertyStatus.UNSET | PropertyStatus.OK: return Api.read_prop_val(cur, prop_type) diff --git a/bin/darkwallet/src/gfx.rs b/bin/darkwallet/src/gfx.rs index f1155a46f..4046ef605 100644 --- a/bin/darkwallet/src/gfx.rs +++ b/bin/darkwallet/src/gfx.rs @@ -848,11 +848,15 @@ impl EventHandler for Stage { if self.last_draw_time.is_none() { return } + // Only allow 20 ms, process as much as we can during that time let elapsed_since_draw = self.last_draw_time.unwrap().elapsed(); + // We're long overdue a redraw. Exit for now if elapsed_since_draw > Duration::from_millis(20) { return } + // The next redraw must happen 20ms since its last one. + // Calculate how much time is remaining until then. let allowed_time = Duration::from_millis(20) - elapsed_since_draw; let deadline = Instant::now() + allowed_time; diff --git a/bin/darkwallet/src/main.rs b/bin/darkwallet/src/main.rs index 47392b560..1e5a7a38b 100644 --- a/bin/darkwallet/src/main.rs +++ b/bin/darkwallet/src/main.rs @@ -27,17 +27,17 @@ extern crate log; #[allow(unused_imports)] use log::LevelFilter; -fn init_zmq(scene_graph: SceneGraphPtr) { +fn start_zmq(scene_graph: SceneGraphPtr) { // detach thread let _ = thread::spawn(move || { let mut zmq_rpc = ZeroMQAdapter::new(scene_graph); - zmq_rpc.poll(); + zmq_rpc.run(); }); } fn main() { let scene_graph = Arc::new(Mutex::new(SceneGraph::new())); - init_zmq(scene_graph.clone()); + start_zmq(scene_graph.clone()); run_gui(scene_graph); } @@ -45,13 +45,18 @@ fn main() { use rustpython_vm::{self as pyvm, convert::ToPyObject}; fn main() { - let code_obj = pyvm::Interpreter::without_stdlib(Default::default()).enter(|vm| { + let module = pyvm::Interpreter::without_stdlib(Default::default()).enter(|vm| { let source = r#" -max(1 + lw/3, 4*10) + foo(2, True)"#; - let code_obj = vm - .compile(source, pyvm::compiler::Mode::Eval, "".to_owned()) - .map_err(|err| vm.new_syntax_error(&err, Some(source))).unwrap(); - code_obj +def foo(): + open("hihi", "w") + return 110 +#max(1 + lw/3, 4*10) + foo(2, True) +"#; + //let code_obj = vm + // .compile(source, pyvm::compiler::Mode::Exec, "".to_owned()) + // .map_err(|err| vm.new_syntax_error(&err, Some(source))).unwrap(); + //code_obj + pyvm::import::import_source(vm, "lain", source).unwrap() }); fn foo(x: u32, y: bool) -> u32 { @@ -70,7 +75,10 @@ max(1 + lw/3, 4*10) + foo(2, True)"#; let scope = pyvm::scope::Scope::new(None, globals); - vm.run_code_obj(code_obj, scope).unwrap() + let foo_fn = module.get_attr("foo", vm).unwrap(); + foo_fn.call((), vm).unwrap() + + //vm.run_code_obj(code_obj, scope).unwrap() }); println!("{:?}", res); } diff --git a/bin/darkwallet/src/net.rs b/bin/darkwallet/src/net.rs index b3f9b69ea..81c8dbd21 100644 --- a/bin/darkwallet/src/net.rs +++ b/bin/darkwallet/src/net.rs @@ -70,7 +70,7 @@ impl ZeroMQAdapter { Self { req_socket, slot_sender, slot_recvr: Some(slot_recvr), scene_graph } } - pub fn poll(&mut self) { + pub fn run(&mut self) { let rx = std::mem::take(&mut self.slot_recvr).unwrap(); let _ = thread::spawn(move || { let zmq_ctx = zmq::Context::new(); @@ -199,6 +199,8 @@ impl ZeroMQAdapter { default.encode(&mut reply).unwrap(); } else if val.is_null() { 2u8.encode(&mut reply).unwrap(); + } else if val.is_expr() { + 3u8.encode(&mut reply).unwrap(); } else { 0u8.encode(&mut reply).unwrap(); val.encode(&mut reply).unwrap();