@stdlib/math-base-napi-quaternary 0.2.2 → 0.2.3
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/NOTICE +1 -1
- package/README.md +85 -23
- package/include/stdlib/math/base/napi/quaternary/dddd_d.h +81 -0
- package/include/stdlib/math/base/napi/quaternary/diii_d.h +84 -0
- package/include/stdlib/math/base/napi/quaternary/ffff_f.h +81 -0
- package/include/stdlib/math/base/napi/quaternary.h +4 -103
- package/manifest.json +38 -36
- package/package.json +2 -2
- package/src/addon.c +0 -1
- package/src/dddd_d.c +111 -0
- package/src/diii_d.c +112 -0
- package/src/{main.c → ffff_f.c} +1 -92
package/NOTICE
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Copyright (c) 2016-
|
|
1
|
+
Copyright (c) 2016-2026 The Stdlib Authors.
|
package/README.md
CHANGED
|
@@ -127,6 +127,29 @@ console.log( headerDir );
|
|
|
127
127
|
#include "stdlib/math/base/napi/quaternary.h"
|
|
128
128
|
```
|
|
129
129
|
|
|
130
|
+
<!-- NOTE: keep in alphabetical order according to the suffix XXXX_X -->
|
|
131
|
+
|
|
132
|
+
#### STDLIB_MATH_BASE_NAPI_MODULE_DDDD_D( fcn )
|
|
133
|
+
|
|
134
|
+
Macro for registering a Node-API module exporting an interface for invoking a quaternary function accepting and returning double-precision floating-point numbers.
|
|
135
|
+
|
|
136
|
+
```c
|
|
137
|
+
static double add( const double x, const double y, const double z, const double w ) {
|
|
138
|
+
return x + y + z + w;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// ...
|
|
142
|
+
|
|
143
|
+
// Register a Node-API module:
|
|
144
|
+
STDLIB_MATH_BASE_NAPI_MODULE_DDDD_D( add );
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
The macro expects the following arguments:
|
|
148
|
+
|
|
149
|
+
- **fcn**: `double (*fcn)( double, double, double, double )` quaternary function.
|
|
150
|
+
|
|
151
|
+
When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration.
|
|
152
|
+
|
|
130
153
|
#### stdlib_math_base_napi_dddd_d( env, info, fcn )
|
|
131
154
|
|
|
132
155
|
Invokes a quaternary function accepting and returning double-precision floating-point numbers.
|
|
@@ -166,16 +189,37 @@ The function accepts the following arguments:
|
|
|
166
189
|
void stdlib_math_base_napi_dddd_d( napi_env env, napi_callback_info info, double (*fcn)( double, double, double, double ) );
|
|
167
190
|
```
|
|
168
191
|
|
|
169
|
-
####
|
|
192
|
+
#### STDLIB_MATH_BASE_NAPI_MODULE_DIII_D( fcn )
|
|
170
193
|
|
|
171
|
-
|
|
194
|
+
Macro for registering a Node-API module exporting an interface invoking a quaternary function accepting a double-precision floating-point number and three signed 32-bit integers and returning a double-precision floating-point number.
|
|
195
|
+
|
|
196
|
+
```c
|
|
197
|
+
static double add( const double x, const int32_t y, const int32_t z, const int32_t w ) {
|
|
198
|
+
return x + y + z + w;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
// ...
|
|
202
|
+
|
|
203
|
+
// Register a Node-API module:
|
|
204
|
+
STDLIB_MATH_BASE_NAPI_MODULE_DIII_D( add );
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
The macro expects the following arguments:
|
|
208
|
+
|
|
209
|
+
- **fcn**: `double (*fcn)( double, int32_t, int32_t, int32_t )` quaternary function.
|
|
210
|
+
|
|
211
|
+
When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration.
|
|
212
|
+
|
|
213
|
+
#### stdlib_math_base_napi_diii_d( env, info, fcn )
|
|
214
|
+
|
|
215
|
+
Invokes a quaternary function accepting a double-precision floating-point number and three signed 32-bit integers and returning a double-precision floating-point number.
|
|
172
216
|
|
|
173
217
|
```c
|
|
174
218
|
#include <node_api.h>
|
|
175
219
|
|
|
176
220
|
// ...
|
|
177
221
|
|
|
178
|
-
static
|
|
222
|
+
static double add( const double x, const int32_t y, const int32_t z, const int32_t w ) {
|
|
179
223
|
return x + y + z + w;
|
|
180
224
|
}
|
|
181
225
|
|
|
@@ -189,7 +233,7 @@ static float addf( const float x, const float y, const float z, const float w )
|
|
|
189
233
|
* @return Node-API value
|
|
190
234
|
*/
|
|
191
235
|
napi_value addon( napi_env env, napi_callback_info info ) {
|
|
192
|
-
return
|
|
236
|
+
return stdlib_math_base_napi_diii_d( env, info, add );
|
|
193
237
|
}
|
|
194
238
|
|
|
195
239
|
// ...
|
|
@@ -199,53 +243,71 @@ The function accepts the following arguments:
|
|
|
199
243
|
|
|
200
244
|
- **env**: `[in] napi_env` environment under which the function is invoked.
|
|
201
245
|
- **info**: `[in] napi_callback_info` callback data.
|
|
202
|
-
- **fcn**: `[in]
|
|
246
|
+
- **fcn**: `[in] double (*fcn)( double, int32_t, int32_t, int32_t )` quaternary function.
|
|
203
247
|
|
|
204
248
|
```c
|
|
205
|
-
void
|
|
249
|
+
void stdlib_math_base_napi_diii_d( napi_env env, napi_callback_info info, double (*fcn)( double, int32_t, int32_t, int32_t ) );
|
|
206
250
|
```
|
|
207
251
|
|
|
208
|
-
####
|
|
252
|
+
#### STDLIB_MATH_BASE_NAPI_MODULE_FFFF_F( fcn )
|
|
209
253
|
|
|
210
|
-
Macro for registering a Node-API module exporting an interface for invoking a quaternary function accepting and returning
|
|
254
|
+
Macro for registering a Node-API module exporting an interface for invoking a quaternary function accepting and returning single-precision floating-point numbers.
|
|
211
255
|
|
|
212
256
|
```c
|
|
213
|
-
static
|
|
257
|
+
static float addf( const float x, const float y, const float z, const float w ) {
|
|
214
258
|
return x + y + z + w;
|
|
215
259
|
}
|
|
216
260
|
|
|
217
261
|
// ...
|
|
218
262
|
|
|
219
263
|
// Register a Node-API module:
|
|
220
|
-
|
|
264
|
+
STDLIB_MATH_BASE_NAPI_MODULE_FFFF_F( addf );
|
|
221
265
|
```
|
|
222
266
|
|
|
223
267
|
The macro expects the following arguments:
|
|
224
268
|
|
|
225
|
-
- **fcn**: `
|
|
269
|
+
- **fcn**: `float (*fcn)( float, float, float, float )` quaternary function.
|
|
226
270
|
|
|
227
271
|
When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration.
|
|
228
272
|
|
|
229
|
-
####
|
|
273
|
+
#### stdlib_math_base_napi_ffff_f( env, info, fcn )
|
|
230
274
|
|
|
231
|
-
|
|
275
|
+
Invokes a quaternary function accepting and returning single-precision floating-point numbers.
|
|
232
276
|
|
|
233
277
|
```c
|
|
278
|
+
#include <node_api.h>
|
|
279
|
+
|
|
280
|
+
// ...
|
|
281
|
+
|
|
234
282
|
static float addf( const float x, const float y, const float z, const float w ) {
|
|
235
283
|
return x + y + z + w;
|
|
236
284
|
}
|
|
237
285
|
|
|
238
286
|
// ...
|
|
239
287
|
|
|
240
|
-
|
|
241
|
-
|
|
288
|
+
/**
|
|
289
|
+
* Receives JavaScript callback invocation data.
|
|
290
|
+
*
|
|
291
|
+
* @param env environment under which the function is invoked
|
|
292
|
+
* @param info callback data
|
|
293
|
+
* @return Node-API value
|
|
294
|
+
*/
|
|
295
|
+
napi_value addon( napi_env env, napi_callback_info info ) {
|
|
296
|
+
return stdlib_math_base_napi_ffff_f( env, info, addf );
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
// ...
|
|
242
300
|
```
|
|
243
301
|
|
|
244
|
-
The
|
|
302
|
+
The function accepts the following arguments:
|
|
245
303
|
|
|
246
|
-
- **
|
|
304
|
+
- **env**: `[in] napi_env` environment under which the function is invoked.
|
|
305
|
+
- **info**: `[in] napi_callback_info` callback data.
|
|
306
|
+
- **fcn**: `[in] float (*fcn)( float, float, float, float )` quaternary function.
|
|
247
307
|
|
|
248
|
-
|
|
308
|
+
```c
|
|
309
|
+
void stdlib_math_base_napi_ffff_f( napi_env env, napi_callback_info info, float (*fcn)( float, float, float, float ) );
|
|
310
|
+
```
|
|
249
311
|
|
|
250
312
|
</section>
|
|
251
313
|
|
|
@@ -322,7 +384,7 @@ See [LICENSE][stdlib-license].
|
|
|
322
384
|
|
|
323
385
|
## Copyright
|
|
324
386
|
|
|
325
|
-
Copyright © 2016-
|
|
387
|
+
Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors].
|
|
326
388
|
|
|
327
389
|
</section>
|
|
328
390
|
|
|
@@ -335,8 +397,8 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors].
|
|
|
335
397
|
[npm-image]: http://img.shields.io/npm/v/@stdlib/math-base-napi-quaternary.svg
|
|
336
398
|
[npm-url]: https://npmjs.org/package/@stdlib/math-base-napi-quaternary
|
|
337
399
|
|
|
338
|
-
[test-image]: https://github.com/stdlib-js/math-base-napi-quaternary/actions/workflows/test.yml/badge.svg?branch=v0.2.
|
|
339
|
-
[test-url]: https://github.com/stdlib-js/math-base-napi-quaternary/actions/workflows/test.yml?query=branch:v0.2.
|
|
400
|
+
[test-image]: https://github.com/stdlib-js/math-base-napi-quaternary/actions/workflows/test.yml/badge.svg?branch=v0.2.3
|
|
401
|
+
[test-url]: https://github.com/stdlib-js/math-base-napi-quaternary/actions/workflows/test.yml?query=branch:v0.2.3
|
|
340
402
|
|
|
341
403
|
[coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/math-base-napi-quaternary/main.svg
|
|
342
404
|
[coverage-url]: https://codecov.io/github/stdlib-js/math-base-napi-quaternary?branch=main
|
|
@@ -348,8 +410,8 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors].
|
|
|
348
410
|
|
|
349
411
|
-->
|
|
350
412
|
|
|
351
|
-
[chat-image]: https://img.shields.io/
|
|
352
|
-
[chat-url]: https://
|
|
413
|
+
[chat-image]: https://img.shields.io/badge/zulip-join_chat-brightgreen.svg
|
|
414
|
+
[chat-url]: https://stdlib.zulipchat.com
|
|
353
415
|
|
|
354
416
|
[stdlib]: https://github.com/stdlib-js/stdlib
|
|
355
417
|
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Apache-2.0
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2025 The Stdlib Authors.
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
#ifndef STDLIB_MATH_BASE_NAPI_QUATERNARY_DDDD_D_H
|
|
20
|
+
#define STDLIB_MATH_BASE_NAPI_QUATERNARY_DDDD_D_H
|
|
21
|
+
|
|
22
|
+
#include <node_api.h>
|
|
23
|
+
#include <assert.h>
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Macro for registering a Node-API module exporting an interface invoking a quaternary function accepting and returning double-precision floating-point numbers.
|
|
27
|
+
*
|
|
28
|
+
* @param fcn quaternary function
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* static double add( const double x, const double y, const double z, const double w ) {
|
|
32
|
+
* return x + y + z + w;
|
|
33
|
+
* }
|
|
34
|
+
*
|
|
35
|
+
* // ...
|
|
36
|
+
*
|
|
37
|
+
* // Register a Node-API module:
|
|
38
|
+
* STDLIB_MATH_BASE_NAPI_MODULE_DDDD_D( add );
|
|
39
|
+
*/
|
|
40
|
+
#define STDLIB_MATH_BASE_NAPI_MODULE_DDDD_D( fcn ) \
|
|
41
|
+
static napi_value stdlib_math_base_napi_dddd_d_wrapper( \
|
|
42
|
+
napi_env env, \
|
|
43
|
+
napi_callback_info info \
|
|
44
|
+
) { \
|
|
45
|
+
return stdlib_math_base_napi_dddd_d( env, info, fcn ); \
|
|
46
|
+
}; \
|
|
47
|
+
static napi_value stdlib_math_base_napi_dddd_d_init( \
|
|
48
|
+
napi_env env, \
|
|
49
|
+
napi_value exports \
|
|
50
|
+
) { \
|
|
51
|
+
napi_value f; \
|
|
52
|
+
napi_status status = napi_create_function( \
|
|
53
|
+
env, \
|
|
54
|
+
"exports", \
|
|
55
|
+
NAPI_AUTO_LENGTH, \
|
|
56
|
+
stdlib_math_base_napi_dddd_d_wrapper, \
|
|
57
|
+
NULL, \
|
|
58
|
+
&f \
|
|
59
|
+
); \
|
|
60
|
+
assert( status == napi_ok ); \
|
|
61
|
+
return f; \
|
|
62
|
+
}; \
|
|
63
|
+
NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_dddd_d_init )
|
|
64
|
+
|
|
65
|
+
/*
|
|
66
|
+
* If C++, prevent name mangling so that the compiler emits a quaternary file having undecorated names, thus mirroring the behavior of a C compiler.
|
|
67
|
+
*/
|
|
68
|
+
#ifdef __cplusplus
|
|
69
|
+
extern "C" {
|
|
70
|
+
#endif
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Invokes a quaternary function accepting and returning double-precision floating-point numbers.
|
|
74
|
+
*/
|
|
75
|
+
napi_value stdlib_math_base_napi_dddd_d( napi_env env, napi_callback_info info, double (*fcn)( double, double, double, double ) );
|
|
76
|
+
|
|
77
|
+
#ifdef __cplusplus
|
|
78
|
+
}
|
|
79
|
+
#endif
|
|
80
|
+
|
|
81
|
+
#endif // !STDLIB_MATH_BASE_NAPI_QUATERNARY_DDDD_D_H
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Apache-2.0
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2025 The Stdlib Authors.
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
#ifndef STDLIB_MATH_BASE_NAPI_QUATERNARY_DIII_D_H
|
|
20
|
+
#define STDLIB_MATH_BASE_NAPI_QUATERNARY_DIII_D_H
|
|
21
|
+
|
|
22
|
+
#include <node_api.h>
|
|
23
|
+
#include <assert.h>
|
|
24
|
+
#include <stdint.h>
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Macro for registering a Node-API module exporting an interface invoking a quaternary function accepting a double-precision floating-point number and three signed 32-bit integers and returning a double-precision floating-point number.
|
|
28
|
+
*
|
|
29
|
+
* @param fcn quaternary function
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* #include <stdint.h>
|
|
33
|
+
*
|
|
34
|
+
* static double add( const double x, const int32_t y, const int32_t z, const int32_t w ) {
|
|
35
|
+
* return x + y + z + w;
|
|
36
|
+
* }
|
|
37
|
+
*
|
|
38
|
+
* // ...
|
|
39
|
+
*
|
|
40
|
+
* // Register a Node-API module:
|
|
41
|
+
* STDLIB_MATH_BASE_NAPI_MODULE_DIII_D( add );
|
|
42
|
+
*/
|
|
43
|
+
#define STDLIB_MATH_BASE_NAPI_MODULE_DIII_D( fcn ) \
|
|
44
|
+
static napi_value stdlib_math_base_napi_diii_d_wrapper( \
|
|
45
|
+
napi_env env, \
|
|
46
|
+
napi_callback_info info \
|
|
47
|
+
) { \
|
|
48
|
+
return stdlib_math_base_napi_diii_d( env, info, fcn ); \
|
|
49
|
+
}; \
|
|
50
|
+
static napi_value stdlib_math_base_napi_diii_d_init( \
|
|
51
|
+
napi_env env, \
|
|
52
|
+
napi_value exports \
|
|
53
|
+
) { \
|
|
54
|
+
napi_value f; \
|
|
55
|
+
napi_status status = napi_create_function( \
|
|
56
|
+
env, \
|
|
57
|
+
"exports", \
|
|
58
|
+
NAPI_AUTO_LENGTH, \
|
|
59
|
+
stdlib_math_base_napi_diii_d_wrapper, \
|
|
60
|
+
NULL, \
|
|
61
|
+
&f \
|
|
62
|
+
); \
|
|
63
|
+
assert( status == napi_ok ); \
|
|
64
|
+
return f; \
|
|
65
|
+
}; \
|
|
66
|
+
NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_diii_d_init )
|
|
67
|
+
|
|
68
|
+
/*
|
|
69
|
+
* If C++, prevent name mangling so that the compiler emits a quaternary file having undecorated names, thus mirroring the behavior of a C compiler.
|
|
70
|
+
*/
|
|
71
|
+
#ifdef __cplusplus
|
|
72
|
+
extern "C" {
|
|
73
|
+
#endif
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Invokes a quaternary function accepting a double-precision floating-point number and three signed 32-bit integers and returning a double-precision floating-point number.
|
|
77
|
+
*/
|
|
78
|
+
napi_value stdlib_math_base_napi_diii_d( napi_env env, napi_callback_info info, double (*fcn)( double, int32_t, int32_t, int32_t ) );
|
|
79
|
+
|
|
80
|
+
#ifdef __cplusplus
|
|
81
|
+
}
|
|
82
|
+
#endif
|
|
83
|
+
|
|
84
|
+
#endif // !STDLIB_MATH_BASE_NAPI_QUATERNARY_DIII_D_H
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Apache-2.0
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2025 The Stdlib Authors.
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
#ifndef STDLIB_MATH_BASE_NAPI_QUATERNARY_FFFF_F_H
|
|
20
|
+
#define STDLIB_MATH_BASE_NAPI_QUATERNARY_FFFF_F_H
|
|
21
|
+
|
|
22
|
+
#include <node_api.h>
|
|
23
|
+
#include <assert.h>
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Macro for registering a Node-API module exporting an interface invoking a quaternary function accepting and returning single-precision floating-point numbers.
|
|
27
|
+
*
|
|
28
|
+
* @param fcn quaternary function
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* static float addf( const float x, const float y, const float z, const float w ) {
|
|
32
|
+
* return x + y + z + w;
|
|
33
|
+
* }
|
|
34
|
+
*
|
|
35
|
+
* // ...
|
|
36
|
+
*
|
|
37
|
+
* // Register a Node-API module:
|
|
38
|
+
* STDLIB_MATH_BASE_NAPI_MODULE_FFFF_F( addf );
|
|
39
|
+
*/
|
|
40
|
+
#define STDLIB_MATH_BASE_NAPI_MODULE_FFFF_F( fcn ) \
|
|
41
|
+
static napi_value stdlib_math_base_napi_ffff_f_wrapper( \
|
|
42
|
+
napi_env env, \
|
|
43
|
+
napi_callback_info info \
|
|
44
|
+
) { \
|
|
45
|
+
return stdlib_math_base_napi_ffff_f( env, info, fcn ); \
|
|
46
|
+
}; \
|
|
47
|
+
static napi_value stdlib_math_base_napi_ffff_f_init( \
|
|
48
|
+
napi_env env, \
|
|
49
|
+
napi_value exports \
|
|
50
|
+
) { \
|
|
51
|
+
napi_value f; \
|
|
52
|
+
napi_status status = napi_create_function( \
|
|
53
|
+
env, \
|
|
54
|
+
"exports", \
|
|
55
|
+
NAPI_AUTO_LENGTH, \
|
|
56
|
+
stdlib_math_base_napi_ffff_f_wrapper, \
|
|
57
|
+
NULL, \
|
|
58
|
+
&f \
|
|
59
|
+
); \
|
|
60
|
+
assert( status == napi_ok ); \
|
|
61
|
+
return f; \
|
|
62
|
+
}; \
|
|
63
|
+
NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_ffff_f_init )
|
|
64
|
+
|
|
65
|
+
/*
|
|
66
|
+
* If C++, prevent name mangling so that the compiler emits a quaternary file having undecorated names, thus mirroring the behavior of a C compiler.
|
|
67
|
+
*/
|
|
68
|
+
#ifdef __cplusplus
|
|
69
|
+
extern "C" {
|
|
70
|
+
#endif
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Invokes a quaternary function accepting and returning single-precision floating-point numbers.
|
|
74
|
+
*/
|
|
75
|
+
napi_value stdlib_math_base_napi_ffff_f( napi_env env, napi_callback_info info, float (*fcn)( float, float, float, float ) );
|
|
76
|
+
|
|
77
|
+
#ifdef __cplusplus
|
|
78
|
+
}
|
|
79
|
+
#endif
|
|
80
|
+
|
|
81
|
+
#endif // !STDLIB_MATH_BASE_NAPI_QUATERNARY_FFFF_F_H
|
|
@@ -19,108 +19,9 @@
|
|
|
19
19
|
#ifndef STDLIB_MATH_BASE_NAPI_QUATERNARY_H
|
|
20
20
|
#define STDLIB_MATH_BASE_NAPI_QUATERNARY_H
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
#include
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
* Macro for registering a Node-API module exporting an interface invoking a quaternary function accepting and returning double-precision floating-point numbers.
|
|
27
|
-
*
|
|
28
|
-
* @param fcn quaternary function
|
|
29
|
-
*
|
|
30
|
-
* @example
|
|
31
|
-
* static double add( const double x, const double y, const double z, const double w ) {
|
|
32
|
-
* return x + y + z + w;
|
|
33
|
-
* }
|
|
34
|
-
*
|
|
35
|
-
* // ...
|
|
36
|
-
*
|
|
37
|
-
* // Register a Node-API module:
|
|
38
|
-
* STDLIB_MATH_BASE_NAPI_MODULE_DDDD_D( add );
|
|
39
|
-
*/
|
|
40
|
-
#define STDLIB_MATH_BASE_NAPI_MODULE_DDDD_D( fcn ) \
|
|
41
|
-
static napi_value stdlib_math_base_napi_dddd_d_wrapper( \
|
|
42
|
-
napi_env env, \
|
|
43
|
-
napi_callback_info info \
|
|
44
|
-
) { \
|
|
45
|
-
return stdlib_math_base_napi_dddd_d( env, info, fcn ); \
|
|
46
|
-
}; \
|
|
47
|
-
static napi_value stdlib_math_base_napi_dddd_d_init( \
|
|
48
|
-
napi_env env, \
|
|
49
|
-
napi_value exports \
|
|
50
|
-
) { \
|
|
51
|
-
napi_value fcn; \
|
|
52
|
-
napi_status status = napi_create_function( \
|
|
53
|
-
env, \
|
|
54
|
-
"exports", \
|
|
55
|
-
NAPI_AUTO_LENGTH, \
|
|
56
|
-
stdlib_math_base_napi_dddd_d_wrapper, \
|
|
57
|
-
NULL, \
|
|
58
|
-
&fcn \
|
|
59
|
-
); \
|
|
60
|
-
assert( status == napi_ok ); \
|
|
61
|
-
return fcn; \
|
|
62
|
-
}; \
|
|
63
|
-
NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_dddd_d_init )
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Macro for registering a Node-API module exporting an interface invoking a quaternary function accepting and returning single-precision floating-point numbers.
|
|
67
|
-
*
|
|
68
|
-
* @param fcn quaternary function
|
|
69
|
-
*
|
|
70
|
-
* @example
|
|
71
|
-
* static float addf( const float x, const float y, const float z, const float w ) {
|
|
72
|
-
* return x + y + z + w;
|
|
73
|
-
* }
|
|
74
|
-
*
|
|
75
|
-
* // ...
|
|
76
|
-
*
|
|
77
|
-
* // Register a Node-API module:
|
|
78
|
-
* STDLIB_MATH_BASE_NAPI_MODULE_FFFF_F( addf );
|
|
79
|
-
*/
|
|
80
|
-
#define STDLIB_MATH_BASE_NAPI_MODULE_FFFF_F( fcn ) \
|
|
81
|
-
static napi_value stdlib_math_base_napi_ffff_f_wrapper( \
|
|
82
|
-
napi_env env, \
|
|
83
|
-
napi_callback_info info \
|
|
84
|
-
) { \
|
|
85
|
-
return stdlib_math_base_napi_ffff_f( env, info, fcn ); \
|
|
86
|
-
}; \
|
|
87
|
-
static napi_value stdlib_math_base_napi_ffff_f_init( \
|
|
88
|
-
napi_env env, \
|
|
89
|
-
napi_value exports \
|
|
90
|
-
) { \
|
|
91
|
-
napi_value fcn; \
|
|
92
|
-
napi_status status = napi_create_function( \
|
|
93
|
-
env, \
|
|
94
|
-
"exports", \
|
|
95
|
-
NAPI_AUTO_LENGTH, \
|
|
96
|
-
stdlib_math_base_napi_ffff_f_wrapper, \
|
|
97
|
-
NULL, \
|
|
98
|
-
&fcn \
|
|
99
|
-
); \
|
|
100
|
-
assert( status == napi_ok ); \
|
|
101
|
-
return fcn; \
|
|
102
|
-
}; \
|
|
103
|
-
NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_ffff_f_init )
|
|
104
|
-
|
|
105
|
-
/*
|
|
106
|
-
* If C++, prevent name mangling so that the compiler emits a quaternary file having undecorated names, thus mirroring the behavior of a C compiler.
|
|
107
|
-
*/
|
|
108
|
-
#ifdef __cplusplus
|
|
109
|
-
extern "C" {
|
|
110
|
-
#endif
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* Invokes a quaternary function accepting and returning double-precision floating-point numbers.
|
|
114
|
-
*/
|
|
115
|
-
napi_value stdlib_math_base_napi_dddd_d( napi_env env, napi_callback_info info, double (*fcn)( double, double, double, double ) );
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* Invokes a quaternary function accepting and returning single-precision floating-point numbers.
|
|
119
|
-
*/
|
|
120
|
-
napi_value stdlib_math_base_napi_ffff_f( napi_env env, napi_callback_info info, float (*fcn)( float, float, float, float ) );
|
|
121
|
-
|
|
122
|
-
#ifdef __cplusplus
|
|
123
|
-
}
|
|
124
|
-
#endif
|
|
22
|
+
// NOTE: keep in alphabetical order...
|
|
23
|
+
#include "stdlib/math/base/napi/quaternary/dddd_d.h"
|
|
24
|
+
#include "stdlib/math/base/napi/quaternary/diii_d.h"
|
|
25
|
+
#include "stdlib/math/base/napi/quaternary/ffff_f.h"
|
|
125
26
|
|
|
126
27
|
#endif // !STDLIB_MATH_BASE_NAPI_QUATERNARY_H
|
package/manifest.json
CHANGED
|
@@ -1,38 +1,40 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
2
|
+
"options": {},
|
|
3
|
+
"fields": [
|
|
4
|
+
{
|
|
5
|
+
"field": "src",
|
|
6
|
+
"resolve": true,
|
|
7
|
+
"relative": true
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
"field": "include",
|
|
11
|
+
"resolve": true,
|
|
12
|
+
"relative": true
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"field": "libraries",
|
|
16
|
+
"resolve": false,
|
|
17
|
+
"relative": false
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"field": "libpath",
|
|
21
|
+
"resolve": true,
|
|
22
|
+
"relative": false
|
|
23
|
+
}
|
|
24
|
+
],
|
|
25
|
+
"confs": [
|
|
26
|
+
{
|
|
27
|
+
"src": [
|
|
28
|
+
"./src/dddd_d.c",
|
|
29
|
+
"./src/diii_d.c",
|
|
30
|
+
"./src/ffff_f.c"
|
|
31
|
+
],
|
|
32
|
+
"include": [
|
|
33
|
+
"./include"
|
|
34
|
+
],
|
|
35
|
+
"libraries": [],
|
|
36
|
+
"libpath": [],
|
|
37
|
+
"dependencies": []
|
|
38
|
+
}
|
|
39
|
+
]
|
|
38
40
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stdlib/math-base-napi-quaternary",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"description": "C APIs for registering a Node-API module exporting an interface for invoking a quaternary numerical function.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": {
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"url": "https://github.com/stdlib-js/stdlib/issues"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@stdlib/utils-library-manifest": "^0.2.
|
|
37
|
+
"@stdlib/utils-library-manifest": "^0.2.2"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {},
|
|
40
40
|
"engines": {
|
package/src/addon.c
CHANGED
package/src/dddd_d.c
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Apache-2.0
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2025 The Stdlib Authors.
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
#include "stdlib/math/base/napi/quaternary/dddd_d.h"
|
|
20
|
+
#include <node_api.h>
|
|
21
|
+
#include <assert.h>
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Invokes a quaternary function accepting and returning double-precision floating-point numbers.
|
|
25
|
+
*
|
|
26
|
+
* ## Notes
|
|
27
|
+
*
|
|
28
|
+
* - This function expects that the callback `info` argument provides access to the following JavaScript arguments:
|
|
29
|
+
*
|
|
30
|
+
* - `x`: input value.
|
|
31
|
+
* - `y`: input value.
|
|
32
|
+
* - `z`: input value.
|
|
33
|
+
* - `w`: input value.
|
|
34
|
+
*
|
|
35
|
+
* @param env environment under which the function is invoked
|
|
36
|
+
* @param info callback data
|
|
37
|
+
* @param fcn quaternary function
|
|
38
|
+
* @return function return value as a Node-API double-precision floating-point number
|
|
39
|
+
*/
|
|
40
|
+
napi_value stdlib_math_base_napi_dddd_d( napi_env env, napi_callback_info info, double (*fcn)( double, double, double, double ) ) {
|
|
41
|
+
napi_status status;
|
|
42
|
+
|
|
43
|
+
size_t argc = 4;
|
|
44
|
+
napi_value argv[ 4 ];
|
|
45
|
+
status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL );
|
|
46
|
+
assert( status == napi_ok );
|
|
47
|
+
|
|
48
|
+
if ( argc < 4 ) {
|
|
49
|
+
status = napi_throw_error( env, NULL, "invalid invocation. Must provide four numbers." );
|
|
50
|
+
assert( status == napi_ok );
|
|
51
|
+
return NULL;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
napi_valuetype vtype0;
|
|
55
|
+
status = napi_typeof( env, argv[ 0 ], &vtype0 );
|
|
56
|
+
assert( status == napi_ok );
|
|
57
|
+
if ( vtype0 != napi_number ) {
|
|
58
|
+
status = napi_throw_type_error( env, NULL, "invalid argument. First argument must be a number." );
|
|
59
|
+
assert( status == napi_ok );
|
|
60
|
+
return NULL;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
napi_valuetype vtype1;
|
|
64
|
+
status = napi_typeof( env, argv[ 1 ], &vtype1 );
|
|
65
|
+
assert( status == napi_ok );
|
|
66
|
+
if ( vtype1 != napi_number ) {
|
|
67
|
+
status = napi_throw_type_error( env, NULL, "invalid argument. Second argument must be a number." );
|
|
68
|
+
assert( status == napi_ok );
|
|
69
|
+
return NULL;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
napi_valuetype vtype2;
|
|
73
|
+
status = napi_typeof( env, argv[ 2 ], &vtype2 );
|
|
74
|
+
assert( status == napi_ok );
|
|
75
|
+
if ( vtype2 != napi_number ) {
|
|
76
|
+
status = napi_throw_type_error( env, NULL, "invalid argument. Third argument must be a number." );
|
|
77
|
+
assert( status == napi_ok );
|
|
78
|
+
return NULL;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
napi_valuetype vtype3;
|
|
82
|
+
status = napi_typeof( env, argv[ 3 ], &vtype3 );
|
|
83
|
+
assert( status == napi_ok );
|
|
84
|
+
if ( vtype3 != napi_number ) {
|
|
85
|
+
status = napi_throw_type_error( env, NULL, "invalid argument. Fourth argument must be a number." );
|
|
86
|
+
assert( status == napi_ok );
|
|
87
|
+
return NULL;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
double x;
|
|
91
|
+
status = napi_get_value_double( env, argv[ 0 ], &x );
|
|
92
|
+
assert( status == napi_ok );
|
|
93
|
+
|
|
94
|
+
double y;
|
|
95
|
+
status = napi_get_value_double( env, argv[ 1 ], &y );
|
|
96
|
+
assert( status == napi_ok );
|
|
97
|
+
|
|
98
|
+
double z;
|
|
99
|
+
status = napi_get_value_double( env, argv[ 2 ], &z );
|
|
100
|
+
assert( status == napi_ok );
|
|
101
|
+
|
|
102
|
+
double w;
|
|
103
|
+
status = napi_get_value_double( env, argv[ 3 ], &w );
|
|
104
|
+
assert( status == napi_ok );
|
|
105
|
+
|
|
106
|
+
napi_value v;
|
|
107
|
+
status = napi_create_double( env, fcn( x, y, z, w ), &v );
|
|
108
|
+
assert( status == napi_ok );
|
|
109
|
+
|
|
110
|
+
return v;
|
|
111
|
+
}
|
package/src/diii_d.c
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Apache-2.0
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2025 The Stdlib Authors.
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
#include "stdlib/math/base/napi/quaternary/diii_d.h"
|
|
20
|
+
#include <node_api.h>
|
|
21
|
+
#include <assert.h>
|
|
22
|
+
#include <stdint.h>
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Invokes a quaternary function accepting a double-precision floating-point number and three signed 32-bit integers and returning a double-precision floating-point number.
|
|
26
|
+
*
|
|
27
|
+
* ## Notes
|
|
28
|
+
*
|
|
29
|
+
* - This function expects that the callback `info` argument provides access to the following JavaScript arguments:
|
|
30
|
+
*
|
|
31
|
+
* - `x`: input value.
|
|
32
|
+
* - `y`: input value.
|
|
33
|
+
* - `z`: input value.
|
|
34
|
+
* - `w`: input value.
|
|
35
|
+
*
|
|
36
|
+
* @param env environment under which the function is invoked
|
|
37
|
+
* @param info callback data
|
|
38
|
+
* @param fcn quaternary function
|
|
39
|
+
* @return function return value as a Node-API double-precision floating-point number
|
|
40
|
+
*/
|
|
41
|
+
napi_value stdlib_math_base_napi_diii_d( napi_env env, napi_callback_info info, double (*fcn)( double, int32_t, int32_t, int32_t ) ) {
|
|
42
|
+
napi_status status;
|
|
43
|
+
|
|
44
|
+
size_t argc = 4;
|
|
45
|
+
napi_value argv[ 4 ];
|
|
46
|
+
status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL );
|
|
47
|
+
assert( status == napi_ok );
|
|
48
|
+
|
|
49
|
+
if ( argc < 4 ) {
|
|
50
|
+
status = napi_throw_error( env, NULL, "invalid invocation. Must provide four numbers." );
|
|
51
|
+
assert( status == napi_ok );
|
|
52
|
+
return NULL;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
napi_valuetype vtype0;
|
|
56
|
+
status = napi_typeof( env, argv[ 0 ], &vtype0 );
|
|
57
|
+
assert( status == napi_ok );
|
|
58
|
+
if ( vtype0 != napi_number ) {
|
|
59
|
+
status = napi_throw_type_error( env, NULL, "invalid argument. First argument must be a number." );
|
|
60
|
+
assert( status == napi_ok );
|
|
61
|
+
return NULL;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
napi_valuetype vtype1;
|
|
65
|
+
status = napi_typeof( env, argv[ 1 ], &vtype1 );
|
|
66
|
+
assert( status == napi_ok );
|
|
67
|
+
if ( vtype1 != napi_number ) {
|
|
68
|
+
status = napi_throw_type_error( env, NULL, "invalid argument. Second argument must be a number." );
|
|
69
|
+
assert( status == napi_ok );
|
|
70
|
+
return NULL;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
napi_valuetype vtype2;
|
|
74
|
+
status = napi_typeof( env, argv[ 2 ], &vtype2 );
|
|
75
|
+
assert( status == napi_ok );
|
|
76
|
+
if ( vtype2 != napi_number ) {
|
|
77
|
+
status = napi_throw_type_error( env, NULL, "invalid argument. Third argument must be a number." );
|
|
78
|
+
assert( status == napi_ok );
|
|
79
|
+
return NULL;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
napi_valuetype vtype3;
|
|
83
|
+
status = napi_typeof( env, argv[ 3 ], &vtype3 );
|
|
84
|
+
assert( status == napi_ok );
|
|
85
|
+
if ( vtype3 != napi_number ) {
|
|
86
|
+
status = napi_throw_type_error( env, NULL, "invalid argument. Fourth argument must be a number." );
|
|
87
|
+
assert( status == napi_ok );
|
|
88
|
+
return NULL;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
double x;
|
|
92
|
+
status = napi_get_value_double( env, argv[ 0 ], &x );
|
|
93
|
+
assert( status == napi_ok );
|
|
94
|
+
|
|
95
|
+
int32_t y;
|
|
96
|
+
status = napi_get_value_int32( env, argv[ 1 ], &y );
|
|
97
|
+
assert( status == napi_ok );
|
|
98
|
+
|
|
99
|
+
int32_t z;
|
|
100
|
+
status = napi_get_value_int32( env, argv[ 2 ], &z );
|
|
101
|
+
assert( status == napi_ok );
|
|
102
|
+
|
|
103
|
+
int32_t w;
|
|
104
|
+
status = napi_get_value_int32( env, argv[ 3 ], &w );
|
|
105
|
+
assert( status == napi_ok );
|
|
106
|
+
|
|
107
|
+
napi_value v;
|
|
108
|
+
status = napi_create_double( env, fcn( x, y, z, w ), &v );
|
|
109
|
+
assert( status == napi_ok );
|
|
110
|
+
|
|
111
|
+
return v;
|
|
112
|
+
}
|
package/src/{main.c → ffff_f.c}
RENAMED
|
@@ -16,101 +16,10 @@
|
|
|
16
16
|
* limitations under the License.
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
|
-
#include "stdlib/math/base/napi/quaternary.h"
|
|
19
|
+
#include "stdlib/math/base/napi/quaternary/ffff_f.h"
|
|
20
20
|
#include <node_api.h>
|
|
21
|
-
#include <stdint.h>
|
|
22
21
|
#include <assert.h>
|
|
23
22
|
|
|
24
|
-
/**
|
|
25
|
-
* Invokes a quaternary function accepting and returning double-precision floating-point numbers.
|
|
26
|
-
*
|
|
27
|
-
* ## Notes
|
|
28
|
-
*
|
|
29
|
-
* - This function expects that the callback `info` argument provides access to the following JavaScript arguments:
|
|
30
|
-
*
|
|
31
|
-
* - `x`: input value.
|
|
32
|
-
* - `y`: input value.
|
|
33
|
-
* - `z`: input value.
|
|
34
|
-
* - `w`: input value.
|
|
35
|
-
*
|
|
36
|
-
* @param env environment under which the function is invoked
|
|
37
|
-
* @param info callback data
|
|
38
|
-
* @param fcn quaternary function
|
|
39
|
-
* @return function return value as a Node-API double-precision floating-point number
|
|
40
|
-
*/
|
|
41
|
-
napi_value stdlib_math_base_napi_dddd_d( napi_env env, napi_callback_info info, double (*fcn)( double, double, double, double ) ) {
|
|
42
|
-
napi_status status;
|
|
43
|
-
|
|
44
|
-
size_t argc = 4;
|
|
45
|
-
napi_value argv[ 4 ];
|
|
46
|
-
status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL );
|
|
47
|
-
assert( status == napi_ok );
|
|
48
|
-
|
|
49
|
-
if ( argc < 4 ) {
|
|
50
|
-
status = napi_throw_error( env, NULL, "invalid invocation. Must provide four numbers." );
|
|
51
|
-
assert( status == napi_ok );
|
|
52
|
-
return NULL;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
napi_valuetype vtype0;
|
|
56
|
-
status = napi_typeof( env, argv[ 0 ], &vtype0 );
|
|
57
|
-
assert( status == napi_ok );
|
|
58
|
-
if ( vtype0 != napi_number ) {
|
|
59
|
-
status = napi_throw_type_error( env, NULL, "invalid argument. First argument must be a number." );
|
|
60
|
-
assert( status == napi_ok );
|
|
61
|
-
return NULL;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
napi_valuetype vtype1;
|
|
65
|
-
status = napi_typeof( env, argv[ 1 ], &vtype1 );
|
|
66
|
-
assert( status == napi_ok );
|
|
67
|
-
if ( vtype1 != napi_number ) {
|
|
68
|
-
status = napi_throw_type_error( env, NULL, "invalid argument. Second argument must be a number." );
|
|
69
|
-
assert( status == napi_ok );
|
|
70
|
-
return NULL;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
napi_valuetype vtype2;
|
|
74
|
-
status = napi_typeof( env, argv[ 2 ], &vtype2 );
|
|
75
|
-
assert( status == napi_ok );
|
|
76
|
-
if ( vtype2 != napi_number ) {
|
|
77
|
-
status = napi_throw_type_error( env, NULL, "invalid argument. Third argument must be a number." );
|
|
78
|
-
assert( status == napi_ok );
|
|
79
|
-
return NULL;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
napi_valuetype vtype3;
|
|
83
|
-
status = napi_typeof( env, argv[ 3 ], &vtype3 );
|
|
84
|
-
assert( status == napi_ok );
|
|
85
|
-
if ( vtype3 != napi_number ) {
|
|
86
|
-
status = napi_throw_type_error( env, NULL, "invalid argument. Fourth argument must be a number." );
|
|
87
|
-
assert( status == napi_ok );
|
|
88
|
-
return NULL;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
double x;
|
|
92
|
-
status = napi_get_value_double( env, argv[ 0 ], &x );
|
|
93
|
-
assert( status == napi_ok );
|
|
94
|
-
|
|
95
|
-
double y;
|
|
96
|
-
status = napi_get_value_double( env, argv[ 1 ], &y );
|
|
97
|
-
assert( status == napi_ok );
|
|
98
|
-
|
|
99
|
-
double z;
|
|
100
|
-
status = napi_get_value_double( env, argv[ 2 ], &z );
|
|
101
|
-
assert( status == napi_ok );
|
|
102
|
-
|
|
103
|
-
double w;
|
|
104
|
-
status = napi_get_value_double( env, argv[ 3 ], &w );
|
|
105
|
-
assert( status == napi_ok );
|
|
106
|
-
|
|
107
|
-
napi_value v;
|
|
108
|
-
status = napi_create_double( env, fcn( x, y, z, w ), &v );
|
|
109
|
-
assert( status == napi_ok );
|
|
110
|
-
|
|
111
|
-
return v;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
23
|
/**
|
|
115
24
|
* Invokes a quaternary function accepting and returning single-precision floating-point numbers.
|
|
116
25
|
*
|