@@ -11,6 +11,7 @@ struct napi_env__ {
11
11
context_persistent(isolate, context) {
12
12
CHECK_EQ (isolate, context->GetIsolate ());
13
13
}
14
+ virtual ~napi_env__ () {}
14
15
v8::Isolate* const isolate; // Shortcut for context()->GetIsolate()
15
16
v8impl::Persistent<v8::Context> context_persistent;
16
17
@@ -21,6 +22,8 @@ struct napi_env__ {
21
22
inline void Ref () { refs++; }
22
23
inline void Unref () { if ( --refs == 0 ) delete this ; }
23
24
25
+ virtual bool can_call_into_js () const { return true ; }
26
+
24
27
v8impl::Persistent<v8::Value> last_exception;
25
28
napi_extended_error_info last_error;
26
29
int open_handle_scopes = 0 ;
@@ -68,11 +71,12 @@ napi_status napi_set_last_error(napi_env env, napi_status error_code,
68
71
RETURN_STATUS_IF_FALSE ((env), !((maybe).IsEmpty()), (status))
69
72
70
73
// 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)); \
76
80
v8impl::TryCatch try_catch ((env))
77
81
78
82
#define CHECK_TO_TYPE (env, type, context, result, src, status ) \
0 commit comments