From c99207bf3976bfd3c5c3ef91d782c86f933977e6 Mon Sep 17 00:00:00 2001 From: J2P Date: Thu, 11 Oct 2018 00:59:36 +0900 Subject: [PATCH] Rename fd to rid --- js/files.ts | 24 ++++++++++++------------ js/files_test.ts | 8 ++++---- js/net.ts | 22 +++++++++++----------- 3 files changed, 27 insertions(+), 27 deletions(-) diff --git a/js/files.ts b/js/files.ts index a23ce47450..c3722a83ff 100644 --- a/js/files.ts +++ b/js/files.ts @@ -7,18 +7,18 @@ import { assert } from "./util"; import { flatbuffers } from "flatbuffers"; export class File implements Reader, Writer, Closer { - constructor(readonly fd: number) {} + constructor(readonly rid: number) {} write(p: ArrayBufferView): Promise { - return write(this.fd, p); + return write(this.rid, p); } read(p: ArrayBufferView): Promise { - return read(this.fd, p); + return read(this.rid, p); } close(): void { - close(this.fd); + close(this.rid); } } @@ -47,17 +47,17 @@ export async function open( assert(msg.Any.OpenRes === baseRes!.innerType()); const res = new msg.OpenRes(); assert(baseRes!.inner(res) != null); - const fd = res.rid(); - return new File(fd); + const rid = res.rid(); + return new File(rid); } export async function read( - fd: number, + rid: number, p: ArrayBufferView ): Promise { const builder = new flatbuffers.Builder(); msg.Read.startRead(builder); - msg.Read.addRid(builder, fd); + msg.Read.addRid(builder, rid); const inner = msg.Read.endRead(builder); const baseRes = await dispatch.sendAsync(builder, msg.Any.Read, inner, p); assert(baseRes != null); @@ -67,10 +67,10 @@ export async function read( return { nread: res.nread(), eof: res.eof() }; } -export async function write(fd: number, p: ArrayBufferView): Promise { +export async function write(rid: number, p: ArrayBufferView): Promise { const builder = new flatbuffers.Builder(); msg.Write.startWrite(builder); - msg.Write.addRid(builder, fd); + msg.Write.addRid(builder, rid); const inner = msg.Write.endWrite(builder); const baseRes = await dispatch.sendAsync(builder, msg.Any.Write, inner, p); assert(baseRes != null); @@ -80,10 +80,10 @@ export async function write(fd: number, p: ArrayBufferView): Promise { return res.nbyte(); } -export function close(fd: number): void { +export function close(rid: number): void { const builder = new flatbuffers.Builder(); msg.Close.startClose(builder); - msg.Close.addRid(builder, fd); + msg.Close.addRid(builder, rid); const inner = msg.Close.endClose(builder); dispatch.sendSync(builder, msg.Any.Close, inner); } diff --git a/js/files_test.ts b/js/files_test.ts index 82af10aa2c..835e06c844 100644 --- a/js/files_test.ts +++ b/js/files_test.ts @@ -4,15 +4,15 @@ import * as deno from "deno"; import { test, assert, assertEqual } from "./test_util.ts"; test(function filesStdioFileDescriptors() { - assertEqual(deno.stdin.fd, 0); - assertEqual(deno.stdout.fd, 1); - assertEqual(deno.stderr.fd, 2); + assertEqual(deno.stdin.rid, 0); + assertEqual(deno.stdout.rid, 1); + assertEqual(deno.stderr.rid, 2); }); test(async function filesCopyToStdout() { const filename = "package.json"; const file = await deno.open(filename); - assert(file.fd > 2); + assert(file.rid > 2); const bytesWritten = await deno.copy(deno.stdout, file); const fileSize = deno.statSync(filename).len; assertEqual(bytesWritten, fileSize); diff --git a/js/net.ts b/js/net.ts index 1258a0ff19..da8a0303e1 100644 --- a/js/net.ts +++ b/js/net.ts @@ -28,12 +28,12 @@ export interface Listener { } class ListenerImpl implements Listener { - constructor(readonly fd: number) {} + constructor(readonly rid: number) {} async accept(): Promise { const builder = new flatbuffers.Builder(); msg.Accept.startAccept(builder); - msg.Accept.addRid(builder, this.fd); + msg.Accept.addRid(builder, this.rid); const inner = msg.Accept.endAccept(builder); const baseRes = await dispatch.sendAsync(builder, msg.Any.Accept, inner); assert(baseRes != null); @@ -44,7 +44,7 @@ class ListenerImpl implements Listener { } close(): void { - close(this.fd); + close(this.rid); } addr(): Addr { @@ -61,35 +61,35 @@ export interface Conn extends Reader, Writer, Closer { class ConnImpl implements Conn { constructor( - readonly fd: number, + readonly rid: number, readonly remoteAddr: string, readonly localAddr: string ) {} write(p: ArrayBufferView): Promise { - return write(this.fd, p); + return write(this.rid, p); } read(p: ArrayBufferView): Promise { - return read(this.fd, p); + return read(this.rid, p); } close(): void { - close(this.fd); + close(this.rid); } /** closeRead shuts down (shutdown(2)) the reading side of the TCP connection. * Most callers should just use close(). */ closeRead(): void { - shutdown(this.fd, ShutdownMode.Read); + shutdown(this.rid, ShutdownMode.Read); } /** closeWrite shuts down (shutdown(2)) the writing side of the TCP * connection. Most callers should just use close(). */ closeWrite(): void { - shutdown(this.fd, ShutdownMode.Write); + shutdown(this.rid, ShutdownMode.Write); } } @@ -101,10 +101,10 @@ enum ShutdownMode { ReadWrite // unused } -function shutdown(fd: number, how: ShutdownMode) { +function shutdown(rid: number, how: ShutdownMode) { const builder = new flatbuffers.Builder(); msg.Shutdown.startShutdown(builder); - msg.Shutdown.addRid(builder, fd); + msg.Shutdown.addRid(builder, rid); msg.Shutdown.addHow(builder, how); const inner = msg.Shutdown.endShutdown(builder); const baseRes = dispatch.sendSync(builder, msg.Any.Shutdown, inner);