From 7a53fcefce63eb2c5ae771b914accb426af08d41 Mon Sep 17 00:00:00 2001 From: Jimmy Thomson Date: Mon, 12 Feb 2018 10:22:21 -0800 Subject: [PATCH] napi: adding napi_*_callback_scope implementations for chakracore --- src/node_api_jsrt.cc | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/node_api_jsrt.cc b/src/node_api_jsrt.cc index 3a9316fa654..202932761b4 100644 --- a/src/node_api_jsrt.cc +++ b/src/node_api_jsrt.cc @@ -2110,6 +2110,34 @@ napi_status napi_async_destroy(napi_env env, return napi_ok; } +napi_status napi_open_callback_scope(napi_env env, + napi_value resource_object, + napi_async_context async_context_handle, + napi_callback_scope* result) { + node::async_context* node_async_context = + reinterpret_cast(async_context_handle); + + // TODO: It'd be nice if we could remove the dependency on v8::* + // from here by changing node::CallbackScope's signature + v8::Local resource = + v8impl::V8LocalValueFromJsValue(resource_object).As(); + + *result = reinterpret_cast( + new node::InternalCallbackScope(node::Environment::GetCurrent(env->isolate), + resource, + *node_async_context)); + + napi_clear_last_error(); + return napi_ok; +} + +napi_status napi_close_callback_scope(napi_env env, napi_callback_scope scope) { + delete reinterpret_cast(scope); + + napi_clear_last_error(); + return napi_ok; +} + napi_status napi_make_callback(napi_env env, napi_async_context async_context, napi_value recv,