diff options
author | Anna Henningsen <anna@addaleax.net> | 2019-02-17 20:05:55 +0300 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2019-02-20 18:54:39 +0300 |
commit | a34a84d281a53e87b6a62c40fc6491a1e0f3c96b (patch) | |
tree | b6d2318a436a953314a6076ebd6f311177cf0253 /src/inspector_js_api.cc | |
parent | 49a2e406329269af2bf55c0ad51560bdf1f14b7f (diff) |
src: simplify InspectorConsoleCall
Instead of a JS object, set the is-in-console-call flag as
a boolean in C++.
PR-URL: https://github.com/nodejs/node/pull/26168
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Eugene Ostroukhov <eostroukhov@google.com>
Diffstat (limited to 'src/inspector_js_api.cc')
-rw-r--r-- | src/inspector_js_api.cc | 25 |
1 files changed, 8 insertions, 17 deletions
diff --git a/src/inspector_js_api.cc b/src/inspector_js_api.cc index e94f42c18eb..c2e80d93fd9 100644 --- a/src/inspector_js_api.cc +++ b/src/inspector_js_api.cc @@ -149,31 +149,22 @@ void InspectorConsoleCall(const FunctionCallbackInfo<Value>& info) { Environment* env = Environment::GetCurrent(info); Isolate* isolate = env->isolate(); Local<Context> context = isolate->GetCurrentContext(); - CHECK_LT(2, info.Length()); - SlicedArguments call_args(info, /* start */ 3); + CHECK_GE(info.Length(), 2); + SlicedArguments call_args(info, /* start */ 2); if (InspectorEnabled(env)) { Local<Value> inspector_method = info[0]; CHECK(inspector_method->IsFunction()); - Local<Value> config_value = info[2]; - CHECK(config_value->IsObject()); - Local<Object> config_object = config_value.As<Object>(); - Local<String> in_call_key = FIXED_ONE_BYTE_STRING(isolate, "in_call"); - bool has_in_call; - if (!config_object->Has(context, in_call_key).To(&has_in_call)) - return; - if (!has_in_call) { - if (config_object->Set(context, - in_call_key, - v8::True(isolate)).IsNothing() || + if (!env->is_in_inspector_console_call()) { + env->set_is_in_inspector_console_call(true); + MaybeLocal<Value> ret = inspector_method.As<Function>()->Call(context, info.Holder(), call_args.length(), - call_args.out()).IsEmpty()) { + call_args.out()); + env->set_is_in_inspector_console_call(false); + if (ret.IsEmpty()) return; - } } - if (config_object->Delete(context, in_call_key).IsNothing()) - return; } Local<Value> node_method = info[1]; |