@@ -109,7 +109,6 @@ using v8::Array;
109109using v8::Boolean;
110110using v8::Context;
111111using v8::DEFAULT;
112- using v8::EscapableHandleScope;
113112using v8::Exception;
114113using v8::Function;
115114using v8::FunctionCallbackInfo;
@@ -560,138 +559,6 @@ void RemoveEnvironmentCleanupHook(Isolate* isolate,
560559 env->RemoveCleanupHook (fun, arg);
561560}
562561
563- MaybeLocal<Value> InternalMakeCallback (Environment* env,
564- Local<Object> recv,
565- const Local<Function> callback,
566- int argc,
567- Local<Value> argv[],
568- async_context asyncContext) {
569- CHECK (!recv.IsEmpty ());
570- InternalCallbackScope scope (env, recv, asyncContext);
571- if (scope.Failed ()) {
572- return MaybeLocal<Value>();
573- }
574-
575- Local<Function> domain_cb = env->domain_callback ();
576- MaybeLocal<Value> ret;
577- if (asyncContext.async_id != 0 || domain_cb.IsEmpty () || recv.IsEmpty ()) {
578- ret = callback->Call (env->context (), recv, argc, argv);
579- } else {
580- std::vector<Local<Value>> args (1 + argc);
581- args[0 ] = callback;
582- std::copy (&argv[0 ], &argv[argc], args.begin () + 1 );
583- ret = domain_cb->Call (env->context (), recv, args.size (), &args[0 ]);
584- }
585-
586- if (ret.IsEmpty ()) {
587- scope.MarkAsFailed ();
588- return MaybeLocal<Value>();
589- }
590-
591- scope.Close ();
592- if (scope.Failed ()) {
593- return MaybeLocal<Value>();
594- }
595-
596- return ret;
597- }
598-
599-
600- // Public MakeCallback()s
601-
602-
603- MaybeLocal<Value> MakeCallback (Isolate* isolate,
604- Local<Object> recv,
605- const char * method,
606- int argc,
607- Local<Value> argv[],
608- async_context asyncContext) {
609- Local<String> method_string =
610- String::NewFromUtf8 (isolate, method, NewStringType::kNormal )
611- .ToLocalChecked ();
612- return MakeCallback (isolate, recv, method_string, argc, argv, asyncContext);
613- }
614-
615-
616- MaybeLocal<Value> MakeCallback (Isolate* isolate,
617- Local<Object> recv,
618- Local<String> symbol,
619- int argc,
620- Local<Value> argv[],
621- async_context asyncContext) {
622- Local<Value> callback_v = recv->Get (isolate->GetCurrentContext (),
623- symbol).ToLocalChecked ();
624- if (callback_v.IsEmpty ()) return Local<Value>();
625- if (!callback_v->IsFunction ()) return Local<Value>();
626- Local<Function> callback = callback_v.As <Function>();
627- return MakeCallback (isolate, recv, callback, argc, argv, asyncContext);
628- }
629-
630-
631- MaybeLocal<Value> MakeCallback (Isolate* isolate,
632- Local<Object> recv,
633- Local<Function> callback,
634- int argc,
635- Local<Value> argv[],
636- async_context asyncContext) {
637- // Observe the following two subtleties:
638- //
639- // 1. The environment is retrieved from the callback function's context.
640- // 2. The context to enter is retrieved from the environment.
641- //
642- // Because of the AssignToContext() call in src/node_contextify.cc,
643- // the two contexts need not be the same.
644- Environment* env = Environment::GetCurrent (callback->CreationContext ());
645- CHECK_NOT_NULL (env);
646- Context::Scope context_scope (env->context ());
647- MaybeLocal<Value> ret = InternalMakeCallback (env, recv, callback,
648- argc, argv, asyncContext);
649- if (ret.IsEmpty () && env->makecallback_depth () == 0 ) {
650- // This is only for legacy compatiblity and we may want to look into
651- // removing/adjusting it.
652- return Undefined (env->isolate ());
653- }
654- return ret;
655- }
656-
657-
658- // Legacy MakeCallback()s
659-
660- Local<Value> MakeCallback (Isolate* isolate,
661- Local<Object> recv,
662- const char * method,
663- int argc,
664- Local<Value>* argv) {
665- EscapableHandleScope handle_scope (isolate);
666- return handle_scope.Escape (
667- MakeCallback (isolate, recv, method, argc, argv, {0 , 0 })
668- .FromMaybe (Local<Value>()));
669- }
670-
671-
672- Local<Value> MakeCallback (Isolate* isolate,
673- Local<Object> recv,
674- Local<String> symbol,
675- int argc,
676- Local<Value>* argv) {
677- EscapableHandleScope handle_scope (isolate);
678- return handle_scope.Escape (
679- MakeCallback (isolate, recv, symbol, argc, argv, {0 , 0 })
680- .FromMaybe (Local<Value>()));
681- }
682-
683-
684- Local<Value> MakeCallback (Isolate* isolate,
685- Local<Object> recv,
686- Local<Function> callback,
687- int argc,
688- Local<Value>* argv) {
689- EscapableHandleScope handle_scope (isolate);
690- return handle_scope.Escape (
691- MakeCallback (isolate, recv, callback, argc, argv, {0 , 0 })
692- .FromMaybe (Local<Value>()));
693- }
694-
695562static void WaitForInspectorDisconnect (Environment* env) {
696563#if HAVE_INSPECTOR
697564 if (env->inspector_agent ()->IsActive ()) {
0 commit comments