From 3452a10840ef47bb5546969ebe776289c7b095f1 Mon Sep 17 00:00:00 2001 From: Jonathon Orsi Date: Sun, 7 Apr 2019 20:51:43 -0400 Subject: [PATCH] use flatbuffer create functions to add fields (#2046) --- js/chmod.ts | 5 +---- js/copy_file.ts | 5 +---- js/dir.ts | 4 +--- js/dispatch.ts | 16 ++++++++++------ js/fetch.ts | 33 ++++++++++++++------------------- js/files.ts | 23 +++++------------------ js/format_error.ts | 4 +--- js/make_temp_dir.ts | 23 +++++++++-------------- js/metrics.ts | 3 +-- js/mkdir.ts | 6 +----- js/net.ts | 19 ++++--------------- js/os.ts | 31 ++++++++++++------------------- js/performance.ts | 3 +-- js/permissions.ts | 10 +++++----- js/process.ts | 36 ++++++++++++------------------------ js/read_dir.ts | 4 +--- js/read_link.ts | 4 +--- js/remove.ts | 5 +---- js/rename.ts | 5 +---- js/repl.ts | 10 ++-------- js/resources.ts | 3 +-- js/stat.ts | 5 +---- js/symlink.ts | 5 +---- js/timers.ts | 3 +-- js/truncate.ts | 5 +---- js/workers.ts | 25 +++++++++---------------- 26 files changed, 98 insertions(+), 197 deletions(-) diff --git a/js/chmod.ts b/js/chmod.ts index b26f785284..5abecb5765 100644 --- a/js/chmod.ts +++ b/js/chmod.ts @@ -9,10 +9,7 @@ function req( ): [flatbuffers.Builder, msg.Any, flatbuffers.Offset] { const builder = flatbuffers.createBuilder(); const path_ = builder.createString(path); - msg.Chmod.startChmod(builder); - msg.Chmod.addPath(builder, path_); - msg.Chmod.addMode(builder, mode); - const inner = msg.Chmod.endChmod(builder); + const inner = msg.Chmod.createChmod(builder, path_, mode); return [builder, msg.Any.Chmod, inner]; } diff --git a/js/copy_file.ts b/js/copy_file.ts index a6ff9439e0..5cab6d5797 100644 --- a/js/copy_file.ts +++ b/js/copy_file.ts @@ -10,10 +10,7 @@ function req( const builder = flatbuffers.createBuilder(); const from_ = builder.createString(from); const to_ = builder.createString(to); - msg.CopyFile.startCopyFile(builder); - msg.CopyFile.addFrom(builder, from_); - msg.CopyFile.addTo(builder, to_); - const inner = msg.CopyFile.endCopyFile(builder); + const inner = msg.CopyFile.createCopyFile(builder, from_, to_); return [builder, msg.Any.CopyFile, inner]; } diff --git a/js/dir.ts b/js/dir.ts index 660a7df2ba..cf93451101 100644 --- a/js/dir.ts +++ b/js/dir.ts @@ -30,8 +30,6 @@ export function cwd(): string { export function chdir(directory: string): void { const builder = flatbuffers.createBuilder(); const directory_ = builder.createString(directory); - msg.Chdir.startChdir(builder); - msg.Chdir.addDirectory(builder, directory_); - const inner = msg.Chdir.endChdir(builder); + const inner = msg.Chdir.createChdir(builder, directory_); sendSync(builder, msg.Any.Chdir, inner); } diff --git a/js/dispatch.ts b/js/dispatch.ts index 528cf320c1..d5e10ad09d 100644 --- a/js/dispatch.ts +++ b/js/dispatch.ts @@ -31,12 +31,16 @@ function sendInternal( sync = true ): [number, null | Uint8Array] { const cmdId = nextCmdId++; - 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)); + const message = msg.Base.createBase( + builder, + cmdId, + sync, + 0, + 0, + innerType, + inner + ); + builder.finish(message); const control = builder.asUint8Array(); const response = core.dispatch(control, zeroCopy); diff --git a/js/fetch.ts b/js/fetch.ts index e4262ea0a3..7cc0750ed7 100644 --- a/js/fetch.ts +++ b/js/fetch.ts @@ -308,32 +308,29 @@ function msgHttpRequest( method: null | string, headers: null | domTypes.Headers ): flatbuffers.Offset { - const methodOffset = !method ? -1 : builder.createString(method); - let fieldsOffset: flatbuffers.Offset = -1; + const methodOffset = !method ? 0 : builder.createString(method); + let fieldsOffset: flatbuffers.Offset = 0; const urlOffset = builder.createString(url); if (headers) { const kvOffsets: flatbuffers.Offset[] = []; for (const [key, val] of headers.entries()) { const keyOffset = builder.createString(key); const valOffset = builder.createString(val); - msg.KeyValue.startKeyValue(builder); - msg.KeyValue.addKey(builder, keyOffset); - msg.KeyValue.addValue(builder, valOffset); - kvOffsets.push(msg.KeyValue.endKeyValue(builder)); + kvOffsets.push( + msg.KeyValue.createKeyValue(builder, keyOffset, valOffset) + ); } fieldsOffset = msg.HttpHeader.createFieldsVector(builder, kvOffsets); } else { } - msg.HttpHeader.startHttpHeader(builder); - msg.HttpHeader.addIsRequest(builder, true); - msg.HttpHeader.addUrl(builder, urlOffset); - if (methodOffset >= 0) { - msg.HttpHeader.addMethod(builder, methodOffset); - } - if (fieldsOffset >= 0) { - msg.HttpHeader.addFields(builder, fieldsOffset); - } - return msg.HttpHeader.endHttpHeader(builder); + return msg.HttpHeader.createHttpHeader( + builder, + true, + methodOffset, + urlOffset, + 0, + fieldsOffset + ); } function deserializeHeaderFields(m: msg.HttpHeader): Array<[string, string]> { @@ -405,12 +402,10 @@ export async function fetch( // Send Fetch message const builder = flatbuffers.createBuilder(); const headerOff = msgHttpRequest(builder, url, method, headers); - msg.Fetch.startFetch(builder); - msg.Fetch.addHeader(builder, headerOff); const resBase = await sendAsync( builder, msg.Any.Fetch, - msg.Fetch.endFetch(builder), + msg.Fetch.createFetch(builder, headerOff), body ); diff --git a/js/files.ts b/js/files.ts index 0724565e47..18ee612bc0 100644 --- a/js/files.ts +++ b/js/files.ts @@ -22,10 +22,7 @@ function reqOpen( const builder = flatbuffers.createBuilder(); const filename_ = builder.createString(filename); const mode_ = builder.createString(mode); - msg.Open.startOpen(builder); - msg.Open.addFilename(builder, filename_); - msg.Open.addMode(builder, mode_); - const inner = msg.Open.endOpen(builder); + const inner = msg.Open.createOpen(builder, filename_, 0, mode_); return [builder, msg.Any.Open, inner]; } @@ -66,9 +63,7 @@ function reqRead( p: Uint8Array ): [flatbuffers.Builder, msg.Any, flatbuffers.Offset, Uint8Array] { const builder = flatbuffers.createBuilder(); - msg.Read.startRead(builder); - msg.Read.addRid(builder, rid); - const inner = msg.Read.endRead(builder); + const inner = msg.Read.createRead(builder, rid); return [builder, msg.Any.Read, inner, p]; } @@ -114,9 +109,7 @@ function reqWrite( p: Uint8Array ): [flatbuffers.Builder, msg.Any, flatbuffers.Offset, Uint8Array] { const builder = flatbuffers.createBuilder(); - msg.Write.startWrite(builder); - msg.Write.addRid(builder, rid); - const inner = msg.Write.endWrite(builder); + const inner = msg.Write.createWrite(builder, rid); return [builder, msg.Any.Write, inner, p]; } @@ -163,11 +156,7 @@ function reqSeek( whence: SeekMode ): [flatbuffers.Builder, msg.Any, flatbuffers.Offset] { const builder = flatbuffers.createBuilder(); - msg.Seek.startSeek(builder); - msg.Seek.addRid(builder, rid); - msg.Seek.addOffset(builder, offset); - msg.Seek.addWhence(builder, whence); - const inner = msg.Seek.endSeek(builder); + const inner = msg.Seek.createSeek(builder, rid, offset, whence); return [builder, msg.Any.Seek, inner]; } @@ -198,9 +187,7 @@ export async function seek( /** Close the file ID. */ export function close(rid: number): void { const builder = flatbuffers.createBuilder(); - msg.Close.startClose(builder); - msg.Close.addRid(builder, rid); - const inner = msg.Close.endClose(builder); + const inner = msg.Close.createClose(builder, rid); dispatch.sendSync(builder, msg.Any.Close, inner); } diff --git a/js/format_error.ts b/js/format_error.ts index 7cdbd72c3b..1c79f36fc7 100644 --- a/js/format_error.ts +++ b/js/format_error.ts @@ -7,9 +7,7 @@ import { assert } from "./util"; export function formatError(errString: string): string { const builder = flatbuffers.createBuilder(); const errString_ = builder.createString(errString); - msg.FormatError.startFormatError(builder); - msg.FormatError.addError(builder, errString_); - const offset = msg.FormatError.endFormatError(builder); + const offset = msg.FormatError.createFormatError(builder, errString_); const baseRes = sendSync(builder, msg.Any.FormatError, offset); assert(baseRes != null); assert(msg.Any.FormatErrorRes === baseRes!.innerType()); diff --git a/js/make_temp_dir.ts b/js/make_temp_dir.ts index ff754a3a87..8a3098b9e7 100644 --- a/js/make_temp_dir.ts +++ b/js/make_temp_dir.ts @@ -16,20 +16,15 @@ function req({ suffix }: MakeTempDirOptions): [flatbuffers.Builder, msg.Any, flatbuffers.Offset] { const builder = flatbuffers.createBuilder(); - const fbDir = dir == null ? -1 : builder.createString(dir); - const fbPrefix = prefix == null ? -1 : builder.createString(prefix); - const fbSuffix = suffix == null ? -1 : builder.createString(suffix); - msg.MakeTempDir.startMakeTempDir(builder); - if (dir != null) { - msg.MakeTempDir.addDir(builder, fbDir); - } - if (prefix != null) { - msg.MakeTempDir.addPrefix(builder, fbPrefix); - } - if (suffix != null) { - msg.MakeTempDir.addSuffix(builder, fbSuffix); - } - const inner = msg.MakeTempDir.endMakeTempDir(builder); + const fbDir = dir == null ? 0 : builder.createString(dir); + const fbPrefix = prefix == null ? 0 : builder.createString(prefix); + const fbSuffix = suffix == null ? 0 : builder.createString(suffix); + const inner = msg.MakeTempDir.createMakeTempDir( + builder, + fbDir, + fbPrefix, + fbSuffix + ); return [builder, msg.Any.MakeTempDir, inner]; } diff --git a/js/metrics.ts b/js/metrics.ts index 503d0e0e6e..92ed5b52e8 100644 --- a/js/metrics.ts +++ b/js/metrics.ts @@ -14,8 +14,7 @@ export interface Metrics { function req(): [flatbuffers.Builder, msg.Any, flatbuffers.Offset] { const builder = flatbuffers.createBuilder(); - msg.Metrics.startMetrics(builder); - const inner = msg.Metrics.endMetrics(builder); + const inner = msg.Metrics.createMetrics(builder); return [builder, msg.Any.Metrics, inner]; } diff --git a/js/mkdir.ts b/js/mkdir.ts index 36a2b6622e..bf13c0e283 100644 --- a/js/mkdir.ts +++ b/js/mkdir.ts @@ -10,11 +10,7 @@ function req( ): [flatbuffers.Builder, msg.Any, flatbuffers.Offset] { const builder = flatbuffers.createBuilder(); const path_ = builder.createString(path); - msg.Mkdir.startMkdir(builder); - msg.Mkdir.addPath(builder, path_); - msg.Mkdir.addRecursive(builder, recursive); - msg.Mkdir.addMode(builder, mode); - const inner = msg.Mkdir.endMkdir(builder); + const inner = msg.Mkdir.createMkdir(builder, path_, recursive, mode); return [builder, msg.Any.Mkdir, inner]; } diff --git a/js/net.ts b/js/net.ts index e982d9455d..214da2927d 100644 --- a/js/net.ts +++ b/js/net.ts @@ -37,10 +37,7 @@ enum ShutdownMode { function shutdown(rid: number, how: ShutdownMode): void { const builder = flatbuffers.createBuilder(); - msg.Shutdown.startShutdown(builder); - msg.Shutdown.addRid(builder, rid); - msg.Shutdown.addHow(builder, how); - const inner = msg.Shutdown.endShutdown(builder); + const inner = msg.Shutdown.createShutdown(builder, rid, how); const baseRes = dispatch.sendSync(builder, msg.Any.Shutdown, inner); assert(baseRes == null); } @@ -84,9 +81,7 @@ class ListenerImpl implements Listener { async accept(): Promise { const builder = flatbuffers.createBuilder(); - msg.Accept.startAccept(builder); - msg.Accept.addRid(builder, this.rid); - const inner = msg.Accept.endAccept(builder); + const inner = msg.Accept.createAccept(builder, this.rid); const baseRes = await dispatch.sendAsync(builder, msg.Any.Accept, inner); assert(baseRes != null); assert(msg.Any.NewConn === baseRes!.innerType()); @@ -140,10 +135,7 @@ export function listen(network: Network, address: string): Listener { const builder = flatbuffers.createBuilder(); const network_ = builder.createString(network); const address_ = builder.createString(address); - msg.Listen.startListen(builder); - msg.Listen.addNetwork(builder, network_); - msg.Listen.addAddress(builder, address_); - const inner = msg.Listen.endListen(builder); + const inner = msg.Listen.createListen(builder, network_, address_); const baseRes = dispatch.sendSync(builder, msg.Any.Listen, inner); assert(baseRes != null); assert(msg.Any.ListenRes === baseRes!.innerType()); @@ -183,10 +175,7 @@ export async function dial(network: Network, address: string): Promise { const builder = flatbuffers.createBuilder(); const network_ = builder.createString(network); const address_ = builder.createString(address); - msg.Dial.startDial(builder); - msg.Dial.addNetwork(builder, network_); - msg.Dial.addAddress(builder, address_); - const inner = msg.Dial.endDial(builder); + const inner = msg.Dial.createDial(builder, network_, address_); const baseRes = await dispatch.sendAsync(builder, msg.Any.Dial, inner); assert(baseRes != null); assert(msg.Any.NewConn === baseRes!.innerType()); diff --git a/js/os.ts b/js/os.ts index 3ef75c003a..86a2c4943c 100644 --- a/js/os.ts +++ b/js/os.ts @@ -36,8 +36,7 @@ interface ResponseModuleMetaData { */ export function isTTY(): { stdin: boolean; stdout: boolean; stderr: boolean } { const builder = flatbuffers.createBuilder(); - msg.IsTTY.startIsTTY(builder); - const inner = msg.IsTTY.endIsTTY(builder); + const inner = msg.IsTTY.createIsTTY(builder); const baseRes = sendSync(builder, msg.Any.IsTTY, inner)!; assert(msg.Any.IsTTYRes === baseRes.innerType()); const res = new msg.IsTTYRes(); @@ -49,9 +48,7 @@ export function isTTY(): { stdin: boolean; stdout: boolean; stderr: boolean } { /** Exit the Deno process with optional exit code. */ export function exit(exitCode = 0): never { const builder = flatbuffers.createBuilder(); - msg.Exit.startExit(builder); - msg.Exit.addCode(builder, exitCode); - const inner = msg.Exit.endExit(builder); + const inner = msg.Exit.createExit(builder, exitCode); sendSync(builder, msg.Any.Exit, inner); return util.unreachable(); } @@ -68,10 +65,11 @@ export function fetchModuleMetaData( const builder = flatbuffers.createBuilder(); const specifier_ = builder.createString(specifier); const referrer_ = builder.createString(referrer); - msg.FetchModuleMetaData.startFetchModuleMetaData(builder); - msg.FetchModuleMetaData.addSpecifier(builder, specifier_); - msg.FetchModuleMetaData.addReferrer(builder, referrer_); - const inner = msg.FetchModuleMetaData.endFetchModuleMetaData(builder); + const inner = msg.FetchModuleMetaData.createFetchModuleMetaData( + builder, + specifier_, + referrer_ + ); const baseRes = sendSync(builder, msg.Any.FetchModuleMetaData, inner); assert(baseRes != null); assert( @@ -94,12 +92,9 @@ export function fetchModuleMetaData( function setEnv(key: string, value: string): void { const builder = flatbuffers.createBuilder(); - const _key = builder.createString(key); - const _value = builder.createString(value); - msg.SetEnv.startSetEnv(builder); - msg.SetEnv.addKey(builder, _key); - msg.SetEnv.addValue(builder, _value); - const inner = msg.SetEnv.endSetEnv(builder); + const key_ = builder.createString(key); + const value_ = builder.createString(value); + const inner = msg.SetEnv.createSetEnv(builder, key_, value_); sendSync(builder, msg.Any.SetEnv, inner); } @@ -137,8 +132,7 @@ export function env(): { [index: string]: string } { }); */ const builder = flatbuffers.createBuilder(); - msg.Environ.startEnviron(builder); - const inner = msg.Environ.endEnviron(builder); + const inner = msg.Environ.createEnviron(builder); const baseRes = sendSync(builder, msg.Any.Environ, inner)!; assert(msg.Any.EnvironRes === baseRes.innerType()); const res = new msg.EnvironRes(); @@ -150,8 +144,7 @@ export function env(): { [index: string]: string } { /** Send to the privileged side that we have setup and are ready. */ function sendStart(): msg.StartRes { const builder = flatbuffers.createBuilder(); - msg.Start.startStart(builder); - const startOffset = msg.Start.endStart(builder); + const startOffset = msg.Start.createStart(builder, 0 /* unused */); const baseRes = sendSync(builder, msg.Any.Start, startOffset); assert(baseRes != null); assert(msg.Any.StartRes === baseRes!.innerType()); diff --git a/js/performance.ts b/js/performance.ts index b4d0fa43bc..1af75809bb 100644 --- a/js/performance.ts +++ b/js/performance.ts @@ -18,8 +18,7 @@ export class Performance { */ now(): number { const builder = flatbuffers.createBuilder(); - msg.Now.startNow(builder); - const inner = msg.Now.endNow(builder); + const inner = msg.Now.createNow(builder); const baseRes = sendSync(builder, msg.Any.Now, inner)!; assert(msg.Any.NowRes === baseRes.innerType()); const res = new msg.NowRes(); diff --git a/js/permissions.ts b/js/permissions.ts index ded8ac305b..46c809cf6e 100644 --- a/js/permissions.ts +++ b/js/permissions.ts @@ -19,8 +19,7 @@ export type Permission = keyof Permissions; function getReq(): [flatbuffers.Builder, msg.Any, flatbuffers.Offset] { const builder = flatbuffers.createBuilder(); - msg.Permissions.startPermissions(builder); - const inner = msg.Permissions.endPermissions(builder); + const inner = msg.Permissions.createPermissions(builder); return [builder, msg.Any.Permissions, inner]; } @@ -55,9 +54,10 @@ function revokeReq( ): [flatbuffers.Builder, msg.Any, flatbuffers.Offset] { const builder = flatbuffers.createBuilder(); const permission_ = builder.createString(permission); - msg.PermissionRevoke.startPermissionRevoke(builder); - msg.PermissionRevoke.addPermission(builder, permission_); - const inner = msg.PermissionRevoke.endPermissionRevoke(builder); + const inner = msg.PermissionRevoke.createPermissionRevoke( + builder, + permission_ + ); return [builder, msg.Any.PermissionRevoke, inner]; } diff --git a/js/process.ts b/js/process.ts index 7e31a13614..fc5e5f652e 100644 --- a/js/process.ts +++ b/js/process.ts @@ -34,9 +34,7 @@ export interface RunOptions { async function runStatus(rid: number): Promise { const builder = flatbuffers.createBuilder(); - msg.RunStatus.startRunStatus(builder); - msg.RunStatus.addRid(builder, rid); - const inner = msg.RunStatus.endRunStatus(builder); + const inner = msg.RunStatus.createRunStatus(builder, rid); const baseRes = await dispatch.sendAsync(builder, msg.Any.RunStatus, inner); assert(baseRes != null); @@ -154,35 +152,25 @@ export function run(opt: RunOptions): Process { builder, opt.args.map(a => builder.createString(a)) ); - const cwdOffset = opt.cwd == null ? -1 : builder.createString(opt.cwd); + const cwdOffset = opt.cwd == null ? 0 : builder.createString(opt.cwd); const kvOffset: flatbuffers.Offset[] = []; if (opt.env) { for (const [key, val] of Object.entries(opt.env)) { const keyOffset = builder.createString(key); const valOffset = builder.createString(String(val)); - msg.KeyValue.startKeyValue(builder); - msg.KeyValue.addKey(builder, keyOffset); - msg.KeyValue.addValue(builder, valOffset); - kvOffset.push(msg.KeyValue.endKeyValue(builder)); + kvOffset.push(msg.KeyValue.createKeyValue(builder, keyOffset, valOffset)); } } const envOffset = msg.Run.createEnvVector(builder, kvOffset); - msg.Run.startRun(builder); - msg.Run.addArgs(builder, argsOffset); - if (opt.cwd != null) { - msg.Run.addCwd(builder, cwdOffset); - } - msg.Run.addEnv(builder, envOffset); - if (opt.stdin) { - msg.Run.addStdin(builder, stdioMap(opt.stdin!)); - } - if (opt.stdout) { - msg.Run.addStdout(builder, stdioMap(opt.stdout!)); - } - if (opt.stderr) { - msg.Run.addStderr(builder, stdioMap(opt.stderr!)); - } - const inner = msg.Run.endRun(builder); + const inner = msg.Run.createRun( + builder, + argsOffset, + cwdOffset, + envOffset, + opt.stdin ? stdioMap(opt.stdin) : stdioMap("inherit"), + opt.stdout ? stdioMap(opt.stdout) : stdioMap("inherit"), + opt.stderr ? stdioMap(opt.stderr) : stdioMap("inherit") + ); const baseRes = dispatch.sendSync(builder, msg.Any.Run, inner); assert(baseRes != null); assert(msg.Any.RunRes === baseRes!.innerType()); diff --git a/js/read_dir.ts b/js/read_dir.ts index 9aa7c33753..1394c8514f 100644 --- a/js/read_dir.ts +++ b/js/read_dir.ts @@ -8,9 +8,7 @@ import { assert } from "./util"; function req(path: string): [flatbuffers.Builder, msg.Any, flatbuffers.Offset] { const builder = flatbuffers.createBuilder(); const path_ = builder.createString(path); - msg.ReadDir.startReadDir(builder); - msg.ReadDir.addPath(builder, path_); - const inner = msg.ReadDir.endReadDir(builder); + const inner = msg.ReadDir.createReadDir(builder, path_); return [builder, msg.Any.ReadDir, inner]; } diff --git a/js/read_link.ts b/js/read_link.ts index 0e1a950f30..83a4ff1ba4 100644 --- a/js/read_link.ts +++ b/js/read_link.ts @@ -7,9 +7,7 @@ import * as dispatch from "./dispatch"; function req(name: string): [flatbuffers.Builder, msg.Any, flatbuffers.Offset] { const builder = flatbuffers.createBuilder(); const name_ = builder.createString(name); - msg.Readlink.startReadlink(builder); - msg.Readlink.addName(builder, name_); - const inner = msg.Readlink.endReadlink(builder); + const inner = msg.Readlink.createReadlink(builder, name_); return [builder, msg.Any.Readlink, inner]; } diff --git a/js/remove.ts b/js/remove.ts index 0bbfd913b9..7abfd18e97 100644 --- a/js/remove.ts +++ b/js/remove.ts @@ -13,10 +13,7 @@ function req( ): [flatbuffers.Builder, msg.Any, flatbuffers.Offset] { const builder = flatbuffers.createBuilder(); const path_ = builder.createString(path); - msg.Remove.startRemove(builder); - msg.Remove.addPath(builder, path_); - msg.Remove.addRecursive(builder, !!options.recursive); - const inner = msg.Remove.endRemove(builder); + const inner = msg.Remove.createRemove(builder, path_, !!options.recursive); return [builder, msg.Any.Remove, inner]; } diff --git a/js/rename.ts b/js/rename.ts index 2bb83e9668..9099f083ad 100644 --- a/js/rename.ts +++ b/js/rename.ts @@ -10,10 +10,7 @@ function req( const builder = flatbuffers.createBuilder(); const oldpath_ = builder.createString(oldpath); const newpath_ = builder.createString(newpath); - msg.Rename.startRename(builder); - msg.Rename.addOldpath(builder, oldpath_); - msg.Rename.addNewpath(builder, newpath_); - const inner = msg.Rename.endRename(builder); + const inner = msg.Rename.createRename(builder, oldpath_, newpath_); return [builder, msg.Any.Rename, inner]; } diff --git a/js/repl.ts b/js/repl.ts index 350aff8676..e521bf5810 100644 --- a/js/repl.ts +++ b/js/repl.ts @@ -30,10 +30,7 @@ const replCommands = { function startRepl(historyFile: string): number { const builder = flatbuffers.createBuilder(); const historyFile_ = builder.createString(historyFile); - - msg.ReplStart.startReplStart(builder); - msg.ReplStart.addHistoryFile(builder, historyFile_); - const inner = msg.ReplStart.endReplStart(builder); + const inner = msg.ReplStart.createReplStart(builder, historyFile_); const baseRes = dispatch.sendSync(builder, msg.Any.ReplStart, inner); assert(baseRes != null); @@ -48,10 +45,7 @@ function startRepl(historyFile: string): number { export async function readline(rid: number, prompt: string): Promise { const builder = flatbuffers.createBuilder(); const prompt_ = builder.createString(prompt); - msg.ReplReadline.startReplReadline(builder); - msg.ReplReadline.addRid(builder, rid); - msg.ReplReadline.addPrompt(builder, prompt_); - const inner = msg.ReplReadline.endReplReadline(builder); + const inner = msg.ReplReadline.createReplReadline(builder, rid, prompt_); const baseRes = await dispatch.sendAsync( builder, diff --git a/js/resources.ts b/js/resources.ts index f78fd0360d..7ccc79c4d9 100644 --- a/js/resources.ts +++ b/js/resources.ts @@ -13,8 +13,7 @@ export interface ResourceMap { */ export function resources(): ResourceMap { const builder = flatbuffers.createBuilder(); - msg.Resources.startResources(builder); - const inner = msg.Resource.endResource(builder); + const inner = msg.Resource.createResource(builder, 0, 0); const baseRes = dispatch.sendSync(builder, msg.Any.Resources, inner); assert(baseRes !== null); assert(msg.Any.ResourcesRes === baseRes!.innerType()); diff --git a/js/stat.ts b/js/stat.ts index ed3e17d197..755753606a 100644 --- a/js/stat.ts +++ b/js/stat.ts @@ -11,10 +11,7 @@ function req( ): [flatbuffers.Builder, msg.Any, flatbuffers.Offset] { const builder = flatbuffers.createBuilder(); const filename_ = builder.createString(filename); - msg.Stat.startStat(builder); - msg.Stat.addFilename(builder, filename_); - msg.Stat.addLstat(builder, lstat); - const inner = msg.Stat.endStat(builder); + const inner = msg.Stat.createStat(builder, filename_, lstat); return [builder, msg.Any.Stat, inner]; } diff --git a/js/symlink.ts b/js/symlink.ts index f260620d68..9230e9fa0b 100644 --- a/js/symlink.ts +++ b/js/symlink.ts @@ -16,10 +16,7 @@ function req( const builder = flatbuffers.createBuilder(); const oldname_ = builder.createString(oldname); const newname_ = builder.createString(newname); - msg.Symlink.startSymlink(builder); - msg.Symlink.addOldname(builder, oldname_); - msg.Symlink.addNewname(builder, newname_); - const inner = msg.Symlink.endSymlink(builder); + const inner = msg.Symlink.createSymlink(builder, oldname_, newname_); return [builder, msg.Any.Symlink, inner]; } diff --git a/js/timers.ts b/js/timers.ts index e372f88c2e..9a595973ce 100644 --- a/js/timers.ts +++ b/js/timers.ts @@ -39,8 +39,7 @@ function getTime(): number { function clearGlobalTimeout(): void { const builder = flatbuffers.createBuilder(); - msg.GlobalTimerStop.startGlobalTimerStop(builder); - const inner = msg.GlobalTimerStop.endGlobalTimerStop(builder); + const inner = msg.GlobalTimerStop.createGlobalTimerStop(builder); globalTimeoutDue = null; let res = sendSync(builder, msg.Any.GlobalTimerStop, inner); assert(res == null); diff --git a/js/truncate.ts b/js/truncate.ts index c721404a10..0e9a8b9774 100644 --- a/js/truncate.ts +++ b/js/truncate.ts @@ -10,10 +10,7 @@ function req( const builder = flatbuffers.createBuilder(); const name_ = builder.createString(name); len = len && len > 0 ? Math.floor(len) : 0; - msg.Truncate.startTruncate(builder); - msg.Truncate.addName(builder, name_); - msg.Truncate.addLen(builder, len); - const inner = msg.Truncate.endTruncate(builder); + const inner = msg.Truncate.createTruncate(builder, name_, len); return [builder, msg.Any.Truncate, inner]; } diff --git a/js/workers.ts b/js/workers.ts index 8c08a8506b..6b768bf087 100644 --- a/js/workers.ts +++ b/js/workers.ts @@ -23,9 +23,7 @@ export function decodeMessage(dataIntArray: Uint8Array): any { function createWorker(specifier: string): number { const builder = flatbuffers.createBuilder(); const specifier_ = builder.createString(specifier); - msg.CreateWorker.startCreateWorker(builder); - msg.CreateWorker.addSpecifier(builder, specifier_); - const inner = msg.CreateWorker.endCreateWorker(builder); + const inner = msg.CreateWorker.createCreateWorker(builder, specifier_); const baseRes = sendSync(builder, msg.Any.CreateWorker, inner); assert(baseRes != null); assert( @@ -39,18 +37,14 @@ function createWorker(specifier: string): number { async function hostGetWorkerClosed(rid: number): Promise { const builder = flatbuffers.createBuilder(); - msg.HostGetWorkerClosed.startHostGetWorkerClosed(builder); - msg.HostGetWorkerClosed.addRid(builder, rid); - const inner = msg.HostGetWorkerClosed.endHostGetWorkerClosed(builder); + const inner = msg.HostGetWorkerClosed.createHostGetWorkerClosed(builder, rid); await sendAsync(builder, msg.Any.HostGetWorkerClosed, inner); } function hostPostMessage(rid: number, data: any): void { const dataIntArray = encodeMessage(data); const builder = flatbuffers.createBuilder(); - msg.HostPostMessage.startHostPostMessage(builder); - msg.HostPostMessage.addRid(builder, rid); - const inner = msg.HostPostMessage.endHostPostMessage(builder); + const inner = msg.HostPostMessage.createHostPostMessage(builder, rid); const baseRes = sendSync( builder, msg.Any.HostPostMessage, @@ -62,9 +56,7 @@ function hostPostMessage(rid: number, data: any): void { async function hostGetMessage(rid: number): Promise { const builder = flatbuffers.createBuilder(); - msg.HostGetMessage.startHostGetMessage(builder); - msg.HostGetMessage.addRid(builder, rid); - const inner = msg.HostGetMessage.endHostGetMessage(builder); + const inner = msg.HostGetMessage.createHostGetMessage(builder, rid); const baseRes = await sendAsync(builder, msg.Any.HostGetMessage, inner); assert(baseRes != null); assert( @@ -88,8 +80,7 @@ export let onmessage: (e: { data: any }) => void = (): void => {}; export function postMessage(data: any): void { const dataIntArray = encodeMessage(data); const builder = flatbuffers.createBuilder(); - msg.WorkerPostMessage.startWorkerPostMessage(builder); - const inner = msg.WorkerPostMessage.endWorkerPostMessage(builder); + const inner = msg.WorkerPostMessage.createWorkerPostMessage(builder); const baseRes = sendSync( builder, msg.Any.WorkerPostMessage, @@ -102,8 +93,10 @@ export function postMessage(data: any): void { export async function getMessage(): Promise { log("getMessage"); const builder = flatbuffers.createBuilder(); - msg.WorkerGetMessage.startWorkerGetMessage(builder); - const inner = msg.WorkerGetMessage.endWorkerGetMessage(builder); + const inner = msg.WorkerGetMessage.createWorkerGetMessage( + builder, + 0 /* unused */ + ); const baseRes = await sendAsync(builder, msg.Any.WorkerGetMessage, inner); assert(baseRes != null); assert(