Skip to content

Commit 0e28d1f

Browse files
committed
refactor: move implementations and macros to separate files
--- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: passed - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent c97212e commit 0e28d1f

File tree

12 files changed

+816
-609
lines changed

12 files changed

+816
-609
lines changed

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

Lines changed: 87 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -104,55 +104,39 @@ console.log( headerDir );
104104
#include "stdlib/math/base/napi/ternary.h"
105105
```
106106

107-
#### stdlib_math_base_napi_ddd_d( env, info, fcn )
108-
109-
Invokes a ternary function accepting and returning double-precision floating-point numbers.
107+
<!-- NOTE: keep in alphabetical order according to the suffix XXX_X -->
110108

111-
```c
112-
#include <node_api.h>
109+
#### STDLIB_MATH_BASE_NAPI_MODULE_DDD_D( fcn )
113110

114-
// ...
111+
Macro for registering a Node-API module exporting an interface for invoking a ternary function accepting and returning double-precision floating-point numbers.
115112

113+
```c
116114
static double add( const double x, const double y, const double z ) {
117115
return x + y + z;
118116
}
119117

120118
// ...
121119

122-
/**
123-
* Receives JavaScript callback invocation data.
124-
*
125-
* @param env environment under which the function is invoked
126-
* @param info callback data
127-
* @return Node-API value
128-
*/
129-
napi_value addon( napi_env env, napi_callback_info info ) {
130-
return stdlib_math_base_napi_ddd_d( env, info, add );
131-
}
132-
133-
// ...
120+
// Register a Node-API module:
121+
STDLIB_MATH_BASE_NAPI_MODULE_DDD_D( add );
134122
```
135123
136-
The function accepts the following arguments:
124+
The macro expects the following arguments:
137125
138-
- **env**: `[in] napi_env` environment under which the function is invoked.
139-
- **info**: `[in] napi_callback_info` callback data.
140-
- **fcn**: `[in] double (*fcn)( double, double, double )` ternary function.
126+
- **fcn**: `double (*fcn)( double, double, double )` ternary function.
141127
142-
```c
143-
void stdlib_math_base_napi_ddd_d( napi_env env, napi_callback_info info, double (*fcn)( double, double, double ) );
144-
```
128+
When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration.
145129
146-
#### stdlib_math_base_napi_fff_f( env, info, fcn )
130+
#### stdlib_math_base_napi_ddd_d( env, info, fcn )
147131
148-
Invokes a ternary function accepting and returning single-precision floating-point numbers.
132+
Invokes a ternary function accepting and returning double-precision floating-point numbers.
149133
150134
```c
151135
#include <node_api.h>
152136
153137
// ...
154138
155-
static float addf( const float x, const float y, const float z ) {
139+
static double add( const double x, const double y, const double z ) {
156140
return x + y + z;
157141
}
158142
@@ -166,7 +150,7 @@ static float addf( const float x, const float y, const float z ) {
166150
* @return Node-API value
167151
*/
168152
napi_value addon( napi_env env, napi_callback_info info ) {
169-
return stdlib_math_base_napi_fff_f( env, info, addf );
153+
return stdlib_math_base_napi_ddd_d( env, info, add );
170154
}
171155
172156
// ...
@@ -176,63 +160,46 @@ The function accepts the following arguments:
176160

177161
- **env**: `[in] napi_env` environment under which the function is invoked.
178162
- **info**: `[in] napi_callback_info` callback data.
179-
- **fcn**: `[in] float (*fcn)( float, float, float )` ternary function.
163+
- **fcn**: `[in] double (*fcn)( double, double, double )` ternary function.
180164

181165
```c
182-
void stdlib_math_base_napi_fff_f( napi_env env, napi_callback_info info, float (*fcn)( float, float, float ) );
166+
void stdlib_math_base_napi_ddd_d( napi_env env, napi_callback_info info, double (*fcn)( double, double, double ) );
183167
```
184168
185-
#### stdlib_math_base_napi_dii_d( env, info, fcn )
169+
#### STDLIB_MATH_BASE_NAPI_MODULE_DII_D( fcn )
186170
187-
Invokes a ternary function accepting a double-precision floating-point number and two signed 32-bit integers and returning a double-precision floating-point number.
171+
Macro for registering a Node-API module exporting an interface for invoking a ternary function accepting a double-precision floating-point number and two signed 32-bit integers and returning a double-precision floating-point number.
188172
189173
```c
190-
#include <node_api.h>
191174
#include <stdint.h>
192175
193-
// ...
194-
195176
static double fcn( const double x, const int32_t y, const int32_t z ) {
196177
// ...
197178
}
198179
199180
// ...
200181
201-
/**
202-
* Receives JavaScript callback invocation data.
203-
*
204-
* @param env environment under which the function is invoked
205-
* @param info callback data
206-
* @return Node-API value
207-
*/
208-
napi_value addon( napi_env env, napi_callback_info info ) {
209-
return stdlib_math_base_napi_dii_d( env, info, fcn );
210-
}
211-
212-
// ...
182+
// Register a Node-API module:
183+
STDLIB_MATH_BASE_NAPI_MODULE_DII_D( fcn );
213184
```
214185

215-
The function accepts the following arguments:
186+
The macro expects the following arguments:
216187

217-
- **env**: `[in] napi_env` environment under which the function is invoked.
218-
- **info**: `[in] napi_callback_info` callback data.
219-
- **fcn**: `[in] double (*fcn)( double, int32_t, int32_t )` ternary function.
188+
- **fcn**: `double (*fcn)( double, int32_t, int32_t )` ternary function.
220189

221-
```c
222-
void stdlib_math_base_napi_dii_d( napi_env env, napi_callback_info info, double (*fcn)( double, int32_t, int32_t ) );
223-
```
190+
When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration.
224191

225-
#### stdlib_math_base_napi_iid_d( env, info, fcn )
192+
#### stdlib_math_base_napi_dii_d( env, info, fcn )
226193

227-
Invokes a ternary function accepting two signed 32-bit integers and a double-precision floating-point number and returning a double-precision floating-point number.
194+
Invokes a ternary function accepting a double-precision floating-point number and two signed 32-bit integers and returning a double-precision floating-point number.
228195

229196
```c
230197
#include <node_api.h>
231198
#include <stdint.h>
232199

