Skip to content

Commit d09f76a

Browse files
m4heshdneoxpert
andcommitted
Update native bindings for latest v8 api
Co-authored-by: neoxpert <18628980+neoxpert@users.noreply.github.com>
1 parent ff76c6f commit d09f76a

File tree

5 files changed

+30
-0
lines changed

5 files changed

+30
-0
lines changed

src/better_sqlite3.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@
1212
#include <node_object_wrap.h>
1313
#include <node_buffer.h>
1414

15+
// v8::Object::GetPrototype has been deprecated. See http://crbug.com/333672197
16+
#if defined(V8_MAJOR_VERSION) && V8_MAJOR_VERSION >= 13
17+
#define USE_GETPROTOTYPEV2
18+
#endif
19+
1520
struct Addon;
1621
class Database;
1722
class Statement;
@@ -46,7 +51,12 @@ class Backup;
4651
#include "objects/statement-iterator.cpp"
4752

4853
NODE_MODULE_INIT(/* exports, context */) {
54+
#if defined(NODE_MODULE_VERSION) && NODE_MODULE_VERSION >= 140
55+
// Use Isolate::GetCurrent as stated in deprecation message within v8_context.h 13.9.72320122
56+
v8::Isolate* isolate = v8::Isolate::GetCurrent();
57+
#else
4958
v8::Isolate* isolate = context->GetIsolate();
59+
#endif
5060
v8::HandleScope scope(isolate);
5161
Addon::ConfigureURI();
5262

src/objects/statement.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,11 @@ NODE_METHOD(Statement::JS_columns) {
363363
);
364364
columns.emplace_back(
365365
v8::Object::New(isolate,
366+
#ifdef USE_GETPROTOTYPEV2
367+
v8::Object::New(isolate)->GetPrototypeV2(),
368+
#else
366369
v8::Object::New(isolate)->GetPrototype(),
370+
#endif
367371
keys.data(),
368372
values.data(),
369373
keys.size()

src/util/binder.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,18 @@ class Binder {
3333
};
3434

3535
static bool IsPlainObject(v8::Isolate* isolate, v8::Local<v8::Object> obj) {
36+
#ifdef USE_GETPROTOTYPEV2
37+
v8::Local<v8::Value> proto = obj->GetPrototypeV2();
38+
#else
3639
v8::Local<v8::Value> proto = obj->GetPrototype();
40+
#endif
3741
v8::Local<v8::Context> ctx = obj->GetCreationContext().ToLocalChecked();
3842
ctx->Enter();
43+
#ifdef USE_GETPROTOTYPEV2
44+
v8::Local<v8::Value> baseProto = v8::Object::New(isolate)->GetPrototypeV2();
45+
#else
3946
v8::Local<v8::Value> baseProto = v8::Object::New(isolate)->GetPrototype();
47+
#endif
4048
ctx->Exit();
4149
return proto->StrictEquals(baseProto) || proto->StrictEquals(v8::Null(isolate));
4250
}

src/util/data.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,11 @@ namespace Data {
146146
}
147147
return v8::Object::New(
148148
isolate,
149+
#ifdef USE_GETPROTOTYPEV2
150+
v8::Object::New(isolate)->GetPrototypeV2(),
151+
#else
149152
v8::Object::New(isolate)->GetPrototype(),
153+
#endif
150154
keys.data(),
151155
values.data(),
152156
column_count

src/util/row-builder.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,11 @@ class RowBuilder {
3333
}
3434

3535
return v8::Object::New(isolate,
36+
#ifdef USE_GETPROTOTYPEV2
37+
v8::Object::New(isolate)->GetPrototypeV2(),
38+
#else
3639
v8::Object::New(isolate)->GetPrototype(),
40+
#endif
3741
keys.data(),
3842
values.data(),
3943
column_count

0 commit comments

Comments
 (0)