1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-01-18 11:53:59 -05:00

Rename fbs to msg.

This commit is contained in:
Ryan Dahl 2018-10-03 21:18:23 -04:00
parent f774953011
commit 818ad37678
22 changed files with 201 additions and 201 deletions

View file

@ -111,8 +111,8 @@ test(function consoleTestStringifyWithDepth() {
test(function consoleTestError() { test(function consoleTestError() {
class MyError extends Error { class MyError extends Error {
constructor(msg: string) { constructor(errStr: string) {
super(msg); super(errStr);
this.name = "MyError"; this.name = "MyError";
} }
} }

View file

@ -1,5 +1,5 @@
// Copyright 2018 the Deno authors. All rights reserved. MIT license. // 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 { flatbuffers } from "flatbuffers";
import * as dispatch from "./dispatch"; import * as dispatch from "./dispatch";
@ -34,13 +34,13 @@ export async function copyFile(from: string, to: string): Promise<void> {
function req( function req(
from: string, from: string,
to: string to: string
): [flatbuffers.Builder, fbs.Any, flatbuffers.Offset] { ): [flatbuffers.Builder, msg.Any, flatbuffers.Offset] {
const builder = new flatbuffers.Builder(); const builder = new flatbuffers.Builder();
const from_ = builder.createString(from); const from_ = builder.createString(from);
const to_ = builder.createString(to); const to_ = builder.createString(to);
fbs.CopyFile.startCopyFile(builder); msg.CopyFile.startCopyFile(builder);
fbs.CopyFile.addFrom(builder, from_); msg.CopyFile.addFrom(builder, from_);
fbs.CopyFile.addTo(builder, to_); msg.CopyFile.addTo(builder, to_);
const inner = fbs.CopyFile.endCopyFile(builder); const inner = msg.CopyFile.endCopyFile(builder);
return [builder, fbs.Any.CopyFile, inner]; return [builder, msg.Any.CopyFile, inner];
} }

View file

@ -1,13 +1,13 @@
// Copyright 2018 the Deno authors. All rights reserved. MIT license. // Copyright 2018 the Deno authors. All rights reserved. MIT license.
import { libdeno } from "./libdeno"; import { libdeno } from "./libdeno";
import { flatbuffers } from "flatbuffers"; 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 errors from "./errors";
import * as util from "./util"; import * as util from "./util";
import { maybePushTrace } from "./trace"; import { maybePushTrace } from "./trace";
let nextCmdId = 0; let nextCmdId = 0;
const promiseTable = new Map<number, util.Resolvable<fbs.Base>>(); const promiseTable = new Map<number, util.Resolvable<msg.Base>>();
let fireTimers: () => void; let fireTimers: () => void;
@ -20,7 +20,7 @@ export function handleAsyncMsgFromRust(ui8: Uint8Array) {
// did not receive a message. // did not receive a message.
if (ui8.length) { if (ui8.length) {
const bb = new flatbuffers.ByteBuffer(ui8); const bb = new flatbuffers.ByteBuffer(ui8);
const base = fbs.Base.getRootAsBase(bb); const base = msg.Base.getRootAsBase(bb);
const cmdId = base.cmdId(); const cmdId = base.cmdId();
const promise = promiseTable.get(cmdId); const promise = promiseTable.get(cmdId);
util.assert(promise != null, `Expecting promise in table. ${cmdId}`); util.assert(promise != null, `Expecting promise in table. ${cmdId}`);
@ -39,14 +39,14 @@ export function handleAsyncMsgFromRust(ui8: Uint8Array) {
// @internal // @internal
export function sendAsync( export function sendAsync(
builder: flatbuffers.Builder, builder: flatbuffers.Builder,
innerType: fbs.Any, innerType: msg.Any,
inner: flatbuffers.Offset, inner: flatbuffers.Offset,
data?: ArrayBufferView data?: ArrayBufferView
): Promise<fbs.Base> { ): Promise<msg.Base> {
maybePushTrace(innerType, false); // add to trace if tracing maybePushTrace(innerType, false); // add to trace if tracing
const [cmdId, resBuf] = sendInternal(builder, innerType, inner, data, false); const [cmdId, resBuf] = sendInternal(builder, innerType, inner, data, false);
util.assert(resBuf == null); util.assert(resBuf == null);
const promise = util.createResolvable<fbs.Base>(); const promise = util.createResolvable<msg.Base>();
promiseTable.set(cmdId, promise); promiseTable.set(cmdId, promise);
return promise; return promise;
} }
@ -54,10 +54,10 @@ export function sendAsync(
// @internal // @internal
export function sendSync( export function sendSync(
builder: flatbuffers.Builder, builder: flatbuffers.Builder,
innerType: fbs.Any, innerType: msg.Any,
inner: flatbuffers.Offset, inner: flatbuffers.Offset,
data?: ArrayBufferView data?: ArrayBufferView
): null | fbs.Base { ): null | msg.Base {
maybePushTrace(innerType, true); // add to trace if tracing maybePushTrace(innerType, true); // add to trace if tracing
const [cmdId, resBuf] = sendInternal(builder, innerType, inner, data, true); const [cmdId, resBuf] = sendInternal(builder, innerType, inner, data, true);
util.assert(cmdId >= 0); util.assert(cmdId >= 0);
@ -66,7 +66,7 @@ export function sendSync(
} else { } else {
const u8 = new Uint8Array(resBuf!); const u8 = new Uint8Array(resBuf!);
const bb = new flatbuffers.ByteBuffer(u8); const bb = new flatbuffers.ByteBuffer(u8);
const baseRes = fbs.Base.getRootAsBase(bb); const baseRes = msg.Base.getRootAsBase(bb);
errors.maybeThrowError(baseRes); errors.maybeThrowError(baseRes);
return baseRes; return baseRes;
} }
@ -74,18 +74,18 @@ export function sendSync(
function sendInternal( function sendInternal(
builder: flatbuffers.Builder, builder: flatbuffers.Builder,
innerType: fbs.Any, innerType: msg.Any,
inner: flatbuffers.Offset, inner: flatbuffers.Offset,
data: undefined | ArrayBufferView, data: undefined | ArrayBufferView,
sync = true sync = true
): [number, null | Uint8Array] { ): [number, null | Uint8Array] {
const cmdId = nextCmdId++; const cmdId = nextCmdId++;
fbs.Base.startBase(builder); msg.Base.startBase(builder);
fbs.Base.addInner(builder, inner); msg.Base.addInner(builder, inner);
fbs.Base.addInnerType(builder, innerType); msg.Base.addInnerType(builder, innerType);
fbs.Base.addSync(builder, sync); msg.Base.addSync(builder, sync);
fbs.Base.addCmdId(builder, cmdId); msg.Base.addCmdId(builder, cmdId);
builder.finish(fbs.Base.endBase(builder)); builder.finish(msg.Base.endBase(builder));
return [cmdId, libdeno.send(builder.asUint8Array(), data)]; return [cmdId, libdeno.send(builder.asUint8Array(), data)];
} }

View file

@ -1,25 +1,25 @@
import * as fbs from "gen/msg_generated"; import * as msg from "gen/msg_generated";
export { ErrorKind } from "gen/msg_generated"; export { ErrorKind } from "gen/msg_generated";
// @internal // @internal
export class DenoError<T extends fbs.ErrorKind> extends Error { export class DenoError<T extends msg.ErrorKind> extends Error {
constructor(readonly kind: T, msg: string) { constructor(readonly kind: T, errStr: string) {
super(msg); super(errStr);
this.name = fbs.ErrorKind[kind]; this.name = msg.ErrorKind[kind];
} }
} }
// @internal // @internal
export function maybeThrowError(base: fbs.Base): void { export function maybeThrowError(base: msg.Base): void {
const err = maybeError(base); const err = maybeError(base);
if (err != null) { if (err != null) {
throw err; 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(); const kind = base.errorKind();
if (kind === fbs.ErrorKind.NoError) { if (kind === msg.ErrorKind.NoError) {
return null; return null;
} else { } else {
return new DenoError(kind, base.error()!); return new DenoError(kind, base.error()!);

View file

@ -9,7 +9,7 @@ import {
} from "./util"; } from "./util";
import { flatbuffers } from "flatbuffers"; import { flatbuffers } from "flatbuffers";
import { sendAsync } from "./dispatch"; import { sendAsync } from "./dispatch";
import * as fbs from "gen/msg_generated"; import * as msg from "gen/msg_generated";
import { import {
Headers, Headers,
Request, Request,
@ -170,7 +170,7 @@ class FetchResponse implements Response {
onHeader?: (res: FetchResponse) => void; onHeader?: (res: FetchResponse) => void;
onError?: (error: Error) => void; onError?: (error: Error) => void;
onMsg(base: fbs.Base) { onMsg(base: msg.Base) {
/* /*
const error = base.error(); const error = base.error();
if (error != null) { if (error != null) {
@ -196,17 +196,17 @@ export async function fetch(
// Send FetchReq message // Send FetchReq message
const builder = new flatbuffers.Builder(); const builder = new flatbuffers.Builder();
const url_ = builder.createString(url); const url_ = builder.createString(url);
fbs.FetchReq.startFetchReq(builder); msg.FetchReq.startFetchReq(builder);
fbs.FetchReq.addUrl(builder, url_); msg.FetchReq.addUrl(builder, url_);
const resBase = await sendAsync( const resBase = await sendAsync(
builder, builder,
fbs.Any.FetchReq, msg.Any.FetchReq,
fbs.FetchReq.endFetchReq(builder) msg.FetchReq.endFetchReq(builder)
); );
// Decode FetchRes // Decode FetchRes
assert(fbs.Any.FetchRes === resBase.innerType()); assert(msg.Any.FetchRes === resBase.innerType());
const inner = new fbs.FetchRes(); const inner = new msg.FetchRes();
assert(resBase.inner(inner) != null); assert(resBase.inner(inner) != null);
const status = inner.status(); const status = inner.status();

View file

@ -1,5 +1,5 @@
// Copyright 2018 the Deno authors. All rights reserved. MIT license. // 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`, * A FileInfo describes a file and is returned by `stat`, `lstat`,
@ -73,7 +73,7 @@ export class FileInfoImpl implements FileInfo {
path: string | null; path: string | null;
/* @internal */ /* @internal */
constructor(private _inner: fbs.StatRes) { constructor(private _inner: msg.StatRes) {
const modified = this._inner.modified().toFloat64(); const modified = this._inner.modified().toFloat64();
const accessed = this._inner.accessed().toFloat64(); const accessed = this._inner.accessed().toFloat64();
const created = this._inner.created().toFloat64(); const created = this._inner.created().toFloat64();

View file

@ -2,7 +2,7 @@
import { Reader, Writer, Closer, ReadResult } from "./io"; import { Reader, Writer, Closer, ReadResult } from "./io";
import * as dispatch from "./dispatch"; import * as dispatch from "./dispatch";
import * as fbs from "gen/msg_generated"; import * as msg from "gen/msg_generated";
import { assert } from "./util"; import { assert } from "./util";
import { flatbuffers } from "flatbuffers"; import { flatbuffers } from "flatbuffers";
@ -39,13 +39,13 @@ export async function open(
): Promise<File> { ): Promise<File> {
const builder = new flatbuffers.Builder(); const builder = new flatbuffers.Builder();
const filename_ = builder.createString(filename); const filename_ = builder.createString(filename);
fbs.Open.startOpen(builder); msg.Open.startOpen(builder);
fbs.Open.addFilename(builder, filename_); msg.Open.addFilename(builder, filename_);
const inner = fbs.Open.endOpen(builder); const inner = msg.Open.endOpen(builder);
const baseRes = await dispatch.sendAsync(builder, fbs.Any.Open, inner); const baseRes = await dispatch.sendAsync(builder, msg.Any.Open, inner);
assert(baseRes != null); assert(baseRes != null);
assert(fbs.Any.OpenRes === baseRes!.innerType()); assert(msg.Any.OpenRes === baseRes!.innerType());
const res = new fbs.OpenRes(); const res = new msg.OpenRes();
assert(baseRes!.inner(res) != null); assert(baseRes!.inner(res) != null);
const fd = res.rid(); const fd = res.rid();
return new File(fd); return new File(fd);
@ -56,34 +56,34 @@ export async function read(
p: ArrayBufferView p: ArrayBufferView
): Promise<ReadResult> { ): Promise<ReadResult> {
const builder = new flatbuffers.Builder(); const builder = new flatbuffers.Builder();
fbs.Read.startRead(builder); msg.Read.startRead(builder);
fbs.Read.addRid(builder, fd); msg.Read.addRid(builder, fd);
const inner = fbs.Read.endRead(builder); const inner = msg.Read.endRead(builder);
const baseRes = await dispatch.sendAsync(builder, fbs.Any.Read, inner, p); const baseRes = await dispatch.sendAsync(builder, msg.Any.Read, inner, p);
assert(baseRes != null); assert(baseRes != null);
assert(fbs.Any.ReadRes === baseRes!.innerType()); assert(msg.Any.ReadRes === baseRes!.innerType());
const res = new fbs.ReadRes(); const res = new msg.ReadRes();
assert(baseRes!.inner(res) != null); assert(baseRes!.inner(res) != null);
return { nread: res.nread(), eof: res.eof() }; return { nread: res.nread(), eof: res.eof() };
} }
export async function write(fd: number, p: ArrayBufferView): Promise<number> { export async function write(fd: number, p: ArrayBufferView): Promise<number> {
const builder = new flatbuffers.Builder(); const builder = new flatbuffers.Builder();
fbs.Write.startWrite(builder); msg.Write.startWrite(builder);
fbs.Write.addRid(builder, fd); msg.Write.addRid(builder, fd);
const inner = fbs.Write.endWrite(builder); const inner = msg.Write.endWrite(builder);
const baseRes = await dispatch.sendAsync(builder, fbs.Any.Write, inner, p); const baseRes = await dispatch.sendAsync(builder, msg.Any.Write, inner, p);
assert(baseRes != null); assert(baseRes != null);
assert(fbs.Any.WriteRes === baseRes!.innerType()); assert(msg.Any.WriteRes === baseRes!.innerType());
const res = new fbs.WriteRes(); const res = new msg.WriteRes();
assert(baseRes!.inner(res) != null); assert(baseRes!.inner(res) != null);
return res.nbyte(); return res.nbyte();
} }
export function close(fd: number): void { export function close(fd: number): void {
const builder = new flatbuffers.Builder(); const builder = new flatbuffers.Builder();
fbs.Close.startClose(builder); msg.Close.startClose(builder);
fbs.Close.addRid(builder, fd); msg.Close.addRid(builder, fd);
const inner = fbs.Close.endClose(builder); const inner = msg.Close.endClose(builder);
dispatch.sendSync(builder, fbs.Any.Close, inner); dispatch.sendSync(builder, msg.Any.Close, inner);
} }

View file

@ -1,6 +1,6 @@
// Copyright 2018 the Deno authors. All rights reserved. MIT license. // Copyright 2018 the Deno authors. All rights reserved. MIT license.
import { flatbuffers } from "flatbuffers"; 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 { assert, log, setLogDebug } from "./util";
import * as os from "./os"; import * as os from "./os";
import { DenoCompiler } from "./compiler"; import { DenoCompiler } from "./compiler";
@ -8,14 +8,14 @@ import { libdeno } from "./libdeno";
import { args } from "./deno"; import { args } from "./deno";
import { sendSync, handleAsyncMsgFromRust } from "./dispatch"; import { sendSync, handleAsyncMsgFromRust } from "./dispatch";
function sendStart(): fbs.StartRes { function sendStart(): msg.StartRes {
const builder = new flatbuffers.Builder(); const builder = new flatbuffers.Builder();
fbs.Start.startStart(builder); msg.Start.startStart(builder);
const startOffset = fbs.Start.endStart(builder); const startOffset = msg.Start.endStart(builder);
const baseRes = sendSync(builder, fbs.Any.Start, startOffset); const baseRes = sendSync(builder, msg.Any.Start, startOffset);
assert(baseRes != null); assert(baseRes != null);
assert(fbs.Any.StartRes === baseRes!.innerType()); assert(msg.Any.StartRes === baseRes!.innerType());
const startRes = new fbs.StartRes(); const startRes = new msg.StartRes();
assert(baseRes!.inner(startRes) != null); assert(baseRes!.inner(startRes) != null);
return startRes; return startRes;
} }

View file

@ -1,5 +1,5 @@
// Copyright 2018 the Deno authors. All rights reserved. MIT license. // 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 { flatbuffers } from "flatbuffers";
import * as dispatch from "./dispatch"; import * as dispatch from "./dispatch";
import { assert } from "./util"; import { assert } from "./util";
@ -44,29 +44,29 @@ function req({
dir, dir,
prefix, prefix,
suffix suffix
}: MakeTempDirOptions): [flatbuffers.Builder, fbs.Any, flatbuffers.Offset] { }: MakeTempDirOptions): [flatbuffers.Builder, msg.Any, flatbuffers.Offset] {
const builder = new flatbuffers.Builder(); const builder = new flatbuffers.Builder();
const fbDir = dir == null ? -1 : builder.createString(dir); const fbDir = dir == null ? -1 : builder.createString(dir);
const fbPrefix = prefix == null ? -1 : builder.createString(prefix); const fbPrefix = prefix == null ? -1 : builder.createString(prefix);
const fbSuffix = suffix == null ? -1 : builder.createString(suffix); const fbSuffix = suffix == null ? -1 : builder.createString(suffix);
fbs.MakeTempDir.startMakeTempDir(builder); msg.MakeTempDir.startMakeTempDir(builder);
if (dir != null) { if (dir != null) {
fbs.MakeTempDir.addDir(builder, fbDir); msg.MakeTempDir.addDir(builder, fbDir);
} }
if (prefix != null) { if (prefix != null) {
fbs.MakeTempDir.addPrefix(builder, fbPrefix); msg.MakeTempDir.addPrefix(builder, fbPrefix);
} }
if (suffix != null) { if (suffix != null) {
fbs.MakeTempDir.addSuffix(builder, fbSuffix); msg.MakeTempDir.addSuffix(builder, fbSuffix);
} }
const inner = fbs.MakeTempDir.endMakeTempDir(builder); const inner = msg.MakeTempDir.endMakeTempDir(builder);
return [builder, fbs.Any.MakeTempDir, inner]; return [builder, msg.Any.MakeTempDir, inner];
} }
function res(baseRes: null | fbs.Base): string { function res(baseRes: null | msg.Base): string {
assert(baseRes != null); assert(baseRes != null);
assert(fbs.Any.MakeTempDirRes === baseRes!.innerType()); assert(msg.Any.MakeTempDirRes === baseRes!.innerType());
const res = new fbs.MakeTempDirRes(); const res = new msg.MakeTempDirRes();
assert(baseRes!.inner(res) != null); assert(baseRes!.inner(res) != null);
const path = res.path(); const path = res.path();
assert(path != null); assert(path != null);

View file

@ -1,5 +1,5 @@
// Copyright 2018 the Deno authors. All rights reserved. MIT license. // 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 { flatbuffers } from "flatbuffers";
import * as dispatch from "./dispatch"; import * as dispatch from "./dispatch";
@ -26,12 +26,12 @@ export async function mkdir(path: string, mode = 0o777): Promise<void> {
function req( function req(
path: string, path: string,
mode: number mode: number
): [flatbuffers.Builder, fbs.Any, flatbuffers.Offset] { ): [flatbuffers.Builder, msg.Any, flatbuffers.Offset] {
const builder = new flatbuffers.Builder(); const builder = new flatbuffers.Builder();
const path_ = builder.createString(path); const path_ = builder.createString(path);
fbs.Mkdir.startMkdir(builder); msg.Mkdir.startMkdir(builder);
fbs.Mkdir.addPath(builder, path_); msg.Mkdir.addPath(builder, path_);
fbs.Mkdir.addMode(builder, mode); msg.Mkdir.addMode(builder, mode);
const inner = fbs.Mkdir.endMkdir(builder); const inner = msg.Mkdir.endMkdir(builder);
return [builder, fbs.Any.Mkdir, inner]; return [builder, msg.Any.Mkdir, inner];
} }

View file

@ -1,6 +1,6 @@
// Copyright 2018 the Deno authors. All rights reserved. MIT license. // Copyright 2018 the Deno authors. All rights reserved. MIT license.
import { ModuleInfo } from "./types"; import { ModuleInfo } from "./types";
import * as fbs from "gen/msg_generated"; import * as msg from "gen/msg_generated";
import { assert } from "./util"; import { assert } from "./util";
import * as util from "./util"; import * as util from "./util";
import { flatbuffers } from "flatbuffers"; import { flatbuffers } from "flatbuffers";
@ -8,10 +8,10 @@ import { sendSync } from "./dispatch";
export function exit(exitCode = 0): never { export function exit(exitCode = 0): never {
const builder = new flatbuffers.Builder(); const builder = new flatbuffers.Builder();
fbs.Exit.startExit(builder); msg.Exit.startExit(builder);
fbs.Exit.addCode(builder, exitCode); msg.Exit.addCode(builder, exitCode);
const inner = fbs.Exit.endExit(builder); const inner = msg.Exit.endExit(builder);
sendSync(builder, fbs.Any.Exit, inner); sendSync(builder, msg.Any.Exit, inner);
return util.unreachable(); return util.unreachable();
} }
@ -24,17 +24,17 @@ export function codeFetch(
const builder = new flatbuffers.Builder(); const builder = new flatbuffers.Builder();
const moduleSpecifier_ = builder.createString(moduleSpecifier); const moduleSpecifier_ = builder.createString(moduleSpecifier);
const containingFile_ = builder.createString(containingFile); const containingFile_ = builder.createString(containingFile);
fbs.CodeFetch.startCodeFetch(builder); msg.CodeFetch.startCodeFetch(builder);
fbs.CodeFetch.addModuleSpecifier(builder, moduleSpecifier_); msg.CodeFetch.addModuleSpecifier(builder, moduleSpecifier_);
fbs.CodeFetch.addContainingFile(builder, containingFile_); msg.CodeFetch.addContainingFile(builder, containingFile_);
const inner = fbs.CodeFetch.endCodeFetch(builder); const inner = msg.CodeFetch.endCodeFetch(builder);
const baseRes = sendSync(builder, fbs.Any.CodeFetch, inner); const baseRes = sendSync(builder, msg.Any.CodeFetch, inner);
assert(baseRes != null); assert(baseRes != null);
assert( assert(
fbs.Any.CodeFetchRes === baseRes!.innerType(), msg.Any.CodeFetchRes === baseRes!.innerType(),
`base.innerType() unexpectedly is ${baseRes!.innerType()}` `base.innerType() unexpectedly is ${baseRes!.innerType()}`
); );
const codeFetchRes = new fbs.CodeFetchRes(); const codeFetchRes = new msg.CodeFetchRes();
assert(baseRes!.inner(codeFetchRes) != null); assert(baseRes!.inner(codeFetchRes) != null);
return { return {
moduleName: codeFetchRes.moduleName(), moduleName: codeFetchRes.moduleName(),
@ -54,16 +54,16 @@ export function codeCache(
const filename_ = builder.createString(filename); const filename_ = builder.createString(filename);
const sourceCode_ = builder.createString(sourceCode); const sourceCode_ = builder.createString(sourceCode);
const outputCode_ = builder.createString(outputCode); const outputCode_ = builder.createString(outputCode);
fbs.CodeCache.startCodeCache(builder); msg.CodeCache.startCodeCache(builder);
fbs.CodeCache.addFilename(builder, filename_); msg.CodeCache.addFilename(builder, filename_);
fbs.CodeCache.addSourceCode(builder, sourceCode_); msg.CodeCache.addSourceCode(builder, sourceCode_);
fbs.CodeCache.addOutputCode(builder, outputCode_); msg.CodeCache.addOutputCode(builder, outputCode_);
const inner = fbs.CodeCache.endCodeCache(builder); const inner = msg.CodeCache.endCodeCache(builder);
const baseRes = sendSync(builder, fbs.Any.CodeCache, inner); const baseRes = sendSync(builder, msg.Any.CodeCache, inner);
assert(baseRes == null); // Expect null or error. 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 } = {}; const env: { [index: string]: string } = {};
for (let i = 0; i < _inner.mapLength(); i++) { 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 builder = new flatbuffers.Builder();
const _key = builder.createString(key); const _key = builder.createString(key);
const _value = builder.createString(value); const _value = builder.createString(value);
fbs.SetEnv.startSetEnv(builder); msg.SetEnv.startSetEnv(builder);
fbs.SetEnv.addKey(builder, _key); msg.SetEnv.addKey(builder, _key);
fbs.SetEnv.addValue(builder, _value); msg.SetEnv.addValue(builder, _value);
const inner = fbs.SetEnv.endSetEnv(builder); const inner = msg.SetEnv.endSetEnv(builder);
sendSync(builder, fbs.Any.SetEnv, inner); sendSync(builder, msg.Any.SetEnv, inner);
} }
/** /**
@ -107,15 +107,15 @@ function setEnv(key: string, value: string): void {
export function env(): { [index: string]: string } { export function env(): { [index: string]: string } {
/* Ideally we could write /* Ideally we could write
const res = sendSync({ const res = sendSync({
command: fbs.Command.ENV, command: msg.Command.ENV,
}); });
*/ */
const builder = new flatbuffers.Builder(); const builder = new flatbuffers.Builder();
fbs.Environ.startEnviron(builder); msg.Environ.startEnviron(builder);
const inner = fbs.Environ.endEnviron(builder); const inner = msg.Environ.endEnviron(builder);
const baseRes = sendSync(builder, fbs.Any.Environ, inner)!; const baseRes = sendSync(builder, msg.Any.Environ, inner)!;
assert(fbs.Any.EnvironRes === baseRes.innerType()); assert(msg.Any.EnvironRes === baseRes.innerType());
const res = new fbs.EnvironRes(); const res = new msg.EnvironRes();
assert(baseRes.inner(res) != null); assert(baseRes.inner(res) != null);
// TypeScript cannot track assertion above, therefore not null assertion // TypeScript cannot track assertion above, therefore not null assertion
return createEnv(res); return createEnv(res);

View file

@ -1,5 +1,5 @@
// Copyright 2018 the Deno authors. All rights reserved. MIT license. // 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 { flatbuffers } from "flatbuffers";
import * as dispatch from "./dispatch"; import * as dispatch from "./dispatch";
import { FileInfo, FileInfoImpl } from "./fileinfo"; import { FileInfo, FileInfoImpl } from "./fileinfo";
@ -27,19 +27,19 @@ export async function readDir(path: string): Promise<FileInfo[]> {
return res(await dispatch.sendAsync(...req(path))); 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 builder = new flatbuffers.Builder();
const path_ = builder.createString(path); const path_ = builder.createString(path);
fbs.ReadDir.startReadDir(builder); msg.ReadDir.startReadDir(builder);
fbs.ReadDir.addPath(builder, path_); msg.ReadDir.addPath(builder, path_);
const inner = fbs.ReadDir.endReadDir(builder); const inner = msg.ReadDir.endReadDir(builder);
return [builder, fbs.Any.ReadDir, inner]; return [builder, msg.Any.ReadDir, inner];
} }
function res(baseRes: null | fbs.Base): FileInfo[] { function res(baseRes: null | msg.Base): FileInfo[] {
assert(baseRes != null); assert(baseRes != null);
assert(fbs.Any.ReadDirRes === baseRes!.innerType()); assert(msg.Any.ReadDirRes === baseRes!.innerType());
const res = new fbs.ReadDirRes(); const res = new msg.ReadDirRes();
assert(baseRes!.inner(res) != null); assert(baseRes!.inner(res) != null);
const fileInfos: FileInfo[] = []; const fileInfos: FileInfo[] = [];
for (let i = 0; i < res.entriesLength(); i++) { for (let i = 0; i < res.entriesLength(); i++) {

View file

@ -1,5 +1,5 @@
// Copyright 2018 the Deno authors. All rights reserved. MIT license. // 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 { flatbuffers } from "flatbuffers";
import { assert } from "./util"; import { assert } from "./util";
import * as dispatch from "./dispatch"; import * as dispatch from "./dispatch";
@ -30,19 +30,19 @@ export async function readFile(filename: string): Promise<Uint8Array> {
function req( function req(
filename: string filename: string
): [flatbuffers.Builder, fbs.Any, flatbuffers.Offset] { ): [flatbuffers.Builder, msg.Any, flatbuffers.Offset] {
const builder = new flatbuffers.Builder(); const builder = new flatbuffers.Builder();
const filename_ = builder.createString(filename); const filename_ = builder.createString(filename);
fbs.ReadFile.startReadFile(builder); msg.ReadFile.startReadFile(builder);
fbs.ReadFile.addFilename(builder, filename_); msg.ReadFile.addFilename(builder, filename_);
const inner = fbs.ReadFile.endReadFile(builder); const inner = msg.ReadFile.endReadFile(builder);
return [builder, fbs.Any.ReadFile, inner]; return [builder, msg.Any.ReadFile, inner];
} }
function res(baseRes: null | fbs.Base): Uint8Array { function res(baseRes: null | msg.Base): Uint8Array {
assert(baseRes != null); assert(baseRes != null);
assert(fbs.Any.ReadFileRes === baseRes!.innerType()); assert(msg.Any.ReadFileRes === baseRes!.innerType());
const inner = new fbs.ReadFileRes(); const inner = new msg.ReadFileRes();
assert(baseRes!.inner(inner) != null); assert(baseRes!.inner(inner) != null);
const dataArray = inner.dataArray(); const dataArray = inner.dataArray();
assert(dataArray != null); assert(dataArray != null);

View file

@ -1,5 +1,5 @@
// Copyright 2018 the Deno authors. All rights reserved. MIT license. // 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 { flatbuffers } from "flatbuffers";
import { assert } from "./util"; import { assert } from "./util";
import * as dispatch from "./dispatch"; import * as dispatch from "./dispatch";
@ -24,19 +24,19 @@ export async function readlink(name: string): Promise<string> {
return res(await dispatch.sendAsync(...req(name))); 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 builder = new flatbuffers.Builder();
const name_ = builder.createString(name); const name_ = builder.createString(name);
fbs.Readlink.startReadlink(builder); msg.Readlink.startReadlink(builder);
fbs.Readlink.addName(builder, name_); msg.Readlink.addName(builder, name_);
const inner = fbs.Readlink.endReadlink(builder); const inner = msg.Readlink.endReadlink(builder);
return [builder, fbs.Any.Readlink, inner]; return [builder, msg.Any.Readlink, inner];
} }
function res(baseRes: null | fbs.Base): string { function res(baseRes: null | msg.Base): string {
assert(baseRes !== null); assert(baseRes !== null);
assert(fbs.Any.ReadlinkRes === baseRes!.innerType()); assert(msg.Any.ReadlinkRes === baseRes!.innerType());
const res = new fbs.ReadlinkRes(); const res = new msg.ReadlinkRes();
assert(baseRes!.inner(res) !== null); assert(baseRes!.inner(res) !== null);
const path = res.path(); const path = res.path();
assert(path !== null); assert(path !== null);

View file

@ -1,5 +1,5 @@
// Copyright 2018 the Deno authors. All rights reserved. MIT license. // 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 { flatbuffers } from "flatbuffers";
import * as dispatch from "./dispatch"; import * as dispatch from "./dispatch";
@ -52,12 +52,12 @@ export async function removeAll(path: string): Promise<void> {
function req( function req(
path: string, path: string,
recursive: boolean recursive: boolean
): [flatbuffers.Builder, fbs.Any, flatbuffers.Offset] { ): [flatbuffers.Builder, msg.Any, flatbuffers.Offset] {
const builder = new flatbuffers.Builder(); const builder = new flatbuffers.Builder();
const path_ = builder.createString(path); const path_ = builder.createString(path);
fbs.Remove.startRemove(builder); msg.Remove.startRemove(builder);
fbs.Remove.addPath(builder, path_); msg.Remove.addPath(builder, path_);
fbs.Remove.addRecursive(builder, recursive); msg.Remove.addRecursive(builder, recursive);
const inner = fbs.Remove.endRemove(builder); const inner = msg.Remove.endRemove(builder);
return [builder, fbs.Any.Remove, inner]; return [builder, msg.Any.Remove, inner];
} }

View file

@ -1,5 +1,5 @@
// Copyright 2018 the Deno authors. All rights reserved. MIT license. // 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 { flatbuffers } from "flatbuffers";
import * as dispatch from "./dispatch"; import * as dispatch from "./dispatch";
@ -30,13 +30,13 @@ export async function rename(oldpath: string, newpath: string): Promise<void> {
function req( function req(
oldpath: string, oldpath: string,
newpath: string newpath: string
): [flatbuffers.Builder, fbs.Any, flatbuffers.Offset] { ): [flatbuffers.Builder, msg.Any, flatbuffers.Offset] {
const builder = new flatbuffers.Builder(); const builder = new flatbuffers.Builder();
const oldpath_ = builder.createString(oldpath); const oldpath_ = builder.createString(oldpath);
const newpath_ = builder.createString(newpath); const newpath_ = builder.createString(newpath);
fbs.Rename.startRename(builder); msg.Rename.startRename(builder);
fbs.Rename.addOldpath(builder, oldpath_); msg.Rename.addOldpath(builder, oldpath_);
fbs.Rename.addNewpath(builder, newpath_); msg.Rename.addNewpath(builder, newpath_);
const inner = fbs.Rename.endRename(builder); const inner = msg.Rename.endRename(builder);
return [builder, fbs.Any.Rename, inner]; return [builder, msg.Any.Rename, inner];
} }

View file

@ -1,5 +1,5 @@
// Copyright 2018 the Deno authors. All rights reserved. MIT license. // 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 { flatbuffers } from "flatbuffers";
import * as dispatch from "./dispatch"; import * as dispatch from "./dispatch";
import { assert } from "./util"; import { assert } from "./util";
@ -58,20 +58,20 @@ export function statSync(filename: string): FileInfo {
function req( function req(
filename: string, filename: string,
lstat: boolean lstat: boolean
): [flatbuffers.Builder, fbs.Any, flatbuffers.Offset] { ): [flatbuffers.Builder, msg.Any, flatbuffers.Offset] {
const builder = new flatbuffers.Builder(); const builder = new flatbuffers.Builder();
const filename_ = builder.createString(filename); const filename_ = builder.createString(filename);
fbs.Stat.startStat(builder); msg.Stat.startStat(builder);
fbs.Stat.addFilename(builder, filename_); msg.Stat.addFilename(builder, filename_);
fbs.Stat.addLstat(builder, lstat); msg.Stat.addLstat(builder, lstat);
const inner = fbs.Stat.endStat(builder); const inner = msg.Stat.endStat(builder);
return [builder, fbs.Any.Stat, inner]; return [builder, msg.Any.Stat, inner];
} }
function res(baseRes: null | fbs.Base): FileInfo { function res(baseRes: null | msg.Base): FileInfo {
assert(baseRes != null); assert(baseRes != null);
assert(fbs.Any.StatRes === baseRes!.innerType()); assert(msg.Any.StatRes === baseRes!.innerType());
const res = new fbs.StatRes(); const res = new msg.StatRes();
assert(baseRes!.inner(res) != null); assert(baseRes!.inner(res) != null);
return new FileInfoImpl(res); return new FileInfoImpl(res);
} }

View file

@ -1,5 +1,5 @@
// Copyright 2018 the Deno authors. All rights reserved. MIT license. // 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 { flatbuffers } from "flatbuffers";
import * as dispatch from "./dispatch"; import * as dispatch from "./dispatch";
import * as util from "./util"; import * as util from "./util";
@ -40,7 +40,7 @@ function req(
oldname: string, oldname: string,
newname: string, newname: string,
type?: string type?: string
): [flatbuffers.Builder, fbs.Any, flatbuffers.Offset] { ): [flatbuffers.Builder, msg.Any, flatbuffers.Offset] {
// TODO Use type for Windows. // TODO Use type for Windows.
if (type) { if (type) {
return util.notImplemented(); return util.notImplemented();
@ -48,9 +48,9 @@ function req(
const builder = new flatbuffers.Builder(); const builder = new flatbuffers.Builder();
const oldname_ = builder.createString(oldname); const oldname_ = builder.createString(oldname);
const newname_ = builder.createString(newname); const newname_ = builder.createString(newname);
fbs.Symlink.startSymlink(builder); msg.Symlink.startSymlink(builder);
fbs.Symlink.addOldname(builder, oldname_); msg.Symlink.addOldname(builder, oldname_);
fbs.Symlink.addNewname(builder, newname_); msg.Symlink.addNewname(builder, newname_);
const inner = fbs.Symlink.endSymlink(builder); const inner = msg.Symlink.endSymlink(builder);
return [builder, fbs.Any.Symlink, inner]; return [builder, msg.Any.Symlink, inner];
} }

View file

@ -1,6 +1,6 @@
// Copyright 2018 the Deno authors. All rights reserved. MIT license. // Copyright 2018 the Deno authors. All rights reserved. MIT license.
import { assert } from "./util"; import { assert } from "./util";
import * as fbs from "gen/msg_generated"; import * as msg from "gen/msg_generated";
import { flatbuffers } from "flatbuffers"; import { flatbuffers } from "flatbuffers";
import { sendSync, setFireTimersCallback } from "./dispatch"; import { sendSync, setFireTimersCallback } from "./dispatch";
@ -52,10 +52,10 @@ function setGlobalTimeout(due: number | null, now: number) {
} }
// Send message to the backend. // Send message to the backend.
const builder = new flatbuffers.Builder(); const builder = new flatbuffers.Builder();
fbs.SetTimeout.startSetTimeout(builder); msg.SetTimeout.startSetTimeout(builder);
fbs.SetTimeout.addTimeout(builder, timeout); msg.SetTimeout.addTimeout(builder, timeout);
const inner = fbs.SetTimeout.endSetTimeout(builder); const inner = msg.SetTimeout.endSetTimeout(builder);
const res = sendSync(builder, fbs.Any.SetTimeout, inner); const res = sendSync(builder, msg.Any.SetTimeout, inner);
assert(res == null); assert(res == null);
// Remember when when the global timer will fire. // Remember when when the global timer will fire.
globalTimeoutDue = due; globalTimeoutDue = due;

View file

@ -1,5 +1,5 @@
// Copyright 2018 the Deno authors. All rights reserved. MIT license. // 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 { export interface TraceInfo {
sync: boolean; // is synchronous call sync: boolean; // is synchronous call
@ -41,7 +41,7 @@ function popStack(): TraceInfo[] {
} }
// Push to trace stack if we are tracing // 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) { if (current === null) {
return; // no trace requested return; // no trace requested
} }
@ -49,7 +49,7 @@ export function maybePushTrace(op: fbs.Any, sync: boolean): void {
current!.list.push( current!.list.push(
Object.freeze({ Object.freeze({
sync, sync,
name: fbs.Any[op] // convert to enum names name: msg.Any[op] // convert to enum names
}) })
); );
} }

View file

@ -1,5 +1,5 @@
// Copyright 2018 the Deno authors. All rights reserved. MIT license. // 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 { flatbuffers } from "flatbuffers";
import * as dispatch from "./dispatch"; import * as dispatch from "./dispatch";
@ -30,13 +30,13 @@ export async function truncate(name: string, len?: number): Promise<void> {
function req( function req(
name: string, name: string,
len?: number len?: number
): [flatbuffers.Builder, fbs.Any, flatbuffers.Offset] { ): [flatbuffers.Builder, msg.Any, flatbuffers.Offset] {
const builder = new flatbuffers.Builder(); const builder = new flatbuffers.Builder();
const name_ = builder.createString(name); const name_ = builder.createString(name);
len = len && len > 0 ? Math.floor(len) : 0; len = len && len > 0 ? Math.floor(len) : 0;
fbs.Truncate.startTruncate(builder); msg.Truncate.startTruncate(builder);
fbs.Truncate.addName(builder, name_); msg.Truncate.addName(builder, name_);
fbs.Truncate.addLen(builder, len); msg.Truncate.addLen(builder, len);
const inner = fbs.Truncate.endTruncate(builder); const inner = msg.Truncate.endTruncate(builder);
return [builder, fbs.Any.Truncate, inner]; return [builder, msg.Any.Truncate, inner];
} }

View file

@ -1,5 +1,5 @@
// Copyright 2018 the Deno authors. All rights reserved. MIT license. // 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 { flatbuffers } from "flatbuffers";
import * as dispatch from "./dispatch"; import * as dispatch from "./dispatch";
@ -41,12 +41,12 @@ function req(
filename: string, filename: string,
data: Uint8Array, data: Uint8Array,
perm: number perm: number
): [flatbuffers.Builder, fbs.Any, flatbuffers.Offset, Uint8Array] { ): [flatbuffers.Builder, msg.Any, flatbuffers.Offset, Uint8Array] {
const builder = new flatbuffers.Builder(); const builder = new flatbuffers.Builder();
const filename_ = builder.createString(filename); const filename_ = builder.createString(filename);
fbs.WriteFile.startWriteFile(builder); msg.WriteFile.startWriteFile(builder);
fbs.WriteFile.addFilename(builder, filename_); msg.WriteFile.addFilename(builder, filename_);
fbs.WriteFile.addPerm(builder, perm); msg.WriteFile.addPerm(builder, perm);
const inner = fbs.WriteFile.endWriteFile(builder); const inner = msg.WriteFile.endWriteFile(builder);
return [builder, fbs.Any.WriteFile, inner, data]; return [builder, msg.Any.WriteFile, inner, data];
} }