Skip to content

Commit 4b6f839

Browse files
committed
Fix nan_weak.h for V8 >= 14.2.194 (missing EmbedderDataTypeTag)
Commit fcc7b7d added V8 >= 14.2.194 compatibility guards to nan.h for GetAlignedPointerFromInternalField and SetAlignedPointerInInternalField which now require an additional v8::kEmbedderDataTypeTagDefault tag parameter. However, the same unguarded calls in nan_weak.h were missed, causing build failures with Electron 41+ / V8 >= 14.2.194. Apply the exact same preprocessor guard pattern to all occurrences in nan_weak.h.
1 parent 56bbc48 commit 4b6f839

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

nan_weak.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,15 +276,31 @@ inline void Persistent<T, M>::SetWeak(
276276
int count = self->InternalFieldCount();
277277
void *internal_fields[kInternalFieldsInWeakCallback] = {0, 0};
278278
for (int i = 0; i < count && i < kInternalFieldsInWeakCallback; i++) {
279+
#if (V8_MAJOR_VERSION > 14) || \
280+
(V8_MAJOR_VERSION == 14 && V8_MINOR_VERSION > 2) || \
281+
(V8_MAJOR_VERSION == 14 && V8_MINOR_VERSION == 2 && V8_BUILD_NUMBER >= 194)
282+
internal_fields[i] = self->GetAlignedPointerFromInternalField(
283+
i, v8::kEmbedderDataTypeTagDefault
284+
);
285+
# else
279286
internal_fields[i] = self->GetAlignedPointerFromInternalField(i);
287+
# endif
280288
}
281289
wcbd = new WeakCallbackInfo<P>(
282290
reinterpret_cast<Persistent<v8::Value>*>(this)
283291
, callback
284292
, 0
285293
, internal_fields[0]
286294
, internal_fields[1]);
295+
#if (V8_MAJOR_VERSION > 14) || \
296+
(V8_MAJOR_VERSION == 14 && V8_MINOR_VERSION > 2) || \
297+
(V8_MAJOR_VERSION == 14 && V8_MINOR_VERSION == 2 && V8_BUILD_NUMBER >= 194)
298+
self->SetAlignedPointerInInternalField(
299+
0, wcbd, v8::kEmbedderDataTypeTagDefault
300+
);
301+
# else
287302
self->SetAlignedPointerInInternalField(0, wcbd);
303+
# endif
288304
v8::PersistentBase<T>::SetWeak(
289305
static_cast<WeakCallbackInfo<P>*>(0)
290306
, WeakCallbackInfo<P>::template invoketwofield<true>

0 commit comments

Comments
 (0)