Skip to content

Commit 183d056

Browse files
refactor: move implementations and macros to separate files
PR-URL: #5541 Reviewed-by: Athan Reines <kgryte@gmail.com>
1 parent 08f4ebd commit 183d056

File tree

7 files changed

+338
-250
lines changed

7 files changed

+338
-250
lines changed

lib/node_modules/@stdlib/math/base/napi/quinary/README.md

Lines changed: 44 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,29 @@ console.log( headerDir );
104104
#include "stdlib/math/base/napi/quinary.h"
105105
```
106106

107+
<!-- NOTE: keep in alphabetical order according to the suffix XXXXX_X -->
108+
109+
#### STDLIB_MATH_BASE_NAPI_MODULE_DDDDD_D( fcn )
110+
111+
Macro for registering a Node-API module exporting an interface for invoking a quinary function accepting and returning double-precision floating-point numbers.
112+
113+
```c
114+
static double add( const double x, const double y, const double z, const double w, const double u ) {
115+
return x + y + z + w + u;
116+
}
117+
118+
// ...
119+
120+
// Register a Node-API module:
121+
STDLIB_MATH_BASE_NAPI_MODULE_DDDDD_D( add );
122+
```
123+
124+
The macro expects the following arguments:
125+
126+
- **fcn**: `double (*fcn)( double, double, double, double, double )` quinary function.
127+
128+
When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration.
129+
107130
#### stdlib_math_base_napi_ddddd_d( env, info, fcn )
108131
109132
Invokes a quinary function accepting and returning double-precision floating-point numbers.
@@ -143,6 +166,27 @@ The function accepts the following arguments:
143166
void stdlib_math_base_napi_ddddd_d( napi_env env, napi_callback_info info, double (*fcn)( double, double, double, double, double ) );
144167
```
145168
169+
#### STDLIB_MATH_BASE_NAPI_MODULE_FFFFF_F( fcn )
170+
171+
Macro for registering a Node-API module exporting an interface for invoking a quinary function accepting and returning single-precision floating-point numbers.
172+
173+
```c
174+
static float addf( const float x, const float y, const float z, const float w, const float u ) {
175+
return x + y + z + w + u;
176+
}
177+
178+
// ...
179+
180+
// Register a Node-API module:
181+
STDLIB_MATH_BASE_NAPI_MODULE_FFFFF_F( addf );
182+
```
183+
184+
The macro expects the following arguments:
185+
186+
- **fcn**: `float (*fcn)( float, float, float, float, float )` quinary function.
187+
188+
When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration.
189+
146190
#### stdlib_math_base_napi_fffff_f( env, info, fcn )
147191

