diff options
Diffstat (limited to 'js/os.ts')
-rw-r--r-- | js/os.ts | 36 |
1 files changed, 18 insertions, 18 deletions
@@ -4,14 +4,14 @@ import * as fbs from "gen/msg_generated"; import { assert } from "./util"; import * as util from "./util"; import { flatbuffers } from "flatbuffers"; -import { send } from "./fbs_util"; +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 msg = fbs.Exit.endExit(builder); - send(builder, fbs.Any.Exit, msg); + sendSync(builder, fbs.Any.Exit, msg); return util.unreachable(); } @@ -28,7 +28,7 @@ export function codeFetch( fbs.CodeFetch.addModuleSpecifier(builder, moduleSpecifier_); fbs.CodeFetch.addContainingFile(builder, containingFile_); const msg = fbs.CodeFetch.endCodeFetch(builder); - const baseRes = send(builder, fbs.Any.CodeFetch, msg); + const baseRes = sendSync(builder, fbs.Any.CodeFetch, msg); assert(baseRes != null); assert( fbs.Any.CodeFetchRes === baseRes!.msgType(), @@ -59,7 +59,7 @@ export function codeCache( fbs.CodeCache.addSourceCode(builder, sourceCode_); fbs.CodeCache.addOutputCode(builder, outputCode_); const msg = fbs.CodeCache.endCodeCache(builder); - const baseRes = send(builder, fbs.Any.CodeCache, msg); + const baseRes = sendSync(builder, fbs.Any.CodeCache, msg); assert(baseRes == null); // Expect null or error. } @@ -97,7 +97,7 @@ export function makeTempDirSync({ fbs.MakeTempDir.addSuffix(builder, fbSuffix); } const msg = fbs.MakeTempDir.endMakeTempDir(builder); - const baseRes = send(builder, fbs.Any.MakeTempDir, msg); + const baseRes = sendSync(builder, fbs.Any.MakeTempDir, msg); assert(baseRes != null); assert(fbs.Any.MakeTempDirRes === baseRes!.msgType()); const res = new fbs.MakeTempDirRes(); @@ -111,7 +111,7 @@ export function makeTempDirSync({ // and permission bits (before umask). export function mkdirSync(path: string, mode = 0o777): void { /* Ideally we could write: - const res = send({ + const res = sendSync({ command: fbs.Command.MKDIR_SYNC, mkdirSyncPath: path, mkdirSyncMode: mode, @@ -123,7 +123,7 @@ export function mkdirSync(path: string, mode = 0o777): void { fbs.MkdirSync.addPath(builder, path_); fbs.MkdirSync.addMode(builder, mode); const msg = fbs.MkdirSync.endMkdirSync(builder); - send(builder, fbs.Any.MkdirSync, msg); + sendSync(builder, fbs.Any.MkdirSync, msg); } /** @@ -136,7 +136,7 @@ export function mkdirSync(path: string, mode = 0o777): void { */ export function readFileSync(filename: string): Uint8Array { /* Ideally we could write - const res = send({ + const res = sendSync({ command: fbs.Command.READ_FILE_SYNC, readFileSyncFilename: filename }); @@ -147,7 +147,7 @@ export function readFileSync(filename: string): Uint8Array { fbs.ReadFileSync.startReadFileSync(builder); fbs.ReadFileSync.addFilename(builder, filename_); const msg = fbs.ReadFileSync.endReadFileSync(builder); - const baseRes = send(builder, fbs.Any.ReadFileSync, msg); + const baseRes = sendSync(builder, fbs.Any.ReadFileSync, msg); assert(baseRes != null); assert(fbs.Any.ReadFileSyncRes === baseRes!.msgType()); const res = new fbs.ReadFileSyncRes(); @@ -182,7 +182,7 @@ function setEnv(key: string, value: string): void { fbs.SetEnv.addKey(builder, _key); fbs.SetEnv.addValue(builder, _value); const msg = fbs.SetEnv.endSetEnv(builder); - send(builder, fbs.Any.SetEnv, msg); + sendSync(builder, fbs.Any.SetEnv, msg); } /** @@ -200,14 +200,14 @@ function setEnv(key: string, value: string): void { */ export function env(): { [index: string]: string } { /* Ideally we could write - const res = send({ + const res = sendSync({ command: fbs.Command.ENV, }); */ const builder = new flatbuffers.Builder(); fbs.Environ.startEnviron(builder); const msg = fbs.Environ.endEnviron(builder); - const baseRes = send(builder, fbs.Any.Environ, msg)!; + const baseRes = sendSync(builder, fbs.Any.Environ, msg)!; assert(fbs.Any.EnvironRes === baseRes.msgType()); const res = new fbs.EnvironRes(); assert(baseRes.msg(res) != null); @@ -303,7 +303,7 @@ export function statSync(filename: string): FileInfo { function statSyncInner(filename: string, lstat: boolean): FileInfo { /* Ideally we could write - const res = send({ + const res = sendSync({ command: fbs.Command.STAT_FILE_SYNC, StatFilename: filename, StatLStat: lstat, @@ -316,7 +316,7 @@ function statSyncInner(filename: string, lstat: boolean): FileInfo { fbs.StatSync.addFilename(builder, filename_); fbs.StatSync.addLstat(builder, lstat); const msg = fbs.StatSync.endStatSync(builder); - const baseRes = send(builder, fbs.Any.StatSync, msg); + const baseRes = sendSync(builder, fbs.Any.StatSync, msg); assert(baseRes != null); assert(fbs.Any.StatSyncRes === baseRes!.msgType()); const res = new fbs.StatSyncRes(); @@ -338,7 +338,7 @@ export function writeFileSync( perm = 0o666 ): void { /* Ideally we could write: - const res = send({ + const res = sendSync({ command: fbs.Command.WRITE_FILE_SYNC, writeFileSyncFilename: filename, writeFileSyncData: data, @@ -353,7 +353,7 @@ export function writeFileSync( fbs.WriteFileSync.addData(builder, dataOffset); fbs.WriteFileSync.addPerm(builder, perm); const msg = fbs.WriteFileSync.endWriteFileSync(builder); - send(builder, fbs.Any.WriteFileSync, msg); + sendSync(builder, fbs.Any.WriteFileSync, msg); } /** @@ -366,7 +366,7 @@ export function writeFileSync( */ export function renameSync(oldpath: string, newpath: string): void { /* Ideally we could write: - const res = send({ + const res = sendSync({ command: fbs.Command.RENAME_SYNC, renameOldPath: oldpath, renameNewPath: newpath @@ -379,5 +379,5 @@ export function renameSync(oldpath: string, newpath: string): void { fbs.RenameSync.addOldpath(builder, _oldpath); fbs.RenameSync.addNewpath(builder, _newpath); const msg = fbs.RenameSync.endRenameSync(builder); - send(builder, fbs.Any.RenameSync, msg); + sendSync(builder, fbs.Any.RenameSync, msg); } |