Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
afinch7 committed Mar 19, 2020
1 parent 97a0187 commit 1998d2c
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
4 changes: 2 additions & 2 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ rusty_v8 = "0.3.8"
serde_json = "1.0.48"
url = "2.1.1"
# dispatch json stuff
serde = { version = "1.0.102", features = ["derive"] }
serde_derive = "1.0.102"
serde = { version = "1.0.104", features = ["derive"] }
serde_derive = "1.0.104"
tokio = { version = "0.2.13", optional = true }

[[example]]
Expand Down
6 changes: 3 additions & 3 deletions core/dispatch_json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ trait InternalError {
/// Error message as string value.
fn msg(&self) -> String;
/// Make InternalJsonError from this object
fn to_internal_error(&self) -> FinalJsonError {
fn to_final_json_error(&self) -> FinalJsonError {
let kind = match self.kind() {
JsonErrorKind::Kind(k) => {
assert!(k != 0, "kind = 0 is reserved for UnKind");
Expand Down Expand Up @@ -167,15 +167,15 @@ where
Ok(args) => args,
Err(e) => {
let buf =
serialize_result(None, Err(InternalError::to_internal_error(&e)));
serialize_result(None, Err(InternalError::to_final_json_error(&e)));
return CoreOp::Sync(buf);
}
};
let promise_id = async_args.promise_id;
let is_sync = promise_id.is_none();

let result = serde_json::from_slice(control)
.map_err(|e| e.to_internal_error())
.map_err(|e| e.to_final_json_error())
.and_then(|args| d(args, zero_copy).map_err(FinalJsonError::from));

// Convert to CoreOp
Expand Down
10 changes: 6 additions & 4 deletions core/dispatch_json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,16 @@ interface JsonResponse {
promiseId?: number; // Only present in async messages.
}

const core = Deno["core"];

function decode(ui8: Uint8Array): JsonResponse {
const s = Deno["core"].decode(ui8);
const s = core.decode(ui8);
return JSON.parse(s) as JsonResponse;
}

function encode(args: object): Uint8Array {
const s = JSON.stringify(args);
return Deno["core"].encode(s);
return core.encode(s);
}

abstract class DispatchJsonOp {
Expand Down Expand Up @@ -176,8 +178,8 @@ abstract class DispatchJsonOp {

export class DispatchJsonCoreOp extends DispatchJsonOp {
constructor(private readonly opId: number, errorFactory: ErrorFactory) {
super((c, zc) => Deno["core"].dispatch(this.opId, c, zc), errorFactory);
Deno["core"].setAsyncHandler(this.opId, resUi8 => this.handleAsync(resUi8));
super((c, zc) => core.dispatch(this.opId, c, zc), errorFactory);
core.setAsyncHandler(this.opId, resUi8 => this.handleAsync(resUi8));
}
}

Expand Down
1 change: 1 addition & 0 deletions deno_typescript/ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ pub fn op_load_module(s: &mut TSState, v: Value) -> Result<Value, ErrBox> {
let path_prefix = s.extern_crate_modules.get(crate_name).unwrap();
let path =
std::path::Path::new(path_prefix).join(&module_url.path()[1..]);
println!("cargo:rerun-if-changed={}", path.display());
(
module_specifier.as_str().to_string(),
std::fs::read_to_string(&path)?,
Expand Down

0 comments on commit 1998d2c

Please sign in to comment.