233200
// ...
234201

235-
static double fcn( const int32_t x, const int32_t y, const double z ) {
202+
static double fcn( const double x, const int32_t y, const int32_t z ) {
236203
// ...
237204
}
238205

@@ -246,7 +213,7 @@ static double fcn( const int32_t x, const int32_t y, const double z ) {
246213
* @return Node-API value
247214
*/
248215
napi_value addon( napi_env env, napi_callback_info info ) {
249-
return stdlib_math_base_napi_iid_d( env, info, fcn );
216+
return stdlib_math_base_napi_dii_d( env, info, fcn );
250217
}
251218

252219
// ...
@@ -256,99 +223,134 @@ The function accepts the following arguments:
256223
257224
- **env**: `[in] napi_env` environment under which the function is invoked.
258225
- **info**: `[in] napi_callback_info` callback data.
259-
- **fcn**: `[in] double (*fcn)( int32_t, int32_t, double )` ternary function.
226+
- **fcn**: `[in] double (*fcn)( double, int32_t, int32_t )` ternary function.
260227
261228
```c
262-
void stdlib_math_base_napi_iid_d( napi_env env, napi_callback_info info, double (*fcn)( int32_t, int32_t, double ) );
229+
void stdlib_math_base_napi_dii_d( napi_env env, napi_callback_info info, double (*fcn)( double, int32_t, int32_t ) );
263230
```
264231

265-
#### STDLIB_MATH_BASE_NAPI_MODULE_DDD_D( fcn )
232+
#### STDLIB_MATH_BASE_NAPI_MODULE_FFF_F( fcn )
266233

267-
Macro for registering a Node-API module exporting an interface for invoking a ternary function accepting and returning double-precision floating-point numbers.
234+
Macro for registering a Node-API module exporting an interface for invoking a ternary function accepting and returning single-precision floating-point numbers.
268235

269236
```c
270-
static double add( const double x, const double y, const double z ) {
237+
static float addf( const float x, const float y, const float z ) {
271238
return x + y + z;
272239
}
273240

274241
// ...
275242

276243
// Register a Node-API module:
277-
STDLIB_MATH_BASE_NAPI_MODULE_DDD_D( add );
244+
STDLIB_MATH_BASE_NAPI_MODULE_FFF_F( addf );
278245
```
279246
280247
The macro expects the following arguments:
281248
282-
- **fcn**: `double (*fcn)( double, double, double )` ternary function.
249+
- **fcn**: `float (*fcn)( float, float, float )` ternary function.
283250
284251
When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration.
285252
286-
#### STDLIB_MATH_BASE_NAPI_MODULE_FFF_F( fcn )
253+
#### stdlib_math_base_napi_fff_f( env, info, fcn )
287254
288-
Macro for registering a Node-API module exporting an interface for invoking a ternary function accepting and returning single-precision floating-point numbers.
255+
Invokes a ternary function accepting and returning single-precision floating-point numbers.
289256
290257
```c
258+
#include <node_api.h>
259+
260+
// ...
261+
291262
static float addf( const float x, const float y, const float z ) {
292263
return x + y + z;
293264
}
294265
295266
// ...
296267
297-
// Register a Node-API module:
298-
STDLIB_MATH_BASE_NAPI_MODULE_FFF_F( addf );
268+
/**
269+
* Receives JavaScript callback invocation data.
270+
*
271+
* @param env environment under which the function is invoked
272+
* @param info callback data
273+
* @return Node-API value
274+
*/
275+
napi_value addon( napi_env env, napi_callback_info info ) {
276+
return stdlib_math_base_napi_fff_f( env, info, addf );
277+
}
278+
279+
// ...
299280
```
300281

301-
The macro expects the following arguments:
282+
The function accepts the following arguments:
302283

303-
- **fcn**: `float (*fcn)( float, float, float )` ternary function.
284+
- **env**: `[in] napi_env` environment under which the function is invoked.
285+
- **info**: `[in] napi_callback_info` callback data.
286+
- **fcn**: `[in] float (*fcn)( float, float, float )` ternary function.
304287

305-
When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration.
288+
```c
289+
void stdlib_math_base_napi_fff_f( napi_env env, napi_callback_info info, float (*fcn)( float, float, float ) );
290+
```
306291
307-
#### STDLIB_MATH_BASE_NAPI_MODULE_DII_D( fcn )
292+
#### STDLIB_MATH_BASE_NAPI_MODULE_IID_D( fcn )
308293
309-
Macro for registering a Node-API module exporting an interface for invoking a ternary function accepting a double-precision floating-point number and two signed 32-bit integers and returning a double-precision floating-point number.
294+
Macro for registering a Node-API module exporting an interface for invoking a ternary function accepting two signed 32-bit integers and a double-precision floating-point number and returning a double-precision floating-point number.
310295
311296
```c
312297
#include <stdint.h>
313298
314-
static double fcn( const double x, const int32_t y, const int32_t z ) {
299+
static double fcn( const int32_t x, const int32_t y, const double z ) {
315300
// ...
316301
}
317302
318303
// ...
319304
320305
// Register a Node-API module:
321-
STDLIB_MATH_BASE_NAPI_MODULE_DII_D( fcn );
306+
STDLIB_MATH_BASE_NAPI_MODULE_IID_D( fcn );
322307
```
323308

324309
The macro expects the following arguments:
325310

326-
- **fcn**: `double (*fcn)( double, int32_t, int32_t )` ternary function.
311+
- **fcn**: `double (*fcn)( int32_t, int32_t, double )` ternary function.
327312

328313
When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration.
329314

330-
#### STDLIB_MATH_BASE_NAPI_MODULE_IID_D( fcn )
315+
#### stdlib_math_base_napi_iid_d( env, info, fcn )
331316

332-
Macro for registering a Node-API module exporting an interface for invoking a ternary function accepting two signed 32-bit integers and a double-precision floating-point number and returning a double-precision floating-point number.
317+
Invokes a ternary function accepting two signed 32-bit integers and a double-precision floating-point number and returning a double-precision floating-point number.
333318

334319
```c
320+
#include <node_api.h>
335321
#include <stdint.h>
336322

323+
// ...
324+
337325
static double fcn( const int32_t x, const int32_t y, const double z ) {
338326
// ...
339327
}
340328

341329
// ...
342330

343-
// Register a Node-API module:
344-
STDLIB_MATH_BASE_NAPI_MODULE_IID_D( fcn );
331+
/**
332+
* Receives JavaScript callback invocation data.
333+
*
334+
* @param env environment under which the function is invoked
335+
* @param info callback data
336+
* @return Node-API value
337+
*/
338+
napi_value addon( napi_env env, napi_callback_info info ) {
339+
return stdlib_math_base_napi_iid_d( env, info, fcn );
340+
}
341+
342+
// ...
345343
```
346344
347-
The macro expects the following arguments:
345+
The function accepts the following arguments:
348346
349-
- **fcn**: `double (*fcn)( int32_t, int32_t, double )` ternary function.
347+
- **env**: `[in] napi_env` environment under which the function is invoked.
348+
- **info**: `[in] napi_callback_info` callback data.
349+
- **fcn**: `[in] double (*fcn)( int32_t, int32_t, double )` ternary function.
350350
351-
When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration.
351+
```c
352+
void stdlib_math_base_napi_iid_d( napi_env env, napi_callback_info info, double (*fcn)( int32_t, int32_t, double ) );
353+
```
352354

353355
</section>
354356

0 commit comments

Comments
 (0)