148192
Invokes a quinary function accepting and returning single-precision floating-point numbers.
@@ -182,48 +226,6 @@ The function accepts the following arguments:
182226
void stdlib_math_base_napi_fffff_f( napi_env env, napi_callback_info info, float (*fcn)( float, float, float, float, float ) );
183227
```
184228

185-
#### STDLIB_MATH_BASE_NAPI_MODULE_DDDDD_D( fcn )
186-
187-
Macro for registering a Node-API module exporting an interface for invoking a quinary function accepting and returning double-precision floating-point numbers.
188-
189-
```c
190-
static double add( const double x, const double y, const double z, const double w, const double u ) {
191-
return x + y + z + w + u;
192-
}
193-
194-
// ...
195-
196-
// Register a Node-API module:
197-
STDLIB_MATH_BASE_NAPI_MODULE_DDDDD_D( add );
198-
```
199-
200-
The macro expects the following arguments:
201-
202-
- **fcn**: `double (*fcn)( double, double, double, double, double )` quinary function.
203-
204-
When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration.
205-
206-
#### STDLIB_MATH_BASE_NAPI_MODULE_FFFFF_F( fcn )
207-
208-
Macro for registering a Node-API module exporting an interface for invoking a quinary function accepting and returning single-precision floating-point numbers.
209-
210-
```c
211-
static float addf( const float x, const float y, const float z, const float w, const float u ) {
212-
return x + y + z + w + u;
213-
}
214-
215-
// ...
216-
217-
// Register a Node-API module:
218-
STDLIB_MATH_BASE_NAPI_MODULE_FFFFF_F( addf );
219-
```
220-
221-
The macro expects the following arguments:
222-
223-
- **fcn**: `float (*fcn)( float, float, float, float, float )` quinary function.
224-
225-
When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration.
226-
227229
</section>
228230

229231
<!-- /.usage -->

lib/node_modules/@stdlib/math/base/napi/quinary/include/stdlib/math/base/napi/quinary.h

Lines changed: 3 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -22,105 +22,8 @@
2222
#include <node_api.h>
2323
#include <assert.h>
2424

25-
/**
26-
* Macro for registering a Node-API module exporting an interface invoking a quinary function accepting and returning double-precision floating-point numbers.
27-
*
28-
* @param fcn quinary function
29-
*
30-
* @example
31-
* static double add( const double x, const double y, const double z, const double w, const double u ) {
32-
* return x + y + z + w + u;
33-
* }
34-
*
35-
* // ...
36-
*
37-
* // Register a Node-API module:
38-
* STDLIB_MATH_BASE_NAPI_MODULE_DDDDD_D( add );
39-
*/
40-
#define STDLIB_MATH_BASE_NAPI_MODULE_DDDDD_D( fcn ) \
41-
static napi_value stdlib_math_base_napi_ddddd_d_wrapper( \
42-
napi_env env, \
43-
napi_callback_info info \
44-
) { \
45-
return stdlib_math_base_napi_ddddd_d( env, info, fcn ); \
46-
}; \
47-
static napi_value stdlib_math_base_napi_ddddd_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_ddddd_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_ddddd_d_init )
64-
65-
/**
66-
* Macro for registering a Node-API module exporting an interface invoking a quinary function accepting and returning single-precision floating-point numbers.
67-
*
68-
* @param fcn quinary function
69-
*
70-
* @example
71-
* static float addf( const float x, const float y, const float z, const float w, const float u ) {
72-
* return x + y + z + w + u;
73-
* }
74-
*
75-
* // ...
76-
*
77-
* // Register a Node-API module:
78-
* STDLIB_MATH_BASE_NAPI_MODULE_FFFFF_F( addf );
79-
*/
80-
#define STDLIB_MATH_BASE_NAPI_MODULE_FFFFF_F( fcn ) \
81-
static napi_value stdlib_math_base_napi_fffff_f_wrapper( \
82-
napi_env env, \
83-
napi_callback_info info \
84-
) { \
85-
return stdlib_math_base_napi_fffff_f( env, info, fcn ); \
86-
}; \
87-
static napi_value stdlib_math_base_napi_fffff_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_fffff_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_fffff_f_init )
104-
105-
/*
106-
* If C++, prevent name mangling so that the compiler emits a quinary 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 quinary function accepting and returning double-precision floating-point numbers.
114-
*/
115-
napi_value stdlib_math_base_napi_ddddd_d( napi_env env, napi_callback_info info, double (*fcn)( double, double, double, double, double ) );
116-
117-
/**
118-
* Invokes a quinary function accepting and returning single-precision floating-point numbers.
119-
*/
120-
napi_value stdlib_math_base_napi_fffff_f( napi_env env, napi_callback_info info, float (*fcn)( float, float, float, float, float ) );
121-
122-
#ifdef __cplusplus
123-
}
124-
#endif
25+
// NOTE: keep in alphabetical order...
26+
#include "stdlib/math/base/napi/quinary/ddddd_d.h"
27+
#include "stdlib/math/base/napi/quinary/fffff_f.h"
12528

12629
#endif // !STDLIB_MATH_BASE_NAPI_QUINARY_H
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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_QUINARY_DDDDD_D_H
20+
#define STDLIB_MATH_BASE_NAPI_QUINARY_DDDDD_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 quinary function accepting and returning double-precision floating-point numbers.
27+
*
28+
* @param fcn quinary function
29+
*
30+
* @example
31+
* static double add( const double x, const double y, const double z, const double w, const double u ) {
32+
* return x + y + z + w + u;
33+
* }
34+
*
35+
* // ...
36+
*
37+
* // Register a Node-API module:
38+
* STDLIB_MATH_BASE_NAPI_MODULE_DDDDD_D( add );
39+
*/
40+
#define STDLIB_MATH_BASE_NAPI_MODULE_DDDDD_D( fcn ) \
41+
static napi_value stdlib_math_base_napi_ddddd_d_wrapper( \
42+
napi_env env, \
43+
napi_callback_info info \
44+
) { \
45+
return stdlib_math_base_napi_ddddd_d( env, info, fcn ); \
46+
}; \
47+
static napi_value stdlib_math_base_napi_ddddd_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_ddddd_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_ddddd_d_init )
64+
65+
/*
66+
* If C++, prevent name mangling so that the compiler emits a quinary 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 quinary function accepting and returning double-precision floating-point numbers.
74+
*/
75+
napi_value stdlib_math_base_napi_ddddd_d( napi_env env, napi_callback_info info, double (*fcn)( double, double, double, double, double ) );
76+
77+
#ifdef __cplusplus
78+
}
79+
#endif
80+
81+
#endif // !STDLIB_MATH_BASE_NAPI_QUINARY_DDDDD_D_H
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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_QUINARY_FFFFF_F_H
20+
#define STDLIB_MATH_BASE_NAPI_QUINARY_FFFFF_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 quinary function accepting and returning single-precision floating-point numbers.
27+
*
28+
* @param fcn quinary function
29+
*
30+
* @example
31+
* static float addf( const float x, const float y, const float z, const float w, const float u ) {
32+
* return x + y + z + w + u;
33+
* }
34+
*
35+
* // ...
36+
*
37+
* // Register a Node-API module:
38+
* STDLIB_MATH_BASE_NAPI_MODULE_FFFFF_F( addf );
39+
*/
40+
#define STDLIB_MATH_BASE_NAPI_MODULE_FFFFF_F( fcn ) \
41+
static napi_value stdlib_math_base_napi_fffff_f_wrapper( \
42+
napi_env env, \
43+
napi_callback_info info \
44+
) { \
45+
return stdlib_math_base_napi_fffff_f( env, info, fcn ); \
46+
}; \
47+
static napi_value stdlib_math_base_napi_fffff_f_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_fffff_f_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_fffff_f_init )
64+
65+
/*
66+
* If C++, prevent name mangling so that the compiler emits a quinary 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 quinary function accepting and returning single-precision floating-point numbers.
74+
*/
75+
napi_value stdlib_math_base_napi_fffff_f( napi_env env, napi_callback_info info, float (*fcn)( float, float, float, float, float ) );
76+
77+
#ifdef __cplusplus
78+
}
79+
#endif
80+
81+
#endif // !STDLIB_MATH_BASE_NAPI_QUINARY_FFFFF_F_H

lib/node_modules/@stdlib/math/base/napi/quinary/manifest.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
"confs": [
2626
{
2727
"src": [
28-
"./src/main.c"
28+
"./src/ddddd_d.c",
29+
"./src/fffff_f.c"
2930
],
3031
"include": [
3132
"./include"

0 commit comments

Comments
 (0)