Skip to content
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
4 changes: 2 additions & 2 deletions .github/workflows/Test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
node-version: ["lts/*", "node"]
node-version: ["lts/*"]

steps:
- name: Checkout code
Expand Down Expand Up @@ -58,7 +58,7 @@ jobs:
strategy:
matrix:
node-version: ["lts/*"]
arch: ["x64", "arm64"]
arch: ["x64"]
include:
- node-version: "22"
arch: "x86"
Expand Down
9 changes: 5 additions & 4 deletions src/Async/AddDictionaryWorker.cc
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
#include <napi.h>
#include <hunspell.hxx>
#include <string>
#include "Worker.cc"

class AddDictionaryWorker : public Worker {
public:
AddDictionaryWorker(
HunspellContext* context,
Napi::Promise::Deferred d,
const char* dictionary)
: Worker(context, d), dictionary(dictionary) {}
std::string dictionary)
: Worker(context, d), dictionary(std::move(dictionary)) {}

void Execute() {
// Worker thread; don't use N-API here
context->lockWrite();
context->instance->add_dic(dictionary);
context->instance->add_dic(dictionary.c_str());
context->unlockWrite();
}

Expand All @@ -24,5 +25,5 @@ class AddDictionaryWorker : public Worker {
}

private:
const char* dictionary;
std::string dictionary;
};
2 changes: 1 addition & 1 deletion src/Async/AddWithAffixWorker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class AddWithAffixWorker : public Worker {
Napi::Promise::Deferred d,
std::string word,
std::string example)
: Worker(context, d), word(word), example(example) {}
: Worker(context, d), word(std::move(word)), example(std::move(example)) {}

void Execute() {
// Worker thread; don't use N-API here
Expand Down
2 changes: 1 addition & 1 deletion src/Async/AddWorker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class AddWorker : public Worker {
HunspellContext* context,
Napi::Promise::Deferred d,
std::string word)
: Worker(context, d), word(word) {}
: Worker(context, d), word(std::move(word)) {}

void Execute() {
// Worker thread; don't use N-API here
Expand Down
2 changes: 1 addition & 1 deletion src/Async/AnalyzeWorker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class AnalyzeWorker : public Worker {
HunspellContext* context,
Napi::Promise::Deferred d,
std::string word)
: Worker(context, d), word(word) {}
: Worker(context, d), word(std::move(word)) {}

void Execute() {
// Worker thread; don't use N-API here
Expand Down
2 changes: 1 addition & 1 deletion src/Async/GenerateWorker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class GenerateWorker : public Worker {
Napi::Promise::Deferred d,
std::string word,
std::string example)
: Worker(context, d), word(word), example(example) {}
: Worker(context, d), word(std::move(word)), example(std::move(example)) {}

void Execute() {
// Worker thread; don't use N-API here
Expand Down
2 changes: 1 addition & 1 deletion src/Async/RemoveWorker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class RemoveWorker : public Worker {
HunspellContext* context,
Napi::Promise::Deferred d,
std::string word)
: Worker(context, d), word(word) {}
: Worker(context, d), word(std::move(word)) {}

void Execute() {
// Worker thread; don't use N-API here
Expand Down
2 changes: 1 addition & 1 deletion src/Async/SpellWorker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class SpellWorker : public Worker {
HunspellContext* context,
Napi::Promise::Deferred d,
std::string word)
: Worker(context, d), word(word) {}
: Worker(context, d), word(std::move(word)) {}

void Execute() {
// Worker thread; don't use N-API here
Expand Down
2 changes: 1 addition & 1 deletion src/Async/StemWorker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class StemWorker : public Worker {
HunspellContext* context,
Napi::Promise::Deferred d,
std::string word)
: Worker(context, d), word(word) {}
: Worker(context, d), word(std::move(word)) {}

void Execute() {
// Worker thread; don't use N-API here
Expand Down
2 changes: 1 addition & 1 deletion src/Async/SuggestWorker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class SuggestWorker : public Worker {
HunspellContext* context,
Napi::Promise::Deferred d,
std::string word)
: Worker(context, d), word(word) {}
: Worker(context, d), word(std::move(word)) {}

void Execute() {
// Worker thread; don't use N-API here
Expand Down
9 changes: 5 additions & 4 deletions src/Nodehun.cc
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,9 @@ Napi::Value Nodehun::addDictionarySync(const Napi::CallbackInfo& info) {
return error.Value();
} else {
Napi::Buffer<char> dictionaryBuffer = info[0].As<Napi::Buffer<char>>();

context->instance->add_dic(dictionaryBuffer.Data());

std::string dictionary(dictionaryBuffer.Data(), dictionaryBuffer.Length());
context->instance->add_dic(dictionary.c_str());

return env.Undefined();
}
Expand All @@ -135,7 +136,7 @@ Napi::Value Nodehun::addDictionary(const Napi::CallbackInfo& info) {
AddDictionaryWorker* worker = new AddDictionaryWorker(
context,
deferred,
dictionaryBuffer.Data()
std::string(dictionaryBuffer.Data(), dictionaryBuffer.Length())
);

worker->Queue();
Expand Down Expand Up @@ -654,7 +655,7 @@ Napi::Value Nodehun::getWordCharactersUTF16(const Napi::CallbackInfo& info) {
if (chars == NULL) {
return env.Undefined();
} else {
return Napi::String::New(env, ((char16_t*) chars));
return Napi::String::New(env, ((char16_t*) chars), (size_t)length);
}
}

Expand Down