Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
deno
提交
818ad376
D
deno
项目概览
张重言
/
deno
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
deno
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
818ad376
编写于
10月 03, 2018
作者:
R
Ryan Dahl
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Rename fbs to msg.
上级
f7749530
变更
22
隐藏空白更改
内联
并排
Showing
22 changed file
with
201 addition
and
201 deletion
+201
-201
js/console_test.ts
js/console_test.ts
+2
-2
js/copy_file.ts
js/copy_file.ts
+7
-7
js/dispatch.ts
js/dispatch.ts
+16
-16
js/errors.ts
js/errors.ts
+8
-8
js/fetch.ts
js/fetch.ts
+8
-8
js/fileinfo.ts
js/fileinfo.ts
+2
-2
js/files.ts
js/files.ts
+23
-23
js/main.ts
js/main.ts
+7
-7
js/make_temp_dir.ts
js/make_temp_dir.ts
+11
-11
js/mkdir.ts
js/mkdir.ts
+7
-7
js/os.ts
js/os.ts
+30
-30
js/read_dir.ts
js/read_dir.ts
+9
-9
js/read_file.ts
js/read_file.ts
+9
-9
js/read_link.ts
js/read_link.ts
+9
-9
js/remove.ts
js/remove.ts
+7
-7
js/rename.ts
js/rename.ts
+7
-7
js/stat.ts
js/stat.ts
+10
-10
js/symlink.ts
js/symlink.ts
+7
-7
js/timers.ts
js/timers.ts
+5
-5
js/trace.ts
js/trace.ts
+3
-3
js/truncate.ts
js/truncate.ts
+7
-7
js/write_file.ts
js/write_file.ts
+7
-7
未找到文件。
js/console_test.ts
浏览文件 @
818ad376
...
...
@@ -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
"
;
}
}
...
...
js/copy_file.ts
浏览文件 @
818ad376
// 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
];
}
js/dispatch.ts
浏览文件 @
818ad376
// 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
)];
}
js/errors.ts
浏览文件 @
818ad376
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
()
!
);
...
...
js/fetch.ts
浏览文件 @
818ad376
...
...
@@ -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
();
...
...
js/fileinfo.ts
浏览文件 @
818ad376
// 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
();
...
...
js/files.ts
浏览文件 @
818ad376
...
...
@@ -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
);
}
js/main.ts
浏览文件 @
818ad376
// 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
;
}
...
...
js/make_temp_dir.ts
浏览文件 @
818ad376
// 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
);
...
...
js/mkdir.ts
浏览文件 @
818ad376
// 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
];
}
js/os.ts
浏览文件 @
818ad376
// 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
);
...
...
js/read_dir.ts
浏览文件 @
818ad376
// 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
++
)
{
...
...
js/read_file.ts
浏览文件 @
818ad376
// 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
);
...
...
js/read_link.ts
浏览文件 @
818ad376
// 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
);
...
...
js/remove.ts
浏览文件 @
818ad376
// 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
];
}
js/rename.ts
浏览文件 @
818ad376
// 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
];
}
js/stat.ts
浏览文件 @
818ad376
// 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
);
}
js/symlink.ts
浏览文件 @
818ad376
// 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
];
}
js/timers.ts
浏览文件 @
818ad376
// 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
;
...
...
js/trace.ts
浏览文件 @
818ad376
// 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
})
);
}
...
...
js/truncate.ts
浏览文件 @
818ad376
// 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
];
}
js/write_file.ts
浏览文件 @
818ad376
// 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
];
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录