@stdlib/math-base-napi-unary 0.2.3 → 0.2.5

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.
Files changed (40) hide show
  1. package/NOTICE +1 -1
  2. package/README.md +710 -144
  3. package/include/stdlib/math/base/napi/unary/b_b.h +84 -0
  4. package/include/stdlib/math/base/napi/unary/c_c.h +93 -0
  5. package/include/stdlib/math/base/napi/unary/c_f.h +84 -0
  6. package/include/stdlib/math/base/napi/unary/d_d.h +81 -0
  7. package/include/stdlib/math/base/napi/unary/d_f.h +81 -0
  8. package/include/stdlib/math/base/napi/unary/f_f.h +81 -0
  9. package/include/stdlib/math/base/napi/unary/f_i.h +84 -0
  10. package/include/stdlib/math/base/napi/unary/h_h.h +84 -0
  11. package/include/stdlib/math/base/napi/unary/i_d.h +84 -0
  12. package/include/stdlib/math/base/napi/unary/i_f.h +84 -0
  13. package/include/stdlib/math/base/napi/unary/i_i.h +84 -0
  14. package/include/stdlib/math/base/napi/unary/k_k.h +84 -0
  15. package/include/stdlib/math/base/napi/unary/s_s.h +84 -0
  16. package/include/stdlib/math/base/napi/unary/t_t.h +84 -0
  17. package/include/stdlib/math/base/napi/unary/u_u.h +84 -0
  18. package/include/stdlib/math/base/napi/unary/z_d.h +84 -0
  19. package/include/stdlib/math/base/napi/unary/z_z.h +93 -0
  20. package/include/stdlib/math/base/napi/unary.h +18 -406
  21. package/manifest.json +56 -37
  22. package/package.json +8 -10
  23. package/src/b_b.c +71 -0
  24. package/src/c_c.c +129 -0
  25. package/src/c_f.c +109 -0
  26. package/src/d_d.c +69 -0
  27. package/src/d_f.c +69 -0
  28. package/src/f_f.c +69 -0
  29. package/src/f_i.c +70 -0
  30. package/src/h_h.c +74 -0
  31. package/src/i_d.c +70 -0
  32. package/src/i_f.c +70 -0
  33. package/src/i_i.c +70 -0
  34. package/src/k_k.c +70 -0
  35. package/src/s_s.c +71 -0
  36. package/src/t_t.c +70 -0
  37. package/src/u_u.c +70 -0
  38. package/src/z_d.c +109 -0
  39. package/src/z_z.c +129 -0
  40. package/src/main.c +0 -601
