mirror of
https://github.com/denoland/deno.git
synced 2024-12-31 11:34:15 -05:00
Rename fbs to msg.
This commit is contained in:
parent
f774953011
commit
818ad37678
22 changed files with 201 additions and 201 deletions
|
@ -111,8 +111,8 @@ test(function consoleTestStringifyWithDepth() {
|
|||
|
||||
test(function consoleTestError() {
|
||||
class MyError extends Error {
|
||||
constructor(msg: string) {
|
||||
super(msg);
|
||||
constructor(errStr: string) {
|
||||
super(errStr);
|
||||
this.name = "MyError";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Copyright 2018 the Deno authors. All rights reserved. MIT license.
|
||||
import * as fbs from "gen/msg_generated";
|
||||
import * as msg from "gen/msg_generated";
|
||||
import { flatbuffers } from "flatbuffers";
|
||||
import * as dispatch from "./dispatch";
|
||||
|
||||
|
@ -34,13 +34,13 @@ export async function copyFile(from: string, to: string): Promise<void> {
|
|||
function req(
|
||||
from: string,
|
||||
to: string
|
||||
): [flatbuffers.Builder, fbs.Any, flatbuffers.Offset] {
|
||||
): [flatbuffers.Builder, msg.Any, flatbuffers.Offset] {
|
||||
const builder = new flatbuffers.Builder();
|
||||
const from_ = builder.createString(from);
|
||||
const to_ = builder.createString(to);
|
||||
fbs.CopyFile.startCopyFile(builder);
|
||||
fbs.CopyFile.addFrom(builder, from_);
|
||||
fbs.CopyFile.addTo(builder, to_);
|
||||
const inner = fbs.CopyFile.endCopyFile(builder);
|
||||
return [builder, fbs.Any.CopyFile, inner];
|
||||
msg.CopyFile.startCopyFile(builder);
|
||||
msg.CopyFile.addFrom(builder, from_);
|
||||
msg.CopyFile.addTo(builder, to_);
|
||||
const inner = msg.CopyFile.endCopyFile(builder);
|
||||
return [builder, msg.Any.CopyFile, inner];
|
||||
}
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
// Copyright 2018 the Deno authors. All rights reserved. MIT license.
|
||||
import { libdeno } from "./libdeno";
|
||||
import { flatbuffers } from "flatbuffers";
|
||||
import * as fbs from "gen/msg_generated";
|
||||
import * as msg from "gen/msg_generated";
|
||||
import * as errors from "./errors";
|
||||
import * as util from "./util";
|
||||
import { maybePushTrace } from "./trace";
|
||||
|
||||
let nextCmdId = 0;
|
||||
const promiseTable = new Map<number, util.Resolvable<fbs.Base>>();
|
||||
const promiseTable = new Map<number, util.Resolvable<msg.Base>>();
|
||||
|
||||
let fireTimers: () => void;
|
||||
|
||||
|
@ -20,7 +20,7 @@ export function handleAsyncMsgFromRust(ui8: Uint8Array) {
|
|||
// did not receive a message.
|
||||
if (ui8.length) {
|
||||
const bb = new flatbuffers.ByteBuffer(ui8);
|
||||
const base = fbs.Base.getRootAsBase(bb);
|
||||
const base = msg.Base.getRootAsBase(bb);
|
||||
const cmdId = base.cmdId();
|
||||
const promise = promiseTable.get(cmdId);
|
||||
util.assert(promise != null, `Expecting promise in table. ${cmdId}`);
|
||||
|
@ -39,14 +39,14 @@ export function handleAsyncMsgFromRust(ui8: Uint8Array) {
|
|||
// @internal
|
||||
export function sendAsync(
|
||||
builder: flatbuffers.Builder,
|
||||
innerType: fbs.Any,
|
||||
innerType: msg.Any,
|
||||
inner: flatbuffers.Offset,
|
||||
data?: ArrayBufferView
|
||||
): Promise<fbs.Base> {
|
||||
): Promise<msg.Base> {
|
||||
maybePushTrace(innerType, false); // add to trace if tracing
|
||||
const [cmdId, resBuf] = sendInternal(builder, innerType, inner, data, false);
|
||||
util.assert(resBuf == null);
|
||||
const promise = util.createResolvable<fbs.Base>();
|
||||
const promise = util.createResolvable<msg.Base>();
|
||||
promiseTable.set(cmdId, promise);
|
||||
return promise;
|
||||
}
|
||||
|
@ -54,10 +54,10 @@ export function sendAsync(
|
|||
// @internal
|
||||
export function sendSync(
|
||||
builder: flatbuffers.Builder,
|
||||
innerType: fbs.Any,
|
||||
innerType: msg.Any,
|
||||
inner: flatbuffers.Offset,
|
||||
data?: ArrayBufferView
|
||||
): null | fbs.Base {
|
||||
): null | msg.Base {
|
||||
maybePushTrace(innerType, true); // add to trace if tracing
|
||||
const [cmdId, resBuf] = sendInternal(builder, innerType, inner, data, true);
|
||||
util.assert(cmdId >= 0);
|
||||
|
@ -66,7 +66,7 @@ export function sendSync(
|
|||
} else {
|
||||
const u8 = new Uint8Array(resBuf!);
|
||||
const bb = new flatbuffers.ByteBuffer(u8);
|
||||
const baseRes = fbs.Base.getRootAsBase(bb);
|
||||
const baseRes = msg.Base.getRootAsBase(bb);
|
||||
errors.maybeThrowError(baseRes);
|
||||
return baseRes;
|
||||
}
|
||||
|
@ -74,18 +74,18 @@ export function sendSync(
|
|||
|
||||
function sendInternal(
|
||||
builder: flatbuffers.Builder,
|
||||
innerType: fbs.Any,
|
||||
innerType: msg.Any,
|
||||
inner: flatbuffers.Offset,
|
||||
data: undefined | ArrayBufferView,
|
||||
sync = true
|
||||
): [number, null | Uint8Array] {
|
||||
const cmdId = nextCmdId++;
|
||||
fbs.Base.startBase(builder);
|
||||
fbs.Base.addInner(builder, inner);
|
||||
fbs.Base.addInnerType(builder, innerType);
|
||||
fbs.Base.addSync(builder, sync);
|
||||
fbs.Base.addCmdId(builder, cmdId);
|
||||
builder.finish(fbs.Base.endBase(builder));
|
||||
msg.Base.startBase(builder);
|
||||
msg.Base.addInner(builder, inner);
|
||||
msg.Base.addInnerType(builder, innerType);
|
||||
msg.Base.addSync(builder, sync);
|
||||
msg.Base.addCmdId(builder, cmdId);
|
||||
builder.finish(msg.Base.endBase(builder));
|
||||
|
||||
return [cmdId, libdeno.send(builder.asUint8Array(), data)];
|
||||
}
|
||||
|
|
16
js/errors.ts
16
js/errors.ts
|
@ -1,25 +1,25 @@
|
|||
import * as fbs from "gen/msg_generated";
|
||||
import * as msg from "gen/msg_generated";
|
||||
export { ErrorKind } from "gen/msg_generated";
|
||||
|
||||
// @internal
|
||||
export class DenoError<T extends fbs.ErrorKind> extends Error {
|
||||
constructor(readonly kind: T, msg: string) {
|
||||
super(msg);
|
||||
this.name = fbs.ErrorKind[kind];
|
||||
export class DenoError<T extends msg.ErrorKind> extends Error {
|
||||
constructor(readonly kind: T, errStr: string) {
|
||||
super(errStr);
|
||||
this.name = msg.ErrorKind[kind];
|
||||
}
|
||||
}
|
||||
|
||||
// @internal
|
||||
export function maybeThrowError(base: fbs.Base): void {
|
||||
export function maybeThrowError(base: msg.Base): void {
|
||||
const err = maybeError(base);
|
||||
if (err != null) {
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
export function maybeError(base: fbs.Base): null | DenoError<fbs.ErrorKind> {
|
||||
export function maybeError(base: msg.Base): null | DenoError<msg.ErrorKind> {
|
||||
const kind = base.errorKind();
|
||||
if (kind === fbs.ErrorKind.NoError) {
|
||||
if (kind === msg.ErrorKind.NoError) {
|
||||
return null;
|
||||
} else {
|
||||
return new DenoError(kind, base.error()!);
|
||||
|
|
16
js/fetch.ts
16
js/fetch.ts
|
@ -9,7 +9,7 @@ import {
|
|||
} from "./util";
|
||||
import { flatbuffers } from "flatbuffers";
|
||||
import { sendAsync } from "./dispatch";
|
||||
import * as fbs from "gen/msg_generated";
|
||||
import * as msg from "gen/msg_generated";
|
||||
import {
|
||||
Headers,
|
||||
Request,
|
||||
|
@ -170,7 +170,7 @@ class FetchResponse implements Response {
|
|||
onHeader?: (res: FetchResponse) => void;
|
||||
onError?: (error: Error) => void;
|
||||
|
||||
onMsg(base: fbs.Base) {
|
||||
onMsg(base: msg.Base) {
|
||||
/*
|
||||
const error = base.error();
|
||||
if (error != null) {
|
||||
|
@ -196,17 +196,17 @@ export async function fetch(
|
|||
// Send FetchReq message
|
||||
const builder = new flatbuffers.Builder();
|
||||
const url_ = builder.createString(url);
|
||||
fbs.FetchReq.startFetchReq(builder);
|
||||
fbs.FetchReq.addUrl(builder, url_);
|
||||
msg.FetchReq.startFetchReq(builder);
|
||||
msg.FetchReq.addUrl(builder, url_);
|
||||
const resBase = await sendAsync(
|
||||
builder,
|
||||
fbs.Any.FetchReq,
|
||||
fbs.FetchReq.endFetchReq(builder)
|
||||
msg.Any.FetchReq,
|
||||
msg.FetchReq.endFetchReq(builder)
|
||||
);
|
||||
|
||||
// Decode FetchRes
|
||||
assert(fbs.Any.FetchRes === resBase.innerType());
|
||||
const inner = new fbs.FetchRes();
|
||||
assert(msg.Any.FetchRes === resBase.innerType());
|
||||
const inner = new msg.FetchRes();
|
||||
assert(resBase.inner(inner) != null);
|
||||
|
||||
const status = inner.status();
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Copyright 2018 the Deno authors. All rights reserved. MIT license.
|
||||
import * as fbs from "gen/msg_generated";
|
||||
import * as msg from "gen/msg_generated";
|
||||
|
||||
/**
|
||||
* A FileInfo describes a file and is returned by `stat`, `lstat`,
|
||||
|
@ -73,7 +73,7 @@ export class FileInfoImpl implements FileInfo {
|
|||
path: string | null;
|
||||
|
||||
/* @internal */
|
||||
constructor(private _inner: fbs.StatRes) {
|
||||
constructor(private _inner: msg.StatRes) {
|
||||
const modified = this._inner.modified().toFloat64();
|
||||
const accessed = this._inner.accessed().toFloat64();
|
||||
const created = this._inner.created().toFloat64();
|
||||
|
|
46
js/files.ts
46
js/files.ts
|
@ -2,7 +2,7 @@
|
|||
|
||||
import { Reader, Writer, Closer, ReadResult } from "./io";
|
||||
import * as dispatch from "./dispatch";
|
||||
import * as fbs from "gen/msg_generated";
|
||||
import * as msg from "gen/msg_generated";
|
||||
import { assert } from "./util";
|
||||
import { flatbuffers } from "flatbuffers";
|
||||
|
||||
|
@ -39,13 +39,13 @@ export async function open(
|
|||
): Promise<File> {
|
||||
const builder = new flatbuffers.Builder();
|
||||
const filename_ = builder.createString(filename);
|
||||
fbs.Open.startOpen(builder);
|
||||
fbs.Open.addFilename(builder, filename_);
|
||||
const inner = fbs.Open.endOpen(builder);
|
||||
const baseRes = await dispatch.sendAsync(builder, fbs.Any.Open, inner);
|
||||
msg.Open.startOpen(builder);
|
||||
msg.Open.addFilename(builder, filename_);
|
||||
const inner = msg.Open.endOpen(builder);
|
||||
const baseRes = await dispatch.sendAsync(builder, msg.Any.Open, inner);
|
||||
assert(baseRes != null);
|
||||
assert(fbs.Any.OpenRes === baseRes!.innerType());
|
||||
const res = new fbs.OpenRes();
|
||||
assert(msg.Any.OpenRes === baseRes!.innerType());
|
||||
const res = new msg.OpenRes();
|
||||
assert(baseRes!.inner(res) != null);
|
||||
const fd = res.rid();
|
||||
return new File(fd);
|
||||
|
@ -56,34 +56,34 @@ export async function read(
|
|||
p: ArrayBufferView
|
||||
): Promise<ReadResult> {
|
||||
const builder = new flatbuffers.Builder();
|
||||
fbs.Read.startRead(builder);
|
||||
fbs.Read.addRid(builder, fd);
|
||||
const inner = fbs.Read.endRead(builder);
|
||||
const baseRes = await dispatch.sendAsync(builder, fbs.Any.Read, inner, p);
|
||||
msg.Read.startRead(builder);
|
||||
msg.Read.addRid(builder, fd);
|
||||
const inner = msg.Read.endRead(builder);
|
||||
const baseRes = await dispatch.sendAsync(builder, msg.Any.Read, inner, p);
|
||||
assert(baseRes != null);
|
||||
assert(fbs.Any.ReadRes === baseRes!.innerType());
|
||||
const res = new fbs.ReadRes();
|
||||
assert(msg.Any.ReadRes === baseRes!.innerType());
|
||||
const res = new msg.ReadRes();
|
||||
assert(baseRes!.inner(res) != null);
|
||||
return { nread: res.nread(), eof: res.eof() };
|
||||
}
|
||||
|
||||
export async function write(fd: number, p: ArrayBufferView): Promise<number> {
|
||||
const builder = new flatbuffers.Builder();
|
||||
fbs.Write.startWrite(builder);
|
||||
fbs.Write.addRid(builder, fd);
|
||||
const inner = fbs.Write.endWrite(builder);
|
||||
const baseRes = await dispatch.sendAsync(builder, fbs.Any.Write, inner, p);
|
||||
msg.Write.startWrite(builder);
|
||||
msg.Write.addRid(builder, fd);
|
||||
const inner = msg.Write.endWrite(builder);
|
||||
const baseRes = await dispatch.sendAsync(builder, msg.Any.Write, inner, p);
|
||||
assert(baseRes != null);
|
||||
assert(fbs.Any.WriteRes === baseRes!.innerType());
|
||||
const res = new fbs.WriteRes();
|
||||
assert(msg.Any.WriteRes === baseRes!.innerType());
|
||||
const res = new msg.WriteRes();
|
||||
assert(baseRes!.inner(res) != null);
|
||||
return res.nbyte();
|
||||
}
|
||||
|
||||
export function close(fd: number): void {
|
||||
const builder = new flatbuffers.Builder();
|
||||
fbs.Close.startClose(builder);
|
||||
fbs.Close.addRid(builder, fd);
|
||||
const inner = fbs.Close.endClose(builder);
|
||||
dispatch.sendSync(builder, fbs.Any.Close, inner);
|
||||
msg.Close.startClose(builder);
|
||||
msg.Close.addRid(builder, fd);
|
||||
const inner = msg.Close.endClose(builder);
|
||||
dispatch.sendSync(builder, msg.Any.Close, inner);
|
||||
}
|
||||
|
|
14
js/main.ts
14
js/main.ts
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2018 the Deno authors. All rights reserved. MIT license.
|
||||
import { flatbuffers } from "flatbuffers";
|
||||
import * as fbs from "gen/msg_generated";
|
||||
import * as msg from "gen/msg_generated";
|
||||
import { assert, log, setLogDebug } from "./util";
|
||||
import * as os from "./os";
|
||||
import { DenoCompiler } from "./compiler";
|
||||
|
@ -8,14 +8,14 @@ import { libdeno } from "./libdeno";
|
|||
import { args } from "./deno";
|
||||
import { sendSync, handleAsyncMsgFromRust } from "./dispatch";
|
||||
|
||||
function sendStart(): fbs.StartRes {
|
||||
function sendStart(): msg.StartRes {
|
||||
const builder = new flatbuffers.Builder();
|
||||
fbs.Start.startStart(builder);
|
||||
const startOffset = fbs.Start.endStart(builder);
|
||||
const baseRes = sendSync(builder, fbs.Any.Start, startOffset);
|
||||
msg.Start.startStart(builder);
|
||||
const startOffset = msg.Start.endStart(builder);
|
||||
const baseRes = sendSync(builder, msg.Any.Start, startOffset);
|
||||
assert(baseRes != null);
|
||||
assert(fbs.Any.StartRes === baseRes!.innerType());
|
||||
const startRes = new fbs.StartRes();
|
||||
assert(msg.Any.StartRes === baseRes!.innerType());
|
||||
const startRes = new msg.StartRes();
|
||||
assert(baseRes!.inner(startRes) != null);
|
||||
return startRes;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Copyright 2018 the Deno authors. All rights reserved. MIT license.
|
||||
import * as fbs from "gen/msg_generated";
|
||||
import * as msg from "gen/msg_generated";
|
||||
import { flatbuffers } from "flatbuffers";
|
||||
import * as dispatch from "./dispatch";
|
||||
import { assert } from "./util";
|
||||
|
@ -44,29 +44,29 @@ function req({
|
|||
dir,
|
||||
prefix,
|
||||
suffix
|
||||
}: MakeTempDirOptions): [flatbuffers.Builder, fbs.Any, flatbuffers.Offset] {
|
||||
}: MakeTempDirOptions): [flatbuffers.Builder, msg.Any, flatbuffers.Offset] {
|
||||
const builder = new flatbuffers.Builder();
|
||||
const fbDir = dir == null ? -1 : builder.createString(dir);
|
||||
const fbPrefix = prefix == null ? -1 : builder.createString(prefix);
|
||||
const fbSuffix = suffix == null ? -1 : builder.createString(suffix);
|
||||
fbs.MakeTempDir.startMakeTempDir(builder);
|
||||
msg.MakeTempDir.startMakeTempDir(builder);
|
||||
if (dir != null) {
|
||||
fbs.MakeTempDir.addDir(builder, fbDir);
|
||||
msg.MakeTempDir.addDir(builder, fbDir);
|
||||
}
|
||||
if (prefix != null) {
|
||||
fbs.MakeTempDir.addPrefix(builder, fbPrefix);
|
||||
msg.MakeTempDir.addPrefix(builder, fbPrefix);
|
||||
}
|
||||
if (suffix != null) {
|
||||
fbs.MakeTempDir.addSuffix(builder, fbSuffix);
|
||||
msg.MakeTempDir.addSuffix(builder, fbSuffix);
|
||||
}
|
||||
const inner = fbs.MakeTempDir.endMakeTempDir(builder);
|
||||
return [builder, fbs.Any.MakeTempDir, inner];
|
||||
const inner = msg.MakeTempDir.endMakeTempDir(builder);
|
||||
return [builder, msg.Any.MakeTempDir, inner];
|
||||
}
|
||||
|
||||
function res(baseRes: null | fbs.Base): string {
|
||||
function res(baseRes: null | msg.Base): string {
|
||||
assert(baseRes != null);
|
||||
assert(fbs.Any.MakeTempDirRes === baseRes!.innerType());
|
||||
const res = new fbs.MakeTempDirRes();
|
||||
assert(msg.Any.MakeTempDirRes === baseRes!.innerType());
|
||||
const res = new msg.MakeTempDirRes();
|
||||
assert(baseRes!.inner(res) != null);
|
||||
const path = res.path();
|
||||
assert(path != null);
|
||||
|
|
14
js/mkdir.ts
14
js/mkdir.ts
|
@ -1,5 +1,5 @@
|
|||
// Copyright 2018 the Deno authors. All rights reserved. MIT license.
|
||||
import * as fbs from "gen/msg_generated";
|
||||
import * as msg from "gen/msg_generated";
|
||||
import { flatbuffers } from "flatbuffers";
|
||||
import * as dispatch from "./dispatch";
|
||||
|
||||
|
@ -26,12 +26,12 @@ export async function mkdir(path: string, mode = 0o777): Promise<void> {
|
|||
function req(
|
||||
path: string,
|
||||
mode: number
|
||||
): [flatbuffers.Builder, fbs.Any, flatbuffers.Offset] {
|
||||
): [flatbuffers.Builder, msg.Any, flatbuffers.Offset] {
|
||||
const builder = new flatbuffers.Builder();
|
||||
const path_ = builder.createString(path);
|
||||
fbs.Mkdir.startMkdir(builder);
|
||||
fbs.Mkdir.addPath(builder, path_);
|
||||
fbs.Mkdir.addMode(builder, mode);
|
||||
const inner = fbs.Mkdir.endMkdir(builder);
|
||||
return [builder, fbs.Any.Mkdir, inner];
|
||||
msg.Mkdir.startMkdir(builder);
|
||||
msg.Mkdir.addPath(builder, path_);
|
||||
msg.Mkdir.addMode(builder, mode);
|
||||
const inner = msg.Mkdir.endMkdir(builder);
|
||||
return [builder, msg.Any.Mkdir, inner];
|
||||
}
|
||||
|
|
60
js/os.ts
60
js/os.ts
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2018 the Deno authors. All rights reserved. MIT license.
|
||||
import { ModuleInfo } from "./types";
|
||||
import * as fbs from "gen/msg_generated";
|
||||
import * as msg from "gen/msg_generated";
|
||||
import { assert } from "./util";
|
||||
import * as util from "./util";
|
||||
import { flatbuffers } from "flatbuffers";
|
||||
|
@ -8,10 +8,10 @@ import { sendSync } from "./dispatch";
|
|||
|
||||
export function exit(exitCode = 0): never {
|
||||
const builder = new flatbuffers.Builder();
|
||||
fbs.Exit.startExit(builder);
|
||||
fbs.Exit.addCode(builder, exitCode);
|
||||
const inner = fbs.Exit.endExit(builder);
|
||||
sendSync(builder, fbs.Any.Exit, inner);
|
||||
msg.Exit.startExit(builder);
|
||||
msg.Exit.addCode(builder, exitCode);
|
||||
const inner = msg.Exit.endExit(builder);
|
||||
sendSync(builder, msg.Any.Exit, inner);
|
||||
return util.unreachable();
|
||||
}
|
||||
|
||||
|
@ -24,17 +24,17 @@ export function codeFetch(
|
|||
const builder = new flatbuffers.Builder();
|
||||
const moduleSpecifier_ = builder.createString(moduleSpecifier);
|
||||
const containingFile_ = builder.createString(containingFile);
|
||||
fbs.CodeFetch.startCodeFetch(builder);
|
||||
fbs.CodeFetch.addModuleSpecifier(builder, moduleSpecifier_);
|
||||
fbs.CodeFetch.addContainingFile(builder, containingFile_);
|
||||
const inner = fbs.CodeFetch.endCodeFetch(builder);
|
||||
const baseRes = sendSync(builder, fbs.Any.CodeFetch, inner);
|
||||
msg.CodeFetch.startCodeFetch(builder);
|
||||
msg.CodeFetch.addModuleSpecifier(builder, moduleSpecifier_);
|
||||
msg.CodeFetch.addContainingFile(builder, containingFile_);
|
||||
const inner = msg.CodeFetch.endCodeFetch(builder);
|
||||
const baseRes = sendSync(builder, msg.Any.CodeFetch, inner);
|
||||
assert(baseRes != null);
|
||||
assert(
|
||||
fbs.Any.CodeFetchRes === baseRes!.innerType(),
|
||||
msg.Any.CodeFetchRes === baseRes!.innerType(),
|
||||
`base.innerType() unexpectedly is ${baseRes!.innerType()}`
|
||||
);
|
||||
const codeFetchRes = new fbs.CodeFetchRes();
|
||||
const codeFetchRes = new msg.CodeFetchRes();
|
||||
assert(baseRes!.inner(codeFetchRes) != null);
|
||||
return {
|
||||
moduleName: codeFetchRes.moduleName(),
|
||||
|
@ -54,16 +54,16 @@ export function codeCache(
|
|||
const filename_ = builder.createString(filename);
|
||||
const sourceCode_ = builder.createString(sourceCode);
|
||||
const outputCode_ = builder.createString(outputCode);
|
||||
fbs.CodeCache.startCodeCache(builder);
|
||||
fbs.CodeCache.addFilename(builder, filename_);
|
||||
fbs.CodeCache.addSourceCode(builder, sourceCode_);
|
||||
fbs.CodeCache.addOutputCode(builder, outputCode_);
|
||||
const inner = fbs.CodeCache.endCodeCache(builder);
|
||||
const baseRes = sendSync(builder, fbs.Any.CodeCache, inner);
|
||||
msg.CodeCache.startCodeCache(builder);
|
||||
msg.CodeCache.addFilename(builder, filename_);
|
||||
msg.CodeCache.addSourceCode(builder, sourceCode_);
|
||||
msg.CodeCache.addOutputCode(builder, outputCode_);
|
||||
const inner = msg.CodeCache.endCodeCache(builder);
|
||||
const baseRes = sendSync(builder, msg.Any.CodeCache, inner);
|
||||
assert(baseRes == null); // Expect null or error.
|
||||
}
|
||||
|
||||
function createEnv(_inner: fbs.EnvironRes): { [index: string]: string } {
|
||||
function createEnv(_inner: msg.EnvironRes): { [index: string]: string } {
|
||||
const env: { [index: string]: string } = {};
|
||||
|
||||
for (let i = 0; i < _inner.mapLength(); i++) {
|
||||
|
@ -84,11 +84,11 @@ function setEnv(key: string, value: string): void {
|
|||
const builder = new flatbuffers.Builder();
|
||||
const _key = builder.createString(key);
|
||||
const _value = builder.createString(value);
|
||||
fbs.SetEnv.startSetEnv(builder);
|
||||
fbs.SetEnv.addKey(builder, _key);
|
||||
fbs.SetEnv.addValue(builder, _value);
|
||||
const inner = fbs.SetEnv.endSetEnv(builder);
|
||||
sendSync(builder, fbs.Any.SetEnv, inner);
|
||||
msg.SetEnv.startSetEnv(builder);
|
||||
msg.SetEnv.addKey(builder, _key);
|
||||
msg.SetEnv.addValue(builder, _value);
|
||||
const inner = msg.SetEnv.endSetEnv(builder);
|
||||
sendSync(builder, msg.Any.SetEnv, inner);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -107,15 +107,15 @@ function setEnv(key: string, value: string): void {
|
|||
export function env(): { [index: string]: string } {
|
||||
/* Ideally we could write
|
||||
const res = sendSync({
|
||||
command: fbs.Command.ENV,
|
||||
command: msg.Command.ENV,
|
||||
});
|
||||
*/
|
||||
const builder = new flatbuffers.Builder();
|
||||
fbs.Environ.startEnviron(builder);
|
||||
const inner = fbs.Environ.endEnviron(builder);
|
||||
const baseRes = sendSync(builder, fbs.Any.Environ, inner)!;
|
||||
assert(fbs.Any.EnvironRes === baseRes.innerType());
|
||||
const res = new fbs.EnvironRes();
|
||||
msg.Environ.startEnviron(builder);
|
||||
const inner = msg.Environ.endEnviron(builder);
|
||||
const baseRes = sendSync(builder, msg.Any.Environ, inner)!;
|
||||
assert(msg.Any.EnvironRes === baseRes.innerType());
|
||||
const res = new msg.EnvironRes();
|
||||
assert(baseRes.inner(res) != null);
|
||||
// TypeScript cannot track assertion above, therefore not null assertion
|
||||
return createEnv(res);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Copyright 2018 the Deno authors. All rights reserved. MIT license.
|
||||
import * as fbs from "gen/msg_generated";
|
||||
import * as msg from "gen/msg_generated";
|
||||
import { flatbuffers } from "flatbuffers";
|
||||
import * as dispatch from "./dispatch";
|
||||
import { FileInfo, FileInfoImpl } from "./fileinfo";
|
||||
|
@ -27,19 +27,19 @@ export async function readDir(path: string): Promise<FileInfo[]> {
|
|||
return res(await dispatch.sendAsync(...req(path)));
|
||||
}
|
||||
|
||||
function req(path: string): [flatbuffers.Builder, fbs.Any, flatbuffers.Offset] {
|
||||
function req(path: string): [flatbuffers.Builder, msg.Any, flatbuffers.Offset] {
|
||||
const builder = new flatbuffers.Builder();
|
||||
const path_ = builder.createString(path);
|
||||
fbs.ReadDir.startReadDir(builder);
|
||||
fbs.ReadDir.addPath(builder, path_);
|
||||
const inner = fbs.ReadDir.endReadDir(builder);
|
||||
return [builder, fbs.Any.ReadDir, inner];
|
||||
msg.ReadDir.startReadDir(builder);
|
||||
msg.ReadDir.addPath(builder, path_);
|
||||
const inner = msg.ReadDir.endReadDir(builder);
|
||||
return [builder, msg.Any.ReadDir, inner];
|
||||
}
|
||||
|
||||
function res(baseRes: null | fbs.Base): FileInfo[] {
|
||||
function res(baseRes: null | msg.Base): FileInfo[] {
|
||||
assert(baseRes != null);
|
||||
assert(fbs.Any.ReadDirRes === baseRes!.innerType());
|
||||
const res = new fbs.ReadDirRes();
|
||||
assert(msg.Any.ReadDirRes === baseRes!.innerType());
|
||||
const res = new msg.ReadDirRes();
|
||||
assert(baseRes!.inner(res) != null);
|
||||
const fileInfos: FileInfo[] = [];
|
||||
for (let i = 0; i < res.entriesLength(); i++) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Copyright 2018 the Deno authors. All rights reserved. MIT license.
|
||||
import * as fbs from "gen/msg_generated";
|
||||
import * as msg from "gen/msg_generated";
|
||||
import { flatbuffers } from "flatbuffers";
|
||||
import { assert } from "./util";
|
||||
import * as dispatch from "./dispatch";
|
||||
|
@ -30,19 +30,19 @@ export async function readFile(filename: string): Promise<Uint8Array> {
|
|||
|
||||
function req(
|
||||
filename: string
|
||||
): [flatbuffers.Builder, fbs.Any, flatbuffers.Offset] {
|
||||
): [flatbuffers.Builder, msg.Any, flatbuffers.Offset] {
|
||||
const builder = new flatbuffers.Builder();
|
||||
const filename_ = builder.createString(filename);
|
||||
fbs.ReadFile.startReadFile(builder);
|
||||
fbs.ReadFile.addFilename(builder, filename_);
|
||||
const inner = fbs.ReadFile.endReadFile(builder);
|
||||
return [builder, fbs.Any.ReadFile, inner];
|
||||
msg.ReadFile.startReadFile(builder);
|
||||
msg.ReadFile.addFilename(builder, filename_);
|
||||
const inner = msg.ReadFile.endReadFile(builder);
|
||||
return [builder, msg.Any.ReadFile, inner];
|
||||
}
|
||||
|
||||
function res(baseRes: null | fbs.Base): Uint8Array {
|
||||
function res(baseRes: null | msg.Base): Uint8Array {
|
||||
assert(baseRes != null);
|
||||
assert(fbs.Any.ReadFileRes === baseRes!.innerType());
|
||||
const inner = new fbs.ReadFileRes();
|
||||
assert(msg.Any.ReadFileRes === baseRes!.innerType());
|
||||
const inner = new msg.ReadFileRes();
|
||||
assert(baseRes!.inner(inner) != null);
|
||||
const dataArray = inner.dataArray();
|
||||
assert(dataArray != null);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Copyright 2018 the Deno authors. All rights reserved. MIT license.
|
||||
import * as fbs from "gen/msg_generated";
|
||||
import * as msg from "gen/msg_generated";
|
||||
import { flatbuffers } from "flatbuffers";
|
||||
import { assert } from "./util";
|
||||
import * as dispatch from "./dispatch";
|
||||
|
@ -24,19 +24,19 @@ export async function readlink(name: string): Promise<string> {
|
|||
return res(await dispatch.sendAsync(...req(name)));
|
||||
}
|
||||
|
||||
function req(name: string): [flatbuffers.Builder, fbs.Any, flatbuffers.Offset] {
|
||||
function req(name: string): [flatbuffers.Builder, msg.Any, flatbuffers.Offset] {
|
||||
const builder = new flatbuffers.Builder();
|
||||
const name_ = builder.createString(name);
|
||||
fbs.Readlink.startReadlink(builder);
|
||||
fbs.Readlink.addName(builder, name_);
|
||||
const inner = fbs.Readlink.endReadlink(builder);
|
||||
return [builder, fbs.Any.Readlink, inner];
|
||||
msg.Readlink.startReadlink(builder);
|
||||
msg.Readlink.addName(builder, name_);
|
||||
const inner = msg.Readlink.endReadlink(builder);
|
||||
return [builder, msg.Any.Readlink, inner];
|
||||
}
|
||||
|
||||
function res(baseRes: null | fbs.Base): string {
|
||||
function res(baseRes: null | msg.Base): string {
|
||||
assert(baseRes !== null);
|
||||
assert(fbs.Any.ReadlinkRes === baseRes!.innerType());
|
||||
const res = new fbs.ReadlinkRes();
|
||||
assert(msg.Any.ReadlinkRes === baseRes!.innerType());
|
||||
const res = new msg.ReadlinkRes();
|
||||
assert(baseRes!.inner(res) !== null);
|
||||
const path = res.path();
|
||||
assert(path !== null);
|
||||
|
|
14
js/remove.ts
14
js/remove.ts
|
@ -1,5 +1,5 @@
|
|||
// Copyright 2018 the Deno authors. All rights reserved. MIT license.
|
||||
import * as fbs from "gen/msg_generated";
|
||||
import * as msg from "gen/msg_generated";
|
||||
import { flatbuffers } from "flatbuffers";
|
||||
import * as dispatch from "./dispatch";
|
||||
|
||||
|
@ -52,12 +52,12 @@ export async function removeAll(path: string): Promise<void> {
|
|||
function req(
|
||||
path: string,
|
||||
recursive: boolean
|
||||
): [flatbuffers.Builder, fbs.Any, flatbuffers.Offset] {
|
||||
): [flatbuffers.Builder, msg.Any, flatbuffers.Offset] {
|
||||
const builder = new flatbuffers.Builder();
|
||||
const path_ = builder.createString(path);
|
||||
fbs.Remove.startRemove(builder);
|
||||
fbs.Remove.addPath(builder, path_);
|
||||
fbs.Remove.addRecursive(builder, recursive);
|
||||
const inner = fbs.Remove.endRemove(builder);
|
||||
return [builder, fbs.Any.Remove, inner];
|
||||
msg.Remove.startRemove(builder);
|
||||
msg.Remove.addPath(builder, path_);
|
||||
msg.Remove.addRecursive(builder, recursive);
|
||||
const inner = msg.Remove.endRemove(builder);
|
||||
return [builder, msg.Any.Remove, inner];
|
||||
}
|
||||
|
|
14
js/rename.ts
14
js/rename.ts
|
@ -1,5 +1,5 @@
|
|||
// Copyright 2018 the Deno authors. All rights reserved. MIT license.
|
||||
import * as fbs from "gen/msg_generated";
|
||||
import * as msg from "gen/msg_generated";
|
||||
import { flatbuffers } from "flatbuffers";
|
||||
import * as dispatch from "./dispatch";
|
||||
|
||||
|
@ -30,13 +30,13 @@ export async function rename(oldpath: string, newpath: string): Promise<void> {
|
|||
function req(
|
||||
oldpath: string,
|
||||
newpath: string
|
||||
): [flatbuffers.Builder, fbs.Any, flatbuffers.Offset] {
|
||||
): [flatbuffers.Builder, msg.Any, flatbuffers.Offset] {
|
||||
const builder = new flatbuffers.Builder();
|
||||
const oldpath_ = builder.createString(oldpath);
|
||||
const newpath_ = builder.createString(newpath);
|
||||
fbs.Rename.startRename(builder);
|
||||
fbs.Rename.addOldpath(builder, oldpath_);
|
||||
fbs.Rename.addNewpath(builder, newpath_);
|
||||
const inner = fbs.Rename.endRename(builder);
|
||||
return [builder, fbs.Any.Rename, inner];
|
||||
msg.Rename.startRename(builder);
|
||||
msg.Rename.addOldpath(builder, oldpath_);
|
||||
msg.Rename.addNewpath(builder, newpath_);
|
||||
const inner = msg.Rename.endRename(builder);
|
||||
return [builder, msg.Any.Rename, inner];
|
||||
}
|
||||
|
|
20
js/stat.ts
20
js/stat.ts
|
@ -1,5 +1,5 @@
|
|||
// Copyright 2018 the Deno authors. All rights reserved. MIT license.
|
||||
import * as fbs from "gen/msg_generated";
|
||||
import * as msg from "gen/msg_generated";
|
||||
import { flatbuffers } from "flatbuffers";
|
||||
import * as dispatch from "./dispatch";
|
||||
import { assert } from "./util";
|
||||
|
@ -58,20 +58,20 @@ export function statSync(filename: string): FileInfo {
|
|||
function req(
|
||||
filename: string,
|
||||
lstat: boolean
|
||||
): [flatbuffers.Builder, fbs.Any, flatbuffers.Offset] {
|
||||
): [flatbuffers.Builder, msg.Any, flatbuffers.Offset] {
|
||||
const builder = new flatbuffers.Builder();
|
||||
const filename_ = builder.createString(filename);
|
||||
fbs.Stat.startStat(builder);
|
||||
fbs.Stat.addFilename(builder, filename_);
|
||||
fbs.Stat.addLstat(builder, lstat);
|
||||
const inner = fbs.Stat.endStat(builder);
|
||||
return [builder, fbs.Any.Stat, inner];
|
||||
msg.Stat.startStat(builder);
|
||||
msg.Stat.addFilename(builder, filename_);
|
||||
msg.Stat.addLstat(builder, lstat);
|
||||
const inner = msg.Stat.endStat(builder);
|
||||
return [builder, msg.Any.Stat, inner];
|
||||
}
|
||||
|
||||
function res(baseRes: null | fbs.Base): FileInfo {
|
||||
function res(baseRes: null | msg.Base): FileInfo {
|
||||
assert(baseRes != null);
|
||||
assert(fbs.Any.StatRes === baseRes!.innerType());
|
||||
const res = new fbs.StatRes();
|
||||
assert(msg.Any.StatRes === baseRes!.innerType());
|
||||
const res = new msg.StatRes();
|
||||
assert(baseRes!.inner(res) != null);
|
||||
return new FileInfoImpl(res);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Copyright 2018 the Deno authors. All rights reserved. MIT license.
|
||||
import * as fbs from "gen/msg_generated";
|
||||
import * as msg from "gen/msg_generated";
|
||||
import { flatbuffers } from "flatbuffers";
|
||||
import * as dispatch from "./dispatch";
|
||||
import * as util from "./util";
|
||||
|
@ -40,7 +40,7 @@ function req(
|
|||
oldname: string,
|
||||
newname: string,
|
||||
type?: string
|
||||
): [flatbuffers.Builder, fbs.Any, flatbuffers.Offset] {
|
||||
): [flatbuffers.Builder, msg.Any, flatbuffers.Offset] {
|
||||
// TODO Use type for Windows.
|
||||
if (type) {
|
||||
return util.notImplemented();
|
||||
|
@ -48,9 +48,9 @@ function req(
|
|||
const builder = new flatbuffers.Builder();
|
||||
const oldname_ = builder.createString(oldname);
|
||||
const newname_ = builder.createString(newname);
|
||||
fbs.Symlink.startSymlink(builder);
|
||||
fbs.Symlink.addOldname(builder, oldname_);
|
||||
fbs.Symlink.addNewname(builder, newname_);
|
||||
const inner = fbs.Symlink.endSymlink(builder);
|
||||
return [builder, fbs.Any.Symlink, inner];
|
||||
msg.Symlink.startSymlink(builder);
|
||||
msg.Symlink.addOldname(builder, oldname_);
|
||||
msg.Symlink.addNewname(builder, newname_);
|
||||
const inner = msg.Symlink.endSymlink(builder);
|
||||
return [builder, msg.Any.Symlink, inner];
|
||||
}
|
||||
|
|
10
js/timers.ts
10
js/timers.ts
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2018 the Deno authors. All rights reserved. MIT license.
|
||||
import { assert } from "./util";
|
||||
import * as fbs from "gen/msg_generated";
|
||||
import * as msg from "gen/msg_generated";
|
||||
import { flatbuffers } from "flatbuffers";
|
||||
import { sendSync, setFireTimersCallback } from "./dispatch";
|
||||
|
||||
|
@ -52,10 +52,10 @@ function setGlobalTimeout(due: number | null, now: number) {
|
|||
}
|
||||
// Send message to the backend.
|
||||
const builder = new flatbuffers.Builder();
|
||||
fbs.SetTimeout.startSetTimeout(builder);
|
||||
fbs.SetTimeout.addTimeout(builder, timeout);
|
||||
const inner = fbs.SetTimeout.endSetTimeout(builder);
|
||||
const res = sendSync(builder, fbs.Any.SetTimeout, inner);
|
||||
msg.SetTimeout.startSetTimeout(builder);
|
||||
msg.SetTimeout.addTimeout(builder, timeout);
|
||||
const inner = msg.SetTimeout.endSetTimeout(builder);
|
||||
const res = sendSync(builder, msg.Any.SetTimeout, inner);
|
||||
assert(res == null);
|
||||
// Remember when when the global timer will fire.
|
||||
globalTimeoutDue = due;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Copyright 2018 the Deno authors. All rights reserved. MIT license.
|
||||
import * as fbs from "gen/msg_generated";
|
||||
import * as msg from "gen/msg_generated";
|
||||
|
||||
export interface TraceInfo {
|
||||
sync: boolean; // is synchronous call
|
||||
|
@ -41,7 +41,7 @@ function popStack(): TraceInfo[] {
|
|||
}
|
||||
|
||||
// Push to trace stack if we are tracing
|
||||
export function maybePushTrace(op: fbs.Any, sync: boolean): void {
|
||||
export function maybePushTrace(op: msg.Any, sync: boolean): void {
|
||||
if (current === null) {
|
||||
return; // no trace requested
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ export function maybePushTrace(op: fbs.Any, sync: boolean): void {
|
|||
current!.list.push(
|
||||
Object.freeze({
|
||||
sync,
|
||||
name: fbs.Any[op] // convert to enum names
|
||||
name: msg.Any[op] // convert to enum names
|
||||
})
|
||||
);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Copyright 2018 the Deno authors. All rights reserved. MIT license.
|
||||
import * as fbs from "gen/msg_generated";
|
||||
import * as msg from "gen/msg_generated";
|
||||
import { flatbuffers } from "flatbuffers";
|
||||
import * as dispatch from "./dispatch";
|
||||
|
||||
|
@ -30,13 +30,13 @@ export async function truncate(name: string, len?: number): Promise<void> {
|
|||
function req(
|
||||
name: string,
|
||||
len?: number
|
||||
): [flatbuffers.Builder, fbs.Any, flatbuffers.Offset] {
|
||||
): [flatbuffers.Builder, msg.Any, flatbuffers.Offset] {
|
||||
const builder = new flatbuffers.Builder();
|
||||
const name_ = builder.createString(name);
|
||||
len = len && len > 0 ? Math.floor(len) : 0;
|
||||
fbs.Truncate.startTruncate(builder);
|
||||
fbs.Truncate.addName(builder, name_);
|
||||
fbs.Truncate.addLen(builder, len);
|
||||
const inner = fbs.Truncate.endTruncate(builder);
|
||||
return [builder, fbs.Any.Truncate, inner];
|
||||
msg.Truncate.startTruncate(builder);
|
||||
msg.Truncate.addName(builder, name_);
|
||||
msg.Truncate.addLen(builder, len);
|
||||
const inner = msg.Truncate.endTruncate(builder);
|
||||
return [builder, msg.Any.Truncate, inner];
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Copyright 2018 the Deno authors. All rights reserved. MIT license.
|
||||
import * as fbs from "gen/msg_generated";
|
||||
import * as msg from "gen/msg_generated";
|
||||
import { flatbuffers } from "flatbuffers";
|
||||
import * as dispatch from "./dispatch";
|
||||
|
||||
|
@ -41,12 +41,12 @@ function req(
|
|||
filename: string,
|
||||
data: Uint8Array,
|
||||
perm: number
|
||||
): [flatbuffers.Builder, fbs.Any, flatbuffers.Offset, Uint8Array] {
|
||||
): [flatbuffers.Builder, msg.Any, flatbuffers.Offset, Uint8Array] {
|
||||
const builder = new flatbuffers.Builder();
|
||||
const filename_ = builder.createString(filename);
|
||||
fbs.WriteFile.startWriteFile(builder);
|
||||
fbs.WriteFile.addFilename(builder, filename_);
|
||||
fbs.WriteFile.addPerm(builder, perm);
|
||||
const inner = fbs.WriteFile.endWriteFile(builder);
|
||||
return [builder, fbs.Any.WriteFile, inner, data];
|
||||
msg.WriteFile.startWriteFile(builder);
|
||||
msg.WriteFile.addFilename(builder, filename_);
|
||||
msg.WriteFile.addPerm(builder, perm);
|
||||
const inner = msg.WriteFile.endWriteFile(builder);
|
||||
return [builder, msg.Any.WriteFile, inner, data];
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue