summaryrefslogtreecommitdiff
path: root/runtime
diff options
context:
space:
mode:
Diffstat (limited to 'runtime')
-rw-r--r--runtime/ops/fs.rs35
-rw-r--r--runtime/ops/net.rs14
-rw-r--r--runtime/ops/net_unix.rs4
-rw-r--r--runtime/ops/process.rs4
-rw-r--r--runtime/ops/signal.rs6
-rw-r--r--runtime/ops/tls.rs6
-rw-r--r--runtime/ops/tty.rs41
7 files changed, 54 insertions, 56 deletions
diff --git a/runtime/ops/fs.rs b/runtime/ops/fs.rs
index c92c17fbf..890c47da2 100644
--- a/runtime/ops/fs.rs
+++ b/runtime/ops/fs.rs
@@ -208,13 +208,13 @@ async fn op_open_async(
#[derive(Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SeekArgs {
- rid: i32,
+ rid: u32,
offset: i64,
whence: i32,
}
fn seek_helper(args: SeekArgs) -> Result<(u32, SeekFrom), AnyError> {
- let rid = args.rid as u32;
+ let rid = args.rid;
let offset = args.offset;
let whence = args.whence as u32;
// Translate seek mode to Rust repr.
@@ -273,7 +273,7 @@ async fn op_seek_async(
#[derive(Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct FdatasyncArgs {
- rid: i32,
+ rid: u32,
}
fn op_fdatasync_sync(
@@ -281,7 +281,7 @@ fn op_fdatasync_sync(
args: FdatasyncArgs,
_zero_copy: &mut [ZeroCopyBuf],
) -> Result<Value, AnyError> {
- let rid = args.rid as u32;
+ let rid = args.rid;
StdFileResource::with(state, rid, |r| match r {
Ok(std_file) => std_file.sync_data().map_err(AnyError::from),
Err(_) => Err(type_error("cannot sync this type of resource".to_string())),
@@ -294,7 +294,7 @@ async fn op_fdatasync_async(
args: FdatasyncArgs,
_zero_copy: BufVec,
) -> Result<Value, AnyError> {
- let rid = args.rid as u32;
+ let rid = args.rid;
let resource = state
.borrow_mut()
@@ -317,7 +317,7 @@ async fn op_fdatasync_async(
#[derive(Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct FsyncArgs {
- rid: i32,
+ rid: u32,
}
fn op_fsync_sync(
@@ -325,7 +325,7 @@ fn op_fsync_sync(
args: FsyncArgs,
_zero_copy: &mut [ZeroCopyBuf],
) -> Result<Value, AnyError> {
- let rid = args.rid as u32;
+ let rid = args.rid;
StdFileResource::with(state, rid, |r| match r {
Ok(std_file) => std_file.sync_all().map_err(AnyError::from),
Err(_) => Err(type_error("cannot sync this type of resource".to_string())),
@@ -338,7 +338,7 @@ async fn op_fsync_async(
args: FsyncArgs,
_zero_copy: BufVec,
) -> Result<Value, AnyError> {
- let rid = args.rid as u32;
+ let rid = args.rid;
let resource = state
.borrow_mut()
@@ -361,7 +361,7 @@ async fn op_fsync_async(
#[derive(Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct FstatArgs {
- rid: i32,
+ rid: u32,
}
fn op_fstat_sync(
@@ -370,8 +370,7 @@ fn op_fstat_sync(
_zero_copy: &mut [ZeroCopyBuf],
) -> Result<Value, AnyError> {
super::check_unstable(state, "Deno.fstat");
- let rid = args.rid as u32;
- let metadata = StdFileResource::with(state, rid, |r| match r {
+ let metadata = StdFileResource::with(state, args.rid, |r| match r {
Ok(std_file) => std_file.metadata().map_err(AnyError::from),
Err(_) => Err(type_error("cannot stat this type of resource".to_string())),
})?;
@@ -385,7 +384,7 @@ async fn op_fstat_async(
) -> Result<Value, AnyError> {
super::check_unstable2(&state, "Deno.fstat");
- let rid = args.rid as u32;
+ let rid = args.rid;
let resource = state
.borrow_mut()
@@ -1314,7 +1313,7 @@ async fn op_read_link_async(
#[derive(Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct FtruncateArgs {
- rid: i32,
+ rid: u32,
len: i32,
}
@@ -1324,7 +1323,7 @@ fn op_ftruncate_sync(
_zero_copy: &mut [ZeroCopyBuf],
) -> Result<Value, AnyError> {
super::check_unstable(state, "Deno.ftruncate");
- let rid = args.rid as u32;
+ let rid = args.rid;
let len = args.len as u64;
StdFileResource::with(state, rid, |r| match r {
Ok(std_file) => std_file.set_len(len).map_err(AnyError::from),
@@ -1339,7 +1338,7 @@ async fn op_ftruncate_async(
_zero_copy: BufVec,
) -> Result<Value, AnyError> {
super::check_unstable2(&state, "Deno.ftruncate");
- let rid = args.rid as u32;
+ let rid = args.rid;
let len = args.len as u64;
let resource = state
@@ -1586,7 +1585,7 @@ async fn op_make_temp_file_async(
#[derive(Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct FutimeArgs {
- rid: i32,
+ rid: u32,
atime: (i64, u32),
mtime: (i64, u32),
}
@@ -1597,7 +1596,7 @@ fn op_futime_sync(
_zero_copy: &mut [ZeroCopyBuf],
) -> Result<Value, AnyError> {
super::check_unstable(state, "Deno.futimeSync");
- let rid = args.rid as u32;
+ let rid = args.rid;
let atime = filetime::FileTime::from_unix_time(args.atime.0, args.atime.1);
let mtime = filetime::FileTime::from_unix_time(args.mtime.0, args.mtime.1);
@@ -1620,7 +1619,7 @@ async fn op_futime_async(
_zero_copy: BufVec,
) -> Result<Value, AnyError> {
super::check_unstable2(&state, "Deno.futime");
- let rid = args.rid as u32;
+ let rid = args.rid;
let atime = filetime::FileTime::from_unix_time(args.atime.0, args.atime.1);
let mtime = filetime::FileTime::from_unix_time(args.mtime.0, args.mtime.1);
diff --git a/runtime/ops/net.rs b/runtime/ops/net.rs
index c3714e33c..012b5b8ef 100644
--- a/runtime/ops/net.rs
+++ b/runtime/ops/net.rs
@@ -55,7 +55,7 @@ pub fn init(rt: &mut deno_core::JsRuntime) {
#[derive(Deserialize)]
pub(crate) struct AcceptArgs {
- pub rid: i32,
+ pub rid: u32,
pub transport: String,
}
@@ -64,7 +64,7 @@ async fn accept_tcp(
args: AcceptArgs,
_zero_copy: BufVec,
) -> Result<Value, AnyError> {
- let rid = args.rid as u32;
+ let rid = args.rid;
let resource = state
.borrow()
@@ -125,7 +125,7 @@ async fn op_accept(
#[derive(Deserialize)]
pub(crate) struct ReceiveArgs {
- pub rid: i32,
+ pub rid: u32,
pub transport: String,
}
@@ -137,7 +137,7 @@ async fn receive_udp(
assert_eq!(zero_copy.len(), 1, "Invalid number of arguments");
let mut zero_copy = zero_copy[0].clone();
- let rid = args.rid as u32;
+ let rid = args.rid;
let resource = state
.borrow_mut()
@@ -181,7 +181,7 @@ async fn op_datagram_receive(
#[derive(Deserialize)]
struct SendArgs {
- rid: i32,
+ rid: u32,
transport: String,
#[serde(flatten)]
transport_args: ArgsEnum,
@@ -215,7 +215,7 @@ async fn op_datagram_send(
let resource = state
.borrow_mut()
.resource_table
- .get::<UdpSocketResource>(rid as u32)
+ .get::<UdpSocketResource>(rid)
.ok_or_else(|| bad_resource("Socket has been closed"))?;
let socket = RcRef::map(&resource, |r| &r.socket).borrow().await;
let byte_length = socket.send_to(&zero_copy, &addr).await?;
@@ -235,7 +235,7 @@ async fn op_datagram_send(
let resource = state
.borrow()
.resource_table
- .get::<net_unix::UnixDatagramResource>(rid as u32)
+ .get::<net_unix::UnixDatagramResource>(rid)
.ok_or_else(|| {
custom_error("NotConnected", "Socket has been closed")
})?;
diff --git a/runtime/ops/net_unix.rs b/runtime/ops/net_unix.rs
index c3e561568..6d9afb70f 100644
--- a/runtime/ops/net_unix.rs
+++ b/runtime/ops/net_unix.rs
@@ -65,7 +65,7 @@ pub(crate) async fn accept_unix(
args: AcceptArgs,
_bufs: BufVec,
) -> Result<Value, AnyError> {
- let rid = args.rid as u32;
+ let rid = args.rid;
let resource = state
.borrow()
@@ -104,7 +104,7 @@ pub(crate) async fn receive_unix_packet(
) -> Result<Value, AnyError> {
assert_eq!(bufs.len(), 1, "Invalid number of arguments");
- let rid = args.rid as u32;
+ let rid = args.rid;
let mut buf = bufs.into_iter().next().unwrap();
let resource = state
diff --git a/runtime/ops/process.rs b/runtime/ops/process.rs
index c9715039b..bea4708f7 100644
--- a/runtime/ops/process.rs
+++ b/runtime/ops/process.rs
@@ -178,7 +178,7 @@ fn op_run(
#[derive(Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct RunStatusArgs {
- rid: i32,
+ rid: u32,
}
async fn op_run_status(
@@ -186,7 +186,7 @@ async fn op_run_status(
args: RunStatusArgs,
_zero_copy: BufVec,
) -> Result<Value, AnyError> {
- let rid = args.rid as u32;
+ let rid = args.rid;
{
let s = state.borrow();
diff --git a/runtime/ops/signal.rs b/runtime/ops/signal.rs
index 86eb91c1b..a083549a1 100644
--- a/runtime/ops/signal.rs
+++ b/runtime/ops/signal.rs
@@ -63,7 +63,7 @@ pub struct BindSignalArgs {
#[cfg(unix)]
#[derive(Deserialize)]
pub struct SignalArgs {
- rid: i32,
+ rid: u32,
}
#[cfg(unix)]
@@ -93,7 +93,7 @@ async fn op_signal_poll(
_zero_copy: BufVec,
) -> Result<Value, AnyError> {
super::check_unstable2(&state, "Deno.signal");
- let rid = args.rid as u32;
+ let rid = args.rid;
let resource = state
.borrow_mut()
@@ -116,7 +116,7 @@ pub fn op_signal_unbind(
_zero_copy: &mut [ZeroCopyBuf],
) -> Result<Value, AnyError> {
super::check_unstable(state, "Deno.signal");
- let rid = args.rid as u32;
+ let rid = args.rid;
state
.resource_table
.close(rid)
diff --git a/runtime/ops/tls.rs b/runtime/ops/tls.rs
index 2e6399222..2c0f2df4d 100644
--- a/runtime/ops/tls.rs
+++ b/runtime/ops/tls.rs
@@ -98,7 +98,7 @@ async fn op_start_tls(
args: StartTLSArgs,
_zero_copy: BufVec,
) -> Result<Value, AnyError> {
- let rid = args.rid as u32;
+ let rid = args.rid;
let mut domain = args.hostname.as_str();
if domain.is_empty() {
@@ -350,7 +350,7 @@ fn op_listen_tls(
#[derive(Deserialize)]
pub struct AcceptTlsArgs {
- rid: i32,
+ rid: u32,
}
async fn op_accept_tls(
@@ -358,7 +358,7 @@ async fn op_accept_tls(
args: AcceptTlsArgs,
_zero_copy: BufVec,
) -> Result<Value, AnyError> {
- let rid = args.rid as u32;
+ let rid = args.rid;
let resource = state
.borrow()
diff --git a/runtime/ops/tty.rs b/runtime/ops/tty.rs
index 390f948dc..45d458b79 100644
--- a/runtime/ops/tty.rs
+++ b/runtime/ops/tty.rs
@@ -225,27 +225,26 @@ fn op_isatty(
) -> Result<Value, AnyError> {
let rid = args.rid;
- let isatty: bool =
- StdFileResource::with(state, rid as u32, move |r| match r {
- Ok(std_file) => {
- #[cfg(windows)]
- {
- use winapi::um::consoleapi;
-
- let handle = get_windows_handle(&std_file)?;
- let mut test_mode: DWORD = 0;
- // If I cannot get mode out of console, it is not a console.
- Ok(unsafe { consoleapi::GetConsoleMode(handle, &mut test_mode) != 0 })
- }
- #[cfg(unix)]
- {
- use std::os::unix::io::AsRawFd;
- let raw_fd = std_file.as_raw_fd();
- Ok(unsafe { libc::isatty(raw_fd as libc::c_int) == 1 })
- }
+ let isatty: bool = StdFileResource::with(state, rid, move |r| match r {
+ Ok(std_file) => {
+ #[cfg(windows)]
+ {
+ use winapi::um::consoleapi;
+
+ let handle = get_windows_handle(&std_file)?;
+ let mut test_mode: DWORD = 0;
+ // If I cannot get mode out of console, it is not a console.
+ Ok(unsafe { consoleapi::GetConsoleMode(handle, &mut test_mode) != 0 })
}
- _ => Ok(false),
- })?;
+ #[cfg(unix)]
+ {
+ use std::os::unix::io::AsRawFd;
+ let raw_fd = std_file.as_raw_fd();
+ Ok(unsafe { libc::isatty(raw_fd as libc::c_int) == 1 })
+ }
+ }
+ _ => Ok(false),
+ })?;
Ok(json!(isatty))
}
@@ -269,7 +268,7 @@ fn op_console_size(
let rid = args.rid;
- let size = StdFileResource::with(state, rid as u32, move |r| match r {
+ let size = StdFileResource::with(state, rid, move |r| match r {
Ok(std_file) => {
#[cfg(windows)]
{