@@ -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_UNARY_B_B_H
20
+ #define STDLIB_MATH_BASE_NAPI_UNARY_B_B_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 unary function accepting and returning 8-bit unsigned integers.
28
+ *
29
+ * @param fcn unary function
30
+ *
31
+ * @example
32
+ * #include <stdint.h>
33
+ *
34
+ * static uint8_t scale( const uint8_t x ) {
35
+ * return x * 10;
36
+ * }
37
+ *
38
+ * // ...
39
+ *
40
+ * // Register a Node-API module:
41
+ * STDLIB_MATH_BASE_NAPI_MODULE_B_B( scale );
42
+ */
43
+ #define STDLIB_MATH_BASE_NAPI_MODULE_B_B( fcn ) \
44
+ static napi_value stdlib_math_base_napi_b_b_wrapper( \
45
+ napi_env env, \
46
+ napi_callback_info info \
47
+ ) { \
48
+ return stdlib_math_base_napi_b_b( env, info, fcn ); \
49
+ }; \
50
+ static napi_value stdlib_math_base_napi_b_b_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_b_b_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_b_b_init )
67
+
68
+ /*
69
+ * If C++, prevent name mangling so that the compiler emits a binary 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 unary function accepting and returning unsigned 8-bit integers.
77
+ */
78
+ napi_value stdlib_math_base_napi_b_b( napi_env env, napi_callback_info info, uint8_t (*fcn)( uint8_t ) );
79
+
80
+ #ifdef __cplusplus
81
+ }
82
+ #endif
83
+
84
+ #endif // !STDLIB_MATH_BASE_NAPI_UNARY_B_B_H
@@ -0,0 +1,93 @@
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_UNARY_C_C_H
20
+ #define STDLIB_MATH_BASE_NAPI_UNARY_C_C_H
21
+
22
+ #include "stdlib/complex/float32/ctor.h"
23
+ #include <node_api.h>
24
+ #include <assert.h>
25
+
26
+ /**
27
+ * Macro for registering a Node-API module exporting an interface invoking a unary function accepting and returning single-precision complex floating-point numbers.
28
+ *
29
+ * @param fcn unary function
30
+ *
31
+ * @example
32
+ * #include "stdlib/complex/float32/ctor.h"
33
+ * #include "stdlib/complex/float32/reim.h"
34
+ *
35
+ * static stdlib_complex64_t scale( const stdlib_complex64_t x ) {
36
+ * float re;
37
+ * float im;
38
+ *
39
+ * stdlib_complex64_reim( x, &re, &im );
40
+ *
41
+ * re *= 10.0f;
42
+ * im *= 10.0f;
43
+ *
44
+ * return stdlib_complex64( re, im );
45
+ * }
46
+ *
47
+ * // ...
48
+ *
49
+ * // Register a Node-API module:
50
+ * STDLIB_MATH_BASE_NAPI_MODULE_C_C( scale );
51
+ */
52
+ #define STDLIB_MATH_BASE_NAPI_MODULE_C_C( fcn ) \
53
+ static napi_value stdlib_math_base_napi_c_c_wrapper( \
54
+ napi_env env, \
55
+ napi_callback_info info \
56
+ ) { \
57
+ return stdlib_math_base_napi_c_c( env, info, fcn ); \
58
+ }; \
59
+ static napi_value stdlib_math_base_napi_c_c_init( \
60
+ napi_env env, \
61
+ napi_value exports \
62
+ ) { \
63
+ napi_value f; \
64
+ napi_status status = napi_create_function( \
65
+ env, \
66
+ "exports", \
67
+ NAPI_AUTO_LENGTH, \
68
+ stdlib_math_base_napi_c_c_wrapper, \
69
+ NULL, \
70
+ &f \
71
+ ); \
72
+ assert( status == napi_ok ); \
73
+ return f; \
74
+ }; \
75
+ NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_c_c_init )
76
+
77
+ /*
78
+ * If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler.
79
+ */
80
+ #ifdef __cplusplus
81
+ extern "C" {
82
+ #endif
83
+
84
+ /**
85
+ * Invokes a unary function accepting and returning single-precision complex floating-point numbers.
86
+ */
87
+ napi_value stdlib_math_base_napi_c_c( napi_env env, napi_callback_info info, stdlib_complex64_t (*fcn)( stdlib_complex64_t ) );
88
+
89
+ #ifdef __cplusplus
90
+ }
91
+ #endif
92
+
93
+ #endif // !STDLIB_MATH_BASE_NAPI_UNARY_C_C_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_UNARY_C_F_H
20
+ #define STDLIB_MATH_BASE_NAPI_UNARY_C_F_H
21
+
22
+ #include "stdlib/complex/float32/ctor.h"
23
+ #include <node_api.h>
24
+ #include <assert.h>
25
+
26
+ /**
27
+ * Macro for registering a Node-API module exporting an interface invoking a unary function accepting a single-precision complex floating-point number and returning a single-precision floating-point number.
28
+ *
29
+ * @param fcn unary function
30
+ *
31
+ * @example
32
+ * #include "stdlib/complex/float32/ctor.h"
33
+ *
34
+ * static float fcn( const stdlib_complex64_t x ) {
35
+ * // ...
36
+ * }
37
+ *
38
+ * // ...
39
+ *
40
+ * // Register a Node-API module:
41
+ * STDLIB_MATH_BASE_NAPI_MODULE_C_F( fcn );
42
+ */
43
+ #define STDLIB_MATH_BASE_NAPI_MODULE_C_F( fcn ) \
44
+ static napi_value stdlib_math_base_napi_c_f_wrapper( \
45
+ napi_env env, \
46
+ napi_callback_info info \
47
+ ) { \
48
+ return stdlib_math_base_napi_c_f( env, info, fcn ); \
49
+ }; \
50
+ static napi_value stdlib_math_base_napi_c_f_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_c_f_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_c_f_init )
67
+
68
+ /*
69
+ * If C++, prevent name mangling so that the compiler emits a binary 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 unary function accepting a single-precision complex floating-point number and returning a single-precision floating-point number.
77
+ */
78
+ napi_value stdlib_math_base_napi_c_f( napi_env env, napi_callback_info info, float (*fcn)( stdlib_complex64_t ) );
79
+
80
+ #ifdef __cplusplus
81
+ }
82
+ #endif
83
+
84
+ #endif // !STDLIB_MATH_BASE_NAPI_UNARY_C_F_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_UNARY_D_D_H
20
+ #define STDLIB_MATH_BASE_NAPI_UNARY_D_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 unary function accepting and returning double-precision floating-point numbers.
27
+ *
28
+ * @param fcn unary function
29
+ *
30
+ * @example
31
+ * static double scale( const double x ) {
32
+ * return x * 10.0;
33
+ * }
34
+ *
35
+ * // ...
36
+ *
37
+ * // Register a Node-API module:
38
+ * STDLIB_MATH_BASE_NAPI_MODULE_D_D( scale );
39
+ */
40
+ #define STDLIB_MATH_BASE_NAPI_MODULE_D_D( fcn ) \
41
+ static napi_value stdlib_math_base_napi_d_d_wrapper( \
42
+ napi_env env, \
43
+ napi_callback_info info \
44
+ ) { \
45
+ return stdlib_math_base_napi_d_d( env, info, fcn ); \
46
+ }; \
47
+ static napi_value stdlib_math_base_napi_d_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_d_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_d_d_init )
64
+
65
+ /*
66
+ * If C++, prevent name mangling so that the compiler emits a binary 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 unary function accepting and returning double-precision floating-point numbers.
74
+ */
75
+ napi_value stdlib_math_base_napi_d_d( napi_env env, napi_callback_info info, double (*fcn)( double ) );
76
+
77
+ #ifdef __cplusplus
78
+ }
79
+ #endif
80
+
81
+ #endif // !STDLIB_MATH_BASE_NAPI_UNARY_D_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_UNARY_D_F_H
20
+ #define STDLIB_MATH_BASE_NAPI_UNARY_D_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 unary function accepting a double-precision floating-point number and returning a single-precision floating-point number.
27
+ *
28
+ * @param fcn unary function
29
+ *
30
+ * @example
31
+ * static float fcn( const double x ) {
32
+ * return (float)x;
33
+ * }
34
+ *
35
+ * // ...
36
+ *
37
+ * // Register a Node-API module:
38
+ * STDLIB_MATH_BASE_NAPI_MODULE_D_F( fcn );
39
+ */
40
+ #define STDLIB_MATH_BASE_NAPI_MODULE_D_F( fcn ) \
41
+ static napi_value stdlib_math_base_napi_d_f_wrapper( \
42
+ napi_env env, \
43
+ napi_callback_info info \
44
+ ) { \
45
+ return stdlib_math_base_napi_d_f( env, info, fcn ); \
46
+ }; \
47
+ static napi_value stdlib_math_base_napi_d_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_d_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_d_f_init )
64
+
65
+ /*
66
+ * If C++, prevent name mangling so that the compiler emits a binary 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 unary function accepting a double-precision floating-point number and returning a single-precision floating-point number.
74
+ */
75
+ napi_value stdlib_math_base_napi_d_f( napi_env env, napi_callback_info info, float (*fcn)( double ) );
76
+
77
+ #ifdef __cplusplus
78
+ }
79
+ #endif
80
+
81
+ #endif // !STDLIB_MATH_BASE_NAPI_UNARY_D_F_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_UNARY_F_F_H
20
+ #define STDLIB_MATH_BASE_NAPI_UNARY_F_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 unary function accepting and returning single-precision floating-point numbers.
27
+ *
28
+ * @param fcn unary function
29
+ *
30
+ * @example
31
+ * static float scale( const float x ) {
32
+ * return x * 10.0f;
33
+ * }
34
+ *
35
+ * // ...
36
+ *
37
+ * // Register a Node-API module:
38
+ * STDLIB_MATH_BASE_NAPI_MODULE_F_F( scale );
39
+ */
40
+ #define STDLIB_MATH_BASE_NAPI_MODULE_F_F( fcn ) \
41
+ static napi_value stdlib_math_base_napi_f_f_wrapper( \
42
+ napi_env env, \
43
+ napi_callback_info info \
44
+ ) { \
45
+ return stdlib_math_base_napi_f_f( env, info, fcn ); \
46
+ }; \
47
+ static napi_value stdlib_math_base_napi_f_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_f_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_f_f_init )
64
+
65
+ /*
66
+ * If C++, prevent name mangling so that the compiler emits a binary 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 unary function accepting and returning single-precision floating-point numbers.
74
+ */
75
+ napi_value stdlib_math_base_napi_f_f( napi_env env, napi_callback_info info, float (*fcn)( float ) );
76
+
77
+ #ifdef __cplusplus
78
+ }
79
+ #endif
80
+
81
+ #endif // !STDLIB_MATH_BASE_NAPI_UNARY_F_F_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_UNARY_F_I_H
20
+ #define STDLIB_MATH_BASE_NAPI_UNARY_F_I_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 unary function accepting a single-precision floating-point number and returning a signed 32-bit integer.
28
+ *
29
+ * @param fcn unary function
30
+ *
31
+ * @example
32
+ * #include <stdint.h>
33
+ *
34
+ * static int32_t fcn( const float x ) {
35
+ * // ...
36
+ * }
37
+ *
38
+ * // ...
39
+ *
40
+ * // Register a Node-API module:
41
+ * STDLIB_MATH_BASE_NAPI_MODULE_F_I( fcn );
42
+ */
43
+ #define STDLIB_MATH_BASE_NAPI_MODULE_F_I( fcn ) \
44
+ static napi_value stdlib_math_base_napi_f_i_wrapper( \
45
+ napi_env env, \
46
+ napi_callback_info info \
47
+ ) { \
48
+ return stdlib_math_base_napi_f_i( env, info, fcn ); \
49
+ }; \
50
+ static napi_value stdlib_math_base_napi_f_i_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_f_i_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_f_i_init )
67
+
68
+ /*
69
+ * If C++, prevent name mangling so that the compiler emits a binary 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 unary function accepting a single-precision floating-point number and returning a signed 32-bit integer.
77
+ */
78
+ napi_value stdlib_math_base_napi_f_i( napi_env env, napi_callback_info info, int32_t (*fcn)( float ) );
79
+
80
+ #ifdef __cplusplus
81
+ }
82
+ #endif
83
+
84
+ #endif // !STDLIB_MATH_BASE_NAPI_UNARY_F_I_H
@@ -0,0 +1,84 @@
1
+ /**
2
+ * @license Apache-2.0
3
+ *
4
+ * Copyright (c) 2026 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_UNARY_H_H_H
20
+ #define STDLIB_MATH_BASE_NAPI_UNARY_H_H_H
21
+
22
+ #include "stdlib/number/float16/ctor.h"
23
+ #include <node_api.h>
24
+ #include <assert.h>
25
+
26
+ /**
27
+ * Macro for registering a Node-API module exporting an interface invoking a unary function accepting and returning half-precision floating-point numbers.
28
+ *
29
+ * @param fcn unary function
30
+ *
31
+ * @example
32
+ * #include "stdlib/number/float16/ctor.h"
33
+ *
34
+ * static stdlib_float16_t identity( const stdlib_float16_t x ) {
35
+ * return x;
36
+ * }
37
+ *
38
+ * // ...
39
+ *
40
+ * // Register a Node-API module:
41
+ * STDLIB_MATH_BASE_NAPI_MODULE_H_H( identity );
42
+ */
43
+ #define STDLIB_MATH_BASE_NAPI_MODULE_H_H( fcn ) \
44
+ static napi_value stdlib_math_base_napi_h_h_wrapper( \
45
+ napi_env env, \
46
+ napi_callback_info info \
47
+ ) { \
48
+ return stdlib_math_base_napi_h_h( env, info, fcn ); \
49
+ }; \
50
+ static napi_value stdlib_math_base_napi_h_h_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_h_h_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_h_h_init )
67
+
68
+ /*
69
+ * If C++, prevent name mangling so that the compiler emits a binary 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 unary function accepting and returning half-precision floating-point numbers.
77
+ */
78
+ napi_value stdlib_math_base_napi_h_h( napi_env env, napi_callback_info info, stdlib_float16_t (*fcn)( stdlib_float16_t ) );
79
+
80
+ #ifdef __cplusplus
81
+ }
82
+ #endif
83
+
84
+ #endif // !STDLIB_MATH_BASE_NAPI_UNARY_H_H_H