diff --git a/lib/node_modules/@stdlib/math/base/napi/quinary/README.md b/lib/node_modules/@stdlib/math/base/napi/quinary/README.md index 66ec59bdb3c0..1cdb1f313743 100644 --- a/lib/node_modules/@stdlib/math/base/napi/quinary/README.md +++ b/lib/node_modules/@stdlib/math/base/napi/quinary/README.md @@ -104,6 +104,29 @@ console.log( headerDir ); #include "stdlib/math/base/napi/quinary.h" ``` + + +#### STDLIB_MATH_BASE_NAPI_MODULE_DDDDD_D( fcn ) + +Macro for registering a Node-API module exporting an interface for invoking a quinary function accepting and returning double-precision floating-point numbers. + +```c +static double add( const double x, const double y, const double z, const double w, const double u ) { + return x + y + z + w + u; +} + +// ... + +// Register a Node-API module: +STDLIB_MATH_BASE_NAPI_MODULE_DDDDD_D( add ); +``` + +The macro expects the following arguments: + +- **fcn**: `double (*fcn)( double, double, double, double, double )` quinary function. + +When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration. + #### stdlib_math_base_napi_ddddd_d( env, info, fcn ) Invokes a quinary function accepting and returning double-precision floating-point numbers. @@ -143,6 +166,27 @@ The function accepts the following arguments: void stdlib_math_base_napi_ddddd_d( napi_env env, napi_callback_info info, double (*fcn)( double, double, double, double, double ) ); ``` +#### STDLIB_MATH_BASE_NAPI_MODULE_FFFFF_F( fcn ) + +Macro for registering a Node-API module exporting an interface for invoking a quinary function accepting and returning single-precision floating-point numbers. + +```c +static float addf( const float x, const float y, const float z, const float w, const float u ) { + return x + y + z + w + u; +} + +// ... + +// Register a Node-API module: +STDLIB_MATH_BASE_NAPI_MODULE_FFFFF_F( addf ); +``` + +The macro expects the following arguments: + +- **fcn**: `float (*fcn)( float, float, float, float, float )` quinary function. + +When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration. + #### stdlib_math_base_napi_fffff_f( env, info, fcn ) Invokes a quinary function accepting and returning single-precision floating-point numbers. @@ -182,48 +226,6 @@ The function accepts the following arguments: void stdlib_math_base_napi_fffff_f( napi_env env, napi_callback_info info, float (*fcn)( float, float, float, float, float ) ); ``` -#### STDLIB_MATH_BASE_NAPI_MODULE_DDDDD_D( fcn ) - -Macro for registering a Node-API module exporting an interface for invoking a quinary function accepting and returning double-precision floating-point numbers. - -```c -static double add( const double x, const double y, const double z, const double w, const double u ) { - return x + y + z + w + u; -} - -// ... - -// Register a Node-API module: -STDLIB_MATH_BASE_NAPI_MODULE_DDDDD_D( add ); -``` - -The macro expects the following arguments: - -- **fcn**: `double (*fcn)( double, double, double, double, double )` quinary function. - -When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration. - -#### STDLIB_MATH_BASE_NAPI_MODULE_FFFFF_F( fcn ) - -Macro for registering a Node-API module exporting an interface for invoking a quinary function accepting and returning single-precision floating-point numbers. - -```c -static float addf( const float x, const float y, const float z, const float w, const float u ) { - return x + y + z + w + u; -} - -// ... - -// Register a Node-API module: -STDLIB_MATH_BASE_NAPI_MODULE_FFFFF_F( addf ); -``` - -The macro expects the following arguments: - -- **fcn**: `float (*fcn)( float, float, float, float, float )` quinary function. - -When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration. - diff --git a/lib/node_modules/@stdlib/math/base/napi/quinary/include/stdlib/math/base/napi/quinary.h b/lib/node_modules/@stdlib/math/base/napi/quinary/include/stdlib/math/base/napi/quinary.h index 59561359eb2b..fd7fff661f94 100644 --- a/lib/node_modules/@stdlib/math/base/napi/quinary/include/stdlib/math/base/napi/quinary.h +++ b/lib/node_modules/@stdlib/math/base/napi/quinary/include/stdlib/math/base/napi/quinary.h @@ -22,105 +22,8 @@ #include #include -/** -* Macro for registering a Node-API module exporting an interface invoking a quinary function accepting and returning double-precision floating-point numbers. -* -* @param fcn quinary function -* -* @example -* static double add( const double x, const double y, const double z, const double w, const double u ) { -* return x + y + z + w + u; -* } -* -* // ... -* -* // Register a Node-API module: -* STDLIB_MATH_BASE_NAPI_MODULE_DDDDD_D( add ); -*/ -#define STDLIB_MATH_BASE_NAPI_MODULE_DDDDD_D( fcn ) \ - static napi_value stdlib_math_base_napi_ddddd_d_wrapper( \ - napi_env env, \ - napi_callback_info info \ - ) { \ - return stdlib_math_base_napi_ddddd_d( env, info, fcn ); \ - }; \ - static napi_value stdlib_math_base_napi_ddddd_d_init( \ - napi_env env, \ - napi_value exports \ - ) { \ - napi_value fcn; \ - napi_status status = napi_create_function( \ - env, \ - "exports", \ - NAPI_AUTO_LENGTH, \ - stdlib_math_base_napi_ddddd_d_wrapper, \ - NULL, \ - &fcn \ - ); \ - assert( status == napi_ok ); \ - return fcn; \ - }; \ - NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_ddddd_d_init ) - -/** -* Macro for registering a Node-API module exporting an interface invoking a quinary function accepting and returning single-precision floating-point numbers. -* -* @param fcn quinary function -* -* @example -* static float addf( const float x, const float y, const float z, const float w, const float u ) { -* return x + y + z + w + u; -* } -* -* // ... -* -* // Register a Node-API module: -* STDLIB_MATH_BASE_NAPI_MODULE_FFFFF_F( addf ); -*/ -#define STDLIB_MATH_BASE_NAPI_MODULE_FFFFF_F( fcn ) \ - static napi_value stdlib_math_base_napi_fffff_f_wrapper( \ - napi_env env, \ - napi_callback_info info \ - ) { \ - return stdlib_math_base_napi_fffff_f( env, info, fcn ); \ - }; \ - static napi_value stdlib_math_base_napi_fffff_f_init( \ - napi_env env, \ - napi_value exports \ - ) { \ - napi_value fcn; \ - napi_status status = napi_create_function( \ - env, \ - "exports", \ - NAPI_AUTO_LENGTH, \ - stdlib_math_base_napi_fffff_f_wrapper, \ - NULL, \ - &fcn \ - ); \ - assert( status == napi_ok ); \ - return fcn; \ - }; \ - NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_fffff_f_init ) - -/* -* If C++, prevent name mangling so that the compiler emits a quinary file having undecorated names, thus mirroring the behavior of a C compiler. -*/ -#ifdef __cplusplus -extern "C" { -#endif - -/** -* Invokes a quinary function accepting and returning double-precision floating-point numbers. -*/ -napi_value stdlib_math_base_napi_ddddd_d( napi_env env, napi_callback_info info, double (*fcn)( double, double, double, double, double ) ); - -/** -* Invokes a quinary function accepting and returning single-precision floating-point numbers. -*/ -napi_value stdlib_math_base_napi_fffff_f( napi_env env, napi_callback_info info, float (*fcn)( float, float, float, float, float ) ); - -#ifdef __cplusplus -} -#endif +// NOTE: keep in alphabetical order... +#include "stdlib/math/base/napi/quinary/ddddd_d.h" +#include "stdlib/math/base/napi/quinary/fffff_f.h" #endif // !STDLIB_MATH_BASE_NAPI_QUINARY_H diff --git a/lib/node_modules/@stdlib/math/base/napi/quinary/include/stdlib/math/base/napi/quinary/ddddd_d.h b/lib/node_modules/@stdlib/math/base/napi/quinary/include/stdlib/math/base/napi/quinary/ddddd_d.h new file mode 100644 index 000000000000..4957f75a1dd8 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/napi/quinary/include/stdlib/math/base/napi/quinary/ddddd_d.h @@ -0,0 +1,81 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#ifndef STDLIB_MATH_BASE_NAPI_QUINARY_DDDDD_D_H +#define STDLIB_MATH_BASE_NAPI_QUINARY_DDDDD_D_H + +#include +#include + +/** +* Macro for registering a Node-API module exporting an interface invoking a quinary function accepting and returning double-precision floating-point numbers. +* +* @param fcn quinary function +* +* @example +* static double add( const double x, const double y, const double z, const double w, const double u ) { +* return x + y + z + w + u; +* } +* +* // ... +* +* // Register a Node-API module: +* STDLIB_MATH_BASE_NAPI_MODULE_DDDDD_D( add ); +*/ +#define STDLIB_MATH_BASE_NAPI_MODULE_DDDDD_D( fcn ) \ + static napi_value stdlib_math_base_napi_ddddd_d_wrapper( \ + napi_env env, \ + napi_callback_info info \ + ) { \ + return stdlib_math_base_napi_ddddd_d( env, info, fcn ); \ + }; \ + static napi_value stdlib_math_base_napi_ddddd_d_init( \ + napi_env env, \ + napi_value exports \ + ) { \ + napi_value fcn; \ + napi_status status = napi_create_function( \ + env, \ + "exports", \ + NAPI_AUTO_LENGTH, \ + stdlib_math_base_napi_ddddd_d_wrapper, \ + NULL, \ + &fcn \ + ); \ + assert( status == napi_ok ); \ + return fcn; \ + }; \ + NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_ddddd_d_init ) + +/* +* If C++, prevent name mangling so that the compiler emits a quinary file having undecorated names, thus mirroring the behavior of a C compiler. +*/ +#ifdef __cplusplus +extern "C" { +#endif + +/** +* Invokes a quinary function accepting and returning double-precision floating-point numbers. +*/ +napi_value stdlib_math_base_napi_ddddd_d( napi_env env, napi_callback_info info, double (*fcn)( double, double, double, double, double ) ); + +#ifdef __cplusplus +} +#endif + +#endif // !STDLIB_MATH_BASE_NAPI_QUINARY_DDDDD_D_H diff --git a/lib/node_modules/@stdlib/math/base/napi/quinary/include/stdlib/math/base/napi/quinary/fffff_f.h b/lib/node_modules/@stdlib/math/base/napi/quinary/include/stdlib/math/base/napi/quinary/fffff_f.h new file mode 100644 index 000000000000..613ea3d1d37b --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/napi/quinary/include/stdlib/math/base/napi/quinary/fffff_f.h @@ -0,0 +1,81 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#ifndef STDLIB_MATH_BASE_NAPI_QUINARY_FFFFF_F_H +#define STDLIB_MATH_BASE_NAPI_QUINARY_FFFFF_F_H + +#include +#include + +/** +* Macro for registering a Node-API module exporting an interface invoking a quinary function accepting and returning single-precision floating-point numbers. +* +* @param fcn quinary function +* +* @example +* static float addf( const float x, const float y, const float z, const float w, const float u ) { +* return x + y + z + w + u; +* } +* +* // ... +* +* // Register a Node-API module: +* STDLIB_MATH_BASE_NAPI_MODULE_FFFFF_F( addf ); +*/ +#define STDLIB_MATH_BASE_NAPI_MODULE_FFFFF_F( fcn ) \ + static napi_value stdlib_math_base_napi_fffff_f_wrapper( \ + napi_env env, \ + napi_callback_info info \ + ) { \ + return stdlib_math_base_napi_fffff_f( env, info, fcn ); \ + }; \ + static napi_value stdlib_math_base_napi_fffff_f_init( \ + napi_env env, \ + napi_value exports \ + ) { \ + napi_value fcn; \ + napi_status status = napi_create_function( \ + env, \ + "exports", \ + NAPI_AUTO_LENGTH, \ + stdlib_math_base_napi_fffff_f_wrapper, \ + NULL, \ + &fcn \ + ); \ + assert( status == napi_ok ); \ + return fcn; \ + }; \ + NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_fffff_f_init ) + +/* +* If C++, prevent name mangling so that the compiler emits a quinary file having undecorated names, thus mirroring the behavior of a C compiler. +*/ +#ifdef __cplusplus +extern "C" { +#endif + +/** +* Invokes a quinary function accepting and returning single-precision floating-point numbers. +*/ +napi_value stdlib_math_base_napi_fffff_f( napi_env env, napi_callback_info info, float (*fcn)( float, float, float, float, float ) ); + +#ifdef __cplusplus +} +#endif + +#endif // !STDLIB_MATH_BASE_NAPI_QUINARY_FFFFF_F_H diff --git a/lib/node_modules/@stdlib/math/base/napi/quinary/manifest.json b/lib/node_modules/@stdlib/math/base/napi/quinary/manifest.json index 04e61e361caa..8a61ed423e2a 100644 --- a/lib/node_modules/@stdlib/math/base/napi/quinary/manifest.json +++ b/lib/node_modules/@stdlib/math/base/napi/quinary/manifest.json @@ -25,7 +25,8 @@ "confs": [ { "src": [ - "./src/main.c" + "./src/ddddd_d.c", + "./src/fffff_f.c" ], "include": [ "./include" diff --git a/lib/node_modules/@stdlib/math/base/napi/quinary/src/ddddd_d.c b/lib/node_modules/@stdlib/math/base/napi/quinary/src/ddddd_d.c new file mode 100644 index 000000000000..6b3764fd3fe9 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/napi/quinary/src/ddddd_d.c @@ -0,0 +1,125 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "stdlib/math/base/napi/quinary/ddddd_d.h" +#include +#include + +/** +* Invokes a quinary function accepting and returning double-precision floating-point numbers. +* +* ## Notes +* +* - This function expects that the callback `info` argument provides access to the following JavaScript arguments: +* +* - `x`: input value. +* - `y`: input value. +* - `z`: input value. +* - `w`: input value. +* - `u`: input value. +* +* @param env environment under which the function is invoked +* @param info callback data +* @param fcn quinary function +* @return function return value as a Node-API double-precision floating-point number +*/ +napi_value stdlib_math_base_napi_ddddd_d( napi_env env, napi_callback_info info, double (*fcn)( double, double, double, double, double ) ) { + napi_status status; + + size_t argc = 5; + napi_value argv[ 5 ]; + status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL ); + assert( status == napi_ok ); + + if ( argc < 5 ) { + status = napi_throw_error( env, NULL, "invalid invocation. Must provide five numbers." ); + assert( status == napi_ok ); + return NULL; + } + + napi_valuetype vtype0; + status = napi_typeof( env, argv[ 0 ], &vtype0 ); + assert( status == napi_ok ); + if ( vtype0 != napi_number ) { + status = napi_throw_type_error( env, NULL, "invalid argument. First argument must be a number." ); + assert( status == napi_ok ); + return NULL; + } + + napi_valuetype vtype1; + status = napi_typeof( env, argv[ 1 ], &vtype1 ); + assert( status == napi_ok ); + if ( vtype1 != napi_number ) { + status = napi_throw_type_error( env, NULL, "invalid argument. Second argument must be a number." ); + assert( status == napi_ok ); + return NULL; + } + + napi_valuetype vtype2; + status = napi_typeof( env, argv[ 2 ], &vtype2 ); + assert( status == napi_ok ); + if ( vtype2 != napi_number ) { + status = napi_throw_type_error( env, NULL, "invalid argument. Third argument must be a number." ); + assert( status == napi_ok ); + return NULL; + } + + napi_valuetype vtype3; + status = napi_typeof( env, argv[ 3 ], &vtype3 ); + assert( status == napi_ok ); + if ( vtype3 != napi_number ) { + status = napi_throw_type_error( env, NULL, "invalid argument. Fourth argument must be a number." ); + assert( status == napi_ok ); + return NULL; + } + + napi_valuetype vtype4; + status = napi_typeof( env, argv[ 4 ], &vtype4 ); + assert( status == napi_ok ); + if ( vtype4 != napi_number ) { + status = napi_throw_type_error( env, NULL, "invalid argument. Fifth argument must be a number." ); + assert( status == napi_ok ); + return NULL; + } + + double x; + status = napi_get_value_double( env, argv[ 0 ], &x ); + assert( status == napi_ok ); + + double y; + status = napi_get_value_double( env, argv[ 1 ], &y ); + assert( status == napi_ok ); + + double z; + status = napi_get_value_double( env, argv[ 2 ], &z ); + assert( status == napi_ok ); + + double w; + status = napi_get_value_double( env, argv[ 3 ], &w ); + assert( status == napi_ok ); + + double u; + status = napi_get_value_double( env, argv[ 4 ], &u ); + assert( status == napi_ok ); + + napi_value v; + status = napi_create_double( env, fcn( x, y, z, w, u ), &v ); + assert( status == napi_ok ); + + return v; +} diff --git a/lib/node_modules/@stdlib/math/base/napi/quinary/src/main.c b/lib/node_modules/@stdlib/math/base/napi/quinary/src/fffff_f.c similarity index 53% rename from lib/node_modules/@stdlib/math/base/napi/quinary/src/main.c rename to lib/node_modules/@stdlib/math/base/napi/quinary/src/fffff_f.c index 50c4d2c5ec42..0a618154e8ab 100644 --- a/lib/node_modules/@stdlib/math/base/napi/quinary/src/main.c +++ b/lib/node_modules/@stdlib/math/base/napi/quinary/src/fffff_f.c @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2023 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,115 +16,10 @@ * limitations under the License. */ -#include "stdlib/math/base/napi/quinary.h" +#include "stdlib/math/base/napi/quinary/fffff_f.h" #include -#include #include -/** -* Invokes a quinary function accepting and returning double-precision floating-point numbers. -* -* ## Notes -* -* - This function expects that the callback `info` argument provides access to the following JavaScript arguments: -* -* - `x`: input value. -* - `y`: input value. -* - `z`: input value. -* - `w`: input value. -* - `u`: input value. -* -* @param env environment under which the function is invoked -* @param info callback data -* @param fcn quinary function -* @return function return value as a Node-API double-precision floating-point number -*/ -napi_value stdlib_math_base_napi_ddddd_d( napi_env env, napi_callback_info info, double (*fcn)( double, double, double, double, double ) ) { - napi_status status; - - size_t argc = 5; - napi_value argv[ 5 ]; - status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL ); - assert( status == napi_ok ); - - if ( argc < 5 ) { - status = napi_throw_error( env, NULL, "invalid invocation. Must provide five numbers." ); - assert( status == napi_ok ); - return NULL; - } - - napi_valuetype vtype0; - status = napi_typeof( env, argv[ 0 ], &vtype0 ); - assert( status == napi_ok ); - if ( vtype0 != napi_number ) { - status = napi_throw_type_error( env, NULL, "invalid argument. First argument must be a number." ); - assert( status == napi_ok ); - return NULL; - } - - napi_valuetype vtype1; - status = napi_typeof( env, argv[ 1 ], &vtype1 ); - assert( status == napi_ok ); - if ( vtype1 != napi_number ) { - status = napi_throw_type_error( env, NULL, "invalid argument. Second argument must be a number." ); - assert( status == napi_ok ); - return NULL; - } - - napi_valuetype vtype2; - status = napi_typeof( env, argv[ 2 ], &vtype2 ); - assert( status == napi_ok ); - if ( vtype2 != napi_number ) { - status = napi_throw_type_error( env, NULL, "invalid argument. Third argument must be a number." ); - assert( status == napi_ok ); - return NULL; - } - - napi_valuetype vtype3; - status = napi_typeof( env, argv[ 3 ], &vtype3 ); - assert( status == napi_ok ); - if ( vtype3 != napi_number ) { - status = napi_throw_type_error( env, NULL, "invalid argument. Fourth argument must be a number." ); - assert( status == napi_ok ); - return NULL; - } - - napi_valuetype vtype4; - status = napi_typeof( env, argv[ 4 ], &vtype4 ); - assert( status == napi_ok ); - if ( vtype4 != napi_number ) { - status = napi_throw_type_error( env, NULL, "invalid argument. Fifth argument must be a number." ); - assert( status == napi_ok ); - return NULL; - } - - double x; - status = napi_get_value_double( env, argv[ 0 ], &x ); - assert( status == napi_ok ); - - double y; - status = napi_get_value_double( env, argv[ 1 ], &y ); - assert( status == napi_ok ); - - double z; - status = napi_get_value_double( env, argv[ 2 ], &z ); - assert( status == napi_ok ); - - double w; - status = napi_get_value_double( env, argv[ 3 ], &w ); - assert( status == napi_ok ); - - double u; - status = napi_get_value_double( env, argv[ 4 ], &u ); - assert( status == napi_ok ); - - napi_value v; - status = napi_create_double( env, fcn( x, y, z, w, u ), &v ); - assert( status == napi_ok ); - - return v; -} - /** * Invokes a quinary function accepting and returning single-precision floating-point numbers. *