mirror of
https://github.com/darkrenaissance/darkfi.git
synced 2026-04-28 03:00:18 -04:00
wallet: add PropertyStatus.EXPR
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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, "<embedded>".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, "<embedded>".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);
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user