Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf(ext/node): move winerror binding to rust #17792

Merged
merged 5 commits into from
Feb 16, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
hookup
  • Loading branch information
littledivy committed Feb 16, 2023
commit 6f2fee292fa3a541c1948e759e7ad37e17fc6d03
2 changes: 2 additions & 0 deletions ext/node/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ mod package_json;
mod path;
mod polyfill;
mod resolution;
mod winerror;

pub use package_json::PackageJson;
pub use path::PathClean;
Expand Down Expand Up @@ -412,6 +413,7 @@ pub fn init_polyfill() -> Extension {
crypto::op_node_hash_update::decl(),
crypto::op_node_hash_digest::decl(),
crypto::op_node_hash_clone::decl(),
winerror::op_node_sys_to_uv_error::decl(),
op_node_build_os::decl(),
])
.build()
Expand Down
24 changes: 1 addition & 23 deletions ext/node/polyfills/internal_binding/_libuv_winerror.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,6 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
/* Copyright Joyent, Inc. and other Node contributors. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/

// This module ports:
// - https://github.com/libuv/libuv/blob/master/src/win/error.c

const { ops } = globalThis.__bootstrap.core;
export function uvTranslateSysError(sysErrno: number): string {
return ops.op_node_uv_to_sys_error(sysErrno);
}
31 changes: 28 additions & 3 deletions ext/node/winerror.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,29 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
/* Copyright Joyent, Inc. and other Node contributors. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/

// This module ports:
// - https://github.com/libuv/libuv/blob/master/src/win/error.c
#![allow(unused)]

use deno_core::op;

#[op]
Expand Down Expand Up @@ -105,7 +131,6 @@ fn op_node_sys_to_uv_error(err: i32) -> String {
uv_err.to_string()
}

// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
/*++

Copyright (c) Microsoft Corporation. All rights reserved.
Expand Down Expand Up @@ -1457,7 +1482,7 @@ pub const ERROR_BAD_EXE_FORMAT: i32 = 193;
// The operating system cannot run %1.
//
// deno-lint-ignore camelcase
pub const ERROR_ITERATED_DATA_EXCEEDS_64k: i32 = 194;
pub const ERROR_ITERATED_DATA_EXCEEDS_64K: i32 = 194;

//
// MessageId: ERROR_INVALID_MINALLOCSIZE
Expand Down Expand Up @@ -1503,7 +1528,7 @@ pub const ERROR_INVALID_SEGDPL: i32 = 198;
// The operating system cannot run this application program.
//
// deno-lint-ignore camelcase
pub const ERROR_AUTODATASEG_EXCEEDS_64k: i32 = 199;
pub const ERROR_AUTODATASEG_EXCEEDS_64K: i32 = 199;

//
// MessageId: ERROR_RING2SEG_MUST_BE_MOVABLE
Expand Down