Skip to content

Commit

Permalink
Incremental improvements in the web server/client
Browse files Browse the repository at this point in the history
  * Begin support for parsing flexbuffers in the client, just the
  initial addition of the flexbuffer parser.

  * Begin support for invoking verbs from the client.
  • Loading branch information
rdaum committed Aug 31, 2024
1 parent 440d244 commit 4876d3d
Show file tree
Hide file tree
Showing 16 changed files with 1,513 additions and 8 deletions.
6 changes: 3 additions & 3 deletions crates/daemon/src/rpc_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ use moor_values::model::{Named, ObjectRef, PropFlag, ValSet, VerbFlag};
use moor_values::tasks::SchedulerError::CommandExecutionError;
use moor_values::tasks::{CommandError, NarrativeEvent, SchedulerError, TaskId};
use moor_values::util::parse_into_words;
use moor_values::var::Symbol;
use moor_values::var::v_objid;
use moor_values::var::Variant;
use moor_values::var::{v_objid, v_string};
use moor_values::var::{v_str, Symbol};
use moor_values::var::{Objid, Var};
use moor_values::SYSTEM_OBJECT;
use rpc_common::RpcResponse::{LoginResult, NewConnection};
Expand Down Expand Up @@ -604,7 +604,7 @@ impl RpcServer {
connection,
ObjectRef::Id(SYSTEM_OBJECT),
Symbol::mk("do_login_command"),
args.iter().map(|s| v_string(s.clone())).collect(),
args.iter().map(|s| v_str(&s)).collect(),

Check warning on line 607 in crates/daemon/src/rpc_server.rs

View workflow job for this annotation

GitHub Actions / clippy

this expression creates a reference which is immediately dereferenced by the compiler

warning: this expression creates a reference which is immediately dereferenced by the compiler --> crates/daemon/src/rpc_server.rs:607:39 | 607 | args.iter().map(|s| v_str(&s)).collect(), | ^^ help: change this to: `s` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow = note: `#[warn(clippy::needless_borrow)]` on by default
args.join(" "),
SYSTEM_OBJECT,
session,
Expand Down
28 changes: 28 additions & 0 deletions crates/web-host/src/client/flexbuffers/bit-width-util.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { BitWidth } from './bit-width.js';
export function toByteWidth(bitWidth) {
return 1 << bitWidth;
}
export function iwidth(value) {
if (value >= -128 && value <= 127) return BitWidth.WIDTH8;
if (value >= -32768 && value <= 32767) return BitWidth.WIDTH16;
if (value >= -2147483648 && value <= 2147483647) return BitWidth.WIDTH32;
return BitWidth.WIDTH64;
}
export function fwidth(value) {
return value === Math.fround(value) ? BitWidth.WIDTH32 : BitWidth.WIDTH64;
}
export function uwidth(value) {
if (value <= 255) return BitWidth.WIDTH8;
if (value <= 65535) return BitWidth.WIDTH16;
if (value <= 4294967295) return BitWidth.WIDTH32;
return BitWidth.WIDTH64;
}
export function fromByteWidth(value) {
if (value === 1) return BitWidth.WIDTH8;
if (value === 2) return BitWidth.WIDTH16;
if (value === 4) return BitWidth.WIDTH32;
return BitWidth.WIDTH64;
}
export function paddingSize(bufSize, scalarSize) {
return ~bufSize + 1 & scalarSize - 1;
}
7 changes: 7 additions & 0 deletions crates/web-host/src/client/flexbuffers/bit-width.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export var BitWidth;
(function(BitWidth) {
BitWidth[BitWidth["WIDTH8"] = 0] = "WIDTH8";
BitWidth[BitWidth["WIDTH16"] = 1] = "WIDTH16";
BitWidth[BitWidth["WIDTH32"] = 2] = "WIDTH32";
BitWidth[BitWidth["WIDTH64"] = 3] = "WIDTH64";
})(BitWidth || (BitWidth = {}));
Loading

0 comments on commit 4876d3d

Please sign in to comment.