Skip to content

Commit

Permalink
User new ArrayBuffer API for Electron 13
Browse files Browse the repository at this point in the history
  • Loading branch information
sergei-dyshel committed Sep 3, 2021
1 parent a020dcc commit 961870e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/conversions.cc
Expand Up @@ -28,7 +28,8 @@ void InitConversions(Local<Object> exports) {
end_position_key.Reset(Nan::Persistent<String>(Nan::New("endPosition").ToLocalChecked()));

point_transfer_buffer = static_cast<uint32_t *>(malloc(2 * sizeof(uint32_t)));
auto js_point_transfer_buffer = ArrayBuffer::New(Isolate::GetCurrent(), point_transfer_buffer, 2 * sizeof(uint32_t));
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));
Nan::Set(exports, Nan::New("pointTransferArray").ToLocalChecked(), Uint32Array::New(js_point_transfer_buffer, 0, 2));
}

Expand Down
3 changes: 2 additions & 1 deletion src/node.cc
Expand Up @@ -29,7 +29,8 @@ 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)));
auto js_transfer_buffer = ArrayBuffer::New(Isolate::GetCurrent(), transfer_buffer, transfer_buffer_length * sizeof(uint32_t));
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));
Nan::Set(
Nan::New(module_exports),
Nan::New("nodeTransferArray").ToLocalChecked(),
Expand Down

2 comments on commit 961870e

@gpetrov
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sergei-dyshel could you please make PR's for this to the original node-tree-sitter? Thanks!

@gpetrov
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems this code gives some errors when building on Windows:

conversions.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: static class std::unique_ptr<class v8::BackingStore,struct std::default_delete<class v8::BackingStore> > __cdecl v8::ArrayBuffer::NewBackingStore(void *,unsigned __int64,void (__cdecl*)(void *,unsigned __int64,void *),void *)" (__imp_?NewBackingStore@ArrayBuffer@v8@@SA?AV?$unique_ptr@VBackingStore@v8@@U?$default_delete@VBackingStore@v8@@@std@@@std@@PEAX_KP6AX010@Z0@Z) [C:\Develop\xxxxx\node_modules\tree-sitter\build\tree_sitter_runtime_binding.vcxproj]
conversions.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: static class v8::Local<class v8::ArrayBuffer> __cdecl v8::ArrayBuffer::New(class v8::Isolate *,class std::shared_ptr<class v8::BackingStore>)" (__imp_?New@ArrayBuffer@v8@@SA?AV?$Local@VArrayBuffer@v8@@@2@PEAVIsolate@2@V?shared_ptr@VBackingStore@v8@@@std@@@Z) [C:\Develop\xxxxx\node_modules\tree-sitter\build\tree_sitter_runtime_binding.vcxproj]C:\Develop\xxxxx\node_modules\tree-sitter\build\Release\tree_sitter_runtime_binding.node : fatal error LNK1120: 2 unresolved externals [C:\Develop\xxxxx\node_modules\tree-sitter\build\tree_sitter_runtime_binding.vcxproj]

Any clues?

Please sign in to comment.