Skip to content

Commit 8617ed6

Browse files
authored
fix: use HolderV2() for PropertyCallbackInfo on V8 >= 12.5 (#1459)
fix: use HolderV2() for PropertyCallbackInfo on V8 >= 13 PR #1456 replaced This() with Holder() in NODE_GETTER contexts, but Electron 41 (V8 14.6) removed both This() and Holder() from PropertyCallbackInfo. Only HolderV2() remains (to be renamed back to Holder() in a future V8 version per crbug.com/333672197). Add a PROPERTY_HOLDER compat macro that uses HolderV2() on V8 >= 13 and falls back to This() on older versions. Same pattern as the existing GET_PROTOTYPE macro. Verified: compiles and runs on Electron 41.0.1 (V8 14.6.202). Fixes #1458
1 parent 959a018 commit 8617ed6

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

src/objects/database.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -408,10 +408,10 @@ NODE_METHOD(Database::JS_unsafeMode) {
408408
}
409409

410410
NODE_GETTER(Database::JS_open) {
411-
info.GetReturnValue().Set(Unwrap<Database>(info.Holder())->open);
411+
info.GetReturnValue().Set(Unwrap<Database>(PROPERTY_HOLDER(info))->open);
412412
}
413413

414414
NODE_GETTER(Database::JS_inTransaction) {
415-
Database* db = Unwrap<Database>(info.Holder());
415+
Database* db = Unwrap<Database>(PROPERTY_HOLDER(info));
416416
info.GetReturnValue().Set(db->open && !static_cast<bool>(sqlite3_get_autocommit(db->db_handle)));
417417
}

src/objects/statement.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,6 @@ NODE_METHOD(Statement::JS_columns) {
378378
}
379379

380380
NODE_GETTER(Statement::JS_busy) {
381-
Statement* stmt = Unwrap<Statement>(info.Holder());
381+
Statement* stmt = Unwrap<Statement>(PROPERTY_HOLDER(info));
382382
info.GetReturnValue().Set(stmt->alive && stmt->locked);
383383
}

src/util/macros.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,19 @@
1111
#define GET_PROTOTYPE(obj) ((obj)->GetPrototype())
1212
#endif
1313

14+
// PropertyCallbackInfo::This() and Holder() were removed; use HolderV2().
15+
// Tracking bug for V8 API removals: http://crbug.com/333672197
16+
// V8 head has since restored Holder() and deprecated HolderV2():
17+
// https://chromium.googlesource.com/v8/v8/+/main/include/v8-function-callback.h
18+
// V8_INLINE Local<Object> Holder() const;
19+
// V8_DEPRECATE_SOON("Use Holder().")
20+
// V8_INLINE Local<Object> HolderV2() const;
21+
#if defined(V8_MAJOR_VERSION) && V8_MAJOR_VERSION >= 13
22+
#define PROPERTY_HOLDER(info) (info).HolderV2()
23+
#else
24+
#define PROPERTY_HOLDER(info) (info).This()
25+
#endif
26+
1427
#define EasyIsolate v8::Isolate* isolate = v8::Isolate::GetCurrent()
1528
#define OnlyIsolate info.GetIsolate()
1629
#define OnlyContext isolate->GetCurrentContext()

0 commit comments

Comments
 (0)