msgpackr-extract 1.0.16-napi.1 → 2.0.0-beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/prebuild.yml +16 -5
- package/binding.gyp +0 -2
- package/index.js +1 -1
- package/package.json +8 -9
- package/prebuilds/darwin-arm64/README.md +1 -0
- package/prebuilds/darwin-arm64/index.js +0 -0
- package/prebuilds/darwin-arm64/node.napi.glibc.node +0 -0
- package/prebuilds/darwin-arm64/package.json +11 -0
- package/prebuilds/darwin-x64/README.md +1 -0
- package/prebuilds/darwin-x64/index.js +0 -0
- package/prebuilds/darwin-x64/{node.napi.node → node.napi.glibc.node} +0 -0
- package/prebuilds/darwin-x64/package.json +11 -0
- package/prebuilds/linux-arm64/README.md +1 -0
- package/prebuilds/linux-arm64/index.js +0 -0
- package/prebuilds/linux-arm64/node.napi.glibc.node +0 -0
- package/prebuilds/linux-arm64/package.json +11 -0
- package/prebuilds/linux-x64/README.md +1 -0
- package/prebuilds/linux-x64/index.js +0 -0
- package/prebuilds/linux-x64/node.napi.glibc.node +0 -0
- package/prebuilds/linux-x64/package.json +11 -0
- package/prebuilds/win32-x64/README.md +1 -0
- package/prebuilds/win32-x64/index.js +0 -0
- package/prebuilds/win32-x64/node.napi.node +0 -0
- package/prebuilds/win32-x64/package.json +11 -0
- package/src/extract.cpp +84 -91
- package/prebuilds/linux-x64/node.napi.musl.node +0 -0
- package/prebuilds/linux-x64/node.napi.node +0 -0
|
@@ -12,10 +12,12 @@ jobs:
|
|
|
12
12
|
node-version: 12
|
|
13
13
|
- run: npm install
|
|
14
14
|
- run: npm test
|
|
15
|
-
- run: npm run prebuild
|
|
15
|
+
- run: npm run prebuild-libc
|
|
16
16
|
if: startsWith(github.ref, 'refs/tags/')
|
|
17
|
-
- run: npm run prebuild-
|
|
17
|
+
- run: npm run prebuild-libc
|
|
18
18
|
if: startsWith(github.ref, 'refs/tags/')
|
|
19
|
+
env:
|
|
20
|
+
PREBUILD_ARCH: arm64
|
|
19
21
|
- run: tar --create --format ustar --verbose --file=prebuild-darwin.tar -C prebuilds .
|
|
20
22
|
if: startsWith(github.ref, 'refs/tags/')
|
|
21
23
|
- name: Prebuild
|
|
@@ -35,7 +37,7 @@ jobs:
|
|
|
35
37
|
with:
|
|
36
38
|
node-version: 12
|
|
37
39
|
- run: npm install
|
|
38
|
-
- run: npm run prebuild
|
|
40
|
+
- run: npm run prebuild-libc
|
|
39
41
|
- run: npm test
|
|
40
42
|
- run: tar --create --verbose --file=prebuild-linux.tar -C prebuilds .
|
|
41
43
|
- name: Prebuild
|
|
@@ -51,7 +53,15 @@ jobs:
|
|
|
51
53
|
- run: apk add python3 py3-pip build-base
|
|
52
54
|
- uses: actions/checkout@v2
|
|
53
55
|
- run: npm install
|
|
54
|
-
- run: npm run prebuild-
|
|
56
|
+
- run: npm run prebuild-libc
|
|
57
|
+
env:
|
|
58
|
+
PREBUILD_LIBC: musl
|
|
59
|
+
PREBUILD_ARCH: arm64
|
|
60
|
+
CC: ${PWD}/aarch64-linux-musl-cross/bin/aarch64-linux-musl-gcc
|
|
61
|
+
CXX: ${PWD}/aarch64-linux-musl-cross/bin/aarch64-linux-musl-g++
|
|
62
|
+
- run: npm run prebuild-libc
|
|
63
|
+
env:
|
|
64
|
+
PREBUILD_LIBC: musl
|
|
55
65
|
- run: npm test
|
|
56
66
|
- run: tar --create --verbose --file=prebuild-alpine.tar -C prebuilds .
|
|
57
67
|
- name: Prebuild
|
|
@@ -74,9 +84,10 @@ jobs:
|
|
|
74
84
|
with:
|
|
75
85
|
node-version: 12
|
|
76
86
|
- run: npm install
|
|
77
|
-
- run: npm run prebuild-
|
|
87
|
+
- run: npm run prebuild-libc
|
|
78
88
|
if: startsWith(github.ref, 'refs/tags/')
|
|
79
89
|
env:
|
|
90
|
+
PREBUILD_ARCH: arm64
|
|
80
91
|
CC: aarch64-linux-gnu-gcc
|
|
81
92
|
CXX: aarch64-linux-gnu-g++
|
|
82
93
|
- run: tar --create --verbose --file=prebuild-linux-arm64.tar -C prebuilds .
|
package/binding.gyp
CHANGED
|
@@ -11,8 +11,6 @@
|
|
|
11
11
|
"src/extract.cpp",
|
|
12
12
|
],
|
|
13
13
|
"defines": [ "NAPI_DISABLE_CPP_EXCEPTIONS" ],
|
|
14
|
-
"include_dirs" : ["<!(node -p \"require('node-addon-api').include_dir\")"],
|
|
15
|
-
"dependencies": ["<!(node -p \"require('node-addon-api').gyp\")"],
|
|
16
14
|
"conditions": [
|
|
17
15
|
["OS=='linux'", {
|
|
18
16
|
"variables": {
|
package/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
module.exports = require('node-gyp-build')(__dirname)
|
|
1
|
+
module.exports = require('node-gyp-build')(__dirname);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "msgpackr-extract",
|
|
3
3
|
"author": "Kris Zyp",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "2.0.0-beta",
|
|
5
5
|
"description": "Node addon for string extraction for msgpackr",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
@@ -11,20 +11,19 @@
|
|
|
11
11
|
"scripts": {
|
|
12
12
|
"install": "node-gyp-build",
|
|
13
13
|
"recompile": "node-gyp build",
|
|
14
|
-
"before-publish": "prebuildify-ci download && prebuildify --napi --target 12.22.7",
|
|
15
|
-
"prebuild": "prebuildify --napi --target 12.22.7",
|
|
16
|
-
"prebuild-
|
|
17
|
-
"
|
|
18
|
-
"test": ""
|
|
14
|
+
"before-publish": "prebuildify-ci download && prebuildify --optional-packages --napi --target 12.22.7",
|
|
15
|
+
"prebuild": "prebuildify --optional-packages --napi --target 12.22.7",
|
|
16
|
+
"prebuild-libc": "prebuildify --optional-packages --napi --tag-libc --target 12.22.7",
|
|
17
|
+
"publish-all": "cd prebuilds/win32-x64 && npm publish --otp %OTP% && cd ../darwin-x64 && npm publish --otp %OTP% && cd ../darwin-arm64 && npm publish --otp %OTP% && cd ../linux-x64 && npm publish --otp %OTP% && cd ../linux-arm64 && npm publish --otp %OTP% && cd ../.. && npm publish --otp %OTP%",
|
|
18
|
+
"test": "node ./index.js"
|
|
19
19
|
},
|
|
20
20
|
"main": "./index.js",
|
|
21
21
|
"gypfile": true,
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"node-
|
|
24
|
-
"node-gyp-build": "^4.2.3"
|
|
23
|
+
"node-gyp-build": "kriszyp/node-gyp-build#optional-packages"
|
|
25
24
|
},
|
|
26
25
|
"devDependencies": {
|
|
27
|
-
"prebuildify": "
|
|
26
|
+
"prebuildify": "kriszyp/prebuildify#optional-packages",
|
|
28
27
|
"prebuildify-ci": "^1.0.5"
|
|
29
28
|
}
|
|
30
29
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Platform specific binary for msgpackr-extract on darwin OS with arm64 architecture
|
|
File without changes
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Platform specific binary for msgpackr-extract on darwin OS with x64 architecture
|
|
File without changes
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Platform specific binary for msgpackr-extract on linux OS with arm64 architecture
|
|
File without changes
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Platform specific binary for msgpackr-extract on linux OS with x64 architecture
|
|
File without changes
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Platform specific binary for msgpackr-extract on win32 OS with x64 architecture
|
|
File without changes
|
|
Binary file
|
package/src/extract.cpp
CHANGED
|
@@ -5,12 +5,8 @@ provides much better performance. This will parse and produce up to 256 strings
|
|
|
5
5
|
times as necessary to get more strings. This must be partially capable of parsing MessagePack so it can know where to
|
|
6
6
|
find the string tokens and determine their position and length. All strings are decoded as UTF-8.
|
|
7
7
|
*/
|
|
8
|
-
#include <v8.h>
|
|
9
|
-
#include <napi.h>
|
|
10
8
|
#include <node_api.h>
|
|
11
9
|
|
|
12
|
-
using namespace Napi;
|
|
13
|
-
|
|
14
10
|
#ifndef thread_local
|
|
15
11
|
#ifdef __GNUC__
|
|
16
12
|
# define thread_local __thread
|
|
@@ -24,20 +20,27 @@ using namespace Napi;
|
|
|
24
20
|
#endif
|
|
25
21
|
|
|
26
22
|
const int MAX_TARGET_SIZE = 255;
|
|
27
|
-
typedef int (*token_handler)(
|
|
23
|
+
typedef int (*token_handler)(uint8_t* source, int position, int size);
|
|
28
24
|
token_handler tokenTable[256] = {};
|
|
25
|
+
napi_value unexpectedEnd(napi_env env) {
|
|
26
|
+
napi_value returnValue;
|
|
27
|
+
napi_get_undefined(env, &returnValue);
|
|
28
|
+
napi_throw_type_error(env, NULL, "Unexpected end of buffer reading string");
|
|
29
|
+
return returnValue;
|
|
30
|
+
}
|
|
31
|
+
|
|
29
32
|
class Extractor {
|
|
30
33
|
public:
|
|
31
|
-
|
|
32
|
-
|
|
34
|
+
napi_value target[MAX_TARGET_SIZE + 1]; // leave one for the queued string
|
|
35
|
+
napi_ref targetArray;
|
|
36
|
+
bool hasTargetArray = false;
|
|
33
37
|
uint8_t* source;
|
|
34
38
|
int position = 0;
|
|
35
39
|
int writePosition = 0;
|
|
36
40
|
int stringStart = 0;
|
|
37
41
|
int lastStringEnd = 0;
|
|
38
|
-
v8::Isolate *isolate = v8::Isolate::GetCurrent();
|
|
39
42
|
|
|
40
|
-
void readString(
|
|
43
|
+
void readString(napi_env env, int length, bool allowStringBlocks) {
|
|
41
44
|
int start = position;
|
|
42
45
|
int end = position + length;
|
|
43
46
|
if (allowStringBlocks) { // for larger strings, we don't bother to check every character for being latin, and just go right to creating a new string
|
|
@@ -52,18 +55,24 @@ public:
|
|
|
52
55
|
if (position < end) {
|
|
53
56
|
// non-latin character
|
|
54
57
|
if (lastStringEnd) {
|
|
55
|
-
|
|
58
|
+
napi_value value;
|
|
59
|
+
napi_create_string_latin1(env, (const char*) source + stringStart, lastStringEnd - stringStart, &value);
|
|
60
|
+
target[writePosition++] = value;
|
|
56
61
|
lastStringEnd = 0;
|
|
57
62
|
}
|
|
58
63
|
// use standard utf-8 conversion
|
|
59
|
-
|
|
64
|
+
napi_value value;
|
|
65
|
+
napi_create_string_utf8(env, (const char*) source + start, (int) length, &value);
|
|
66
|
+
target[writePosition++] = value;
|
|
60
67
|
position = end;
|
|
61
68
|
return;
|
|
62
69
|
}
|
|
63
70
|
|
|
64
71
|
if (lastStringEnd) {
|
|
65
72
|
if (start - lastStringEnd > 40 || end - stringStart > 6000) {
|
|
66
|
-
|
|
73
|
+
napi_value value;
|
|
74
|
+
napi_create_string_latin1(env, (const char*) source + stringStart, lastStringEnd - stringStart, &value);
|
|
75
|
+
target[writePosition++] = value;
|
|
67
76
|
stringStart = start;
|
|
68
77
|
}
|
|
69
78
|
} else {
|
|
@@ -72,7 +81,7 @@ public:
|
|
|
72
81
|
lastStringEnd = end;
|
|
73
82
|
}
|
|
74
83
|
|
|
75
|
-
napi_value extractStrings(
|
|
84
|
+
napi_value extractStrings(napi_env env, int startingPosition, int size, uint8_t* inputSource, napi_value array) {
|
|
76
85
|
writePosition = 0;
|
|
77
86
|
lastStringEnd = 0;
|
|
78
87
|
position = startingPosition;
|
|
@@ -85,8 +94,7 @@ public:
|
|
|
85
94
|
// fixstr, we want to convert this
|
|
86
95
|
token -= 0xa0;
|
|
87
96
|
if (token + position > size) {
|
|
88
|
-
|
|
89
|
-
return env.Null();
|
|
97
|
+
return unexpectedEnd(env);
|
|
90
98
|
}
|
|
91
99
|
readString(env,token, true);
|
|
92
100
|
if (writePosition >= MAX_TARGET_SIZE)
|
|
@@ -94,39 +102,33 @@ public:
|
|
|
94
102
|
} else if (token <= 0xdb && token >= 0xd9) {
|
|
95
103
|
if (token == 0xd9) { //str 8
|
|
96
104
|
if (position >= size) {
|
|
97
|
-
|
|
98
|
-
return env.Null();
|
|
105
|
+
return unexpectedEnd(env);
|
|
99
106
|
}
|
|
100
107
|
int length = source[position++];
|
|
101
108
|
if (length + position > size) {
|
|
102
|
-
|
|
103
|
-
return env.Null();
|
|
109
|
+
return unexpectedEnd(env);
|
|
104
110
|
}
|
|
105
111
|
readString(env,length, true);
|
|
106
112
|
} else if (token == 0xda) { //str 16
|
|
107
113
|
if (2 + position > size) {
|
|
108
|
-
|
|
109
|
-
return env.Null();
|
|
114
|
+
return unexpectedEnd(env);
|
|
110
115
|
}
|
|
111
116
|
int length = source[position++] << 8;
|
|
112
117
|
length += source[position++];
|
|
113
118
|
if (length + position > size) {
|
|
114
|
-
|
|
115
|
-
return env.Null();
|
|
119
|
+
return unexpectedEnd(env);
|
|
116
120
|
}
|
|
117
121
|
readString(env,length, false);
|
|
118
122
|
} else { //str 32
|
|
119
123
|
if (4 + position > size) {
|
|
120
|
-
|
|
121
|
-
return env.Null();
|
|
124
|
+
return unexpectedEnd(env);
|
|
122
125
|
}
|
|
123
126
|
int length = source[position++] << 24;
|
|
124
127
|
length += source[position++] << 16;
|
|
125
128
|
length += source[position++] << 8;
|
|
126
129
|
length += source[position++];
|
|
127
130
|
if (length + position > size) {
|
|
128
|
-
|
|
129
|
-
return env.Null();
|
|
131
|
+
return unexpectedEnd(env);
|
|
130
132
|
}
|
|
131
133
|
readString(env, length, false);
|
|
132
134
|
}
|
|
@@ -137,43 +139,52 @@ public:
|
|
|
137
139
|
if ((size_t ) handle < 20) {
|
|
138
140
|
position += (size_t ) handle;
|
|
139
141
|
} else {
|
|
140
|
-
position = tokenTable[token](
|
|
142
|
+
position = tokenTable[token](source, position, size);
|
|
141
143
|
if (position < 0) {
|
|
142
|
-
|
|
143
|
-
return env.Null();
|
|
144
|
+
return unexpectedEnd(env);
|
|
144
145
|
}
|
|
145
146
|
}
|
|
146
147
|
}
|
|
147
148
|
}
|
|
148
|
-
|
|
149
|
+
|
|
149
150
|
if (lastStringEnd) {
|
|
151
|
+
napi_value value;
|
|
152
|
+
napi_create_string_latin1(env, (const char*) source + stringStart, lastStringEnd - stringStart, &value);
|
|
150
153
|
if (writePosition == 0) {
|
|
151
|
-
|
|
152
|
-
|
|
154
|
+
if (!hasTargetArray) {
|
|
155
|
+
hasTargetArray = true;
|
|
156
|
+
napi_create_reference(env, array, 1, &targetArray);
|
|
157
|
+
}
|
|
158
|
+
return value;
|
|
153
159
|
}
|
|
154
|
-
target[writePosition++] =
|
|
160
|
+
target[writePosition++] = value;
|
|
155
161
|
} else if (writePosition == 1) {
|
|
156
|
-
|
|
157
|
-
|
|
162
|
+
if (!hasTargetArray) {
|
|
163
|
+
hasTargetArray = true;
|
|
164
|
+
napi_create_reference(env, array, 1, &targetArray);
|
|
165
|
+
}
|
|
166
|
+
return target[0];
|
|
158
167
|
}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
/*#else
|
|
166
|
-
v8::Local<v8::Array> array = v8::Array::New(isolate, writePosition);
|
|
167
|
-
v8::Local<v8::Context> context = v8::Isolate::GetCurrentContext();
|
|
168
|
-
for (int i = 0; i < writePosition; i++) {
|
|
169
|
-
array->Set(context, i, target[i]);
|
|
168
|
+
//napi_value array;
|
|
169
|
+
//napi_get_reference_value(env, targetArray, &array);
|
|
170
|
+
//napi_create_array_with_length(env, writePosition, &array);
|
|
171
|
+
if (hasTargetArray) {
|
|
172
|
+
napi_get_reference_value(env, targetArray, &array);
|
|
173
|
+
hasTargetArray = false;
|
|
170
174
|
}
|
|
175
|
+
int i = 0;
|
|
176
|
+
for (i = 0; i < writePosition; i++) {
|
|
177
|
+
napi_set_element(env, array, i, target[i]);
|
|
178
|
+
}
|
|
179
|
+
napi_value length;
|
|
180
|
+
napi_create_int32(env, i, &length);
|
|
181
|
+
return length;/*
|
|
182
|
+
napi_set_element(env, array, i, undefined);
|
|
171
183
|
return array;*/
|
|
172
|
-
//#endif
|
|
173
184
|
}
|
|
174
185
|
};
|
|
175
186
|
|
|
176
|
-
void setupTokenTable(
|
|
187
|
+
void setupTokenTable() {
|
|
177
188
|
for (int i = 0; i < 256; i++) {
|
|
178
189
|
tokenTable[i] = nullptr;
|
|
179
190
|
}
|
|
@@ -194,26 +205,24 @@ void setupTokenTable(Env env) {
|
|
|
194
205
|
// fixext 16
|
|
195
206
|
tokenTable[0xd8] = (token_handler) 17;
|
|
196
207
|
// bin 8
|
|
197
|
-
tokenTable[0xc4] = ([](
|
|
208
|
+
tokenTable[0xc4] = ([](uint8_t* source, int position, int size) -> int {
|
|
198
209
|
if (position >= size) {
|
|
199
|
-
|
|
200
|
-
return size;
|
|
210
|
+
return -1;
|
|
201
211
|
}
|
|
202
212
|
int length = source[position++];
|
|
203
213
|
return position + length;
|
|
204
214
|
});
|
|
205
215
|
// bin 16
|
|
206
|
-
tokenTable[0xc5] = ([](
|
|
216
|
+
tokenTable[0xc5] = ([](uint8_t* source, int position, int size) -> int {
|
|
207
217
|
if (position + 2 > size) {
|
|
208
|
-
|
|
209
|
-
return size;
|
|
218
|
+
return -1;
|
|
210
219
|
}
|
|
211
220
|
int length = source[position++] << 8;
|
|
212
221
|
length += source[position++];
|
|
213
222
|
return position + length;
|
|
214
223
|
});
|
|
215
224
|
// bin 32
|
|
216
|
-
tokenTable[0xc6] = ([](
|
|
225
|
+
tokenTable[0xc6] = ([](uint8_t* source, int position, int size) -> int {
|
|
217
226
|
if (position + 4 > size)
|
|
218
227
|
return -1;
|
|
219
228
|
int length = source[position++] << 24;
|
|
@@ -223,7 +232,7 @@ void setupTokenTable(Env env) {
|
|
|
223
232
|
return position + length;
|
|
224
233
|
});
|
|
225
234
|
// ext 8
|
|
226
|
-
tokenTable[0xc7] = ([](
|
|
235
|
+
tokenTable[0xc7] = ([](uint8_t* source, int position, int size) -> int {
|
|
227
236
|
if (position >= size)
|
|
228
237
|
return -1;
|
|
229
238
|
int length = source[position++];
|
|
@@ -231,7 +240,7 @@ void setupTokenTable(Env env) {
|
|
|
231
240
|
return position + length;
|
|
232
241
|
});
|
|
233
242
|
// ext 16
|
|
234
|
-
tokenTable[0xc8] = ([](
|
|
243
|
+
tokenTable[0xc8] = ([](uint8_t* source, int position, int size) -> int {
|
|
235
244
|
if (position + 2 > size)
|
|
236
245
|
return -1;
|
|
237
246
|
int length = source[position++] << 8;
|
|
@@ -240,7 +249,7 @@ void setupTokenTable(Env env) {
|
|
|
240
249
|
return position + length;
|
|
241
250
|
});
|
|
242
251
|
// ext 32
|
|
243
|
-
tokenTable[0xc9] = ([](
|
|
252
|
+
tokenTable[0xc9] = ([](uint8_t* source, int position, int size) -> int {
|
|
244
253
|
if (position + 4 > size)
|
|
245
254
|
return -1;
|
|
246
255
|
int length = source[position++] << 24;
|
|
@@ -251,41 +260,25 @@ void setupTokenTable(Env env) {
|
|
|
251
260
|
return position + length;
|
|
252
261
|
});
|
|
253
262
|
}
|
|
254
|
-
|
|
255
263
|
static thread_local Extractor* extractor;
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
napi_value isOneByte(const CallbackInfo& info) {
|
|
270
|
-
Env env = info.Env();
|
|
271
|
-
size_t length;
|
|
272
|
-
napi_get_value_string_latin1(env, info[0], nullptr, 0, &length);
|
|
273
|
-
|
|
274
|
-
return Boolean::New(env, length == 1);
|
|
264
|
+
napi_value extractStrings(napi_env env, napi_callback_info info) {
|
|
265
|
+
size_t argc = extractor->hasTargetArray ? 3 : 4;
|
|
266
|
+
napi_value args[4];
|
|
267
|
+
napi_get_cb_info(env, info, &argc, args, NULL, NULL);
|
|
268
|
+
uint32_t position;
|
|
269
|
+
uint32_t size;
|
|
270
|
+
napi_get_value_uint32(env, args[0], &position);
|
|
271
|
+
napi_get_value_uint32(env, args[1], &size);
|
|
272
|
+
uint8_t* source;
|
|
273
|
+
napi_get_typedarray_info(env, args[2], NULL, NULL, (void**) &source, NULL, NULL);
|
|
274
|
+
return extractor->extractStrings(env, position, size, source, args[3]);
|
|
275
275
|
}
|
|
276
|
-
|
|
277
|
-
|
|
276
|
+
#define EXPORT_NAPI_FUNCTION(name, func) { napi_property_descriptor desc = { name, 0, func, 0, 0, 0, (napi_property_attributes) (napi_writable | napi_configurable), 0 }; napi_define_properties(env, exports, 1, &desc); }
|
|
277
|
+
napi_value Init(napi_env env, napi_value exports) {
|
|
278
278
|
extractor = new Extractor(); // create our thread-local extractor
|
|
279
|
-
setupTokenTable(
|
|
280
|
-
|
|
281
|
-
String::New(env, "extractStrings"),
|
|
282
|
-
Function::New(env, extractStrings)
|
|
283
|
-
);
|
|
284
|
-
exports.Set(
|
|
285
|
-
String::New(env, "isOneByte"),
|
|
286
|
-
Function::New(env, isOneByte)
|
|
287
|
-
);
|
|
279
|
+
setupTokenTable();
|
|
280
|
+
EXPORT_NAPI_FUNCTION("extractStrings", extractStrings);
|
|
288
281
|
return exports;
|
|
289
282
|
}
|
|
290
283
|
|
|
291
|
-
|
|
284
|
+
NAPI_MODULE(extractor, Init)
|
|
Binary file
|
|
Binary file
|