summaryrefslogtreecommitdiff
path: root/core/bindings.rs
diff options
context:
space:
mode:
authorAaron O'Mullan <aaron.omullan@gmail.com>2021-05-03 01:30:03 +0200
committerGitHub <noreply@github.com>2021-05-02 19:30:03 -0400
commitea917384feb1c800438d13dddac9ee977d2c47fe (patch)
treee3d5069ac4f96713c98519853cfe25e93c32f883 /core/bindings.rs
parentc9ac851b9005e5a1e90016e52b3a10dd1f1012b7 (diff)
refactor(core): convert core.print() to a builtin op (#10436)
Diffstat (limited to 'core/bindings.rs')
-rw-r--r--core/bindings.rs40
1 files changed, 0 insertions, 40 deletions
diff --git a/core/bindings.rs b/core/bindings.rs
index ea45daff4..8a32bc5da 100644
--- a/core/bindings.rs
+++ b/core/bindings.rs
@@ -13,7 +13,6 @@ use serde::Serialize;
use serde_v8::to_v8;
use std::convert::TryFrom;
use std::convert::TryInto;
-use std::io::{stdout, Write};
use std::option::Option;
use url::Url;
use v8::MapFnTo;
@@ -22,9 +21,6 @@ lazy_static::lazy_static! {
pub static ref EXTERNAL_REFERENCES: v8::ExternalReferences =
v8::ExternalReferences::new(&[
v8::ExternalReference {
- function: print.map_fn_to()
- },
- v8::ExternalReference {
function: opcall.map_fn_to()
},
v8::ExternalReference {
@@ -117,7 +113,6 @@ pub fn initialize_context<'s>(
deno_val.set(scope, core_key.into(), core_val.into());
// Bind functions to Deno.core.*
- set_func(scope, core_val, "print", print);
set_func(scope, core_val, "opcall", opcall);
set_func(
scope,
@@ -268,41 +263,6 @@ pub extern "C" fn promise_reject_callback(message: v8::PromiseRejectMessage) {
};
}
-fn print(
- scope: &mut v8::HandleScope,
- args: v8::FunctionCallbackArguments,
- _rv: v8::ReturnValue,
-) {
- let arg_len = args.length();
- if !(0..=2).contains(&arg_len) {
- return throw_type_error(scope, "Expected a maximum of 2 arguments.");
- }
-
- let obj = args.get(0);
- let is_err_arg = args.get(1);
-
- let mut is_err = false;
- if arg_len == 2 {
- let int_val = match is_err_arg.integer_value(scope) {
- Some(v) => v,
- None => return throw_type_error(scope, "Invalid argument. Argument 2 should indicate whether or not to print to stderr."),
- };
- is_err = int_val != 0;
- };
- let tc_scope = &mut v8::TryCatch::new(scope);
- let str_ = match obj.to_string(tc_scope) {
- Some(s) => s,
- None => v8::String::new(tc_scope, "").unwrap(),
- };
- if is_err {
- eprint!("{}", str_.to_rust_string_lossy(tc_scope));
- stdout().flush().unwrap();
- } else {
- print!("{}", str_.to_rust_string_lossy(tc_scope));
- stdout().flush().unwrap();
- }
-}
-
fn opcall<'s>(
scope: &mut v8::HandleScope<'s>,
args: v8::FunctionCallbackArguments,