diff options
| author | Aaron O'Mullan <aaron.omullan@gmail.com> | 2021-04-12 21:55:05 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-04-12 15:55:05 -0400 |
| commit | 46b1c653c0c433932908b7610f60b409af134c76 (patch) | |
| tree | 00d8b59c8c4e9b90538d548ebd828d2b3f94d4fd /runtime | |
| parent | a20504642d083172f297543f9788b128e9c2e0bc (diff) | |
refactor(deno): remove concept of bin & json ops (#10145)
Diffstat (limited to 'runtime')
44 files changed, 333 insertions, 389 deletions
diff --git a/runtime/js/11_timers.js b/runtime/js/11_timers.js index eef1d39b2..cfd9ad72d 100644 --- a/runtime/js/11_timers.js +++ b/runtime/js/11_timers.js @@ -6,23 +6,23 @@ const core = window.Deno.core; function opStopGlobalTimer() { - core.jsonOpSync("op_global_timer_stop"); + core.opSync("op_global_timer_stop"); } function opStartGlobalTimer(timeout) { - return core.jsonOpSync("op_global_timer_start", timeout); + return core.opSync("op_global_timer_start", timeout); } async function opWaitGlobalTimer() { - await core.jsonOpAsync("op_global_timer"); + await core.opAsync("op_global_timer"); } function opNow() { - return core.jsonOpSync("op_now"); + return core.opSync("op_now"); } function sleepSync(millis = 0) { - return core.jsonOpSync("op_sleep_sync", millis); + return core.opSync("op_sleep_sync", millis); } // Derived from https://github.com/vadimg/js_bintrees. MIT Licensed. diff --git a/runtime/js/11_workers.js b/runtime/js/11_workers.js index b11195713..2c602ab60 100644 --- a/runtime/js/11_workers.js +++ b/runtime/js/11_workers.js @@ -17,7 +17,7 @@ permissions, name, ) { - return core.jsonOpSync("op_create_worker", { + return core.opSync("op_create_worker", { hasSourceCode, name, permissions, @@ -28,15 +28,15 @@ } function hostTerminateWorker(id) { - core.jsonOpSync("op_host_terminate_worker", id); + core.opSync("op_host_terminate_worker", id); } function hostPostMessage(id, data) { - core.jsonOpSync("op_host_post_message", id, data); + core.opSync("op_host_post_message", id, data); } function hostGetMessage(id) { - return core.jsonOpAsync("op_host_get_message", id); + return core.opAsync("op_host_get_message", id); } const encoder = new TextEncoder(); @@ -268,7 +268,7 @@ if (globalThis instanceof Window) { throw new Error("Unhandled error event reached main worker."); } else { - core.jsonOpSync( + core.opSync( "op_host_unhandled_error", event.error.message, ); @@ -287,7 +287,7 @@ if (globalThis instanceof Window) { throw new Error("Unhandled error event reached main worker."); } else { - core.jsonOpSync( + core.opSync( "op_host_unhandled_error", event.error.message, ); diff --git a/runtime/js/12_io.js b/runtime/js/12_io.js index a6b6aeebd..8df3de92f 100644 --- a/runtime/js/12_io.js +++ b/runtime/js/12_io.js @@ -81,7 +81,7 @@ return 0; } - const nread = core.binOpSync("op_read_sync", rid, buffer); + const nread = core.opSync("op_read_sync", rid, buffer); return nread === 0 ? null : nread; } @@ -94,17 +94,17 @@ return 0; } - const nread = await core.binOpAsync("op_read_async", rid, buffer); + const nread = await core.opAsync("op_read_async", rid, buffer); return nread === 0 ? null : nread; } function writeSync(rid, data) { - return core.binOpSync("op_write_sync", rid, data); + return core.opSync("op_write_sync", rid, data); } async function write(rid, data) { - return await core.binOpAsync("op_write_async", rid, data); + return await core.opAsync("op_write_async", rid, data); } const READ_PER_ITER = 32 * 1024; diff --git a/runtime/js/30_fs.js b/runtime/js/30_fs.js index af2aebd3e..72126e6bb 100644 --- a/runtime/js/30_fs.js +++ b/runtime/js/30_fs.js @@ -7,11 +7,11 @@ const build = window.__bootstrap.build.build; function chmodSync(path, mode) { - core.jsonOpSync("op_chmod_sync", { path: pathFromURL(path), mode }); + core.opSync("op_chmod_sync", { path: pathFromURL(path), mode }); } async function chmod(path, mode) { - await core.jsonOpAsync("op_chmod_async", { path: pathFromURL(path), mode }); + await core.opAsync("op_chmod_async", { path: pathFromURL(path), mode }); } function chownSync( @@ -19,7 +19,7 @@ uid, gid, ) { - core.jsonOpSync("op_chown_sync", { path: pathFromURL(path), uid, gid }); + core.opSync("op_chown_sync", { path: pathFromURL(path), uid, gid }); } async function chown( @@ -27,7 +27,7 @@ uid, gid, ) { - await core.jsonOpAsync( + await core.opAsync( "op_chown_async", { path: pathFromURL(path), uid, gid }, ); @@ -37,7 +37,7 @@ fromPath, toPath, ) { - core.jsonOpSync("op_copy_file_sync", { + core.opSync("op_copy_file_sync", { from: pathFromURL(fromPath), to: pathFromURL(toPath), }); @@ -47,34 +47,34 @@ fromPath, toPath, ) { - await core.jsonOpAsync("op_copy_file_async", { + await core.opAsync("op_copy_file_async", { from: pathFromURL(fromPath), to: pathFromURL(toPath), }); } function cwd() { - return core.jsonOpSync("op_cwd"); + return core.opSync("op_cwd"); } function chdir(directory) { - core.jsonOpSync("op_chdir", directory); + core.opSync("op_chdir", directory); } function makeTempDirSync(options = {}) { - return core.jsonOpSync("op_make_temp_dir_sync", options); + return core.opSync("op_make_temp_dir_sync", options); } function makeTempDir(options = {}) { - return core.jsonOpAsync("op_make_temp_dir_async", options); + return core.opAsync("op_make_temp_dir_async", options); } function makeTempFileSync(options = {}) { - return core.jsonOpSync("op_make_temp_file_sync", options); + return core.opSync("op_make_temp_file_sync", options); } function makeTempFile(options = {}) { - return core.jsonOpAsync("op_make_temp_file_async", options); + return core.opAsync("op_make_temp_file_async", options); } function mkdirArgs(path, options) { @@ -91,24 +91,24 @@ } function mkdirSync(path, options) { - core.jsonOpSync("op_mkdir_sync", mkdirArgs(path, options)); + core.opSync("op_mkdir_sync", mkdirArgs(path, options)); } async function mkdir( path, options, ) { - await core.jsonOpAsync("op_mkdir_async", mkdirArgs(path, options)); + await core.opAsync("op_mkdir_async", mkdirArgs(path, options)); } function readDirSync(path) { - return core.jsonOpSync("op_read_dir_sync", pathFromURL(path))[ + return core.opSync("op_read_dir_sync", pathFromURL(path))[ Symbol.iterator ](); } function readDir(path) { - const array = core.jsonOpAsync( + const array = core.opAsync( "op_read_dir_async", pathFromURL(path), ); @@ -120,26 +120,26 @@ } function readLinkSync(path) { - return core.jsonOpSync("op_read_link_sync", pathFromURL(path)); + return core.opSync("op_read_link_sync", pathFromURL(path)); } function readLink(path) { - return core.jsonOpAsync("op_read_link_async", pathFromURL(path)); + return core.opAsync("op_read_link_async", pathFromURL(path)); } function realPathSync(path) { - return core.jsonOpSync("op_realpath_sync", path); + return core.opSync("op_realpath_sync", path); } function realPath(path) { - return core.jsonOpAsync("op_realpath_async", path); + return core.opAsync("op_realpath_async", path); } function removeSync( path, options = {}, ) { - core.jsonOpSync("op_remove_sync", { + core.opSync("op_remove_sync", { path: pathFromURL(path), recursive: !!options.recursive, }); @@ -149,18 +149,18 @@ path, options = {}, ) { - await core.jsonOpAsync("op_remove_async", { + await core.opAsync("op_remove_async", { path: pathFromURL(path), recursive: !!options.recursive, }); } function renameSync(oldpath, newpath) { - core.jsonOpSync("op_rename_sync", { oldpath, newpath }); + core.opSync("op_rename_sync", { oldpath, newpath }); } async function rename(oldpath, newpath) { - await core.jsonOpAsync("op_rename_async", { oldpath, newpath }); + await core.opAsync("op_rename_async", { oldpath, newpath }); } function parseFileInfo(response) { @@ -189,15 +189,15 @@ } function fstatSync(rid) { - return parseFileInfo(core.jsonOpSync("op_fstat_sync", rid)); + return parseFileInfo(core.opSync("op_fstat_sync", rid)); } async function fstat(rid) { - return parseFileInfo(await core.jsonOpAsync("op_fstat_async", rid)); + return parseFileInfo(await core.opAsync("op_fstat_async", rid)); } async function lstat(path) { - const res = await core.jsonOpAsync("op_stat_async", { + const res = await core.opAsync("op_stat_async", { path: pathFromURL(path), lstat: true, }); @@ -205,7 +205,7 @@ } function lstatSync(path) { - const res = core.jsonOpSync("op_stat_sync", { + const res = core.opSync("op_stat_sync", { path: pathFromURL(path), lstat: true, }); @@ -213,7 +213,7 @@ } async function stat(path) { - const res = await core.jsonOpAsync("op_stat_async", { + const res = await core.opAsync("op_stat_async", { path: pathFromURL(path), lstat: false, }); @@ -221,7 +221,7 @@ } function statSync(path) { - const res = core.jsonOpSync("op_stat_sync", { + const res = core.opSync("op_stat_sync", { path: pathFromURL(path), lstat: false, }); @@ -237,31 +237,31 @@ } function ftruncateSync(rid, len) { - core.jsonOpSync("op_ftruncate_sync", { rid, len: coerceLen(len) }); + core.opSync("op_ftruncate_sync", { rid, len: coerceLen(len) }); } async function ftruncate(rid, len) { - await core.jsonOpAsync("op_ftruncate_async", { rid, len: coerceLen(len) }); + await core.opAsync("op_ftruncate_async", { rid, len: coerceLen(len) }); } function truncateSync(path, len) { - core.jsonOpSync("op_truncate_sync", { path, len: coerceLen(len) }); + core.opSync("op_truncate_sync", { path, len: coerceLen(len) }); } async function truncate(path, len) { - await core.jsonOpAsync("op_truncate_async", { path, len: coerceLen(len) }); + await core.opAsync("op_truncate_async", { path, len: coerceLen(len) }); } function umask(mask) { - return core.jsonOpSync("op_umask", mask); + return core.opSync("op_umask", mask); } function linkSync(oldpath, newpath) { - core.jsonOpSync("op_link_sync", { oldpath, newpath }); + core.opSync("op_link_sync", { oldpath, newpath }); } async function link(oldpath, newpath) { - await core.jsonOpAsync("op_link_async", { oldpath, newpath }); + await core.opAsync("op_link_async", { oldpath, newpath }); } function toUnixTimeFromEpoch(value) { @@ -290,7 +290,7 @@ atime, mtime, ) { - core.jsonOpSync("op_futime_sync", { + core.opSync("op_futime_sync", { rid, atime: toUnixTimeFromEpoch(atime), mtime: toUnixTimeFromEpoch(mtime), @@ -302,7 +302,7 @@ atime, mtime, ) { - await core.jsonOpAsync("op_futime_async", { + await core.opAsync("op_futime_async", { rid, atime: toUnixTimeFromEpoch(atime), mtime: toUnixTimeFromEpoch(mtime), @@ -314,7 +314,7 @@ atime, mtime, ) { - core.jsonOpSync("op_utime_sync", { + core.opSync("op_utime_sync", { path, atime: toUnixTimeFromEpoch(atime), mtime: toUnixTimeFromEpoch(mtime), @@ -326,7 +326,7 @@ atime, mtime, ) { - await core.jsonOpAsync("op_utime_async", { + await core.opAsync("op_utime_async", { path, atime: toUnixTimeFromEpoch(atime), mtime: toUnixTimeFromEpoch(mtime), @@ -338,7 +338,7 @@ newpath, options, ) { - core.jsonOpSync("op_symlink_sync", { oldpath, newpath, options }); + core.opSync("op_symlink_sync", { oldpath, newpath, options }); } async function symlink( @@ -346,23 +346,23 @@ newpath, options, ) { - await core.jsonOpAsync("op_symlink_async", { oldpath, newpath, options }); + await core.opAsync("op_symlink_async", { oldpath, newpath, options }); } function fdatasyncSync(rid) { - core.jsonOpSync("op_fdatasync_sync", rid); + core.opSync("op_fdatasync_sync", rid); } async function fdatasync(rid) { - await core.jsonOpAsync("op_fdatasync_async", rid); + await core.opAsync("op_fdatasync_async", rid); } function fsyncSync(rid) { - core.jsonOpSync("op_fsync_sync", rid); + core.opSync("op_fsync_sync", rid); } async function fsync(rid) { - await core.jsonOpAsync("op_fsync_async", rid); + await core.opAsync("op_fsync_async", rid); } window.__bootstrap.fs = { diff --git a/runtime/js/30_metrics.js b/runtime/js/30_metrics.js index ed062fce3..ecc1cfc64 100644 --- a/runtime/js/30_metrics.js +++ b/runtime/js/30_metrics.js @@ -5,7 +5,7 @@ const core = window.Deno.core; function metrics() { - const { combined, ops } = core.jsonOpSync("op_metrics"); + const { combined, ops } = core.opSync("op_metrics"); if (ops) { combined.ops = ops; } diff --git a/runtime/js/30_net.js b/runtime/js/30_net.js index 56fb94f26..2d4b1e48e 100644 --- a/runtime/js/30_net.js +++ b/runtime/js/30_net.js @@ -7,23 +7,23 @@ const { read, write } = window.__bootstrap.io; function shutdown(rid) { - return core.jsonOpAsync("op_shutdown", rid); + return core.opAsync("op_shutdown", rid); } function opAccept(rid, transport) { - return core.jsonOpAsync("op_accept", { rid, transport }); + return core.opAsync("op_accept", { rid, transport }); } function opListen(args) { - return core.jsonOpSync("op_listen", args); + return core.opSync("op_listen", args); } function opConnect(args) { - return core.jsonOpAsync("op_connect", args); + return core.opAsync("op_connect", args); } function opReceive(rid, transport, zeroCopy) { - return core.jsonOpAsync( + return core.opAsync( "op_datagram_receive", { rid, transport }, zeroCopy, @@ -31,11 +31,11 @@ } function opSend(args, zeroCopy) { - return core.jsonOpAsync("op_datagram_send", args, zeroCopy); + return core.opAsync("op_datagram_send", args, zeroCopy); } function resolveDns(query, recordType, options) { - return core.jsonOpAsync("op_dns_resolve", { query, recordType, options }); + return core.opAsync("op_dns_resolve", { query, recordType, options }); } class Conn { diff --git a/runtime/js/30_os.js b/runtime/js/30_os.js index 0ce831775..2d11d6fde 100644 --- a/runtime/js/30_os.js +++ b/runtime/js/30_os.js @@ -5,23 +5,23 @@ const core = window.Deno.core; function loadavg() { - return core.jsonOpSync("op_loadavg"); + return core.opSync("op_loadavg"); } function hostname() { - return core.jsonOpSync("op_hostname"); + return core.opSync("op_hostname"); } function osRelease() { - return core.jsonOpSync("op_os_release"); + return core.opSync("op_os_release"); } function systemMemoryInfo() { - return core.jsonOpSync("op_system_memory_info"); + return core.opSync("op_system_memory_info"); } function systemCpuInfo() { - const { cores, speed } = core.jsonOpSync("op_system_cpu_info"); + const { cores, speed } = core.opSync("op_system_cpu_info"); // Map nulls to undefined for compatibility return { cores: cores ?? undefined, @@ -49,33 +49,33 @@ return; } - core.jsonOpSync("op_exit", code); + core.opSync("op_exit", code); throw new Error("Code not reachable"); } function setEnv(key, value) { - core.jsonOpSync("op_set_env", { key, value }); + core.opSync("op_set_env", { key, value }); } function getEnv(key) { - return core.jsonOpSync("op_get_env", key) ?? undefined; + return core.opSync("op_get_env", key) ?? undefined; } function deleteEnv(key) { - core.jsonOpSync("op_delete_env", key); + core.opSync("op_delete_env", key); } const env = { get: getEnv, toObject() { - return core.jsonOpSync("op_env"); + return core.opSync("op_env"); }, set: setEnv, delete: deleteEnv, }; function execPath() { - return core.jsonOpSync("op_exec_path"); + return core.opSync("op_exec_path"); } window.__bootstrap.os = { diff --git a/runtime/js/40_compiler_api.js b/runtime/js/40_compiler_api.js index cce12f2f8..b30ffc5d5 100644 --- a/runtime/js/40_compiler_api.js +++ b/runtime/js/40_compiler_api.js @@ -39,7 +39,7 @@ * @returns {Promise<OpEmitResponse>} */ function opEmit(request) { - return core.jsonOpAsync("op_emit", request); + return core.opAsync("op_emit", request); } /** diff --git a/runtime/js/40_error_stack.js b/runtime/js/40_error_stack.js index 9bc6567a0..e73975044 100644 --- a/runtime/js/40_error_stack.js +++ b/runtime/js/40_error_stack.js @@ -5,11 +5,11 @@ const core = window.Deno.core; function opFormatDiagnostics(diagnostics) { - return core.jsonOpSync("op_format_diagnostic", diagnostics); + return core.opSync("op_format_diagnostic", diagnostics); } function opApplySourceMap(location) { - const res = core.jsonOpSync("op_apply_source_map", location); + const res = core.opSync("op_apply_source_map", location); return { fileName: res.fileName, lineNumber: res.lineNumber, diff --git a/runtime/js/40_files.js b/runtime/js/40_files.js index d552b4ba5..82cf19ffc 100644 --- a/runtime/js/40_files.js +++ b/runtime/js/40_files.js @@ -12,7 +12,7 @@ offset, whence, ) { - return core.jsonOpSync("op_seek_sync", { rid, offset, whence }); + return core.opSync("op_seek_sync", { rid, offset, whence }); } function seek( @@ -20,7 +20,7 @@ offset, whence, ) { - return core.jsonOpAsync("op_seek_async", { rid, offset, whence }); + return core.opAsync("op_seek_async", { rid, offset, whence }); } function openSync( @@ -29,7 +29,7 @@ ) { checkOpenOptions(options); const mode = options?.mode; - const rid = core.jsonOpSync( + const rid = core.opSync( "op_open_sync", { path: pathFromURL(path), options, mode }, ); @@ -43,7 +43,7 @@ ) { checkOpenOptions(options); const mode = options?.mode; - const rid = await core.jsonOpAsync( + const rid = await core.opAsync( "op_open_async", { path: pathFromURL(path), options, mode }, ); diff --git a/runtime/js/40_fs_events.js b/runtime/js/40_fs_events.js index 06ad3a29c..a1a9877b4 100644 --- a/runtime/js/40_fs_events.js +++ b/runtime/js/40_fs_events.js @@ -10,7 +10,7 @@ constructor(paths, options) { const { recursive } = options; - this.#rid = core.jsonOpSync("op_fs_events_open", { recursive, paths }); + this.#rid = core.opSync("op_fs_events_open", { recursive, paths }); } get rid() { @@ -19,7 +19,7 @@ async next() { try { - const value = await core.jsonOpAsync("op_fs_events_poll", this.rid); + const value = await core.opAsync("op_fs_events_poll", this.rid); return value ? { value, done: false } : { value: undefined, done: true }; diff --git a/runtime/js/40_http.js b/runtime/js/40_http.js index d9dff7b52..4a2dcdf4a 100644 --- a/runtime/js/40_http.js +++ b/runtime/js/40_http.js @@ -10,7 +10,7 @@ const { ReadableStream } = window.__bootstrap.streams; function serveHttp(conn) { - const rid = Deno.core.jsonOpSync("op_http_start", conn.rid); + const rid = Deno.core.opSync("op_http_start", conn.rid); return new HttpConn(rid); } @@ -30,7 +30,7 @@ async nextRequest() { let nextRequest; try { - nextRequest = await Deno.core.jsonOpAsync( + nextRequest = await Deno.core.opAsync( "op_http_request_next", this.#rid, ); @@ -88,7 +88,7 @@ } function readRequest(requestRid, zeroCopyBuf) { - return Deno.core.jsonOpAsync( + return Deno.core.opAsync( "op_http_request_read", requestRid, zeroCopyBuf, @@ -129,7 +129,7 @@ zeroCopyBuf = null; } - const responseBodyRid = Deno.core.jsonOpSync("op_http_response", [ + const responseBodyRid = Deno.core.opSync("op_http_response", [ responseSenderRid, resp.status ?? 200, flattenHeaders(resp.headers), @@ -149,7 +149,7 @@ chunk.byteOffset, chunk.byteLength, ); - await Deno.core.jsonOpAsync( + await Deno.core.opAsync( "op_http_response_write", responseBodyRid, data, @@ -158,7 +158,7 @@ // Once all chunks are sent, and the request body is closed, we can close // the response body. - await Deno.core.jsonOpAsync("op_http_response_close", responseBodyRid); + await Deno.core.opAsync("op_http_response_close", responseBodyRid); } }; } diff --git a/runtime/js/40_permissions.js b/runtime/js/40_permissions.js index 7a81ca425..dd4ce5533 100644 --- a/runtime/js/40_permissions.js +++ b/runtime/js/40_permissions.js @@ -31,7 +31,7 @@ * @returns {Deno.PermissionState} */ function opQuery(desc) { - return core.jsonOpSync("op_query_permission", desc); + return core.opSync("op_query_permission", desc); } /** @@ -39,7 +39,7 @@ * @returns {Deno.PermissionState} */ function opRevoke(desc) { - return core.jsonOpSync("op_revoke_permission", desc); + return core.opSync("op_revoke_permission", desc); } /** @@ -47,7 +47,7 @@ * @returns {Deno.PermissionState} */ function opRequest(desc) { - return core.jsonOpSync("op_request_permission", desc); + return core.opSync("op_request_permission", desc); } class PermissionStatus extends EventTarget { diff --git a/runtime/js/40_plugins.js b/runtime/js/40_plugins.js index 5ebcfddad..e9a3142b4 100644 --- a/runtime/js/40_plugins.js +++ b/runtime/js/40_plugins.js @@ -5,7 +5,7 @@ const core = window.Deno.core; function openPlugin(filename) { - return core.jsonOpSync("op_open_plugin", filename); + return core.opSync("op_open_plugin", filename); } window.__bootstrap.plugins = { diff --git a/runtime/js/40_process.js b/runtime/js/40_process.js index a93818b95..91e37701a 100644 --- a/runtime/js/40_process.js +++ b/runtime/js/40_process.js @@ -8,16 +8,16 @@ const { assert, pathFromURL } = window.__bootstrap.util; function opKill(pid, signo) { - core.jsonOpSync("op_kill", { pid, signo }); + core.opSync("op_kill", { pid, signo }); } function opRunStatus(rid) { - return core.jsonOpAsync("op_run_status", rid); + return core.opAsync("op_run_status", rid); } function opRun(request) { assert(request.cmd.length > 0); - return core.jsonOpSync("op_run", request); + return core.opSync("op_run", request); } async function runStatus(rid) { diff --git a/runtime/js/40_signals.js b/runtime/js/40_signals.js index e222a9199..dfc604759 100644 --- a/runtime/js/40_signals.js +++ b/runtime/js/40_signals.js @@ -7,15 +7,15 @@ const { errors } = window.__bootstrap.errors; function bindSignal(signo) { - return core.jsonOpSync("op_signal_bind", signo); + return core.opSync("op_signal_bind", signo); } function pollSignal(rid) { - return core.jsonOpAsync("op_signal_poll", rid); + return core.opAsync("op_signal_poll", rid); } function unbindSignal(rid) { - core.jsonOpSync("op_signal_unbind", rid); + core.opSync("op_signal_unbind", rid); } // From `kill -l` diff --git a/runtime/js/40_tls.js b/runtime/js/40_tls.js index e11754b0d..4fafe9079 100644 --- a/runtime/js/40_tls.js +++ b/runtime/js/40_tls.js @@ -8,19 +8,19 @@ function opConnectTls( args, ) { - return core.jsonOpAsync("op_connect_tls", args); + return core.opAsync("op_connect_tls", args); } function opAcceptTLS(rid) { - return core.jsonOpAsync("op_accept_tls", rid); + return core.opAsync("op_accept_tls", rid); } function opListenTls(args) { - return core.jsonOpSync("op_listen_tls", args); + return core.opSync("op_listen_tls", args); } function opStartTls(args) { - return core.jsonOpAsync("op_start_tls", args); + return core.opAsync("op_start_tls", args); } async function connectTls({ diff --git a/runtime/js/40_tty.js b/runtime/js/40_tty.js index 9b23b1ec1..e76d7d90e 100644 --- a/runtime/js/40_tty.js +++ b/runtime/js/40_tty.js @@ -5,11 +5,11 @@ const core = window.Deno.core; function consoleSize(rid) { - return core.jsonOpSync("op_console_size", rid); + return core.opSync("op_console_size", rid); } function isatty(rid) { - return core.jsonOpSync("op_isatty", rid); + return core.opSync("op_isatty", rid); } const DEFAULT_SET_RAW_OPTIONS = { @@ -18,7 +18,7 @@ function setRaw(rid, mode, options = {}) { const rOptions = { ...DEFAULT_SET_RAW_OPTIONS, ...options }; - core.jsonOpSync("op_set_raw", { rid, mode, options: rOptions }); + core.opSync("op_set_raw", { rid, mode, options: rOptions }); } window.__bootstrap.tty = { diff --git a/runtime/js/99_main.js b/runtime/js/99_main.js index 7f24e10cd..977755007 100644 --- a/runtime/js/99_main.js +++ b/runtime/js/99_main.js @@ -129,15 +129,15 @@ delete Object.prototype.__proto__; } function opPostMessage(data) { - core.jsonOpSync("op_worker_post_message", null, data); + core.opSync("op_worker_post_message", null, data); } function opCloseWorker() { - core.jsonOpSync("op_worker_close"); + core.opSync("op_worker_close"); } function opMainModule() { - return core.jsonOpSync("op_main_module"); + return core.opSync("op_main_module"); } function runtimeStart(runtimeOptions, source) { diff --git a/runtime/ops/crypto.rs b/runtime/ops/crypto.rs index 43a9d1126..432cc0185 100644 --- a/runtime/ops/crypto.rs +++ b/runtime/ops/crypto.rs @@ -10,7 +10,7 @@ pub fn init(rt: &mut deno_core::JsRuntime, maybe_seed: Option<u64>) { let mut state = op_state.borrow_mut(); state.put::<StdRng>(rng); } - super::reg_json_sync( + super::reg_sync( rt, "op_crypto_get_random_values", op_crypto_get_random_values, diff --git a/runtime/ops/fetch.rs b/runtime/ops/fetch.rs index 3cb0c6c78..17656974a 100644 --- a/runtime/ops/fetch.rs +++ b/runtime/ops/fetch.rs @@ -20,19 +20,19 @@ pub fn init( ca_data, }); } - super::reg_json_sync(rt, "op_fetch", deno_fetch::op_fetch::<Permissions>); - super::reg_json_async(rt, "op_fetch_send", deno_fetch::op_fetch_send); - super::reg_json_async( + super::reg_sync(rt, "op_fetch", deno_fetch::op_fetch::<Permissions>); + super::reg_async(rt, "op_fetch_send", deno_fetch::op_fetch_send); + super::reg_async( rt, "op_fetch_request_write", deno_fetch::op_fetch_request_write, ); - super::reg_json_async( + super::reg_async( rt, "op_fetch_response_read", deno_fetch::op_fetch_response_read, ); - super::reg_json_sync( + super::reg_sync( rt, "op_create_http_client", deno_fetch::op_create_http_client::<Permissions>, diff --git a/runtime/ops/file.rs b/runtime/ops/file.rs index e7f68b207..8f471ebbd 100644 --- a/runtime/ops/file.rs +++ b/runtime/ops/file.rs @@ -18,14 +18,6 @@ pub fn init( op_state.put(Location(location)); } } - super::reg_json_sync( - rt, - "op_file_create_object_url", - op_file_create_object_url, - ); - super::reg_json_sync( - rt, - "op_file_revoke_object_url", - op_file_revoke_object_url, - ); + super::reg_sync(rt, "op_file_create_object_url", op_file_create_object_url); + super::reg_sync(rt, "op_file_revoke_object_url", op_file_revoke_object_url); } diff --git a/runtime/ops/fs.rs b/runtime/ops/fs.rs index aa3780624..19933dcb6 100644 --- a/runtime/ops/fs.rs +++ b/runtime/ops/fs.rs @@ -34,79 +34,79 @@ use deno_core::error::generic_error; use deno_core::error::not_supported; pub fn init(rt: &mut deno_core::JsRuntime) { - super::reg_json_sync(rt, "op_open_sync", op_open_sync); - super::reg_json_async(rt, "op_open_async", op_open_async); + super::reg_sync(rt, "op_open_sync", op_open_sync); + super::reg_async(rt, "op_open_async", op_open_async); - super::reg_json_sync(rt, "op_seek_sync", op_seek_sync); - super::reg_json_async(rt, "op_seek_async", op_seek_async); + super::reg_sync(rt, "op_seek_sync", op_seek_sync); + super::reg_async(rt, "op_seek_async", op_seek_async); - super::reg_json_sync(rt, "op_fdatasync_sync", op_fdatasync_sync); - super::reg_json_async(rt, "op_fdatasync_async", op_fdatasync_async); + super::reg_sync(rt, "op_fdatasync_sync", op_fdatasync_sync); + super::reg_async(rt, "op_fdatasync_async", op_fdatasync_async); - super::reg_json_sync(rt, "op_fsync_sync", op_fsync_sync); - super::reg_json_async(rt, "op_fsync_async", op_fsync_async); + super::reg_sync(rt, "op_fsync_sync", op_fsync_sync); + super::reg_async(rt, "op_fsync_async", op_fsync_async); - super::reg_json_sync(rt, "op_fstat_sync", op_fstat_sync); - super::reg_json_async(rt, "op_fstat_async", op_fstat_async); + super::reg_sync(rt, "op_fstat_sync", op_fstat_sync); + super::reg_async(rt, "op_fstat_async", op_fstat_async); - super::reg_json_sync(rt, "op_umask", op_umask); - super::reg_json_sync(rt, "op_chdir", op_chdir); + super::reg_sync(rt, "op_umask", op_umask); + super::reg_sync(rt, "op_chdir", op_chdir); - super::reg_json_sync(rt, "op_mkdir_sync", op_mkdir_sync); - super::reg_json_async(rt, "op_mkdir_async", op_mkdir_async); + super::reg_sync(rt, "op_mkdir_sync", op_mkdir_sync); + super::reg_async(rt, "op_mkdir_async", op_mkdir_async); - super::reg_json_sync(rt, "op_chmod_sync", op_chmod_sync); - super::reg_json_async(rt, "op_chmod_async", op_chmod_async); + super::reg_sync(rt, "op_chmod_sync", op_chmod_sync); + super::reg_async(rt, "op_chmod_async", op_chmod_async); - super::reg_json_sync(rt, "op_chown_sync", op_chown_sync); - super::reg_json_async(rt, "op_chown_async", op_chown_async); + super::reg_sync(rt, "op_chown_sync", op_chown_sync); + super::reg_async(rt, "op_chown_async", op_chown_async); - super::reg_json_sync(rt, "op_remove_sync", op_remove_sync); - super::reg_json_async(rt, "op_remove_async", op_remove_async); + super::reg_sync(rt, "op_remove_sync", op_remove_sync); + super::reg_async(rt, "op_remove_async", op_remove_async); - super::reg_json_sync(rt, "op_copy_file_sync", op_copy_file_sync); - super::reg_json_async(rt, "op_copy_file_async", op_copy_file_async); + super::reg_sync(rt, "op_copy_file_sync", op_copy_file_sync); + super::reg_async(rt, "op_copy_file_async", op_copy_file_async); - super::reg_json_sync(rt, "op_stat_sync", op_stat_sync); - super::reg_json_async(rt, "op_stat_async", op_stat_async); + super::reg_sync(rt, "op_stat_sync", op_stat_sync); + super::reg_async(rt, "op_stat_async", op_stat_async); - super::reg_json_sync(rt, "op_realpath_sync", op_realpath_sync); - super::reg_json_async(rt, "op_realpath_async", op_realpath_async); + super::reg_sync(rt, "op_realpath_sync", op_realpath_sync); + super::reg_async(rt, "op_realpath_async", op_realpath_async); - super::reg_json_sync(rt, "op_read_dir_sync", op_read_dir_sync); - super::reg_json_async(rt, "op_read_dir_async", op_read_dir_async); + super::reg_sync(rt, "op_read_dir_sync", op_read_dir_sync); + super::reg_async(rt, "op_read_dir_async", op_read_dir_async); - super::reg_json_sync(rt, "op_rename_sync", op_rename_sync); - super::reg_json_async(rt, "op_rename_async", op_rename_async); + super::reg_sync(rt, "op_rename_sync", op_rename_sync); + super::reg_async(rt, "op_rename_async", op_rename_async); - super::reg_json_sync(rt, "op_link_sync", op_link_sync); - super::reg_json_async(rt, "op_link_async", op_link_async); + super::reg_sync(rt, "op_link_sync", op_link_sync); + super::reg_async(rt, "op_link_async", op_link_async); - super::reg_json_sync(rt, "op_symlink_sync", op_symlink_sync); - super::reg_json_async(rt, "op_symlink_async", op_symlink_async); + super::reg_sync(rt, "op_symlink_sync", op_symlink_sync); + super::reg_async(rt, "op_symlink_async", op_symlink_async); - super::reg_json_sync(rt, "op_read_link_sync", op_read_link_sync); - super::reg_json_async(rt, "op_read_link_async", op_read_link_async); + super::reg_sync(rt, "op_read_link_sync", op_read_link_sync); + super::reg_async(rt, "op_read_link_async", op_read_link_async); - super::reg_json_sync(rt, "op_ftruncate_sync", op_ftruncate_sync); - super::reg_json_async(rt, "op_ftruncate_async", op_ftruncate_async); + super::reg_sync(rt, "op_ftruncate_sync", op_ftruncate_sync); + super::reg_async(rt, "op_ftruncate_async", op_ftruncate_async); - super::reg_json_sync(rt, "op_truncate_sync", op_truncate_sync); - super::reg_json_async(rt, "op_truncate_async", op_truncate_async); + super::reg_sync(rt, "op_truncate_sync", op_truncate_sync); + super::reg_async(rt, "op_truncate_async", op_truncate_async); - super::reg_json_sync(rt, "op_make_temp_dir_sync", op_make_temp_dir_sync); - super::reg_json_async(rt, "op_make_temp_dir_async", op_make_temp_dir_async); + super::reg_sync(rt, "op_make_temp_dir_sync", op_make_temp_dir_sync); + super::reg_async(rt, "op_make_temp_dir_async", op_make_temp_dir_async); - super::reg_json_sync(rt, "op_make_temp_file_sync", op_make_temp_file_sync); - super::reg_json_async(rt, "op_make_temp_file_async", op_make_temp_file_async); + super::reg_sync(rt, "op_make_temp_file_sync", op_make_temp_file_sync); + super::reg_async(rt, "op_make_temp_file_async", op_make_temp_file_async); - super::reg_json_sync(rt, "op_cwd", op_cwd); + super::reg_sync(rt, "op_cwd", op_cwd); - super::reg_json_sync(rt, "op_futime_sync", op_futime_sync); - super::reg_json_async(rt, "op_futime_async", op_futime_async); + super::reg_sync(rt, "op_futime_sync", op_futime_sync); + super::reg_async(rt, "op_futime_async", op_futime_async); - super::reg_json_sync(rt, "op_utime_sync", op_utime_sync); - super::reg_json_async(rt, "op_utime_async", op_utime_async); + super::reg_sync(rt, "op_utime_sync", op_utime_sync); + super::reg_async(rt, "op_utime_async", op_utime_async); } #[derive(Deserialize)] diff --git a/runtime/ops/fs_events.rs b/runtime/ops/fs_events.rs index 30ab69ba5..8bc9c4c57 100644 --- a/runtime/ops/fs_events.rs +++ b/runtime/ops/fs_events.rs @@ -28,8 +28,8 @@ use std::rc::Rc; use tokio::sync::mpsc; pub fn init(rt: &mut deno_core::JsRuntime) { - super::reg_json_sync(rt, "op_fs_events_open", op_fs_events_open); - super::reg_json_async(rt, "op_fs_events_poll", op_fs_events_poll); + super::reg_sync(rt, "op_fs_events_open", op_fs_events_open); + super::reg_async(rt, "op_fs_events_poll", op_fs_events_poll); } struct FsEventsResource { diff --git a/runtime/ops/http.rs b/runtime/ops/http.rs index 9cf4ff9d5..f209662c4 100644 --- a/runtime/ops/http.rs +++ b/runtime/ops/http.rs @@ -43,14 +43,14 @@ use tokio_rustls::server::TlsStream; use tokio_util::io::StreamReader; pub fn init(rt: &mut deno_core::JsRuntime) { - super::reg_json_sync(rt, "op_http_start", op_http_start); + super::reg_sync(rt, "op_http_start", op_http_start); - super::reg_json_async(rt, "op_http_request_next", op_http_request_next); - super::reg_json_async(rt, "op_http_request_read", op_http_request_read); + super::reg_async(rt, "op_http_request_next", op_http_request_next); + super::reg_async(rt, "op_http_request_read", op_http_request_read); - super::reg_json_sync(rt, "op_http_response", op_http_response); - super::reg_json_async(rt, "op_http_response_write", op_http_response_write); - super::reg_json_async(rt, "op_http_response_close", op_http_response_close); + super::reg_sync(rt, "op_http_response", op_http_response); + super::reg_async(rt, "op_http_response_write", op_http_response_write); + super::reg_async(rt, "op_http_response_close", op_http_response_close); } struct ServiceInner { diff --git a/runtime/ops/io.rs b/runtime/ops/io.rs index f8ab92704..0e4e3f42a 100644 --- a/runtime/ops/io.rs +++ b/runtime/ops/io.rs @@ -96,13 +96,13 @@ lazy_static::lazy_static! { } pub fn init(rt: &mut JsRuntime) { - super::reg_bin_async(rt, "op_read_async", op_read_async); - super::reg_bin_async(rt, "op_write_async", op_write_async); + super::reg_async(rt, "op_read_async", op_read_async); + super::reg_async(rt, "op_write_async", op_write_async); - super::reg_bin_sync(rt, "op_read_sync", op_read_sync); - super::reg_bin_sync(rt, "op_write_sync", op_write_sync); + super::reg_sync(rt, "op_read_sync", op_read_sync); + super::reg_sync(rt, "op_write_sync", op_write_sync); - super::reg_json_async(rt, "op_shutdown", op_shutdown); + super::reg_async(rt, "op_shutdown", op_shutdown); } pub fn get_stdio() -> ( diff --git a/runtime/ops/mod.rs b/runtime/ops/mod.rs index d9bd2ba83..825950d65 100644 --- a/runtime/ops/mod.rs +++ b/runtime/ops/mod.rs @@ -27,59 +27,35 @@ pub mod websocket; pub mod worker_host; use crate::metrics::metrics_op; -use deno_core::bin_op_async; -use deno_core::bin_op_sync; use deno_core::error::AnyError; -use deno_core::json_op_async; -use deno_core::json_op_sync; +use deno_core::op_async; +use deno_core::op_sync; use deno_core::serde::de::DeserializeOwned; use deno_core::serde::Serialize; use deno_core::JsRuntime; use deno_core::OpState; -use deno_core::ValueOrVector; use deno_core::ZeroCopyBuf; use std::cell::RefCell; use std::future::Future; use std::rc::Rc; -pub fn reg_json_async<F, V, R, RV>( - rt: &mut JsRuntime, - name: &'static str, - op_fn: F, -) where +pub fn reg_async<F, V, R, RV>(rt: &mut JsRuntime, name: &'static str, op_fn: F) +where F: Fn(Rc<RefCell<OpState>>, V, Option<ZeroCopyBuf>) -> R + 'static, V: DeserializeOwned, R: Future<Output = Result<RV, AnyError>> + 'static, RV: Serialize + 'static, { - rt.register_op(name, metrics_op(name, json_op_async(op_fn))); + rt.register_op(name, metrics_op(name, op_async(op_fn))); } -pub fn reg_json_sync<F, V, R>(rt: &mut JsRuntime, name: &'static str, op_fn: F) +pub fn reg_sync<F, V, R>(rt: &mut JsRuntime, name: &'static str, op_fn: F) where F: Fn(&mut OpState, V, Option<ZeroCopyBuf>) -> Result<R, AnyError> + 'static, V: DeserializeOwned, R: Serialize + 'static, { - rt.register_op(name, metrics_op(name, json_op_sync(op_fn))); -} - -pub fn reg_bin_async<F, R, RV>(rt: &mut JsRuntime, name: &'static str, op_fn: F) -where - F: Fn(Rc<RefCell<OpState>>, u32, Option<ZeroCopyBuf>) -> R + 'static, - R: Future<Output = Result<RV, AnyError>> + 'static, - RV: ValueOrVector, -{ - rt.register_op(name, metrics_op(name, bin_op_async(op_fn))); -} - -pub fn reg_bin_sync<F, R>(rt: &mut JsRuntime, name: &'static str, op_fn: F) -where - F: - Fn(&mut OpState, u32, Option<ZeroCopyBuf>) -> Result<R, AnyError> + 'static, - R: ValueOrVector, -{ - rt.register_op(name, metrics_op(name, bin_op_sync(op_fn))); + rt.register_op(name, metrics_op(name, op_sync(op_fn))); } /// `UnstableChecker` is a struct so it can be placed inside `GothamState`; diff --git a/runtime/ops/net.rs b/runtime/ops/net.rs index 934ff7926..ee762ed47 100644 --- a/runtime/ops/net.rs +++ b/runtime/ops/net.rs @@ -43,12 +43,12 @@ use crate::ops::io::UnixStreamResource; use std::path::Path; pub fn init(rt: &mut deno_core::JsRuntime) { - super::reg_json_async(rt, "op_accept", op_accept); - super::reg_json_async(rt, "op_connect", op_connect); - super::reg_json_sync(rt, "op_listen", op_listen); - super::reg_json_async(rt, "op_datagram_receive", op_datagram_receive); - super::reg_json_async(rt, "op_datagram_send", op_datagram_send); - super::reg_json_async(rt, "op_dns_resolve", op_dns_resolve); + super::reg_async(rt, "op_accept", op_accept); + super::reg_async(rt, "op_connect", op_connect); + super::reg_sync(rt, "op_listen", op_listen); + super::reg_async(rt, "op_datagram_receive", op_datagram_receive); + super::reg_async(rt, "op_datagram_send", op_datagram_send); + super::reg_async(rt, "op_dns_resolve", op_dns_resolve); } #[derive(Serialize)] diff --git a/runtime/ops/os.rs b/runtime/ops/os.rs index b13b54d22..b9511fcdc 100644 --- a/runtime/ops/os.rs +++ b/runtime/ops/os.rs @@ -12,17 +12,17 @@ use std::collections::HashMap; use std::env; pub fn init(rt: &mut deno_core::JsRuntime) { - super::reg_json_sync(rt, "op_exit", op_exit); - super::reg_json_sync(rt, "op_env", op_env); - super::reg_json_sync(rt, "op_exec_path", op_exec_path); - super::reg_json_sync(rt, "op_set_env", op_set_env); - super::reg_json_sync(rt, "op_get_env", op_get_env); - super::reg_json_sync(rt, "op_delete_env", op_delete_env); - super::reg_json_sync(rt, "op_hostname", op_hostname); - super::reg_json_sync(rt, "op_loadavg", op_loadavg); - super::reg_json_sync(rt, "op_os_release", op_os_release); - super::reg_json_sync(rt, "op_system_memory_info", op_system_memory_info); - super::reg_json_sync(rt, "op_system_cpu_info", op_system_cpu_info); + super::reg_sync(rt, "op_exit", op_exit); + super::reg_sync(rt, "op_env", op_env); + super::reg_sync(rt, "op_exec_path", op_exec_path); + super::reg_sync(rt, "op_set_env", op_set_env); + super::reg_sync(rt, "op_get_env", op_get_env); + super::reg_sync(rt, "op_delete_env", op_delete_env); + super::reg_sync(rt, "op_hostname", op_hostname); + super::reg_sync(rt, "op_loadavg", op_loadavg); + super::reg_sync(rt, "op_os_release", op_os_release); + super::reg_sync(rt, "op_system_memory_info", op_system_memory_info); + super::reg_sync(rt, "op_system_cpu_info", op_system_cpu_info); } fn op_exec_path( diff --git a/runtime/ops/permissions.rs b/runtime/ops/permissions.rs index 77d095d84..ce89def54 100644 --- a/runtime/ops/permissions.rs +++ b/runtime/ops/permissions.rs @@ -11,9 +11,9 @@ use serde::Deserialize; use std::path::Path; pub fn init(rt: &mut deno_core::JsRuntime) { - super::reg_json_sync(rt, "op_query_permission", op_query_permission); - super::reg_json_sync(rt, "op_revoke_permission", op_revoke_permission); - super::reg_json_sync(rt, "op_request_permission", op_request_permission); + super::reg_sync(rt, "op_query_permission", op_query_permission); + super::reg_sync(rt, "op_revoke_permission", op_revoke_permission); + super::reg_sync(rt, "op_request_permission", op_request_permission); } #[derive(Deserialize)] diff --git a/runtime/ops/plugin.rs b/runtime/ops/plugin.rs index d0fc989f4..c265c757f 100644 --- a/runtime/ops/plugin.rs +++ b/runtime/ops/plugin.rs @@ -23,7 +23,7 @@ use std::task::Context; use std::task::Poll; pub fn init(rt: &mut JsRuntime) { - super::reg_json_sync(rt, "op_open_plugin", op_open_plugin); + super::reg_sync(rt, "op_open_plugin", op_open_plugin); } pub fn op_open_plugin( diff --git a/runtime/ops/process.rs b/runtime/ops/process.rs index 4b49e21f3..bf074db2c 100644 --- a/runtime/ops/process.rs +++ b/runtime/ops/process.rs @@ -26,9 +26,9 @@ use tokio::process::Command; use std::os::unix::process::ExitStatusExt; pub fn init(rt: &mut deno_core::JsRuntime) { - super::reg_json_sync(rt, "op_run", op_run); - super::reg_json_async(rt, "op_run_status", op_run_status); - super::reg_json_sync(rt, "op_kill", op_kill); + super::reg_sync(rt, "op_run", op_run); + super::reg_async(rt, "op_run_status", op_run_status); + super::reg_sync(rt, "op_kill", op_kill); } fn clone_file( diff --git a/runtime/ops/runtime.rs b/runtime/ops/runtime.rs index d694cb9c9..d90e92593 100644 --- a/runtime/ops/runtime.rs +++ b/runtime/ops/runtime.rs @@ -17,8 +17,8 @@ pub fn init(rt: &mut deno_core::JsRuntime, main_module: ModuleSpecifier) { let mut state = op_state.borrow_mut(); state.put::<ModuleSpecifier>(main_module); } - super::reg_json_sync(rt, "op_main_module", op_main_module); - super::reg_json_sync(rt, "op_metrics", op_metrics); + super::reg_sync(rt, "op_main_module", op_main_module); + super::reg_sync(rt, "op_metrics", op_metrics); } fn op_main_module( diff --git a/runtime/ops/signal.rs b/runtime/ops/signal.rs index 5235da612..2a19e4e98 100644 --- a/runtime/ops/signal.rs +++ b/runtime/ops/signal.rs @@ -25,9 +25,9 @@ use std::borrow::Cow; use tokio::signal::unix::{signal, Signal, SignalKind}; pub fn init(rt: &mut deno_core::JsRuntime) { - super::reg_json_sync(rt, "op_signal_bind", op_signal_bind); - super::reg_json_sync(rt, "op_signal_unbind", op_signal_unbind); - super::reg_json_async(rt, "op_signal_poll", op_signal_poll); + super::reg_sync(rt, "op_signal_bind", op_signal_bind); + super::reg_sync(rt, "op_signal_unbind", op_signal_unbind); + super::reg_async(rt, "op_signal_poll", op_signal_poll); } #[cfg(unix)] diff --git a/runtime/ops/timers.rs b/runtime/ops/timers.rs index aee38cf8d..8e709440e 100644 --- a/runtime/ops/timers.rs +++ b/runtime/ops/timers.rs @@ -69,11 +69,11 @@ pub fn init(rt: &mut deno_core::JsRuntime) { state.put::<GlobalTimer>(GlobalTimer::default()); state.put::<StartTime>(StartTime::now()); } - super::reg_json_sync(rt, "op_global_timer_stop", op_global_timer_stop); - super::reg_json_sync(rt, "op_global_timer_start", op_global_timer_start); - super::reg_json_async(rt, "op_global_timer", op_global_timer); - super::reg_json_sync(rt, "op_now", op_now); - super::reg_json_sync(rt, "op_sleep_sync", op_sleep_sync); + super::reg_sync(rt, "op_global_timer_stop", op_global_timer_stop); + super::reg_sync(rt, "op_global_timer_start", op_global_timer_start); + super::reg_async(rt, "op_global_timer", op_global_timer); + super::reg_sync(rt, "op_now", op_now); + super::reg_sync(rt, "op_sleep_sync", op_sleep_sync); } #[allow(clippy::unnecessary_wraps)] diff --git a/runtime/ops/tls.rs b/runtime/ops/tls.rs index 36762d66c..10293cf92 100644 --- a/runtime/ops/tls.rs +++ b/runtime/ops/tls.rs @@ -71,10 +71,10 @@ impl StoresClientSessions for ClientSessionMemoryCache { } pub fn init(rt: &mut deno_core::JsRuntime) { - super::reg_json_async(rt, "op_start_tls", op_start_tls); - super::reg_json_async(rt, "op_connect_tls", op_connect_tls); - super::reg_json_sync(rt, "op_listen_tls", op_listen_tls); - super::reg_json_async(rt, "op_accept_tls", op_accept_tls); + super::reg_async(rt, "op_start_tls", op_start_tls); + super::reg_async(rt, "op_connect_tls", op_connect_tls); + super::reg_sync(rt, "op_listen_tls", op_listen_tls); + super::reg_async(rt, "op_accept_tls", op_accept_tls); } #[derive(Deserialize)] diff --git a/runtime/ops/tty.rs b/runtime/ops/tty.rs index 9af72b5cd..a62a9ba02 100644 --- a/runtime/ops/tty.rs +++ b/runtime/ops/tty.rs @@ -44,9 +44,9 @@ fn get_windows_handle( } pub fn init(rt: &mut deno_core::JsRuntime) { - super::reg_json_sync(rt, "op_set_raw", op_set_raw); - super::reg_json_sync(rt, "op_isatty", op_isatty); - super::reg_json_sync(rt, "op_console_size", op_console_size); + super::reg_sync(rt, "op_set_raw", op_set_raw); + super::reg_sync(rt, "op_isatty", op_isatty); + super::reg_sync(rt, "op_console_size", op_console_size); } #[derive(Deserialize)] diff --git a/runtime/ops/url.rs b/runtime/ops/url.rs index 4add9132d..5168a7242 100644 --- a/runtime/ops/url.rs +++ b/runtime/ops/url.rs @@ -4,13 +4,9 @@ use deno_url::op_url_parse_search_params; use deno_url::op_url_stringify_search_params; pub fn init(rt: &mut deno_core::JsRuntime) { - super::reg_json_sync(rt, "op_url_parse", op_url_parse); - super::reg_json_sync( - rt, - "op_url_parse_search_params", - op_url_parse_search_params, - ); - super::reg_json_sync( + super::reg_sync(rt, "op_url_parse", op_url_parse); + super::reg_sync(rt, "op_url_parse_search_params", op_url_parse_search_params); + super::reg_sync( rt, "op_url_stringify_search_params", op_url_stringify_search_params, diff --git a/runtime/ops/web_worker.rs b/runtime/ops/web_worker.rs index 5f63a03b7..68cef110c 100644 --- a/runtime/ops/web_worker.rs +++ b/runtime/ops/web_worker.rs @@ -12,7 +12,7 @@ pub fn init( ) { // Post message to host as guest worker. let sender_ = sender.clone(); - super::reg_json_sync( + super::reg_sync( rt, "op_worker_post_message", move |_state, _args: (), buf| { @@ -27,15 +27,11 @@ pub fn init( ); // Notify host that guest worker closes. - super::reg_json_sync( - rt, - "op_worker_close", - move |_state, _args: (), _bufs| { - // Notify parent that we're finished - sender.clone().close_channel(); - // Terminate execution of current worker - handle.terminate(); - Ok(()) - }, - ); + super::reg_sync(rt, "op_worker_close", move |_state, _args: (), _bufs| { + // Notify parent that we're finished + sender.clone().close_channel(); + // Terminate execution of current worker + handle.terminate(); + Ok(()) + }); } diff --git a/runtime/ops/webgpu.rs b/runtime/ops/webgpu.rs index d48913ce8..55c6d1817 100644 --- a/runtime/ops/webgpu.rs +++ b/runtime/ops/webgpu.rs @@ -10,40 +10,28 @@ pub fn init(rt: &mut deno_core::JsRuntime) { state.put(Unstable(unstable)); } - super::reg_json_async( - rt, - "op_webgpu_request_adapter", - op_webgpu_request_adapter, - ); - super::reg_json_async( - rt, - "op_webgpu_request_device", - op_webgpu_request_device, - ); - super::reg_json_sync( - rt, - "op_webgpu_create_query_set", - op_webgpu_create_query_set, - ); + super::reg_async(rt, "op_webgpu_request_adapter", op_webgpu_request_adapter); + super::reg_async(rt, "op_webgpu_request_device", op_webgpu_request_device); + super::reg_sync(rt, "op_webgpu_create_query_set", op_webgpu_create_query_set); { // buffer - super::reg_json_sync( + super::reg_sync( rt, "op_webgpu_create_buffer", buffer::op_webgpu_create_buffer, ); - super::reg_json_async( + super::reg_async( rt, "op_webgpu_buffer_get_map_async", buffer::op_webgpu_buffer_get_map_async, ); - super::reg_json_sync( + super::reg_sync( rt, "op_webgpu_buffer_get_mapped_range", buffer::op_webgpu_buffer_get_mapped_range, ); - super::reg_json_sync( + super::reg_sync( rt, "op_webgpu_buffer_unmap", buffer::op_webgpu_buffer_unmap, @@ -51,12 +39,12 @@ pub fn init(rt: &mut deno_core::JsRuntime) { } { // texture - super::reg_json_sync( + super::reg_sync( rt, "op_webgpu_create_texture", texture::op_webgpu_create_texture, ); - super::reg_json_sync( + super::reg_sync( rt, "op_webgpu_create_texture_view", texture::op_webgpu_create_texture_view, @@ -64,7 +52,7 @@ pub fn init(rt: &mut deno_core::JsRuntime) { } { // sampler - super::reg_json_sync( + super::reg_sync( rt, "op_webgpu_create_sampler", sampler::op_webgpu_create_sampler, @@ -72,17 +60,17 @@ pub fn init(rt: &mut deno_core::JsRuntime) { } { // binding - super::reg_json_sync( + super::reg_sync( rt, "op_webgpu_create_bind_group_layout", binding::op_webgpu_create_bind_group_layout, ); - super::reg_json_sync( + super::reg_sync( rt, "op_webgpu_create_pipeline_layout", binding::op_webgpu_create_pipeline_layout, ); - super::reg_json_sync( + super::reg_sync( rt, "op_webgpu_create_bind_group", binding::op_webgpu_create_bind_group, @@ -90,22 +78,22 @@ pub fn init(rt: &mut deno_core::JsRuntime) { } { // pipeline - super::reg_json_sync( + super::reg_sync( rt, "op_webgpu_create_compute_pipeline", pipeline::op_webgpu_create_compute_pipeline, ); - super::reg_json_sync( + super::reg_sync( rt, "op_webgpu_compute_pipeline_get_bind_group_layout", pipeline::op_webgpu_compute_pipeline_get_bind_group_layout, ); - super::reg_json_sync( + super::reg_sync( rt, "op_webgpu_create_render_pipeline", pipeline::op_webgpu_create_render_pipeline, ); - super::reg_json_sync( + super::reg_sync( rt, "op_webgpu_render_pipeline_get_bind_group_layout", pipeline::op_webgpu_render_pipeline_get_bind_group_layout, @@ -113,67 +101,67 @@ pub fn init(rt: &mut deno_core::JsRuntime) { } { // command_encoder - super::reg_json_sync( + super::reg_sync( rt, "op_webgpu_create_command_encoder", command_encoder::op_webgpu_create_command_encoder, ); - super::reg_json_sync( + super::reg_sync( rt, "op_webgpu_command_encoder_begin_render_pass", command_encoder::op_webgpu_command_encoder_begin_render_pass, ); - super::reg_json_sync( + super::reg_sync( rt, "op_webgpu_command_encoder_begin_compute_pass", command_encoder::op_webgpu_command_encoder_begin_compute_pass, ); - super::reg_json_sync( + super::reg_sync( rt, "op_webgpu_command_encoder_copy_buffer_to_buffer", command_encoder::op_webgpu_command_encoder_copy_buffer_to_buffer, ); - super::reg_json_sync( + super::reg_sync( rt, "op_webgpu_command_encoder_copy_buffer_to_texture", command_encoder::op_webgpu_command_encoder_copy_buffer_to_texture, ); - super::reg_json_sync( + super::reg_sync( rt, "op_webgpu_command_encoder_copy_texture_to_buffer", command_encoder::op_webgpu_command_encoder_copy_texture_to_buffer, ); - super::reg_json_sync( + super::reg_sync( rt, "op_webgpu_command_encoder_copy_texture_to_texture", command_encoder::op_webgpu_command_encoder_copy_texture_to_texture, ); - super::reg_json_sync( + super::reg_sync( rt, "op_webgpu_command_encoder_push_debug_group", command_encoder::op_webgpu_command_encoder_push_debug_group, ); - super::reg_json_sync( + super::reg_sync( rt, "op_webgpu_command_encoder_pop_debug_group", command_encoder::op_webgpu_command_encoder_pop_debug_group, ); - super::reg_json_sync( + super::reg_sync( rt, "op_webgpu_command_encoder_insert_debug_marker", command_encoder::op_webgpu_command_encoder_insert_debug_marker, ); - super::reg_json_sync( + super::reg_sync( rt, "op_webgpu_command_encoder_write_timestamp", command_encoder::op_webgpu_command_encoder_write_timestamp, ); - super::reg_json_sync( + super::reg_sync( rt, "op_webgpu_command_encoder_resolve_query_set", command_encoder::op_webgpu_command_encoder_resolve_query_set, ); - super::reg_json_sync( + super::reg_sync( rt, "op_webgpu_command_encoder_finish", command_encoder::op_webgpu_command_encoder_finish, @@ -181,102 +169,102 @@ pub fn init(rt: &mut deno_core::JsRuntime) { } { // render_pass - super::reg_json_sync( + super::reg_sync( rt, "op_webgpu_render_pass_set_viewport", render_pass::op_webgpu_render_pass_set_viewport, ); - super::reg_json_sync( + super::reg_sync( rt, "op_webgpu_render_pass_set_scissor_rect", render_pass::op_webgpu_render_pass_set_scissor_rect, ); - super::reg_json_sync( + super::reg_sync( rt, "op_webgpu_render_pass_set_blend_color", render_pass::op_webgpu_render_pass_set_blend_color, ); - super::reg_json_sync( + super::reg_sync( rt, "op_webgpu_render_pass_set_stencil_reference", render_pass::op_webgpu_render_pass_set_stencil_reference, ); - super::reg_json_sync( + super::reg_sync( rt, "op_webgpu_render_pass_begin_pipeline_statistics_query", render_pass::op_webgpu_render_pass_begin_pipeline_statistics_query, ); - super::reg_json_sync( + super::reg_sync( rt, "op_webgpu_render_pass_end_pipeline_statistics_query", render_pass::op_webgpu_render_pass_end_pipeline_statistics_query, ); - super::reg_json_sync( + super::reg_sync( rt, "op_webgpu_render_pass_write_timestamp", render_pass::op_webgpu_render_pass_write_timestamp, ); - super::reg_json_sync( + super::reg_sync( rt, "op_webgpu_render_pass_execute_bundles", render_pass::op_webgpu_render_pass_execute_bundles, ); - super::reg_json_sync( + super::reg_sync( rt, "op_webgpu_render_pass_end_pass", render_pass::op_webgpu_render_pass_end_pass, ); - super::reg_json_sync( + super::reg_sync( rt, "op_webgpu_render_pass_set_bind_group", render_pass::op_webgpu_render_pass_set_bind_group, ); - super::reg_json_sync( + super::reg_sync( rt, "op_webgpu_render_pass_push_debug_group", render_pass::op_webgpu_render_pass_push_debug_group, ); - super::reg_json_sync( + super::reg_sync( rt, "op_webgpu_render_pass_pop_debug_group", render_pass::op_webgpu_render_pass_pop_debug_group, ); - super::reg_json_sync( + super::reg_sync( rt, "op_webgpu_render_pass_insert_debug_marker", render_pass::op_webgpu_render_pass_insert_debug_marker, ); - super::reg_json_sync( + super::reg_sync( rt, "op_webgpu_render_pass_set_pipeline", render_pass::op_webgpu_render_pass_set_pipeline, ); - super::reg_json_sync( + super::reg_sync( rt, "op_webgpu_render_pass_set_index_buffer", render_pass::op_webgpu_render_pass_set_index_buffer, ); - super::reg_json_sync( + super::reg_sync( rt, "op_webgpu_render_pass_set_vertex_buffer", render_pass::op_webgpu_render_pass_set_vertex_buffer, ); - super::reg_json_sync( + super::reg_sync( rt, "op_webgpu_render_pass_draw", render_pass::op_webgpu_render_pass_draw, ); - super::reg_json_sync( + super::reg_sync( rt, "op_webgpu_render_pass_draw_indexed", render_pass::op_webgpu_render_pass_draw_indexed, ); - super::reg_json_sync( + super::reg_sync( rt, "op_webgpu_render_pass_draw_indirect", render_pass::op_webgpu_render_pass_draw_indirect, ); - super::reg_json_sync( + super::reg_sync( rt, "op_webgpu_render_pass_draw_indexed_indirect", render_pass::op_webgpu_render_pass_draw_indexed_indirect, @@ -284,42 +272,42 @@ pub fn init(rt: &mut deno_core::JsRuntime) { } { // compute_pass - super::reg_json_sync( + super::reg_sync( rt, "op_webgpu_compute_pass_set_pipeline", compute_pass::op_webgpu_compute_pass_set_pipeline, ); - super::reg_json_sync( + super::reg_sync( rt, "op_webgpu_compute_pass_dispatch", compute_pass::op_webgpu_compute_pass_dispatch, ); - super::reg_json_sync( + super::reg_sync( rt, "op_webgpu_compute_pass_dispatch_indirect", compute_pass::op_webgpu_compute_pass_dispatch_indirect, ); - super::reg_json_sync( + super::reg_sync( rt, "op_webgpu_compute_pass_end_pass", compute_pass::op_webgpu_compute_pass_end_pass, ); - super::reg_json_sync( + super::reg_sync( rt, "op_webgpu_compute_pass_set_bind_group", compute_pass::op_webgpu_compute_pass_set_bind_group, ); - super::reg_json_sync( + super::reg_sync( rt, "op_webgpu_compute_pass_push_debug_group", compute_pass::op_webgpu_compute_pass_push_debug_group, ); - super::reg_json_sync( + super::reg_sync( rt, "op_webgpu_compute_pass_pop_debug_group", compute_pass::op_webgpu_compute_pass_pop_debug_group, ); - super::reg_json_sync( + super::reg_sync( rt, "op_webgpu_compute_pass_insert_debug_marker", compute_pass::op_webgpu_compute_pass_insert_debug_marker, @@ -327,62 +315,62 @@ pub fn init(rt: &mut deno_core::JsRuntime) { } { // bundle - super::reg_json_sync( + super::reg_sync( rt, "op_webgpu_create_render_bundle_encoder", bundle::op_webgpu_create_render_bundle_encoder, ); - super::reg_json_sync( + super::reg_sync( rt, "op_webgpu_render_bundle_encoder_finish", bundle::op_webgpu_render_bundle_encoder_finish, ); - super::reg_json_sync( + super::reg_sync( rt, "op_webgpu_render_bundle_encoder_set_bind_group", bundle::op_webgpu_render_bundle_encoder_set_bind_group, ); - super::reg_json_sync( + super::reg_sync( rt, "op_webgpu_render_bundle_encoder_push_debug_group", bundle::op_webgpu_render_bundle_encoder_push_debug_group, ); - super::reg_json_sync( + super::reg_sync( rt, "op_webgpu_render_bundle_encoder_pop_debug_group", bundle::op_webgpu_render_bundle_encoder_pop_debug_group, ); - super::reg_json_sync( + super::reg_sync( rt, "op_webgpu_render_bundle_encoder_insert_debug_marker", bundle::op_webgpu_render_bundle_encoder_insert_debug_marker, ); - super::reg_json_sync( + super::reg_sync( rt, "op_webgpu_render_bundle_encoder_set_pipeline", bundle::op_webgpu_render_bundle_encoder_set_pipeline, ); - super::reg_json_sync( + super::reg_sync( rt, "op_webgpu_render_bundle_encoder_set_index_buffer", bundle::op_webgpu_render_bundle_encoder_set_index_buffer, ); - super::reg_json_sync( + super::reg_sync( rt, "op_webgpu_render_bundle_encoder_set_vertex_buffer", bundle::op_webgpu_render_bundle_encoder_set_vertex_buffer, ); - super::reg_json_sync( + super::reg_sync( rt, "op_webgpu_render_bundle_encoder_draw", bundle::op_webgpu_render_bundle_encoder_draw, ); - super::reg_json_sync( + super::reg_sync( rt, "op_webgpu_render_bundle_encoder_draw_indexed", bundle::op_webgpu_render_bundle_encoder_draw_indexed, ); - super::reg_json_sync( + super::reg_sync( rt, "op_webgpu_render_bundle_encoder_draw_indirect", bundle::op_webgpu_render_bundle_encoder_draw_indirect, @@ -390,17 +378,17 @@ pub fn init(rt: &mut deno_core::JsRuntime) { } { // queue - super::reg_json_sync( + super::reg_sync( rt, "op_webgpu_queue_submit", queue::op_webgpu_queue_submit, ); - super::reg_json_sync( + super::reg_sync( rt, "op_webgpu_write_buffer", queue::op_webgpu_write_buffer, ); - super::reg_json_sync( + super::reg_sync( rt, "op_webgpu_write_texture", queue::op_webgpu_write_texture, @@ -408,7 +396,7 @@ pub fn init(rt: &mut deno_core::JsRuntime) { } { // shader - super::reg_json_sync( + super::reg_sync( rt, "op_webgpu_create_shader_module", shader::op_webgpu_create_shader_module, diff --git a/runtime/ops/websocket.rs b/runtime/ops/websocket.rs index 1563961d7..1c44f8b80 100644 --- a/runtime/ops/websocket.rs +++ b/runtime/ops/websocket.rs @@ -21,13 +21,13 @@ pub fn init( state.put::<WsCaData>(WsCaData(ca_data)); } } - super::reg_json_sync( + super::reg_sync( rt, "op_ws_check_permission", op_ws_check_permission::<Permissions>, ); - super::reg_json_async(rt, "op_ws_create", op_ws_create::<Permissions>); - super::reg_json_async(rt, "op_ws_send", op_ws_send); - super::reg_json_async(rt, "op_ws_close", op_ws_close); - super::reg_json_async(rt, "op_ws_next_event", op_ws_next_event); + super::reg_async(rt, "op_ws_create", op_ws_create::<Permissions>); + super::reg_async(rt, "op_ws_send", op_ws_send); + super::reg_async(rt, "op_ws_close", op_ws_close); + super::reg_async(rt, "op_ws_next_event", op_ws_next_event); } diff --git a/runtime/ops/worker_host.rs b/runtime/ops/worker_host.rs index 2f297fb08..92de420e3 100644 --- a/runtime/ops/worker_host.rs +++ b/runtime/ops/worker_host.rs @@ -80,15 +80,11 @@ pub fn init( let create_module_loader = CreateWebWorkerCbHolder(create_web_worker_cb); state.put::<CreateWebWorkerCbHolder>(create_module_loader); } - super::reg_json_sync(rt, "op_create_worker", op_create_worker); - super::reg_json_sync( - rt, - "op_host_terminate_worker", - op_host_terminate_worker, - ); - super::reg_json_sync(rt, "op_host_post_message", op_host_post_message); - super::reg_json_async(rt, "op_host_get_message", op_host_get_message); - super::reg_json_sync( + super::reg_sync(rt, "op_create_worker", op_create_worker); + super::reg_sync(rt, "op_host_terminate_worker", op_host_terminate_worker); + super::reg_sync(rt, "op_host_post_message", op_host_post_message); + super::reg_async(rt, "op_host_get_message", op_host_get_message); + super::reg_sync( rt, "op_host_unhandled_error", move |_state, message: String, _zero_copy| { diff --git a/runtime/web_worker.rs b/runtime/web_worker.rs index c30b715e4..68bbe1a5d 100644 --- a/runtime/web_worker.rs +++ b/runtime/web_worker.rs @@ -231,8 +231,8 @@ impl WebWorker { Some(sender), options.create_web_worker_cb.clone(), ); - ops::reg_json_sync(js_runtime, "op_close", deno_core::op_close); - ops::reg_json_sync(js_runtime, "op_resources", deno_core::op_resources); + ops::reg_sync(js_runtime, "op_close", deno_core::op_close); + ops::reg_sync(js_runtime, "op_resources", deno_core::op_resources); ops::url::init(js_runtime); ops::file::init( js_runtime, diff --git a/runtime/worker.rs b/runtime/worker.rs index 5db542b42..253725533 100644 --- a/runtime/worker.rs +++ b/runtime/worker.rs @@ -128,8 +128,8 @@ impl MainWorker { options.create_web_worker_cb.clone(), ); ops::crypto::init(js_runtime, options.seed); - ops::reg_json_sync(js_runtime, "op_close", deno_core::op_close); - ops::reg_json_sync(js_runtime, "op_resources", deno_core::op_resources); + ops::reg_sync(js_runtime, "op_close", deno_core::op_close); + ops::reg_sync(js_runtime, "op_resources", deno_core::op_resources); ops::url::init(js_runtime); ops::file::init( js_runtime, |
