Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support builds for Electron v29 #1151

Merged
merged 3 commits into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ on:

env:
NODE_BUILD_CMD: npx --no-install prebuild -r node -t 18.0.0 -t 20.0.0 -t 21.0.0 --include-regex 'better_sqlite3.node$'
ELECTRON_BUILD_CMD: npx --no-install prebuild -r electron -t 16.0.0 -t 17.0.0 -t 18.0.0 -t 19.0.0 -t 20.0.0 -t 21.0.0 -t 22.0.0 -t 23.0.0 -t 24.0.0 -t 25.0.0 -t 26.0.0 -t 27.0.0 -t 28.0.0 --include-regex 'better_sqlite3.node$'
ELECTRON_BUILD_CMD: npx --no-install prebuild -r electron -t 16.0.0 -t 17.0.0 -t 18.0.0 -t 19.0.0 -t 20.0.0 -t 21.0.0 -t 22.0.0 -t 23.0.0 -t 24.0.0 -t 25.0.0 -t 26.0.0 -t 27.0.0 -t 28.0.0 -t 29.0.0 --include-regex 'better_sqlite3.node$'

jobs:
test:
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"fs-extra": "^11.1.1",
"mocha": "^10.2.0",
"nodemark": "^0.3.0",
"prebuild": "^12.0.0",
"prebuild": "^13.0.0",
"sqlite": "^5.0.1",
"sqlite3": "^5.1.6"
},
Expand Down
44 changes: 29 additions & 15 deletions src/better_sqlite3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,35 @@
//

#include "better_sqlite3.hpp"
#line 161 "./src/util/macros.lzz"
#line 153 "./src/util/macros.lzz"
void SetPrototypeGetter(
v8::Isolate* isolate,
v8::Local<v8::External> data,
v8::Local<v8::FunctionTemplate> recv,
const char* name,
v8::AccessorGetterCallback func
) {
v8::HandleScope scope(isolate);

#if defined NODE_MODULE_VERSION && NODE_MODULE_VERSION < 121
recv->InstanceTemplate()->SetAccessor(
InternalizedFromLatin1(isolate, name),
func,
0,
data,
v8::AccessControl::DEFAULT,
v8::PropertyAttribute::None
);
#else
recv->InstanceTemplate()->SetAccessor(
InternalizedFromLatin1(isolate, name),
func,
0,
data
);
#endif
}
#line 183 "./src/util/macros.lzz"
#ifndef V8_COMPRESS_POINTERS_IN_SHARED_CAGE
#define SAFE_NEW_BUFFER(env, data, length, finalizeCallback, finalizeHint) node::Buffer::New(env, data, length, finalizeCallback, finalizeHint)
#else
Expand Down Expand Up @@ -119,20 +147,6 @@ void SetPrototypeSymbolMethod (v8::Isolate * isolate, v8::Local <v8::External> d
v8::FunctionTemplate::New(isolate, func, data, v8::Signature::New(isolate, recv))
);
}
#line 142 "./src/util/macros.lzz"
void SetPrototypeGetter (v8::Isolate * isolate, v8::Local <v8::External> data, v8::Local <v8::FunctionTemplate> recv, char const * name, v8::AccessorGetterCallback func)
#line 148 "./src/util/macros.lzz"
{
v8::HandleScope scope(isolate);
recv->InstanceTemplate()->SetAccessor(
InternalizedFromLatin1(isolate, name),
func,
0,
data,
v8::AccessControl::DEFAULT,
v8::PropertyAttribute::None
);
}
#line 4 "./src/util/constants.lzz"
v8::Local <v8::String> CS::Code (v8::Isolate * isolate, int code)
#line 4 "./src/util/constants.lzz"
Expand Down
10 changes: 8 additions & 2 deletions src/better_sqlite3.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@
#include <node_buffer.h>
#line 31 "./src/util/macros.lzz"
template <class T> using CopyablePersistent = v8::Persistent<T, v8::CopyablePersistentTraits<T>>;
#line 144 "./src/util/macros.lzz"
void SetPrototypeGetter(
v8::Isolate* isolate,
v8::Local<v8::External> data,
v8::Local<v8::FunctionTemplate> recv,
const char* name,
v8::AccessorGetterCallback func
);
#line 36 "./src/util/binder.lzz"
static bool IsPlainObject(v8::Isolate* isolate, v8::Local<v8::Object> obj);
#define LZZ_INLINE inline
Expand Down Expand Up @@ -53,8 +61,6 @@ v8::Local <v8::FunctionTemplate> NewConstructorTemplate (v8::Isolate * isolate,
void SetPrototypeMethod (v8::Isolate * isolate, v8::Local <v8::External> data, v8::Local <v8::FunctionTemplate> recv, char const * name, v8::FunctionCallback func);
#line 129 "./src/util/macros.lzz"
void SetPrototypeSymbolMethod (v8::Isolate * isolate, v8::Local <v8::External> data, v8::Local <v8::FunctionTemplate> recv, v8::Local <v8::Symbol> symbol, v8::FunctionCallback func);
#line 142 "./src/util/macros.lzz"
void SetPrototypeGetter (v8::Isolate * isolate, v8::Local <v8::External> data, v8::Local <v8::FunctionTemplate> recv, char const * name, v8::AccessorGetterCallback func);
#line 1 "./src/util/constants.lzz"
class CS
{
Expand Down
22 changes: 22 additions & 0 deletions src/util/macros.lzz
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,17 @@ void SetPrototypeSymbolMethod(
v8::FunctionTemplate::New(isolate, func, data, v8::Signature::New(isolate, recv))
);
}

#hdr
void SetPrototypeGetter(
v8::Isolate* isolate,
v8::Local<v8::External> data,
v8::Local<v8::FunctionTemplate> recv,
const char* name,
v8::AccessorGetterCallback func
);
#end
#src
void SetPrototypeGetter(
v8::Isolate* isolate,
v8::Local<v8::External> data,
Expand All @@ -147,6 +158,8 @@ void SetPrototypeGetter(
v8::AccessorGetterCallback func
) {
v8::HandleScope scope(isolate);

#if defined NODE_MODULE_VERSION && NODE_MODULE_VERSION < 121
recv->InstanceTemplate()->SetAccessor(
InternalizedFromLatin1(isolate, name),
func,
Expand All @@ -155,7 +168,16 @@ void SetPrototypeGetter(
v8::AccessControl::DEFAULT,
v8::PropertyAttribute::None
);
#else
recv->InstanceTemplate()->SetAccessor(
InternalizedFromLatin1(isolate, name),
func,
0,
data
);
#endif
}
#end

#src
#ifndef V8_COMPRESS_POINTERS_IN_SHARED_CAGE
Expand Down