Skip to content

Commit

Permalink
Merge pull request #150 from verhovsky/fix-macro
Browse files Browse the repository at this point in the history
Fix macro
  • Loading branch information
verhovsky committed Jun 22, 2023
2 parents 97681db + 24875e2 commit d10867d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
5 changes: 4 additions & 1 deletion binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@
'RuntimeLibrary': 0,
},
},
}]
}],
['runtime=="electron"', {
'defines': ['NODE_RUNTIME_ELECTRON=1']
}],
],
},
{
Expand Down
6 changes: 3 additions & 3 deletions src/conversions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ void InitConversions(Local<Object> exports) {

point_transfer_buffer = static_cast<uint32_t *>(malloc(2 * sizeof(uint32_t)));

#if (V8_MAJOR_VERSION > 8 || (V8_MAJOR_VERSION == 8 && V8_MINOR_VERSION > 3))
#if (V8_MAJOR_VERSION < 8 || (V8_MAJOR_VERSION == 8 && V8_MINOR_VERSION < 4) || (V8_MAJOR_VERSION == 8 && NODE_RUNTIME_ELECTRON))
auto js_point_transfer_buffer = ArrayBuffer::New(Isolate::GetCurrent(), point_transfer_buffer, 2 * sizeof(uint32_t));
#else
auto backing_store = ArrayBuffer::NewBackingStore(point_transfer_buffer, 2 * sizeof(uint32_t), BackingStore::EmptyDeleter, nullptr);
auto js_point_transfer_buffer = ArrayBuffer::New(Isolate::GetCurrent(), std::move(backing_store));
#else
auto js_point_transfer_buffer = ArrayBuffer::New(Isolate::GetCurrent(), point_transfer_buffer, 2 * sizeof(uint32_t));
#endif

Nan::Set(exports, Nan::New("pointTransferArray").ToLocalChecked(), Uint32Array::New(js_point_transfer_buffer, 0, 2));
Expand Down
6 changes: 3 additions & 3 deletions src/node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ static inline void setup_transfer_buffer(uint32_t node_count) {
transfer_buffer_length = new_length;
transfer_buffer = static_cast<uint32_t *>(malloc(transfer_buffer_length * sizeof(uint32_t)));

#if (V8_MAJOR_VERSION > 8 || (V8_MAJOR_VERSION == 8 && V8_MINOR_VERSION > 3))
#if (V8_MAJOR_VERSION < 8 || (V8_MAJOR_VERSION == 8 && V8_MINOR_VERSION < 4) || (V8_MAJOR_VERSION == 8 && NODE_RUNTIME_ELECTRON))
auto js_transfer_buffer = ArrayBuffer::New(Isolate::GetCurrent(), transfer_buffer, transfer_buffer_length * sizeof(uint32_t));
#else
auto backing_store = ArrayBuffer::NewBackingStore(transfer_buffer, transfer_buffer_length * sizeof(uint32_t), BackingStore::EmptyDeleter, nullptr);
auto js_transfer_buffer = ArrayBuffer::New(Isolate::GetCurrent(), std::move(backing_store));
#else
auto js_transfer_buffer = ArrayBuffer::New(Isolate::GetCurrent(), transfer_buffer, transfer_buffer_length * sizeof(uint32_t));
#endif

Nan::Set(
Expand Down

0 comments on commit d10867d

Please sign in to comment.