@@ -11,6 +11,7 @@ struct napi_env__ {
1111 context_persistent(isolate, context) {
1212 CHECK_EQ (isolate, context->GetIsolate ());
1313 }
14+ virtual ~napi_env__ () {}
1415 v8::Isolate* const isolate; // Shortcut for context()->GetIsolate()
1516 v8impl::Persistent<v8::Context> context_persistent;
1617
@@ -21,6 +22,8 @@ struct napi_env__ {
2122 inline void Ref () { refs++; }
2223 inline void Unref () { if ( --refs == 0 ) delete this ; }
2324
25+ virtual bool can_call_into_js () const { return true ; }
26+
2427 v8impl::Persistent<v8::Value> last_exception;
2528 napi_extended_error_info last_error;
2629 int open_handle_scopes = 0 ;
@@ -68,11 +71,12 @@ napi_status napi_set_last_error(napi_env env, napi_status error_code,
6871 RETURN_STATUS_IF_FALSE ((env), !((maybe).IsEmpty()), (status))
6972
7073// NAPI_PREAMBLE is not wrapped in do..while: try_catch must have function scope
71- #define NAPI_PREAMBLE (env ) \
72- CHECK_ENV ((env)); \
73- RETURN_STATUS_IF_FALSE ((env), (env)->last_exception.IsEmpty(), \
74- napi_pending_exception); \
75- napi_clear_last_error ((env)); \
74+ #define NAPI_PREAMBLE (env ) \
75+ CHECK_ENV ((env)); \
76+ RETURN_STATUS_IF_FALSE ((env), \
77+ (env)->last_exception.IsEmpty() && (env)->can_call_into_js (), \
78+ napi_pending_exception); \
79+ napi_clear_last_error ((env)); \
7680 v8impl::TryCatch try_catch ((env))
7781
7882#define CHECK_TO_TYPE (env, type, context, result, src, status ) \
0 commit comments