@stdlib/math-base-napi-unary
Advanced tools
| /** | ||
| * @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_UNARY_B_B_H | ||
| #define STDLIB_MATH_BASE_NAPI_UNARY_B_B_H | ||
| #include <node_api.h> | ||
| #include <assert.h> | ||
| #include <stdint.h> | ||
| /** | ||
| * Macro for registering a Node-API module exporting an interface invoking a unary function accepting and returning 8-bit unsigned integers. | ||
| * | ||
| * @param fcn unary function | ||
| * | ||
| * @example | ||
| * #include <stdint.h> | ||
| * | ||
| * static uint8_t scale( const uint8_t x ) { | ||
| * return x * 10; | ||
| * } | ||
| * | ||
| * // ... | ||
| * | ||
| * // Register a Node-API module: | ||
| * STDLIB_MATH_BASE_NAPI_MODULE_B_B( scale ); | ||
| */ | ||
| #define STDLIB_MATH_BASE_NAPI_MODULE_B_B( fcn ) \ | ||
| static napi_value stdlib_math_base_napi_b_b_wrapper( \ | ||
| napi_env env, \ | ||
| napi_callback_info info \ | ||
| ) { \ | ||
| return stdlib_math_base_napi_b_b( env, info, fcn ); \ | ||
| }; \ | ||
| static napi_value stdlib_math_base_napi_b_b_init( \ | ||
| napi_env env, \ | ||
| napi_value exports \ | ||
| ) { \ | ||
| napi_value f; \ | ||
| napi_status status = napi_create_function( \ | ||
| env, \ | ||
| "exports", \ | ||
| NAPI_AUTO_LENGTH, \ | ||
| stdlib_math_base_napi_b_b_wrapper, \ | ||
| NULL, \ | ||
| &f \ | ||
| ); \ | ||
| assert( status == napi_ok ); \ | ||
| return f; \ | ||
| }; \ | ||
| NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_b_b_init ) | ||
| /* | ||
| * If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. | ||
| */ | ||
| #ifdef __cplusplus | ||
| extern "C" { | ||
| #endif | ||
| /** | ||
| * Invokes a unary function accepting and returning unsigned 8-bit integers. | ||
| */ | ||
| napi_value stdlib_math_base_napi_b_b( napi_env env, napi_callback_info info, uint8_t (*fcn)( uint8_t ) ); | ||
| #ifdef __cplusplus | ||
| } | ||
| #endif | ||
| #endif // !STDLIB_MATH_BASE_NAPI_UNARY_B_B_H |
| /** | ||
| * @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_UNARY_C_C_H | ||
| #define STDLIB_MATH_BASE_NAPI_UNARY_C_C_H | ||
| #include "stdlib/complex/float32/ctor.h" | ||
| #include <node_api.h> | ||
| #include <assert.h> | ||
| /** | ||
| * Macro for registering a Node-API module exporting an interface invoking a unary function accepting and returning single-precision complex floating-point numbers. | ||
| * | ||
| * @param fcn unary function | ||
| * | ||
| * @example | ||
| * #include "stdlib/complex/float32/ctor.h" | ||
| * #include "stdlib/complex/float32/reim.h" | ||
| * | ||
| * static stdlib_complex64_t scale( const stdlib_complex64_t x ) { | ||
| * float re; | ||
| * float im; | ||
| * | ||
| * stdlib_complex64_reim( x, &re, &im ); | ||
| * | ||
| * re *= 10.0f; | ||
| * im *= 10.0f; | ||
| * | ||
| * return stdlib_complex64( re, im ); | ||
| * } | ||
| * | ||
| * // ... | ||
| * | ||
| * // Register a Node-API module: | ||
| * STDLIB_MATH_BASE_NAPI_MODULE_C_C( scale ); | ||
| */ | ||
| #define STDLIB_MATH_BASE_NAPI_MODULE_C_C( fcn ) \ | ||
| static napi_value stdlib_math_base_napi_c_c_wrapper( \ | ||
| napi_env env, \ | ||
| napi_callback_info info \ | ||
| ) { \ | ||
| return stdlib_math_base_napi_c_c( env, info, fcn ); \ | ||
| }; \ | ||
| static napi_value stdlib_math_base_napi_c_c_init( \ | ||
| napi_env env, \ | ||
| napi_value exports \ | ||
| ) { \ | ||
| napi_value f; \ | ||
| napi_status status = napi_create_function( \ | ||
| env, \ | ||
| "exports", \ | ||
| NAPI_AUTO_LENGTH, \ | ||
| stdlib_math_base_napi_c_c_wrapper, \ | ||
| NULL, \ | ||
| &f \ | ||
| ); \ | ||
| assert( status == napi_ok ); \ | ||
| return f; \ | ||
| }; \ | ||
| NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_c_c_init ) | ||
| /* | ||
| * If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. | ||
| */ | ||
| #ifdef __cplusplus | ||
| extern "C" { | ||
| #endif | ||
| /** | ||
| * Invokes a unary function accepting and returning single-precision complex floating-point numbers. | ||
| */ | ||
| napi_value stdlib_math_base_napi_c_c( napi_env env, napi_callback_info info, stdlib_complex64_t (*fcn)( stdlib_complex64_t ) ); | ||
| #ifdef __cplusplus | ||
| } | ||
| #endif | ||
| #endif // !STDLIB_MATH_BASE_NAPI_UNARY_C_C_H |
| /** | ||
| * @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_UNARY_C_F_H | ||
| #define STDLIB_MATH_BASE_NAPI_UNARY_C_F_H | ||
| #include "stdlib/complex/float32/ctor.h" | ||
| #include <node_api.h> | ||
| #include <assert.h> | ||
| /** | ||
| * 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. | ||
| * | ||
| * @param fcn unary function | ||
| * | ||
| * @example | ||
| * #include "stdlib/complex/float32/ctor.h" | ||
| * | ||
| * static float fcn( const stdlib_complex64_t x ) { | ||
| * // ... | ||
| * } | ||
| * | ||
| * // ... | ||
| * | ||
| * // Register a Node-API module: | ||
| * STDLIB_MATH_BASE_NAPI_MODULE_C_F( fcn ); | ||
| */ | ||
| #define STDLIB_MATH_BASE_NAPI_MODULE_C_F( fcn ) \ | ||
| static napi_value stdlib_math_base_napi_c_f_wrapper( \ | ||
| napi_env env, \ | ||
| napi_callback_info info \ | ||
| ) { \ | ||
| return stdlib_math_base_napi_c_f( env, info, fcn ); \ | ||
| }; \ | ||
| static napi_value stdlib_math_base_napi_c_f_init( \ | ||
| napi_env env, \ | ||
| napi_value exports \ | ||
| ) { \ | ||
| napi_value f; \ | ||
| napi_status status = napi_create_function( \ | ||
| env, \ | ||
| "exports", \ | ||
| NAPI_AUTO_LENGTH, \ | ||
| stdlib_math_base_napi_c_f_wrapper, \ | ||
| NULL, \ | ||
| &f \ | ||
| ); \ | ||
| assert( status == napi_ok ); \ | ||
| return f; \ | ||
| }; \ | ||
| NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_c_f_init ) | ||
| /* | ||
| * If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. | ||
| */ | ||
| #ifdef __cplusplus | ||
| extern "C" { | ||
| #endif | ||
| /** | ||
| * Invokes a unary function accepting a single-precision complex floating-point number and returning a single-precision floating-point number. | ||
| */ | ||
| napi_value stdlib_math_base_napi_c_f( napi_env env, napi_callback_info info, float (*fcn)( stdlib_complex64_t ) ); | ||
| #ifdef __cplusplus | ||
| } | ||
| #endif | ||
| #endif // !STDLIB_MATH_BASE_NAPI_UNARY_C_F_H |
| /** | ||
| * @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_UNARY_D_D_H | ||
| #define STDLIB_MATH_BASE_NAPI_UNARY_D_D_H | ||
| #include <node_api.h> | ||
| #include <assert.h> | ||
| /** | ||
| * Macro for registering a Node-API module exporting an interface invoking a unary function accepting and returning double-precision floating-point numbers. | ||
| * | ||
| * @param fcn unary function | ||
| * | ||
| * @example | ||
| * static double scale( const double x ) { | ||
| * return x * 10.0; | ||
| * } | ||
| * | ||
| * // ... | ||
| * | ||
| * // Register a Node-API module: | ||
| * STDLIB_MATH_BASE_NAPI_MODULE_D_D( scale ); | ||
| */ | ||
| #define STDLIB_MATH_BASE_NAPI_MODULE_D_D( fcn ) \ | ||
| static napi_value stdlib_math_base_napi_d_d_wrapper( \ | ||
| napi_env env, \ | ||
| napi_callback_info info \ | ||
| ) { \ | ||
| return stdlib_math_base_napi_d_d( env, info, fcn ); \ | ||
| }; \ | ||
| static napi_value stdlib_math_base_napi_d_d_init( \ | ||
| napi_env env, \ | ||
| napi_value exports \ | ||
| ) { \ | ||
| napi_value f; \ | ||
| napi_status status = napi_create_function( \ | ||
| env, \ | ||
| "exports", \ | ||
| NAPI_AUTO_LENGTH, \ | ||
| stdlib_math_base_napi_d_d_wrapper, \ | ||
| NULL, \ | ||
| &f \ | ||
| ); \ | ||
| assert( status == napi_ok ); \ | ||
| return f; \ | ||
| }; \ | ||
| NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_d_d_init ) | ||
| /* | ||
| * If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. | ||
| */ | ||
| #ifdef __cplusplus | ||
| extern "C" { | ||
| #endif | ||
| /** | ||
| * Invokes a unary function accepting and returning double-precision floating-point numbers. | ||
| */ | ||
| napi_value stdlib_math_base_napi_d_d( napi_env env, napi_callback_info info, double (*fcn)( double ) ); | ||
| #ifdef __cplusplus | ||
| } | ||
| #endif | ||
| #endif // !STDLIB_MATH_BASE_NAPI_UNARY_D_D_H |
| /** | ||
| * @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_UNARY_D_F_H | ||
| #define STDLIB_MATH_BASE_NAPI_UNARY_D_F_H | ||
| #include <node_api.h> | ||
| #include <assert.h> | ||
| /** | ||
| * 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. | ||
| * | ||
| * @param fcn unary function | ||
| * | ||
| * @example | ||
| * static float fcn( const double x ) { | ||
| * return (float)x; | ||
| * } | ||
| * | ||
| * // ... | ||
| * | ||
| * // Register a Node-API module: | ||
| * STDLIB_MATH_BASE_NAPI_MODULE_D_F( fcn ); | ||
| */ | ||
| #define STDLIB_MATH_BASE_NAPI_MODULE_D_F( fcn ) \ | ||
| static napi_value stdlib_math_base_napi_d_f_wrapper( \ | ||
| napi_env env, \ | ||
| napi_callback_info info \ | ||
| ) { \ | ||
| return stdlib_math_base_napi_d_f( env, info, fcn ); \ | ||
| }; \ | ||
| static napi_value stdlib_math_base_napi_d_f_init( \ | ||
| napi_env env, \ | ||
| napi_value exports \ | ||
| ) { \ | ||
| napi_value f; \ | ||
| napi_status status = napi_create_function( \ | ||
| env, \ | ||
| "exports", \ | ||
| NAPI_AUTO_LENGTH, \ | ||
| stdlib_math_base_napi_d_f_wrapper, \ | ||
| NULL, \ | ||
| &f \ | ||
| ); \ | ||
| assert( status == napi_ok ); \ | ||
| return f; \ | ||
| }; \ | ||
| NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_d_f_init ) | ||
| /* | ||
| * If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. | ||
| */ | ||
| #ifdef __cplusplus | ||
| extern "C" { | ||
| #endif | ||
| /** | ||
| * Invokes a unary function accepting a double-precision floating-point number and returning a single-precision floating-point number. | ||
| */ | ||
| napi_value stdlib_math_base_napi_d_f( napi_env env, napi_callback_info info, float (*fcn)( double ) ); | ||
| #ifdef __cplusplus | ||
| } | ||
| #endif | ||
| #endif // !STDLIB_MATH_BASE_NAPI_UNARY_D_F_H |
| /** | ||
| * @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_UNARY_F_F_H | ||
| #define STDLIB_MATH_BASE_NAPI_UNARY_F_F_H | ||
| #include <node_api.h> | ||
| #include <assert.h> | ||
| /** | ||
| * Macro for registering a Node-API module exporting an interface invoking a unary function accepting and returning single-precision floating-point numbers. | ||
| * | ||
| * @param fcn unary function | ||
| * | ||
| * @example | ||
| * static float scale( const float x ) { | ||
| * return x * 10.0f; | ||
| * } | ||
| * | ||
| * // ... | ||
| * | ||
| * // Register a Node-API module: | ||
| * STDLIB_MATH_BASE_NAPI_MODULE_F_F( scale ); | ||
| */ | ||
| #define STDLIB_MATH_BASE_NAPI_MODULE_F_F( fcn ) \ | ||
| static napi_value stdlib_math_base_napi_f_f_wrapper( \ | ||
| napi_env env, \ | ||
| napi_callback_info info \ | ||
| ) { \ | ||
| return stdlib_math_base_napi_f_f( env, info, fcn ); \ | ||
| }; \ | ||
| static napi_value stdlib_math_base_napi_f_f_init( \ | ||
| napi_env env, \ | ||
| napi_value exports \ | ||
| ) { \ | ||
| napi_value f; \ | ||
| napi_status status = napi_create_function( \ | ||
| env, \ | ||
| "exports", \ | ||
| NAPI_AUTO_LENGTH, \ | ||
| stdlib_math_base_napi_f_f_wrapper, \ | ||
| NULL, \ | ||
| &f \ | ||
| ); \ | ||
| assert( status == napi_ok ); \ | ||
| return f; \ | ||
| }; \ | ||
| NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_f_f_init ) | ||
| /* | ||
| * If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. | ||
| */ | ||
| #ifdef __cplusplus | ||
| extern "C" { | ||
| #endif | ||
| /** | ||
| * Invokes a unary function accepting and returning single-precision floating-point numbers. | ||
| */ | ||
| napi_value stdlib_math_base_napi_f_f( napi_env env, napi_callback_info info, float (*fcn)( float ) ); | ||
| #ifdef __cplusplus | ||
| } | ||
| #endif | ||
| #endif // !STDLIB_MATH_BASE_NAPI_UNARY_F_F_H |
| /** | ||
| * @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_UNARY_F_I_H | ||
| #define STDLIB_MATH_BASE_NAPI_UNARY_F_I_H | ||
| #include <node_api.h> | ||
| #include <assert.h> | ||
| #include <stdint.h> | ||
| /** | ||
| * 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. | ||
| * | ||
| * @param fcn unary function | ||
| * | ||
| * @example | ||
| * #include <stdint.h> | ||
| * | ||
| * static int32_t fcn( const float x ) { | ||
| * // ... | ||
| * } | ||
| * | ||
| * // ... | ||
| * | ||
| * // Register a Node-API module: | ||
| * STDLIB_MATH_BASE_NAPI_MODULE_F_I( fcn ); | ||
| */ | ||
| #define STDLIB_MATH_BASE_NAPI_MODULE_F_I( fcn ) \ | ||
| static napi_value stdlib_math_base_napi_f_i_wrapper( \ | ||
| napi_env env, \ | ||
| napi_callback_info info \ | ||
| ) { \ | ||
| return stdlib_math_base_napi_f_i( env, info, fcn ); \ | ||
| }; \ | ||
| static napi_value stdlib_math_base_napi_f_i_init( \ | ||
| napi_env env, \ | ||
| napi_value exports \ | ||
| ) { \ | ||
| napi_value f; \ | ||
| napi_status status = napi_create_function( \ | ||
| env, \ | ||
| "exports", \ | ||
| NAPI_AUTO_LENGTH, \ | ||
| stdlib_math_base_napi_f_i_wrapper, \ | ||
| NULL, \ | ||
| &f \ | ||
| ); \ | ||
| assert( status == napi_ok ); \ | ||
| return f; \ | ||
| }; \ | ||
| NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_f_i_init ) | ||
| /* | ||
| * If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. | ||
| */ | ||
| #ifdef __cplusplus | ||
| extern "C" { | ||
| #endif | ||
| /** | ||
| * Invokes a unary function accepting a single-precision floating-point number and returning a signed 32-bit integer. | ||
| */ | ||
| napi_value stdlib_math_base_napi_f_i( napi_env env, napi_callback_info info, int32_t (*fcn)( float ) ); | ||
| #ifdef __cplusplus | ||
| } | ||
| #endif | ||
| #endif // !STDLIB_MATH_BASE_NAPI_UNARY_F_I_H |
| /** | ||
| * @license Apache-2.0 | ||
| * | ||
| * Copyright (c) 2026 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_UNARY_H_H_H | ||
| #define STDLIB_MATH_BASE_NAPI_UNARY_H_H_H | ||
| #include "stdlib/number/float16/ctor.h" | ||
| #include <node_api.h> | ||
| #include <assert.h> | ||
| /** | ||
| * Macro for registering a Node-API module exporting an interface invoking a unary function accepting and returning half-precision floating-point numbers. | ||
| * | ||
| * @param fcn unary function | ||
| * | ||
| * @example | ||
| * #include "stdlib/number/float16/ctor.h" | ||
| * | ||
| * static stdlib_float16_t identity( const stdlib_float16_t x ) { | ||
| * return x; | ||
| * } | ||
| * | ||
| * // ... | ||
| * | ||
| * // Register a Node-API module: | ||
| * STDLIB_MATH_BASE_NAPI_MODULE_H_H( identity ); | ||
| */ | ||
| #define STDLIB_MATH_BASE_NAPI_MODULE_H_H( fcn ) \ | ||
| static napi_value stdlib_math_base_napi_h_h_wrapper( \ | ||
| napi_env env, \ | ||
| napi_callback_info info \ | ||
| ) { \ | ||
| return stdlib_math_base_napi_h_h( env, info, fcn ); \ | ||
| }; \ | ||
| static napi_value stdlib_math_base_napi_h_h_init( \ | ||
| napi_env env, \ | ||
| napi_value exports \ | ||
| ) { \ | ||
| napi_value f; \ | ||
| napi_status status = napi_create_function( \ | ||
| env, \ | ||
| "exports", \ | ||
| NAPI_AUTO_LENGTH, \ | ||
| stdlib_math_base_napi_h_h_wrapper, \ | ||
| NULL, \ | ||
| &f \ | ||
| ); \ | ||
| assert( status == napi_ok ); \ | ||
| return f; \ | ||
| }; \ | ||
| NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_h_h_init ) | ||
| /* | ||
| * If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. | ||
| */ | ||
| #ifdef __cplusplus | ||
| extern "C" { | ||
| #endif | ||
| /** | ||
| * Invokes a unary function accepting and returning half-precision floating-point numbers. | ||
| */ | ||
| napi_value stdlib_math_base_napi_h_h( napi_env env, napi_callback_info info, stdlib_float16_t (*fcn)( stdlib_float16_t ) ); | ||
| #ifdef __cplusplus | ||
| } | ||
| #endif | ||
| #endif // !STDLIB_MATH_BASE_NAPI_UNARY_H_H_H |
| /** | ||
| * @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_UNARY_I_D_H | ||
| #define STDLIB_MATH_BASE_NAPI_UNARY_I_D_H | ||
| #include <node_api.h> | ||
| #include <assert.h> | ||
| #include <stdint.h> | ||
| /** | ||
| * Macro for registering a Node-API module exporting an interface invoking a unary function accepting a signed 32-bit integer and returning a double-precision floating-point number. | ||
| * | ||
| * @param fcn unary function | ||
| * | ||
| * @example | ||
| * #include <stdint.h> | ||
| * | ||
| * static double scale( const int32_t x ) { | ||
| * return x * 10.0; | ||
| * } | ||
| * | ||
| * // ... | ||
| * | ||
| * // Register a Node-API module: | ||
| * STDLIB_MATH_BASE_NAPI_MODULE_I_D( scale ); | ||
| */ | ||
| #define STDLIB_MATH_BASE_NAPI_MODULE_I_D( fcn ) \ | ||
| static napi_value stdlib_math_base_napi_i_d_wrapper( \ | ||
| napi_env env, \ | ||
| napi_callback_info info \ | ||
| ) { \ | ||
| return stdlib_math_base_napi_i_d( env, info, fcn ); \ | ||
| }; \ | ||
| static napi_value stdlib_math_base_napi_i_d_init( \ | ||
| napi_env env, \ | ||
| napi_value exports \ | ||
| ) { \ | ||
| napi_value f; \ | ||
| napi_status status = napi_create_function( \ | ||
| env, \ | ||
| "exports", \ | ||
| NAPI_AUTO_LENGTH, \ | ||
| stdlib_math_base_napi_i_d_wrapper, \ | ||
| NULL, \ | ||
| &f \ | ||
| ); \ | ||
| assert( status == napi_ok ); \ | ||
| return f; \ | ||
| }; \ | ||
| NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_i_d_init ) | ||
| /* | ||
| * If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. | ||
| */ | ||
| #ifdef __cplusplus | ||
| extern "C" { | ||
| #endif | ||
| /** | ||
| * Invokes a unary function accepting a signed 32-bit integer and returning a single-precision floating-point number. | ||
| */ | ||
| napi_value stdlib_math_base_napi_i_d( napi_env env, napi_callback_info info, double (*fcn)( int32_t ) ); | ||
| #ifdef __cplusplus | ||
| } | ||
| #endif | ||
| #endif // !STDLIB_MATH_BASE_NAPI_UNARY_I_D_H |
| /** | ||
| * @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_UNARY_I_F_H | ||
| #define STDLIB_MATH_BASE_NAPI_UNARY_I_F_H | ||
| #include <node_api.h> | ||
| #include <assert.h> | ||
| #include <stdint.h> | ||
| /** | ||
| * Macro for registering a Node-API module exporting an interface invoking a unary function accepting a signed 32-bit integer and returning a single-precision floating-point number. | ||
| * | ||
| * @param fcn unary function | ||
| * | ||
| * @example | ||
| * #include <stdint.h> | ||
| * | ||
| * static float fcn( const int32_t x ) { | ||
| * // ... | ||
| * } | ||
| * | ||
| * // ... | ||
| * | ||
| * // Register a Node-API module: | ||
| * STDLIB_MATH_BASE_NAPI_MODULE_I_F( fcn ); | ||
| */ | ||
| #define STDLIB_MATH_BASE_NAPI_MODULE_I_F( fcn ) \ | ||
| static napi_value stdlib_math_base_napi_i_f_wrapper( \ | ||
| napi_env env, \ | ||
| napi_callback_info info \ | ||
| ) { \ | ||
| return stdlib_math_base_napi_i_f( env, info, fcn ); \ | ||
| }; \ | ||
| static napi_value stdlib_math_base_napi_i_f_init( \ | ||
| napi_env env, \ | ||
| napi_value exports \ | ||
| ) { \ | ||
| napi_value f; \ | ||
| napi_status status = napi_create_function( \ | ||
| env, \ | ||
| "exports", \ | ||
| NAPI_AUTO_LENGTH, \ | ||
| stdlib_math_base_napi_i_f_wrapper, \ | ||
| NULL, \ | ||
| &f \ | ||
| ); \ | ||
| assert( status == napi_ok ); \ | ||
| return f; \ | ||
| }; \ | ||
| NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_i_f_init ) | ||
| /* | ||
| * If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. | ||
| */ | ||
| #ifdef __cplusplus | ||
| extern "C" { | ||
| #endif | ||
| /** | ||
| * Invokes a unary function accepting a signed 32-bit integer and returning a single-precision floating-point number. | ||
| */ | ||
| napi_value stdlib_math_base_napi_i_f( napi_env env, napi_callback_info info, float (*fcn)( int32_t ) ); | ||
| #ifdef __cplusplus | ||
| } | ||
| #endif | ||
| #endif // !STDLIB_MATH_BASE_NAPI_UNARY_I_F_H |
| /** | ||
| * @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_UNARY_I_I_H | ||
| #define STDLIB_MATH_BASE_NAPI_UNARY_I_I_H | ||
| #include <node_api.h> | ||
| #include <assert.h> | ||
| #include <stdint.h> | ||
| /** | ||
| * Macro for registering a Node-API module exporting an interface invoking a unary function accepting and returning 32-bit signed integers. | ||
| * | ||
| * @param fcn unary function | ||
| * | ||
| * @example | ||
| * #include <stdint.h> | ||
| * | ||
| * static int32_t scale( const int32_t x ) { | ||
| * return x * 10; | ||
| * } | ||
| * | ||
| * // ... | ||
| * | ||
| * // Register a Node-API module: | ||
| * STDLIB_MATH_BASE_NAPI_MODULE_I_I( scale ); | ||
| */ | ||
| #define STDLIB_MATH_BASE_NAPI_MODULE_I_I( fcn ) \ | ||
| static napi_value stdlib_math_base_napi_i_i_wrapper( \ | ||
| napi_env env, \ | ||
| napi_callback_info info \ | ||
| ) { \ | ||
| return stdlib_math_base_napi_i_i( env, info, fcn ); \ | ||
| }; \ | ||
| static napi_value stdlib_math_base_napi_i_i_init( \ | ||
| napi_env env, \ | ||
| napi_value exports \ | ||
| ) { \ | ||
| napi_value f; \ | ||
| napi_status status = napi_create_function( \ | ||
| env, \ | ||
| "exports", \ | ||
| NAPI_AUTO_LENGTH, \ | ||
| stdlib_math_base_napi_i_i_wrapper, \ | ||
| NULL, \ | ||
| &f \ | ||
| ); \ | ||
| assert( status == napi_ok ); \ | ||
| return f; \ | ||
| }; \ | ||
| NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_i_i_init ) | ||
| /* | ||
| * If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. | ||
| */ | ||
| #ifdef __cplusplus | ||
| extern "C" { | ||
| #endif | ||
| /** | ||
| * Invokes a unary function accepting and returning signed 32-bit integers. | ||
| */ | ||
| napi_value stdlib_math_base_napi_i_i( napi_env env, napi_callback_info info, int32_t (*fcn)( int32_t ) ); | ||
| #ifdef __cplusplus | ||
| } | ||
| #endif | ||
| #endif // !STDLIB_MATH_BASE_NAPI_UNARY_I_I_H |
| /** | ||
| * @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_UNARY_K_K_H | ||
| #define STDLIB_MATH_BASE_NAPI_UNARY_K_K_H | ||
| #include <node_api.h> | ||
| #include <assert.h> | ||
| #include <stdint.h> | ||
| /** | ||
| * Macro for registering a Node-API module exporting an interface invoking a unary function accepting and returning 16-bit signed integers. | ||
| * | ||
| * @param fcn unary function | ||
| * | ||
| * @example | ||
| * #include <stdint.h> | ||
| * | ||
| * static int16_t scale( const int16_t x ) { | ||
| * return x * 10; | ||
| * } | ||
| * | ||
| * // ... | ||
| * | ||
| * // Register a Node-API module: | ||
| * STDLIB_MATH_BASE_NAPI_MODULE_K_K( scale ); | ||
| */ | ||
| #define STDLIB_MATH_BASE_NAPI_MODULE_K_K( fcn ) \ | ||
| static napi_value stdlib_math_base_napi_k_k_wrapper( \ | ||
| napi_env env, \ | ||
| napi_callback_info info \ | ||
| ) { \ | ||
| return stdlib_math_base_napi_k_k( env, info, fcn ); \ | ||
| }; \ | ||
| static napi_value stdlib_math_base_napi_k_k_init( \ | ||
| napi_env env, \ | ||
| napi_value exports \ | ||
| ) { \ | ||
| napi_value f; \ | ||
| napi_status status = napi_create_function( \ | ||
| env, \ | ||
| "exports", \ | ||
| NAPI_AUTO_LENGTH, \ | ||
| stdlib_math_base_napi_k_k_wrapper, \ | ||
| NULL, \ | ||
| &f \ | ||
| ); \ | ||
| assert( status == napi_ok ); \ | ||
| return f; \ | ||
| }; \ | ||
| NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_k_k_init ) | ||
| /* | ||
| * If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. | ||
| */ | ||
| #ifdef __cplusplus | ||
| extern "C" { | ||
| #endif | ||
| /** | ||
| * Invokes a unary function accepting and returning signed 16-bit integers. | ||
| */ | ||
| napi_value stdlib_math_base_napi_k_k( napi_env env, napi_callback_info info, int16_t (*fcn)( int16_t ) ); | ||
| #ifdef __cplusplus | ||
| } | ||
| #endif | ||
| #endif // !STDLIB_MATH_BASE_NAPI_UNARY_K_K_H |
| /** | ||
| * @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_UNARY_S_S_H | ||
| #define STDLIB_MATH_BASE_NAPI_UNARY_S_S_H | ||
| #include <node_api.h> | ||
| #include <assert.h> | ||
| #include <stdint.h> | ||
| /** | ||
| * Macro for registering a Node-API module exporting an interface invoking a unary function accepting and returning 8-bit signed integers. | ||
| * | ||
| * @param fcn unary function | ||
| * | ||
| * @example | ||
| * #include <stdint.h> | ||
| * | ||
| * static int8_t scale( const int8_t x ) { | ||
| * return x * 10; | ||
| * } | ||
| * | ||
| * // ... | ||
| * | ||
| * // Register a Node-API module: | ||
| * STDLIB_MATH_BASE_NAPI_MODULE_S_S( scale ); | ||
| */ | ||
| #define STDLIB_MATH_BASE_NAPI_MODULE_S_S( fcn ) \ | ||
| static napi_value stdlib_math_base_napi_s_s_wrapper( \ | ||
| napi_env env, \ | ||
| napi_callback_info info \ | ||
| ) { \ | ||
| return stdlib_math_base_napi_s_s( env, info, fcn ); \ | ||
| }; \ | ||
| static napi_value stdlib_math_base_napi_s_s_init( \ | ||
| napi_env env, \ | ||
| napi_value exports \ | ||
| ) { \ | ||
| napi_value f; \ | ||
| napi_status status = napi_create_function( \ | ||
| env, \ | ||
| "exports", \ | ||
| NAPI_AUTO_LENGTH, \ | ||
| stdlib_math_base_napi_s_s_wrapper, \ | ||
| NULL, \ | ||
| &f \ | ||
| ); \ | ||
| assert( status == napi_ok ); \ | ||
| return f; \ | ||
| }; \ | ||
| NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_s_s_init ) | ||
| /* | ||
| * If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. | ||
| */ | ||
| #ifdef __cplusplus | ||
| extern "C" { | ||
| #endif | ||
| /** | ||
| * Invokes a unary function accepting and returning signed 8-bit integers. | ||
| */ | ||
| napi_value stdlib_math_base_napi_s_s( napi_env env, napi_callback_info info, int8_t (*fcn)( int8_t ) ); | ||
| #ifdef __cplusplus | ||
| } | ||
| #endif | ||
| #endif // !STDLIB_MATH_BASE_NAPI_UNARY_S_S_H |
| /** | ||
| * @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_UNARY_T_T_H | ||
| #define STDLIB_MATH_BASE_NAPI_UNARY_T_T_H | ||
| #include <node_api.h> | ||
| #include <assert.h> | ||
| #include <stdint.h> | ||
| /** | ||
| * Macro for registering a Node-API module exporting an interface invoking a unary function accepting and returning 16-bit unsigned integers. | ||
| * | ||
| * @param fcn unary function | ||
| * | ||
| * @example | ||
| * #include <stdint.h> | ||
| * | ||
| * static uint16_t scale( const uint16_t x ) { | ||
| * return x * 10; | ||
| * } | ||
| * | ||
| * // ... | ||
| * | ||
| * // Register a Node-API module: | ||
| * STDLIB_MATH_BASE_NAPI_MODULE_T_T( scale ); | ||
| */ | ||
| #define STDLIB_MATH_BASE_NAPI_MODULE_T_T( fcn ) \ | ||
| static napi_value stdlib_math_base_napi_t_t_wrapper( \ | ||
| napi_env env, \ | ||
| napi_callback_info info \ | ||
| ) { \ | ||
| return stdlib_math_base_napi_t_t( env, info, fcn ); \ | ||
| }; \ | ||
| static napi_value stdlib_math_base_napi_t_t_init( \ | ||
| napi_env env, \ | ||
| napi_value exports \ | ||
| ) { \ | ||
| napi_value f; \ | ||
| napi_status status = napi_create_function( \ | ||
| env, \ | ||
| "exports", \ | ||
| NAPI_AUTO_LENGTH, \ | ||
| stdlib_math_base_napi_t_t_wrapper, \ | ||
| NULL, \ | ||
| &f \ | ||
| ); \ | ||
| assert( status == napi_ok ); \ | ||
| return f; \ | ||
| }; \ | ||
| NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_t_t_init ) | ||
| /* | ||
| * If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. | ||
| */ | ||
| #ifdef __cplusplus | ||
| extern "C" { | ||
| #endif | ||
| /** | ||
| * Invokes a unary function accepting and returning unsigned 16-bit integers. | ||
| */ | ||
| napi_value stdlib_math_base_napi_t_t( napi_env env, napi_callback_info info, uint16_t (*fcn)( uint16_t ) ); | ||
| #ifdef __cplusplus | ||
| } | ||
| #endif | ||
| #endif // !STDLIB_MATH_BASE_NAPI_UNARY_T_T_H |
| /** | ||
| * @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_UNARY_U_U_H | ||
| #define STDLIB_MATH_BASE_NAPI_UNARY_U_U_H | ||
| #include <node_api.h> | ||
| #include <assert.h> | ||
| #include <stdint.h> | ||
| /** | ||
| * Macro for registering a Node-API module exporting an interface invoking a unary function accepting and returning 32-bit unsigned integers. | ||
| * | ||
| * @param fcn unary function | ||
| * | ||
| * @example | ||
| * #include <stdint.h> | ||
| * | ||
| * static uint32_t scale( const uint32_t x ) { | ||
| * return x * 10; | ||
| * } | ||
| * | ||
| * // ... | ||
| * | ||
| * // Register a Node-API module: | ||
| * STDLIB_MATH_BASE_NAPI_MODULE_U_U( scale ); | ||
| */ | ||
| #define STDLIB_MATH_BASE_NAPI_MODULE_U_U( fcn ) \ | ||
| static napi_value stdlib_math_base_napi_u_u_wrapper( \ | ||
| napi_env env, \ | ||
| napi_callback_info info \ | ||
| ) { \ | ||
| return stdlib_math_base_napi_u_u( env, info, fcn ); \ | ||
| }; \ | ||
| static napi_value stdlib_math_base_napi_u_u_init( \ | ||
| napi_env env, \ | ||
| napi_value exports \ | ||
| ) { \ | ||
| napi_value f; \ | ||
| napi_status status = napi_create_function( \ | ||
| env, \ | ||
| "exports", \ | ||
| NAPI_AUTO_LENGTH, \ | ||
| stdlib_math_base_napi_u_u_wrapper, \ | ||
| NULL, \ | ||
| &f \ | ||
| ); \ | ||
| assert( status == napi_ok ); \ | ||
| return f; \ | ||
| }; \ | ||
| NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_u_u_init ) | ||
| /* | ||
| * If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. | ||
| */ | ||
| #ifdef __cplusplus | ||
| extern "C" { | ||
| #endif | ||
| /** | ||
| * Invokes a unary function accepting and returning unsigned 32-bit integers. | ||
| */ | ||
| napi_value stdlib_math_base_napi_u_u( napi_env env, napi_callback_info info, uint32_t (*fcn)( uint32_t ) ); | ||
| #ifdef __cplusplus | ||
| } | ||
| #endif | ||
| #endif // !STDLIB_MATH_BASE_NAPI_UNARY_U_U_H |
| /** | ||
| * @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_UNARY_Z_D_H | ||
| #define STDLIB_MATH_BASE_NAPI_UNARY_Z_D_H | ||
| #include "stdlib/complex/float64/ctor.h" | ||
| #include <node_api.h> | ||
| #include <assert.h> | ||
| /** | ||
| * Macro for registering a Node-API module exporting an interface invoking a unary function accepting a double-precision complex floating-point number and returning a double-precision floating-point number. | ||
| * | ||
| * @param fcn unary function | ||
| * | ||
| * @example | ||
| * #include "stdlib/complex/float64/ctor.h" | ||
| * | ||
| * static double fcn( const stdlib_complex128_t x ) { | ||
| * // ... | ||
| * } | ||
| * | ||
| * // ... | ||
| * | ||
| * // Register a Node-API module: | ||
| * STDLIB_MATH_BASE_NAPI_MODULE_Z_D( fcn ); | ||
| */ | ||
| #define STDLIB_MATH_BASE_NAPI_MODULE_Z_D( fcn ) \ | ||
| static napi_value stdlib_math_base_napi_z_d_wrapper( \ | ||
| napi_env env, \ | ||
| napi_callback_info info \ | ||
| ) { \ | ||
| return stdlib_math_base_napi_z_d( env, info, fcn ); \ | ||
| }; \ | ||
| static napi_value stdlib_math_base_napi_z_d_init( \ | ||
| napi_env env, \ | ||
| napi_value exports \ | ||
| ) { \ | ||
| napi_value f; \ | ||
| napi_status status = napi_create_function( \ | ||
| env, \ | ||
| "exports", \ | ||
| NAPI_AUTO_LENGTH, \ | ||
| stdlib_math_base_napi_z_d_wrapper, \ | ||
| NULL, \ | ||
| &f \ | ||
| ); \ | ||
| assert( status == napi_ok ); \ | ||
| return f; \ | ||
| }; \ | ||
| NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_z_d_init ) | ||
| /* | ||
| * If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. | ||
| */ | ||
| #ifdef __cplusplus | ||
| extern "C" { | ||
| #endif | ||
| /** | ||
| * Invokes a unary function accepting a double-precision complex floating-point number and returning a double-precision floating-point number. | ||
| */ | ||
| napi_value stdlib_math_base_napi_z_d( napi_env env, napi_callback_info info, double (*fcn)( stdlib_complex128_t ) ); | ||
| #ifdef __cplusplus | ||
| } | ||
| #endif | ||
| #endif // !STDLIB_MATH_BASE_NAPI_UNARY_Z_D_H |
| /** | ||
| * @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_UNARY_Z_Z_H | ||
| #define STDLIB_MATH_BASE_NAPI_UNARY_Z_Z_H | ||
| #include "stdlib/complex/float64/ctor.h" | ||
| #include <node_api.h> | ||
| #include <assert.h> | ||
| /** | ||
| * Macro for registering a Node-API module exporting an interface invoking a unary function accepting and returning double-precision complex floating-point numbers. | ||
| * | ||
| * @param fcn unary function | ||
| * | ||
| * @example | ||
| * #include "stdlib/complex/float64/ctor.h" | ||
| * #include "stdlib/complex/float64/reim.h" | ||
| * | ||
| * static stdlib_complex128_t scale( const stdlib_complex128_t x ) { | ||
| * double re; | ||
| * double im; | ||
| * | ||
| * stdlib_complex128_reim( x, &re, &im ); | ||
| * | ||
| * re *= 10.0; | ||
| * im *= 10.0; | ||
| * | ||
| * return stdlib_complex128( re, im ); | ||
| * } | ||
| * | ||
| * // ... | ||
| * | ||
| * // Register a Node-API module: | ||
| * STDLIB_MATH_BASE_NAPI_MODULE_Z_Z( scale ); | ||
| */ | ||
| #define STDLIB_MATH_BASE_NAPI_MODULE_Z_Z( fcn ) \ | ||
| static napi_value stdlib_math_base_napi_z_z_wrapper( \ | ||
| napi_env env, \ | ||
| napi_callback_info info \ | ||
| ) { \ | ||
| return stdlib_math_base_napi_z_z( env, info, fcn ); \ | ||
| }; \ | ||
| static napi_value stdlib_math_base_napi_z_z_init( \ | ||
| napi_env env, \ | ||
| napi_value exports \ | ||
| ) { \ | ||
| napi_value f; \ | ||
| napi_status status = napi_create_function( \ | ||
| env, \ | ||
| "exports", \ | ||
| NAPI_AUTO_LENGTH, \ | ||
| stdlib_math_base_napi_z_z_wrapper, \ | ||
| NULL, \ | ||
| &f \ | ||
| ); \ | ||
| assert( status == napi_ok ); \ | ||
| return f; \ | ||
| }; \ | ||
| NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_z_z_init ) | ||
| /* | ||
| * If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. | ||
| */ | ||
| #ifdef __cplusplus | ||
| extern "C" { | ||
| #endif | ||
| /** | ||
| * Invokes a unary function accepting and returning double-precision complex floating-point numbers. | ||
| */ | ||
| napi_value stdlib_math_base_napi_z_z( napi_env env, napi_callback_info info, stdlib_complex128_t (*fcn)( stdlib_complex128_t ) ); | ||
| #ifdef __cplusplus | ||
| } | ||
| #endif | ||
| #endif // !STDLIB_MATH_BASE_NAPI_UNARY_Z_Z_H |
+71
| /** | ||
| * @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/unary/b_b.h" | ||
| #include <node_api.h> | ||
| #include <assert.h> | ||
| #include <stdint.h> | ||
| /** | ||
| * Invokes a unary function accepting and returning unsigned 8-bit integers. | ||
| * | ||
| * ## Notes | ||
| * | ||
| * - This function expects that the callback `info` argument provides access to the following JavaScript arguments: | ||
| * | ||
| * - `x`: input value. | ||
| * | ||
| * @param env environment under which the function is invoked | ||
| * @param info callback data | ||
| * @param fcn unary function | ||
| * @return function return value as a Node-API unsigned 32-bit integer | ||
| */ | ||
| napi_value stdlib_math_base_napi_b_b( napi_env env, napi_callback_info info, uint8_t (*fcn)( uint8_t ) ) { | ||
| napi_status status; | ||
| size_t argc = 1; | ||
| napi_value argv[ 1 ]; | ||
| status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL ); | ||
| assert( status == napi_ok ); | ||
| if ( argc < 1 ) { | ||
| status = napi_throw_error( env, NULL, "invalid invocation. Must provide a number." ); | ||
| 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. Must provide a number." ); | ||
| assert( status == napi_ok ); | ||
| return NULL; | ||
| } | ||
| uint32_t x; | ||
| status = napi_get_value_uint32( env, argv[ 0 ], &x ); | ||
| assert( status == napi_ok ); | ||
| napi_value v; | ||
| status = napi_create_uint32( env, (uint32_t)fcn( (uint8_t)x ), &v ); | ||
| assert( status == napi_ok ); | ||
| return v; | ||
| } | ||
+129
| /** | ||
| * @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/unary/c_c.h" | ||
| #include "stdlib/complex/float32/ctor.h" | ||
| #include "stdlib/complex/float32/reim.h" | ||
| #include <node_api.h> | ||
| #include <assert.h> | ||
| #include <stdbool.h> | ||
| /** | ||
| * Invokes a unary function accepting and returning single-precision complex floating-point numbers. | ||
| * | ||
| * ## Notes | ||
| * | ||
| * - This function expects that the callback `info` argument provides access to the following JavaScript arguments: | ||
| * | ||
| * - `x`: input value. | ||
| * | ||
| * @param env environment under which the function is invoked | ||
| * @param info callback data | ||
| * @param fcn unary function | ||
| * @return function return value as a Node-API complex-like object | ||
| */ | ||
| napi_value stdlib_math_base_napi_c_c( napi_env env, napi_callback_info info, stdlib_complex64_t (*fcn)( stdlib_complex64_t ) ) { | ||
| napi_status status; | ||
| size_t argc = 1; | ||
| napi_value argv[ 1 ]; | ||
| status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL ); | ||
| assert( status == napi_ok ); | ||
| if ( argc < 1 ) { | ||
| status = napi_throw_error( env, NULL, "invalid invocation. Must provide a complex number." ); | ||
| assert( status == napi_ok ); | ||
| return NULL; | ||
| } | ||
| bool hprop; | ||
| status = napi_has_named_property( env, argv[ 0 ], "re", &hprop ); | ||
| assert( status == napi_ok ); | ||
| if ( !hprop ) { | ||
| status = napi_throw_type_error( env, NULL, "invalid argument. Argument must have a real component." ); | ||
| assert( status == napi_ok ); | ||
| return NULL; | ||
| } | ||
| napi_value xre; | ||
| status = napi_get_named_property( env, argv[ 0 ], "re", &xre ); | ||
| assert( status == napi_ok ); | ||
| napi_valuetype xretype; | ||
| status = napi_typeof( env, xre, &xretype ); | ||
| assert( status == napi_ok ); | ||
| if ( xretype != napi_number ) { | ||
| status = napi_throw_type_error( env, NULL, "invalid argument. Argument must have a real component which is a number." ); | ||
| assert( status == napi_ok ); | ||
| return NULL; | ||
| } | ||
| status = napi_has_named_property( env, argv[ 0 ], "im", &hprop ); | ||
| assert( status == napi_ok ); | ||
| if ( !hprop ) { | ||
| status = napi_throw_type_error( env, NULL, "invalid argument. Argument must have an imaginary component." ); | ||
| assert( status == napi_ok ); | ||
| return NULL; | ||
| } | ||
| napi_value xim; | ||
| status = napi_get_named_property( env, argv[ 0 ], "im", &xim ); | ||
| assert( status == napi_ok ); | ||
| napi_valuetype ximtype; | ||
| status = napi_typeof( env, xim, &ximtype ); | ||
| assert( status == napi_ok ); | ||
| if ( ximtype != napi_number ) { | ||
| status = napi_throw_type_error( env, NULL, "invalid argument. Argument must have an imaginary component which a number." ); | ||
| assert( status == napi_ok ); | ||
| return NULL; | ||
| } | ||
| double re0; | ||
| status = napi_get_value_double( env, xre, &re0 ); | ||
| assert( status == napi_ok ); | ||
| double im0; | ||
| status = napi_get_value_double( env, xim, &im0 ); | ||
| assert( status == napi_ok ); | ||
| stdlib_complex64_t v = fcn( stdlib_complex64( (float)re0, (float)im0 ) ); | ||
| float re; | ||
| float im; | ||
| stdlib_complex64_reim( v, &re, &im ); | ||
| napi_value obj; | ||
| status = napi_create_object( env, &obj ); | ||
| assert( status == napi_ok ); | ||
| napi_value vre; | ||
| status = napi_create_double( env, (double)re, &vre ); | ||
| assert( status == napi_ok ); | ||
| status = napi_set_named_property( env, obj, "re", vre ); | ||
| assert( status == napi_ok ); | ||
| napi_value vim; | ||
| status = napi_create_double( env, (double)im, &vim ); | ||
| assert( status == napi_ok ); | ||
| status = napi_set_named_property( env, obj, "im", vim ); | ||
| assert( status == napi_ok ); | ||
| return obj; | ||
| } |
+109
| /** | ||
| * @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/unary/c_f.h" | ||
| #include "stdlib/complex/float32/ctor.h" | ||
| #include <node_api.h> | ||
| #include <assert.h> | ||
| #include <stdbool.h> | ||
| /** | ||
| * Invokes a unary function accepting a single-precision complex floating-point number and returning a single-precision floating-point number. | ||
| * | ||
| * ## Notes | ||
| * | ||
| * - This function expects that the callback `info` argument provides access to the following JavaScript arguments: | ||
| * | ||
| * - `x`: input value. | ||
| * | ||
| * @param env environment under which the function is invoked | ||
| * @param info callback data | ||
| * @param fcn unary function | ||
| * @return function return value as a Node-API complex-like object | ||
| */ | ||
| napi_value stdlib_math_base_napi_c_f( napi_env env, napi_callback_info info, float (*fcn)( stdlib_complex64_t ) ) { | ||
| napi_status status; | ||
| size_t argc = 1; | ||
| napi_value argv[ 1 ]; | ||
| status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL ); | ||
| assert( status == napi_ok ); | ||
| if ( argc < 1 ) { | ||
| status = napi_throw_error( env, NULL, "invalid invocation. Must provide a complex number." ); | ||
| assert( status == napi_ok ); | ||
| return NULL; | ||
| } | ||
| bool hprop; | ||
| status = napi_has_named_property( env, argv[ 0 ], "re", &hprop ); | ||
| assert( status == napi_ok ); | ||
| if ( !hprop ) { | ||
| status = napi_throw_type_error( env, NULL, "invalid argument. Argument must have a real component." ); | ||
| assert( status == napi_ok ); | ||
| return NULL; | ||
| } | ||
| napi_value xre; | ||
| status = napi_get_named_property( env, argv[ 0 ], "re", &xre ); | ||
| assert( status == napi_ok ); | ||
| napi_valuetype xretype; | ||
| status = napi_typeof( env, xre, &xretype ); | ||
| assert( status == napi_ok ); | ||
| if ( xretype != napi_number ) { | ||
| status = napi_throw_type_error( env, NULL, "invalid argument. Argument must have a real component which is a number." ); | ||
| assert( status == napi_ok ); | ||
| return NULL; | ||
| } | ||
| status = napi_has_named_property( env, argv[ 0 ], "im", &hprop ); | ||
| assert( status == napi_ok ); | ||
| if ( !hprop ) { | ||
| status = napi_throw_type_error( env, NULL, "invalid argument. Argument must have an imaginary component." ); | ||
| assert( status == napi_ok ); | ||
| return NULL; | ||
| } | ||
| napi_value xim; | ||
| status = napi_get_named_property( env, argv[ 0 ], "im", &xim ); | ||
| assert( status == napi_ok ); | ||
| napi_valuetype ximtype; | ||
| status = napi_typeof( env, xim, &ximtype ); | ||
| assert( status == napi_ok ); | ||
| if ( ximtype != napi_number ) { | ||
| status = napi_throw_type_error( env, NULL, "invalid argument. Argument must have an imaginary component which a number." ); | ||
| assert( status == napi_ok ); | ||
| return NULL; | ||
| } | ||
| double re; | ||
| status = napi_get_value_double( env, xre, &re ); | ||
| assert( status == napi_ok ); | ||
| double im; | ||
| status = napi_get_value_double( env, xim, &im ); | ||
| assert( status == napi_ok ); | ||
| napi_value v; | ||
| status = napi_create_double( env, (double)fcn( stdlib_complex64( (float)re, (float)im ) ), &v ); | ||
| assert( status == napi_ok ); | ||
| return v; | ||
| } |
+69
| /** | ||
| * @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/unary/d_d.h" | ||
| #include <node_api.h> | ||
| #include <assert.h> | ||
| /** | ||
| * Invokes a unary 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. | ||
| * | ||
| * @param env environment under which the function is invoked | ||
| * @param info callback data | ||
| * @param fcn unary function | ||
| * @return function return value as a Node-API double-precision floating-point number | ||
| */ | ||
| napi_value stdlib_math_base_napi_d_d( napi_env env, napi_callback_info info, double (*fcn)( double ) ) { | ||
| napi_status status; | ||
| size_t argc = 1; | ||
| napi_value argv[ 1 ]; | ||
| status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL ); | ||
| assert( status == napi_ok ); | ||
| if ( argc < 1 ) { | ||
| status = napi_throw_error( env, NULL, "invalid invocation. Must provide a number." ); | ||
| 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. Must provide a number." ); | ||
| assert( status == napi_ok ); | ||
| return NULL; | ||
| } | ||
| double x; | ||
| status = napi_get_value_double( env, argv[ 0 ], &x ); | ||
| assert( status == napi_ok ); | ||
| napi_value v; | ||
| status = napi_create_double( env, fcn( x ), &v ); | ||
| assert( status == napi_ok ); | ||
| return v; | ||
| } |
+69
| /** | ||
| * @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/unary/d_f.h" | ||
| #include <node_api.h> | ||
| #include <assert.h> | ||
| /** | ||
| * Invokes a unary function accepting a double-precision floating-point number and returning a single-precision floating-point number. | ||
| * | ||
| * ## Notes | ||
| * | ||
| * - This function expects that the callback `info` argument provides access to the following JavaScript arguments: | ||
| * | ||
| * - `x`: input value. | ||
| * | ||
| * @param env environment under which the function is invoked | ||
| * @param info callback data | ||
| * @param fcn unary function | ||
| * @return function return value as a Node-API double-precision floating-point number | ||
| */ | ||
| napi_value stdlib_math_base_napi_d_f( napi_env env, napi_callback_info info, float (*fcn)( double ) ) { | ||
| napi_status status; | ||
| size_t argc = 1; | ||
| napi_value argv[ 1 ]; | ||
| status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL ); | ||
| assert( status == napi_ok ); | ||
| if ( argc < 1 ) { | ||
| status = napi_throw_error( env, NULL, "invalid invocation. Must provide a number." ); | ||
| 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. Must provide a number." ); | ||
| assert( status == napi_ok ); | ||
| return NULL; | ||
| } | ||
| double x; | ||
| status = napi_get_value_double( env, argv[ 0 ], &x ); | ||
| assert( status == napi_ok ); | ||
| napi_value v; | ||
| status = napi_create_double( env, (double)fcn( x ), &v ); | ||
| assert( status == napi_ok ); | ||
| return v; | ||
| } |
+69
| /** | ||
| * @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/unary/f_f.h" | ||
| #include <node_api.h> | ||
| #include <assert.h> | ||
| /** | ||
| * Invokes a unary function accepting and returning single-precision floating-point numbers. | ||
| * | ||
| * ## Notes | ||
| * | ||
| * - This function expects that the callback `info` argument provides access to the following JavaScript arguments: | ||
| * | ||
| * - `x`: input value. | ||
| * | ||
| * @param env environment under which the function is invoked | ||
| * @param info callback data | ||
| * @param fcn unary function | ||
| * @return function return value as a Node-API double-precision floating-point number | ||
| */ | ||
| napi_value stdlib_math_base_napi_f_f( napi_env env, napi_callback_info info, float (*fcn)( float ) ) { | ||
| napi_status status; | ||
| size_t argc = 1; | ||
| napi_value argv[ 1 ]; | ||
| status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL ); | ||
| assert( status == napi_ok ); | ||
| if ( argc < 1 ) { | ||
| status = napi_throw_error( env, NULL, "invalid invocation. Must provide a number." ); | ||
| 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. Must provide a number." ); | ||
| assert( status == napi_ok ); | ||
| return NULL; | ||
| } | ||
| double x; | ||
| status = napi_get_value_double( env, argv[ 0 ], &x ); | ||
| assert( status == napi_ok ); | ||
| napi_value v; | ||
| status = napi_create_double( env, (double)fcn( (float)x ), &v ); | ||
| assert( status == napi_ok ); | ||
| return v; | ||
| } |
+70
| /** | ||
| * @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/unary/f_i.h" | ||
| #include <node_api.h> | ||
| #include <assert.h> | ||
| #include <stdint.h> | ||
| /** | ||
| * Invokes a unary function accepting a single-precision floating-point number and returning a signed 32-bit integer. | ||
| * | ||
| * ## Notes | ||
| * | ||
| * - This function expects that the callback `info` argument provides access to the following JavaScript arguments: | ||
| * | ||
| * - `x`: input value. | ||
| * | ||
| * @param env environment under which the function is invoked | ||
| * @param info callback data | ||
| * @param fcn unary function | ||
| * @return function return value as a Node-API signed 32-bit integer | ||
| */ | ||
| napi_value stdlib_math_base_napi_f_i( napi_env env, napi_callback_info info, int32_t (*fcn)( float ) ) { | ||
| napi_status status; | ||
| size_t argc = 1; | ||
| napi_value argv[ 1 ]; | ||
| status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL ); | ||
| assert( status == napi_ok ); | ||
| if ( argc < 1 ) { | ||
| status = napi_throw_error( env, NULL, "invalid invocation. Must provide a number." ); | ||
| 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. Must provide a number." ); | ||
| assert( status == napi_ok ); | ||
| return NULL; | ||
| } | ||
| double x; | ||
| status = napi_get_value_double( env, argv[ 0 ], &x ); | ||
| assert( status == napi_ok ); | ||
| napi_value v; | ||
| status = napi_create_int32( env, (int32_t)fcn( (float)x ), &v ); | ||
| assert( status == napi_ok ); | ||
| return v; | ||
| } |
+74
| /** | ||
| * @license Apache-2.0 | ||
| * | ||
| * Copyright (c) 2026 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/unary/h_h.h" | ||
| #include "stdlib/number/float64/base/to_float16.h" | ||
| #include "stdlib/number/float16/base/to_float64.h" | ||
| #include "stdlib/number/float16/ctor.h" | ||
| #include <node_api.h> | ||
| #include <assert.h> | ||
| /** | ||
| * Invokes a unary function accepting and returning half-precision floating-point numbers. | ||
| * | ||
| * ## Notes | ||
| * | ||
| * - This function expects that the callback `info` argument provides access to the following JavaScript arguments: | ||
| * | ||
| * - `x`: input value. | ||
| * | ||
| * @param env environment under which the function is invoked | ||
| * @param info callback data | ||
| * @param fcn unary function | ||
| * @return function return value as a Node-API half-precision floating-point number | ||
| */ | ||
| napi_value stdlib_math_base_napi_h_h( napi_env env, napi_callback_info info, stdlib_float16_t (*fcn)( stdlib_float16_t ) ) { | ||
| napi_status status; | ||
| size_t argc = 1; | ||
| napi_value argv[ 1 ]; | ||
| status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL ); | ||
| assert( status == napi_ok ); | ||
| if ( argc < 1 ) { | ||
| status = napi_throw_error( env, NULL, "invalid invocation. Must provide a number." ); | ||
| 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. Must provide a number." ); | ||
| assert( status == napi_ok ); | ||
| return NULL; | ||
| } | ||
| double x; | ||
| status = napi_get_value_double( env, argv[ 0 ], &x ); | ||
| assert( status == napi_ok ); | ||
| stdlib_float16_t out = fcn( stdlib_base_float64_to_float16( x ) ); | ||
| napi_value v; | ||
| status = napi_create_double( env, stdlib_base_float16_to_float64( out ), &v ); | ||
| assert( status == napi_ok ); | ||
| return v; | ||
| } |
+70
| /** | ||
| * @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/unary/i_d.h" | ||
| #include <node_api.h> | ||
| #include <assert.h> | ||
| #include <stdint.h> | ||
| /** | ||
| * Invokes a unary function accepting a signed 32-bit integer and returning a single-precision floating-point number. | ||
| * | ||
| * ## Notes | ||
| * | ||
| * - This function expects that the callback `info` argument provides access to the following JavaScript arguments: | ||
| * | ||
| * - `x`: input value. | ||
| * | ||
| * @param env environment under which the function is invoked | ||
| * @param info callback data | ||
| * @param fcn unary function | ||
| * @return function return value as a Node-API double-precision floating-point number | ||
| */ | ||
| napi_value stdlib_math_base_napi_i_d( napi_env env, napi_callback_info info, double (*fcn)( int32_t ) ) { | ||
| napi_status status; | ||
| size_t argc = 1; | ||
| napi_value argv[ 1 ]; | ||
| status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL ); | ||
| assert( status == napi_ok ); | ||
| if ( argc < 1 ) { | ||
| status = napi_throw_error( env, NULL, "invalid invocation. Must provide a number." ); | ||
| 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. Must provide a number." ); | ||
| assert( status == napi_ok ); | ||
| return NULL; | ||
| } | ||
| int32_t x; | ||
| status = napi_get_value_int32( env, argv[ 0 ], &x ); | ||
| assert( status == napi_ok ); | ||
| napi_value v; | ||
| status = napi_create_double( env, fcn( x ), &v ); | ||
| assert( status == napi_ok ); | ||
| return v; | ||
| } |
+70
| /** | ||
| * @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/unary/i_f.h" | ||
| #include <node_api.h> | ||
| #include <assert.h> | ||
| #include <stdint.h> | ||
| /** | ||
| * Invokes a unary function accepting a signed 32-bit integer and returning a single-precision floating-point number. | ||
| * | ||
| * ## Notes | ||
| * | ||
| * - This function expects that the callback `info` argument provides access to the following JavaScript arguments: | ||
| * | ||
| * - `x`: input value. | ||
| * | ||
| * @param env environment under which the function is invoked | ||
| * @param info callback data | ||
| * @param fcn unary function | ||
| * @return function return value as a Node-API double-precision floating-point number | ||
| */ | ||
| napi_value stdlib_math_base_napi_i_f( napi_env env, napi_callback_info info, float (*fcn)( int32_t ) ) { | ||
| napi_status status; | ||
| size_t argc = 1; | ||
| napi_value argv[ 1 ]; | ||
| status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL ); | ||
| assert( status == napi_ok ); | ||
| if ( argc < 1 ) { | ||
| status = napi_throw_error( env, NULL, "invalid invocation. Must provide a number." ); | ||
| 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. Must provide a number." ); | ||
| assert( status == napi_ok ); | ||
| return NULL; | ||
| } | ||
| int32_t x; | ||
| status = napi_get_value_int32( env, argv[ 0 ], &x ); | ||
| assert( status == napi_ok ); | ||
| napi_value v; | ||
| status = napi_create_double( env, (double)fcn( x ), &v ); | ||
| assert( status == napi_ok ); | ||
| return v; | ||
| } |
+70
| /** | ||
| * @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/unary/i_i.h" | ||
| #include <node_api.h> | ||
| #include <assert.h> | ||
| #include <stdint.h> | ||
| /** | ||
| * Invokes a unary function accepting and returning signed 32-bit integers. | ||
| * | ||
| * ## Notes | ||
| * | ||
| * - This function expects that the callback `info` argument provides access to the following JavaScript arguments: | ||
| * | ||
| * - `x`: input value. | ||
| * | ||
| * @param env environment under which the function is invoked | ||
| * @param info callback data | ||
| * @param fcn unary function | ||
| * @return function return value as a Node-API signed 32-bit integer | ||
| */ | ||
| napi_value stdlib_math_base_napi_i_i( napi_env env, napi_callback_info info, int32_t (*fcn)( int32_t ) ) { | ||
| napi_status status; | ||
| size_t argc = 1; | ||
| napi_value argv[ 1 ]; | ||
| status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL ); | ||
| assert( status == napi_ok ); | ||
| if ( argc < 1 ) { | ||
| status = napi_throw_error( env, NULL, "invalid invocation. Must provide a number." ); | ||
| 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. Must provide a number." ); | ||
| assert( status == napi_ok ); | ||
| return NULL; | ||
| } | ||
| int32_t x; | ||
| status = napi_get_value_int32( env, argv[ 0 ], &x ); | ||
| assert( status == napi_ok ); | ||
| napi_value v; | ||
| status = napi_create_int32( env, fcn( x ), &v ); | ||
| assert( status == napi_ok ); | ||
| return v; | ||
| } |
+70
| /** | ||
| * @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/unary/k_k.h" | ||
| #include <node_api.h> | ||
| #include <assert.h> | ||
| #include <stdint.h> | ||
| /** | ||
| * Invokes a unary function accepting and returning signed 16-bit integers. | ||
| * | ||
| * ## Notes | ||
| * | ||
| * - This function expects that the callback `info` argument provides access to the following JavaScript arguments: | ||
| * | ||
| * - `x`: input value. | ||
| * | ||
| * @param env environment under which the function is invoked | ||
| * @param info callback data | ||
| * @param fcn unary function | ||
| * @return function return value as a Node-API signed 32-bit integer | ||
| */ | ||
| napi_value stdlib_math_base_napi_k_k( napi_env env, napi_callback_info info, int16_t (*fcn)( int16_t ) ) { | ||
| napi_status status; | ||
| size_t argc = 1; | ||
| napi_value argv[ 1 ]; | ||
| status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL ); | ||
| assert( status == napi_ok ); | ||
| if ( argc < 1 ) { | ||
| status = napi_throw_error( env, NULL, "invalid invocation. Must provide a number." ); | ||
| 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. Must provide a number." ); | ||
| assert( status == napi_ok ); | ||
| return NULL; | ||
| } | ||
| int32_t x; | ||
| status = napi_get_value_int32( env, argv[ 0 ], &x ); | ||
| assert( status == napi_ok ); | ||
| napi_value v; | ||
| status = napi_create_int32( env, (int32_t)fcn( (int16_t)x ), &v ); | ||
| assert( status == napi_ok ); | ||
| return v; | ||
| } |
+71
| /** | ||
| * @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/unary/s_s.h" | ||
| #include <node_api.h> | ||
| #include <assert.h> | ||
| #include <stdint.h> | ||
| /** | ||
| * Invokes a unary function accepting and returning signed 8-bit integers. | ||
| * | ||
| * ## Notes | ||
| * | ||
| * - This function expects that the callback `info` argument provides access to the following JavaScript arguments: | ||
| * | ||
| * - `x`: input value. | ||
| * | ||
| * @param env environment under which the function is invoked | ||
| * @param info callback data | ||
| * @param fcn unary function | ||
| * @return function return value as a Node-API signed 32-bit integer | ||
| */ | ||
| napi_value stdlib_math_base_napi_s_s( napi_env env, napi_callback_info info, int8_t (*fcn)( int8_t ) ) { | ||
| napi_status status; | ||
| size_t argc = 1; | ||
| napi_value argv[ 1 ]; | ||
| status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL ); | ||
| assert( status == napi_ok ); | ||
| if ( argc < 1 ) { | ||
| status = napi_throw_error( env, NULL, "invalid invocation. Must provide a number." ); | ||
| 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. Must provide a number." ); | ||
| assert( status == napi_ok ); | ||
| return NULL; | ||
| } | ||
| int32_t x; | ||
| status = napi_get_value_int32( env, argv[ 0 ], &x ); | ||
| assert( status == napi_ok ); | ||
| napi_value v; | ||
| status = napi_create_int32( env, (int32_t)fcn( (int8_t)x ), &v ); | ||
| assert( status == napi_ok ); | ||
| return v; | ||
| } | ||
+70
| /** | ||
| * @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/unary/t_t.h" | ||
| #include <node_api.h> | ||
| #include <assert.h> | ||
| #include <stdint.h> | ||
| /** | ||
| * Invokes a unary function accepting and returning unsigned 16-bit integers. | ||
| * | ||
| * ## Notes | ||
| * | ||
| * - This function expects that the callback `info` argument provides access to the following JavaScript arguments: | ||
| * | ||
| * - `x`: input value. | ||
| * | ||
| * @param env environment under which the function is invoked | ||
| * @param info callback data | ||
| * @param fcn unary function | ||
| * @return function return value as a Node-API unsigned 32-bit integer | ||
| */ | ||
| napi_value stdlib_math_base_napi_t_t( napi_env env, napi_callback_info info, uint16_t (*fcn)( uint16_t ) ) { | ||
| napi_status status; | ||
| size_t argc = 1; | ||
| napi_value argv[ 1 ]; | ||
| status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL ); | ||
| assert( status == napi_ok ); | ||
| if ( argc < 1 ) { | ||
| status = napi_throw_error( env, NULL, "invalid invocation. Must provide a number." ); | ||
| 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. Must provide a number." ); | ||
| assert( status == napi_ok ); | ||
| return NULL; | ||
| } | ||
| uint32_t x; | ||
| status = napi_get_value_uint32( env, argv[ 0 ], &x ); | ||
| assert( status == napi_ok ); | ||
| napi_value v; | ||
| status = napi_create_uint32( env, (uint32_t)fcn( (uint16_t)x ), &v ); | ||
| assert( status == napi_ok ); | ||
| return v; | ||
| } |
+70
| /** | ||
| * @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/unary/u_u.h" | ||
| #include <node_api.h> | ||
| #include <assert.h> | ||
| #include <stdint.h> | ||
| /** | ||
| * Invokes a unary function accepting and returning unsigned 32-bit integers. | ||
| * | ||
| * ## Notes | ||
| * | ||
| * - This function expects that the callback `info` argument provides access to the following JavaScript arguments: | ||
| * | ||
| * - `x`: input value. | ||
| * | ||
| * @param env environment under which the function is invoked | ||
| * @param info callback data | ||
| * @param fcn unary function | ||
| * @return function return value as a Node-API unsigned 32-bit integer | ||
| */ | ||
| napi_value stdlib_math_base_napi_u_u( napi_env env, napi_callback_info info, uint32_t (*fcn)( uint32_t ) ) { | ||
| napi_status status; | ||
| size_t argc = 1; | ||
| napi_value argv[ 1 ]; | ||
| status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL ); | ||
| assert( status == napi_ok ); | ||
| if ( argc < 1 ) { | ||
| status = napi_throw_error( env, NULL, "invalid invocation. Must provide a number." ); | ||
| 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. Must provide a number." ); | ||
| assert( status == napi_ok ); | ||
| return NULL; | ||
| } | ||
| uint32_t x; | ||
| status = napi_get_value_uint32( env, argv[ 0 ], &x ); | ||
| assert( status == napi_ok ); | ||
| napi_value v; | ||
| status = napi_create_uint32( env, fcn( x ), &v ); | ||
| assert( status == napi_ok ); | ||
| return v; | ||
| } |
+109
| /** | ||
| * @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/unary/z_d.h" | ||
| #include "stdlib/complex/float64/ctor.h" | ||
| #include <node_api.h> | ||
| #include <assert.h> | ||
| #include <stdbool.h> | ||
| /** | ||
| * Invokes a unary function accepting a double-precision complex floating-point number and returning a double-precision floating-point number. | ||
| * | ||
| * ## Notes | ||
| * | ||
| * - This function expects that the callback `info` argument provides access to the following JavaScript arguments: | ||
| * | ||
| * - `x`: input value. | ||
| * | ||
| * @param env environment under which the function is invoked | ||
| * @param info callback data | ||
| * @param fcn unary function | ||
| * @return function return value as a Node-API complex-like object | ||
| */ | ||
| napi_value stdlib_math_base_napi_z_d( napi_env env, napi_callback_info info, double (*fcn)( stdlib_complex128_t ) ) { | ||
| napi_status status; | ||
| size_t argc = 1; | ||
| napi_value argv[ 1 ]; | ||
| status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL ); | ||
| assert( status == napi_ok ); | ||
| if ( argc < 1 ) { | ||
| status = napi_throw_error( env, NULL, "invalid invocation. Must provide a complex number." ); | ||
| assert( status == napi_ok ); | ||
| return NULL; | ||
| } | ||
| bool hprop; | ||
| status = napi_has_named_property( env, argv[ 0 ], "re", &hprop ); | ||
| assert( status == napi_ok ); | ||
| if ( !hprop ) { | ||
| status = napi_throw_type_error( env, NULL, "invalid argument. Argument must have a real component." ); | ||
| assert( status == napi_ok ); | ||
| return NULL; | ||
| } | ||
| napi_value xre; | ||
| status = napi_get_named_property( env, argv[ 0 ], "re", &xre ); | ||
| assert( status == napi_ok ); | ||
| napi_valuetype xretype; | ||
| status = napi_typeof( env, xre, &xretype ); | ||
| assert( status == napi_ok ); | ||
| if ( xretype != napi_number ) { | ||
| status = napi_throw_type_error( env, NULL, "invalid argument. Argument must have a real component which is a number." ); | ||
| assert( status == napi_ok ); | ||
| return NULL; | ||
| } | ||
| status = napi_has_named_property( env, argv[ 0 ], "im", &hprop ); | ||
| assert( status == napi_ok ); | ||
| if ( !hprop ) { | ||
| status = napi_throw_type_error( env, NULL, "invalid argument. Argument must have an imaginary component." ); | ||
| assert( status == napi_ok ); | ||
| return NULL; | ||
| } | ||
| napi_value xim; | ||
| status = napi_get_named_property( env, argv[ 0 ], "im", &xim ); | ||
| assert( status == napi_ok ); | ||
| napi_valuetype ximtype; | ||
| status = napi_typeof( env, xim, &ximtype ); | ||
| assert( status == napi_ok ); | ||
| if ( ximtype != napi_number ) { | ||
| status = napi_throw_type_error( env, NULL, "invalid argument. Argument must have an imaginary component which a number." ); | ||
| assert( status == napi_ok ); | ||
| return NULL; | ||
| } | ||
| double re; | ||
| status = napi_get_value_double( env, xre, &re ); | ||
| assert( status == napi_ok ); | ||
| double im; | ||
| status = napi_get_value_double( env, xim, &im ); | ||
| assert( status == napi_ok ); | ||
| napi_value v; | ||
| status = napi_create_double( env, fcn( stdlib_complex128( re, im ) ), &v ); | ||
| assert( status == napi_ok ); | ||
| return v; | ||
| } |
+129
| /** | ||
| * @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/unary/z_z.h" | ||
| #include "stdlib/complex/float64/ctor.h" | ||
| #include "stdlib/complex/float64/reim.h" | ||
| #include <node_api.h> | ||
| #include <assert.h> | ||
| #include <stdbool.h> | ||
| /** | ||
| * Invokes a unary function accepting and returning double-precision complex floating-point numbers. | ||
| * | ||
| * ## Notes | ||
| * | ||
| * - This function expects that the callback `info` argument provides access to the following JavaScript arguments: | ||
| * | ||
| * - `x`: input value. | ||
| * | ||
| * @param env environment under which the function is invoked | ||
| * @param info callback data | ||
| * @param fcn unary function | ||
| * @return function return value as a Node-API complex-like object | ||
| */ | ||
| napi_value stdlib_math_base_napi_z_z( napi_env env, napi_callback_info info, stdlib_complex128_t (*fcn)( stdlib_complex128_t ) ) { | ||
| napi_status status; | ||
| size_t argc = 1; | ||
| napi_value argv[ 1 ]; | ||
| status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL ); | ||
| assert( status == napi_ok ); | ||
| if ( argc < 1 ) { | ||
| status = napi_throw_error( env, NULL, "invalid invocation. Must provide a complex number." ); | ||
| assert( status == napi_ok ); | ||
| return NULL; | ||
| } | ||
| bool hprop; | ||
| status = napi_has_named_property( env, argv[ 0 ], "re", &hprop ); | ||
| assert( status == napi_ok ); | ||
| if ( !hprop ) { | ||
| status = napi_throw_type_error( env, NULL, "invalid argument. Argument must have a real component." ); | ||
| assert( status == napi_ok ); | ||
| return NULL; | ||
| } | ||
| napi_value xre; | ||
| status = napi_get_named_property( env, argv[ 0 ], "re", &xre ); | ||
| assert( status == napi_ok ); | ||
| napi_valuetype xretype; | ||
| status = napi_typeof( env, xre, &xretype ); | ||
| assert( status == napi_ok ); | ||
| if ( xretype != napi_number ) { | ||
| status = napi_throw_type_error( env, NULL, "invalid argument. Argument must have a real component which is a number." ); | ||
| assert( status == napi_ok ); | ||
| return NULL; | ||
| } | ||
| status = napi_has_named_property( env, argv[ 0 ], "im", &hprop ); | ||
| assert( status == napi_ok ); | ||
| if ( !hprop ) { | ||
| status = napi_throw_type_error( env, NULL, "invalid argument. Argument must have an imaginary component." ); | ||
| assert( status == napi_ok ); | ||
| return NULL; | ||
| } | ||
| napi_value xim; | ||
| status = napi_get_named_property( env, argv[ 0 ], "im", &xim ); | ||
| assert( status == napi_ok ); | ||
| napi_valuetype ximtype; | ||
| status = napi_typeof( env, xim, &ximtype ); | ||
| assert( status == napi_ok ); | ||
| if ( ximtype != napi_number ) { | ||
| status = napi_throw_type_error( env, NULL, "invalid argument. Argument must have an imaginary component which a number." ); | ||
| assert( status == napi_ok ); | ||
| return NULL; | ||
| } | ||
| double re0; | ||
| status = napi_get_value_double( env, xre, &re0 ); | ||
| assert( status == napi_ok ); | ||
| double im0; | ||
| status = napi_get_value_double( env, xim, &im0 ); | ||
| assert( status == napi_ok ); | ||
| stdlib_complex128_t v = fcn( stdlib_complex128( re0, im0 ) ); | ||
| double re; | ||
| double im; | ||
| stdlib_complex128_reim( v, &re, &im ); | ||
| napi_value obj; | ||
| status = napi_create_object( env, &obj ); | ||
| assert( status == napi_ok ); | ||
| napi_value vre; | ||
| status = napi_create_double( env, re, &vre ); | ||
| assert( status == napi_ok ); | ||
| status = napi_set_named_property( env, obj, "re", vre ); | ||
| assert( status == napi_ok ); | ||
| napi_value vim; | ||
| status = napi_create_double( env, im, &vim ); | ||
| assert( status == napi_ok ); | ||
| status = napi_set_named_property( env, obj, "im", vim ); | ||
| assert( status == napi_ok ); | ||
| return obj; | ||
| } |
@@ -22,409 +22,21 @@ /** | ||
| #include "stdlib/complex/float32/ctor.h" | ||
| #include "stdlib/complex/float64/ctor.h" | ||
| #include <node_api.h> | ||
| #include <assert.h> | ||
| #include <stdint.h> | ||
| // NOTE: keep in alphabetical order... | ||
| #include "stdlib/math/base/napi/unary/b_b.h" | ||
| #include "stdlib/math/base/napi/unary/c_c.h" | ||
| #include "stdlib/math/base/napi/unary/c_f.h" | ||
| #include "stdlib/math/base/napi/unary/d_d.h" | ||
| #include "stdlib/math/base/napi/unary/d_f.h" | ||
| #include "stdlib/math/base/napi/unary/f_f.h" | ||
| #include "stdlib/math/base/napi/unary/f_i.h" | ||
| #include "stdlib/math/base/napi/unary/h_h.h" | ||
| #include "stdlib/math/base/napi/unary/i_d.h" | ||
| #include "stdlib/math/base/napi/unary/i_f.h" | ||
| #include "stdlib/math/base/napi/unary/i_i.h" | ||
| #include "stdlib/math/base/napi/unary/k_k.h" | ||
| #include "stdlib/math/base/napi/unary/s_s.h" | ||
| #include "stdlib/math/base/napi/unary/t_t.h" | ||
| #include "stdlib/math/base/napi/unary/u_u.h" | ||
| #include "stdlib/math/base/napi/unary/z_d.h" | ||
| #include "stdlib/math/base/napi/unary/z_z.h" | ||
| /** | ||
| * Macro for registering a Node-API module exporting an interface invoking a unary function accepting and returning double-precision floating-point numbers. | ||
| * | ||
| * @param fcn unary function | ||
| * | ||
| * @example | ||
| * static double scale( const double x ) { | ||
| * return x * 10.0; | ||
| * } | ||
| * | ||
| * // ... | ||
| * | ||
| * // Register a Node-API module: | ||
| * STDLIB_MATH_BASE_NAPI_MODULE_D_D( scale ); | ||
| */ | ||
| #define STDLIB_MATH_BASE_NAPI_MODULE_D_D( fcn ) \ | ||
| static napi_value stdlib_math_base_napi_d_d_wrapper( \ | ||
| napi_env env, \ | ||
| napi_callback_info info \ | ||
| ) { \ | ||
| return stdlib_math_base_napi_d_d( env, info, fcn ); \ | ||
| }; \ | ||
| static napi_value stdlib_math_base_napi_d_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_d_d_wrapper, \ | ||
| NULL, \ | ||
| &fcn \ | ||
| ); \ | ||
| assert( status == napi_ok ); \ | ||
| return fcn; \ | ||
| }; \ | ||
| NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_d_d_init ) | ||
| /** | ||
| * Macro for registering a Node-API module exporting an interface invoking a unary function accepting and returning single-precision floating-point numbers. | ||
| * | ||
| * @param fcn unary function | ||
| * | ||
| * @example | ||
| * static float scale( const float x ) { | ||
| * return x * 10.0f; | ||
| * } | ||
| * | ||
| * // ... | ||
| * | ||
| * // Register a Node-API module: | ||
| * STDLIB_MATH_BASE_NAPI_MODULE_F_F( scale ); | ||
| */ | ||
| #define STDLIB_MATH_BASE_NAPI_MODULE_F_F( fcn ) \ | ||
| static napi_value stdlib_math_base_napi_f_f_wrapper( \ | ||
| napi_env env, \ | ||
| napi_callback_info info \ | ||
| ) { \ | ||
| return stdlib_math_base_napi_f_f( env, info, fcn ); \ | ||
| }; \ | ||
| static napi_value stdlib_math_base_napi_f_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_f_f_wrapper, \ | ||
| NULL, \ | ||
| &fcn \ | ||
| ); \ | ||
| assert( status == napi_ok ); \ | ||
| return fcn; \ | ||
| }; \ | ||
| NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_f_f_init ) | ||
| /** | ||
| * Macro for registering a Node-API module exporting an interface invoking a unary function accepting and returning double-precision complex floating-point numbers. | ||
| * | ||
| * @param fcn unary function | ||
| * | ||
| * @example | ||
| * #include "stdlib/complex/float64/ctor.h" | ||
| * #include "stdlib/complex/float64/reim.h" | ||
| * | ||
| * static stdlib_complex128_t scale( const stdlib_complex128_t x ) { | ||
| * double re; | ||
| * double im; | ||
| * | ||
| * stdlib_complex128_reim( x, &re, &im ); | ||
| * | ||
| * re *= 10.0; | ||
| * im *= 10.0; | ||
| * | ||
| * return stdlib_complex128( re, im ); | ||
| * } | ||
| * | ||
| * // ... | ||
| * | ||
| * // Register a Node-API module: | ||
| * STDLIB_MATH_BASE_NAPI_MODULE_Z_Z( scale ); | ||
| */ | ||
| #define STDLIB_MATH_BASE_NAPI_MODULE_Z_Z( fcn ) \ | ||
| static napi_value stdlib_math_base_napi_z_z_wrapper( \ | ||
| napi_env env, \ | ||
| napi_callback_info info \ | ||
| ) { \ | ||
| return stdlib_math_base_napi_z_z( env, info, fcn ); \ | ||
| }; \ | ||
| static napi_value stdlib_math_base_napi_z_z_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_z_z_wrapper, \ | ||
| NULL, \ | ||
| &fcn \ | ||
| ); \ | ||
| assert( status == napi_ok ); \ | ||
| return fcn; \ | ||
| }; \ | ||
| NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_z_z_init ) | ||
| /** | ||
| * Macro for registering a Node-API module exporting an interface invoking a unary function accepting a double-precision complex floating-point number and returning a double-precision floating-point number. | ||
| * | ||
| * @param fcn unary function | ||
| * | ||
| * @example | ||
| * #include "stdlib/complex/float64/ctor.h" | ||
| * | ||
| * static double fcn( const stdlib_complex128_t x ) { | ||
| * // ... | ||
| * } | ||
| * | ||
| * // ... | ||
| * | ||
| * // Register a Node-API module: | ||
| * STDLIB_MATH_BASE_NAPI_MODULE_Z_D( fcn ); | ||
| */ | ||
| #define STDLIB_MATH_BASE_NAPI_MODULE_Z_D( fcn ) \ | ||
| static napi_value stdlib_math_base_napi_z_d_wrapper( \ | ||
| napi_env env, \ | ||
| napi_callback_info info \ | ||
| ) { \ | ||
| return stdlib_math_base_napi_z_d( env, info, fcn ); \ | ||
| }; \ | ||
| static napi_value stdlib_math_base_napi_z_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_z_d_wrapper, \ | ||
| NULL, \ | ||
| &fcn \ | ||
| ); \ | ||
| assert( status == napi_ok ); \ | ||
| return fcn; \ | ||
| }; \ | ||
| NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_z_d_init ) | ||
| /** | ||
| * Macro for registering a Node-API module exporting an interface invoking a unary function accepting and returning single-precision complex floating-point numbers. | ||
| * | ||
| * @param fcn unary function | ||
| * | ||
| * @example | ||
| * #include "stdlib/complex/float32/ctor.h" | ||
| * #include "stdlib/complex/float32/reim.h" | ||
| * | ||
| * static stdlib_complex64_t scale( const stdlib_complex64_t x ) { | ||
| * float re; | ||
| * float im; | ||
| * | ||
| * stdlib_complex64_reim( x, &re, &im ); | ||
| * | ||
| * re *= 10.0f; | ||
| * im *= 10.0f; | ||
| * | ||
| * return stdlib_complex64( re, im ); | ||
| * } | ||
| * | ||
| * // ... | ||
| * | ||
| * // Register a Node-API module: | ||
| * STDLIB_MATH_BASE_NAPI_MODULE_C_C( scale ); | ||
| */ | ||
| #define STDLIB_MATH_BASE_NAPI_MODULE_C_C( fcn ) \ | ||
| static napi_value stdlib_math_base_napi_c_c_wrapper( \ | ||
| napi_env env, \ | ||
| napi_callback_info info \ | ||
| ) { \ | ||
| return stdlib_math_base_napi_c_c( env, info, fcn ); \ | ||
| }; \ | ||
| static napi_value stdlib_math_base_napi_c_c_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_c_c_wrapper, \ | ||
| NULL, \ | ||
| &fcn \ | ||
| ); \ | ||
| assert( status == napi_ok ); \ | ||
| return fcn; \ | ||
| }; \ | ||
| NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_c_c_init ) | ||
| /** | ||
| * 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. | ||
| * | ||
| * @param fcn unary function | ||
| * | ||
| * @example | ||
| * #include "stdlib/complex/float32/ctor.h" | ||
| * | ||
| * static float fcn( const stdlib_complex64_t x ) { | ||
| * // ... | ||
| * } | ||
| * | ||
| * // ... | ||
| * | ||
| * // Register a Node-API module: | ||
| * STDLIB_MATH_BASE_NAPI_MODULE_C_F( fcn ); | ||
| */ | ||
| #define STDLIB_MATH_BASE_NAPI_MODULE_C_F( fcn ) \ | ||
| static napi_value stdlib_math_base_napi_c_f_wrapper( \ | ||
| napi_env env, \ | ||
| napi_callback_info info \ | ||
| ) { \ | ||
| return stdlib_math_base_napi_c_f( env, info, fcn ); \ | ||
| }; \ | ||
| static napi_value stdlib_math_base_napi_c_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_c_f_wrapper, \ | ||
| NULL, \ | ||
| &fcn \ | ||
| ); \ | ||
| assert( status == napi_ok ); \ | ||
| return fcn; \ | ||
| }; \ | ||
| NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_c_f_init ) | ||
| /** | ||
| * Macro for registering a Node-API module exporting an interface invoking a unary function accepting and returning 32-bit signed integers. | ||
| * | ||
| * @param fcn unary function | ||
| * | ||
| * @example | ||
| * #include <stdint.h> | ||
| * | ||
| * static int32_t scale( const int32_t x ) { | ||
| * return x * 10; | ||
| * } | ||
| * | ||
| * // ... | ||
| * | ||
| * // Register a Node-API module: | ||
| * STDLIB_MATH_BASE_NAPI_MODULE_I_I( scale ); | ||
| */ | ||
| #define STDLIB_MATH_BASE_NAPI_MODULE_I_I( fcn ) \ | ||
| static napi_value stdlib_math_base_napi_i_i_wrapper( \ | ||
| napi_env env, \ | ||
| napi_callback_info info \ | ||
| ) { \ | ||
| return stdlib_math_base_napi_i_i( env, info, fcn ); \ | ||
| }; \ | ||
| static napi_value stdlib_math_base_napi_i_i_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_i_i_wrapper, \ | ||
| NULL, \ | ||
| &fcn \ | ||
| ); \ | ||
| assert( status == napi_ok ); \ | ||
| return fcn; \ | ||
| }; \ | ||
| NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_i_i_init ) | ||
| /** | ||
| * Macro for registering a Node-API module exporting an interface invoking a unary function accepting a signed 32-bit integer and returning a double-precision floating-point number. | ||
| * | ||
| * @param fcn unary function | ||
| * | ||
| * @example | ||
| * #include <stdint.h> | ||
| * | ||
| * static double scale( const int32_t x ) { | ||
| * return x * 10.0; | ||
| * } | ||
| * | ||
| * // ... | ||
| * | ||
| * // Register a Node-API module: | ||
| * STDLIB_MATH_BASE_NAPI_MODULE_I_D( scale ); | ||
| */ | ||
| #define STDLIB_MATH_BASE_NAPI_MODULE_I_D( fcn ) \ | ||
| static napi_value stdlib_math_base_napi_i_d_wrapper( \ | ||
| napi_env env, \ | ||
| napi_callback_info info \ | ||
| ) { \ | ||
| return stdlib_math_base_napi_i_d( env, info, fcn ); \ | ||
| }; \ | ||
| static napi_value stdlib_math_base_napi_i_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_i_d_wrapper, \ | ||
| NULL, \ | ||
| &fcn \ | ||
| ); \ | ||
| assert( status == napi_ok ); \ | ||
| return fcn; \ | ||
| }; \ | ||
| NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_i_d_init ) | ||
| /* | ||
| * If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. | ||
| */ | ||
| #ifdef __cplusplus | ||
| extern "C" { | ||
| #endif | ||
| /** | ||
| * Invokes a unary function accepting and returning double-precision floating-point numbers. | ||
| */ | ||
| napi_value stdlib_math_base_napi_d_d( napi_env env, napi_callback_info info, double (*fcn)( double ) ); | ||
| /** | ||
| * Invokes a unary function accepting and returning single-precision floating-point numbers. | ||
| */ | ||
| napi_value stdlib_math_base_napi_f_f( napi_env env, napi_callback_info info, float (*fcn)( float ) ); | ||
| /** | ||
| * Invokes a unary function accepting and returning double-precision complex floating-point numbers. | ||
| */ | ||
| napi_value stdlib_math_base_napi_z_z( napi_env env, napi_callback_info info, stdlib_complex128_t (*fcn)( stdlib_complex128_t ) ); | ||
| /** | ||
| * Invokes a unary function accepting a double-precision complex floating-point number and returning a double-precision floating-point number. | ||
| */ | ||
| napi_value stdlib_math_base_napi_z_d( napi_env env, napi_callback_info info, double (*fcn)( stdlib_complex128_t ) ); | ||
| /** | ||
| * Invokes a unary function accepting and returning single-precision complex floating-point numbers. | ||
| */ | ||
| napi_value stdlib_math_base_napi_c_c( napi_env env, napi_callback_info info, stdlib_complex64_t (*fcn)( stdlib_complex64_t ) ); | ||
| /** | ||
| * Invokes a unary function accepting a single-precision complex floating-point number and returning a single-precision floating-point number. | ||
| */ | ||
| napi_value stdlib_math_base_napi_c_f( napi_env env, napi_callback_info info, float (*fcn)( stdlib_complex64_t ) ); | ||
| /** | ||
| * Invokes a unary function accepting and returning signed 32-bit integers. | ||
| */ | ||
| napi_value stdlib_math_base_napi_i_i( napi_env env, napi_callback_info info, int32_t (*fcn)( int32_t ) ); | ||
| /** | ||
| * Invokes a unary function accepting a signed 32-bit integer and returning a single-precision floating-point number. | ||
| */ | ||
| napi_value stdlib_math_base_napi_i_d( napi_env env, napi_callback_info info, double (*fcn)( int32_t ) ); | ||
| #ifdef __cplusplus | ||
| } | ||
| #endif | ||
| #endif // !STDLIB_MATH_BASE_NAPI_UNARY_H |
+56
-37
| { | ||
| "options": {}, | ||
| "fields": [ | ||
| { | ||
| "field": "src", | ||
| "resolve": true, | ||
| "relative": true | ||
| }, | ||
| { | ||
| "field": "include", | ||
| "resolve": true, | ||
| "relative": true | ||
| }, | ||
| { | ||
| "field": "libraries", | ||
| "resolve": false, | ||
| "relative": false | ||
| }, | ||
| { | ||
| "field": "libpath", | ||
| "resolve": true, | ||
| "relative": false | ||
| } | ||
| ], | ||
| "confs": [ | ||
| { | ||
| "src": [ | ||
| "./src/main.c" | ||
| ], | ||
| "include": [ | ||
| "./include" | ||
| ], | ||
| "libraries": [], | ||
| "libpath": [], | ||
| "dependencies": [ | ||
| "options": {}, | ||
| "fields": [ | ||
| { | ||
| "field": "src", | ||
| "resolve": true, | ||
| "relative": true | ||
| }, | ||
| { | ||
| "field": "include", | ||
| "resolve": true, | ||
| "relative": true | ||
| }, | ||
| { | ||
| "field": "libraries", | ||
| "resolve": false, | ||
| "relative": false | ||
| }, | ||
| { | ||
| "field": "libpath", | ||
| "resolve": true, | ||
| "relative": false | ||
| } | ||
| ], | ||
| "confs": [ | ||
| { | ||
| "src": [ | ||
| "./src/b_b.c", | ||
| "./src/c_c.c", | ||
| "./src/c_f.c", | ||
| "./src/d_d.c", | ||
| "./src/d_f.c", | ||
| "./src/f_f.c", | ||
| "./src/f_i.c", | ||
| "./src/h_h.c", | ||
| "./src/i_d.c", | ||
| "./src/i_f.c", | ||
| "./src/i_i.c", | ||
| "./src/k_k.c", | ||
| "./src/s_s.c", | ||
| "./src/t_t.c", | ||
| "./src/u_u.c", | ||
| "./src/z_d.c", | ||
| "./src/z_z.c" | ||
| ], | ||
| "include": [ | ||
| "./include" | ||
| ], | ||
| "libraries": [], | ||
| "libpath": [], | ||
| "dependencies": [ | ||
| "@stdlib/complex-float32-ctor", | ||
| "@stdlib/complex-float64-ctor", | ||
| "@stdlib/complex-float64-reim", | ||
| "@stdlib/complex-float32-reim" | ||
| "@stdlib/complex-float32-reim", | ||
| "@stdlib/number-float16-ctor", | ||
| "@stdlib/number-float64-base-to-float16", | ||
| "@stdlib/number-float16-base-to-float64" | ||
| ] | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
| } |
+1
-1
@@ -1,1 +0,1 @@ | ||
| Copyright (c) 2016-2024 The Stdlib Authors. | ||
| Copyright (c) 2016-2026 The Stdlib Authors. |
+6
-3
| { | ||
| "name": "@stdlib/math-base-napi-unary", | ||
| "version": "0.2.3", | ||
| "version": "0.2.4", | ||
| "description": "C APIs for registering a Node-API module exporting an interface for invoking a unary numerical function.", | ||
@@ -38,5 +38,8 @@ "license": "Apache-2.0", | ||
| "@stdlib/complex-float32-ctor": "^0.0.2", | ||
| "@stdlib/complex-float32-reim": "^0.1.1", | ||
| "@stdlib/complex-float32-reim": "^0.1.2", | ||
| "@stdlib/complex-float64-ctor": "^0.0.3", | ||
| "@stdlib/complex-float64-reim": "^0.1.1", | ||
| "@stdlib/complex-float64-reim": "^0.1.2", | ||
| "@stdlib/number-float16-base-to-float64": "github:stdlib-js/number-float16-base-to-float64#main", | ||
| "@stdlib/number-float16-ctor": "github:stdlib-js/number-float16-ctor#main", | ||
| "@stdlib/number-float64-base-to-float16": "github:stdlib-js/number-float64-base-to-float16#main", | ||
| "@stdlib/utils-library-manifest": "^0.2.2" | ||
@@ -43,0 +46,0 @@ }, |
+684
-118
@@ -130,2 +130,223 @@ <!-- | ||
| <!-- NOTE: keep in alphabetical order according to the suffix X_X --> | ||
| #### STDLIB_MATH_BASE_NAPI_MODULE_B_B( fcn ) | ||
| Macro for registering a Node-API module exporting an interface for invoking a unary function accepting and returning 8-bit unsigned integers. | ||
| ```c | ||
| #include <stdint.h> | ||
| static uint8_t scale( const uint8_t x ) { | ||
| return x * 10; | ||
| } | ||
| // ... | ||
| // Register a Node-API module: | ||
| STDLIB_MATH_BASE_NAPI_MODULE_B_B( scale ); | ||
| ``` | ||
| The macro expects the following arguments: | ||
| - **fcn**: `uint8_t (*fcn)( uint8_t )` unary 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_b_b( env, info, fcn ) | ||
| Invokes a unary function accepting and returning unsigned 8-bit integers. | ||
| ```c | ||
| #include <node_api.h> | ||
| #include <stdint.h> | ||
| // ... | ||
| static uint8_t identity( const uint8_t x ) { | ||
| return x; | ||
| } | ||
| // ... | ||
| /** | ||
| * Receives JavaScript callback invocation data. | ||
| * | ||
| * @param env environment under which the function is invoked | ||
| * @param info callback data | ||
| * @return Node-API value | ||
| */ | ||
| napi_value addon( napi_env env, napi_callback_info info ) { | ||
| return stdlib_math_base_napi_b_b( env, info, identity ); | ||
| } | ||
| // ... | ||
| ``` | ||
| The function accepts the following arguments: | ||
| - **env**: `[in] napi_env` environment under which the function is invoked. | ||
| - **info**: `[in] napi_callback_info` callback data. | ||
| - **fcn**: `[in] uint8_t (*fcn)( uint8_t )` unary function. | ||
| ```c | ||
| void stdlib_math_base_napi_b_b( napi_env env, napi_callback_info info, uint8_t (*fcn)( uint8_t ) ); | ||
| ``` | ||
| #### STDLIB_MATH_BASE_NAPI_MODULE_C_C( fcn ) | ||
| Macro for registering a Node-API module exporting an interface for invoking a unary function accepting and returning single-precision complex floating-point numbers. | ||
| ```c | ||
| #include "stdlib/complex/float32/ctor.h" | ||
| #include "stdlib/complex/float32/reim.h" | ||
| static stdlib_complex64_t scale( const stdlib_complex64_t x ) { | ||
| float re; | ||
| float im; | ||
| stdlib_complex64_reim( x, &re, &im ); | ||
| re *= 10.0f; | ||
| im *= 10.0f; | ||
| return stdlib_complex64( re, im ); | ||
| } | ||
| // ... | ||
| // Register a Node-API module: | ||
| STDLIB_MATH_BASE_NAPI_MODULE_C_C( scale ); | ||
| ``` | ||
| The macro expects the following arguments: | ||
| - **fcn**: `stdlib_complex64_t (*fcn)( stdlib_complex64_t )` unary 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_c_c( env, info, fcn ) | ||
| Invokes a unary function accepting and returning single-precision complex floating-point numbers. | ||
| ```c | ||
| #include "stdlib/complex/float32/ctor.h" | ||
| #include <node_api.h> | ||
| // ... | ||
| static stdlib_complex64_t identity( const stdlib_complex64_t x ) { | ||
| return x; | ||
| } | ||
| // ... | ||
| /** | ||
| * Receives JavaScript callback invocation data. | ||
| * | ||
| * @param env environment under which the function is invoked | ||
| * @param info callback data | ||
| * @return Node-API value | ||
| */ | ||
| napi_value addon( napi_env env, napi_callback_info info ) { | ||
| return stdlib_math_base_napi_c_c( env, info, identity ); | ||
| } | ||
| // ... | ||
| ``` | ||
| The function accepts the following arguments: | ||
| - **env**: `[in] napi_env` environment under which the function is invoked. | ||
| - **info**: `[in] napi_callback_info` callback data. | ||
| - **fcn**: `[in] stdlib_complex64_t (*fcn)( stdlib_complex64_t )` unary function. | ||
| ```c | ||
| void stdlib_math_base_napi_c_c( napi_env env, napi_callback_info info, stdlib_complex64_t (*fcn)( stdlib_complex64_t ) ); | ||
| ``` | ||
| #### STDLIB_MATH_BASE_NAPI_MODULE_C_F( fcn ) | ||
| Macro for registering a Node-API module exporting an interface for invoking a unary function accepting a single-precision complex floating-point number and returning a single-precision floating-point number. | ||
| ```c | ||
| #include "stdlib/complex/float32/ctor.h" | ||
| static float fcn( const stdlib_complex64_t x ) { | ||
| // ... | ||
| } | ||
| // ... | ||
| // Register a Node-API module: | ||
| STDLIB_MATH_BASE_NAPI_MODULE_C_F( fcn ); | ||
| ``` | ||
| The macro expects the following arguments: | ||
| - **fcn**: `float (*fcn)( stdlib_complex64_t )` unary 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_c_f( env, info, fcn ) | ||
| Invokes a unary function accepting a single-precision complex floating-point number and returning a single-precision floating-point number. | ||
| ```c | ||
| #include "stdlib/complex/float32/ctor.h" | ||
| #include <node_api.h> | ||
| // ... | ||
| static float fcn( const stdlib_complex64_t x ) { | ||
| // ... | ||
| } | ||
| // ... | ||
| /** | ||
| * Receives JavaScript callback invocation data. | ||
| * | ||
| * @param env environment under which the function is invoked | ||
| * @param info callback data | ||
| * @return Node-API value | ||
| */ | ||
| napi_value addon( napi_env env, napi_callback_info info ) { | ||
| return stdlib_math_base_napi_c_f( env, info, fcn ); | ||
| } | ||
| // ... | ||
| ``` | ||
| The function accepts the following arguments: | ||
| - **env**: `[in] napi_env` environment under which the function is invoked. | ||
| - **info**: `[in] napi_callback_info` callback data. | ||
| - **fcn**: `[in] float (*fcn)( stdlib_complex64_t )` unary function. | ||
| ```c | ||
| void stdlib_math_base_napi_c_f( napi_env env, napi_callback_info info, float (*fcn)( stdlib_complex64_t ) ); | ||
| ``` | ||
| #### STDLIB_MATH_BASE_NAPI_MODULE_D_D( fcn ) | ||
| Macro for registering a Node-API module exporting an interface for invoking a unary function accepting and returning double-precision floating-point numbers. | ||
| ```c | ||
| static double scale( const double x ) { | ||
| return x * 10.0; | ||
| } | ||
| // ... | ||
| // Register a Node-API module: | ||
| STDLIB_MATH_BASE_NAPI_MODULE_D_D( scale ); | ||
| ``` | ||
| The macro expects the following arguments: | ||
| - **fcn**: `double (*fcn)( double )` unary 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_d_d( env, info, fcn ) | ||
@@ -170,2 +391,83 @@ | ||
| #### STDLIB_MATH_BASE_NAPI_MODULE_D_F( fcn ) | ||
| Macro for registering a Node-API module exporting an interface for invoking a unary function accepting a double-precision floating-point number and returning a single-precision floating-point number. | ||
| ```c | ||
| static float fcn( const double x ) { | ||
| return (float)x; | ||
| } | ||
| // ... | ||
| // Register a Node-API module: | ||
| STDLIB_MATH_BASE_NAPI_MODULE_D_F( fcn ); | ||
| ``` | ||
| The macro expects the following arguments: | ||
| - **fcn**: `float (*fcn)( double )` unary 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_d_f( env, info, fcn ) | ||
| Invokes a unary function accepting a double-precision floating-point number and returning a single-precision floating-point number. | ||
| ```c | ||
| #include <node_api.h> | ||
| // ... | ||
| static float fcn( const double x ) { | ||
| return (float)x; | ||
| } | ||
| // ... | ||
| /** | ||
| * Receives JavaScript callback invocation data. | ||
| * | ||
| * @param env environment under which the function is invoked | ||
| * @param info callback data | ||
| * @return Node-API value | ||
| */ | ||
| napi_value addon( napi_env env, napi_callback_info info ) { | ||
| return stdlib_math_base_napi_d_f( env, info, fcn ); | ||
| } | ||
| // ... | ||
| ``` | ||
| The function accepts the following arguments: | ||
| - **env**: `[in] napi_env` environment under which the function is invoked. | ||
| - **info**: `[in] napi_callback_info` callback data. | ||
| - **fcn**: `[in] float (*fcn)( double )` unary function. | ||
| ```c | ||
| void stdlib_math_base_napi_d_f( napi_env env, napi_callback_info info, float (*fcn)( double ) ); | ||
| ``` | ||
| #### STDLIB_MATH_BASE_NAPI_MODULE_F_F( fcn ) | ||
| Macro for registering a Node-API module exporting an interface for invoking a unary function accepting and returning single-precision floating-point numbers. | ||
| ```c | ||
| static float scale( const float x ) { | ||
| return x * 10.0f; | ||
| } | ||
| // ... | ||
| // Register a Node-API module: | ||
| STDLIB_MATH_BASE_NAPI_MODULE_F_F( scale ); | ||
| ``` | ||
| The macro expects the following arguments: | ||
| - **fcn**: `float (*fcn)( float )` unary 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_f_f( env, info, fcn ) | ||
@@ -210,14 +512,37 @@ | ||
| #### stdlib_math_base_napi_z_z( env, info, fcn ) | ||
| #### STDLIB_MATH_BASE_NAPI_MODULE_F_I( fcn ) | ||
| Invokes a unary function accepting and returning double-precision complex floating-point numbers. | ||
| Macro for registering a Node-API module exporting an interface for invoking a unary function accepting a single-precision floating-point number and returning a signed 32-bit integer. | ||
| ```c | ||
| #include "stdlib/complex/float64/ctor.h" | ||
| #include <stdint.h> | ||
| static int32_t fcn( const float x ) { | ||
| // ... | ||
| } | ||
| // ... | ||
| // Register a Node-API module: | ||
| STDLIB_MATH_BASE_NAPI_MODULE_F_I( fcn ); | ||
| ``` | ||
| The macro expects the following arguments: | ||
| - **fcn**: `int32_t (*fcn)( float )` unary 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_f_i( env, info, fcn ) | ||
| Invokes a unary function accepting a single-precision floating-point number and returning a signed 32-bit integer. | ||
| ```c | ||
| #include <node_api.h> | ||
| #include <stdint.h> | ||
| // ... | ||
| static stdlib_complex128_t identity( const stdlib_complex128_t x ) { | ||
| return x; | ||
| static int32_t fcn( const float x ) { | ||
| // ... | ||
| } | ||
@@ -235,3 +560,3 @@ | ||
| napi_value addon( napi_env env, napi_callback_info info ) { | ||
| return stdlib_math_base_napi_z_z( env, info, identity ); | ||
| return stdlib_math_base_napi_f_i( env, info, fcn ); | ||
| } | ||
@@ -246,14 +571,37 @@ | ||
| - **info**: `[in] napi_callback_info` callback data. | ||
| - **fcn**: `[in] stdlib_complex128_t (*fcn)( stdlib_complex128_t )` unary function. | ||
| - **fcn**: `[in] int32_t (*fcn)( float )` unary function. | ||
| ```c | ||
| void stdlib_math_base_napi_z_z( napi_env env, napi_callback_info info, stdlib_complex128_t (*fcn)( stdlib_complex128_t ) ); | ||
| void stdlib_math_base_napi_f_i( napi_env env, napi_callback_info info, int32_t (*fcn)( float ) ); | ||
| ``` | ||
| #### stdlib_math_base_napi_z_d( env, info, fcn ) | ||
| #### STDLIB_MATH_BASE_NAPI_MODULE_H_H( fcn ) | ||
| Invokes a unary function accepting a double-precision complex floating-point number and returning a double-precision floating-point number. | ||
| Macro for registering a Node-API module exporting an interface for invoking a unary function accepting and returning half-precision floating-point numbers. | ||
| ```c | ||
| #include "stdlib/complex/float64/ctor.h" | ||
| #include "stdlib/number/float16/ctor.h" | ||
| static stdlib_float16_t identity( const stdlib_float16_t x ) { | ||
| return x; | ||
| } | ||
| // ... | ||
| // Register a Node-API module: | ||
| STDLIB_MATH_BASE_NAPI_MODULE_H_H( identity ); | ||
| ``` | ||
| The macro expects the following arguments: | ||
| - **fcn**: `stdlib_float16_t (*fcn)( stdlib_float16_t )` unary 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_h_h( env, info, fcn ) | ||
| Invokes a unary function accepting and returning half-precision floating-point numbers. | ||
| ```c | ||
| #include "stdlib/number/float16/ctor.h" | ||
| #include <node_api.h> | ||
@@ -263,4 +611,4 @@ | ||
| static double fcn( const stdlib_complex128_t x ) { | ||
| // ... | ||
| static stdlib_float16_t identity( const stdlib_float16_t x ) { | ||
| return x; | ||
| } | ||
@@ -278,3 +626,3 @@ | ||
| napi_value addon( napi_env env, napi_callback_info info ) { | ||
| return stdlib_math_base_napi_z_d( env, info, fcn ); | ||
| return stdlib_math_base_napi_h_h( env, info, identity ); | ||
| } | ||
@@ -289,20 +637,43 @@ | ||
| - **info**: `[in] napi_callback_info` callback data. | ||
| - **fcn**: `[in] double (*fcn)( stdlib_complex128_t )` unary function. | ||
| - **fcn**: `[in] stdlib_float16_t (*fcn)( stdlib_float16_t )` unary function. | ||
| ```c | ||
| void stdlib_math_base_napi_z_d( napi_env env, napi_callback_info info, double (*fcn)( stdlib_complex128_t ) ); | ||
| void stdlib_math_base_napi_h_h( napi_env env, napi_callback_info info, stdlib_float16_t (*fcn)( stdlib_float16_t ) ); | ||
| ``` | ||
| #### stdlib_math_base_napi_c_c( env, info, fcn ) | ||
| #### STDLIB_MATH_BASE_NAPI_MODULE_I_D( fcn ) | ||
| Invokes a unary function accepting and returning single-precision complex floating-point numbers. | ||
| Macro for registering a Node-API module exporting an interface for invoking a unary function accepting a signed 32-bit integer and returning a double-precision floating-point number. | ||
| ```c | ||
| #include "stdlib/complex/float32/ctor.h" | ||
| #include <stdint.h> | ||
| static double scale( const int32_t x ) { | ||
| return x * 10.0; | ||
| } | ||
| // ... | ||
| // Register a Node-API module: | ||
| STDLIB_MATH_BASE_NAPI_MODULE_I_D( scale ); | ||
| ``` | ||
| The macro expects the following arguments: | ||
| - **fcn**: `double (*fcn)( int32_t )` unary 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_i_d( env, info, fcn ) | ||
| Invokes a unary function accepting a signed 32-bit integer and returning a double-precision floating-point number. | ||
| ```c | ||
| #include <node_api.h> | ||
| #include <stdint.h> | ||
| // ... | ||
| static stdlib_complex64_t identity( const stdlib_complex64_t x ) { | ||
| return x; | ||
| static double scale( const int32_t x ) { | ||
| return x * 10.0; | ||
| } | ||
@@ -320,3 +691,3 @@ | ||
| napi_value addon( napi_env env, napi_callback_info info ) { | ||
| return stdlib_math_base_napi_c_c( env, info, identity ); | ||
| return stdlib_math_base_napi_i_d( env, info, scale ); | ||
| } | ||
@@ -331,19 +702,42 @@ | ||
| - **info**: `[in] napi_callback_info` callback data. | ||
| - **fcn**: `[in] stdlib_complex64_t (*fcn)( stdlib_complex64_t )` unary function. | ||
| - **fcn**: `[in] double (*fcn)( int32_t )` unary function. | ||
| ```c | ||
| void stdlib_math_base_napi_c_c( napi_env env, napi_callback_info info, stdlib_complex64_t (*fcn)( stdlib_complex64_t ) ); | ||
| void stdlib_math_base_napi_i_d( napi_env env, napi_callback_info info, double (*fcn)( int32_t ) ); | ||
| ``` | ||
| #### stdlib_math_base_napi_c_f( env, info, fcn ) | ||
| #### STDLIB_MATH_BASE_NAPI_MODULE_I_F( fcn ) | ||
| Invokes a unary function accepting a single-precision complex floating-point number and returning a single-precision floating-point number. | ||
| Macro for registering a Node-API module exporting an interface for invoking a unary function accepting a signed 32-bit integer and returning a single-precision floating-point number. | ||
| ```c | ||
| #include "stdlib/complex/float32/ctor.h" | ||
| #include <stdint.h> | ||
| static float fcn( const int32_t x ) { | ||
| // ... | ||
| } | ||
| // ... | ||
| // Register a Node-API module: | ||
| STDLIB_MATH_BASE_NAPI_MODULE_I_F( fcn ); | ||
| ``` | ||
| The macro expects the following arguments: | ||
| - **fcn**: `float (*fcn)( int32_t )` unary 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_i_f( env, info, fcn ) | ||
| Invokes a unary function accepting a signed 32-bit integer and returning a single-precision floating-point number. | ||
| ```c | ||
| #include <node_api.h> | ||
| #include <stdint.h> | ||
| // ... | ||
| static float fcn( const stdlib_complex64_t x ) { | ||
| static float fcn( const int32_t x ) { | ||
| // ... | ||
@@ -362,3 +756,3 @@ } | ||
| napi_value addon( napi_env env, napi_callback_info info ) { | ||
| return stdlib_math_base_napi_c_f( env, info, fcn ); | ||
| return stdlib_math_base_napi_i_f( env, info, fcn ); | ||
| } | ||
@@ -373,8 +767,31 @@ | ||
| - **info**: `[in] napi_callback_info` callback data. | ||
| - **fcn**: `[in] float (*fcn)( stdlib_complex64_t )` unary function. | ||
| - **fcn**: `[in] float (*fcn)( int32_t )` unary function. | ||
| ```c | ||
| void stdlib_math_base_napi_c_f( napi_env env, napi_callback_info info, float (*fcn)( stdlib_complex64_t ) ); | ||
| void stdlib_math_base_napi_i_f( napi_env env, napi_callback_info info, float (*fcn)( int32_t ) ); | ||
| ``` | ||
| #### STDLIB_MATH_BASE_NAPI_MODULE_I_I( fcn ) | ||
| Macro for registering a Node-API module exporting an interface for invoking a unary function accepting and returning 32-bit signed integers. | ||
| ```c | ||
| #include <stdint.h> | ||
| static int32_t scale( const int32_t x ) { | ||
| return x * 10; | ||
| } | ||
| // ... | ||
| // Register a Node-API module: | ||
| STDLIB_MATH_BASE_NAPI_MODULE_I_I( scale ); | ||
| ``` | ||
| The macro expects the following arguments: | ||
| - **fcn**: `int32_t (*fcn)( int32_t )` unary 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_i_i( env, info, fcn ) | ||
@@ -420,7 +837,30 @@ | ||
| #### stdlib_math_base_napi_i_d( env, info, fcn ) | ||
| #### STDLIB_MATH_BASE_NAPI_MODULE_K_K( fcn ) | ||
| Invokes a unary function accepting a signed 32-bit integer and returning a single-precision floating-point number. | ||
| Macro for registering a Node-API module exporting an interface for invoking a unary function accepting and returning 16-bit signed integers. | ||
| ```c | ||
| #include <stdint.h> | ||
| static int16_t scale( const int16_t x ) { | ||
| return x * 10; | ||
| } | ||
| // ... | ||
| // Register a Node-API module: | ||
| STDLIB_MATH_BASE_NAPI_MODULE_K_K( scale ); | ||
| ``` | ||
| The macro expects the following arguments: | ||
| - **fcn**: `int16_t (*fcn)( int16_t )` unary 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_k_k( env, info, fcn ) | ||
| Invokes a unary function accepting and returning signed 16-bit integers. | ||
| ```c | ||
| #include <node_api.h> | ||
@@ -431,4 +871,4 @@ #include <stdint.h> | ||
| static double scale( const int32_t x ) { | ||
| return x * 10.0; | ||
| static int16_t identity( const int16_t x ) { | ||
| return x; | ||
| } | ||
@@ -446,3 +886,3 @@ | ||
| napi_value addon( napi_env env, napi_callback_info info ) { | ||
| return stdlib_math_base_napi_i_d( env, info, scale ); | ||
| return stdlib_math_base_napi_k_k( env, info, identity ); | ||
| } | ||
@@ -457,15 +897,17 @@ | ||
| - **info**: `[in] napi_callback_info` callback data. | ||
| - **fcn**: `[in] double (*fcn)( int32_t )` unary function. | ||
| - **fcn**: `[in] int16_t (*fcn)( int16_t )` unary function. | ||
| ```c | ||
| void stdlib_math_base_napi_i_i( napi_env env, napi_callback_info info, double (*fcn)( int32_t ) ); | ||
| void stdlib_math_base_napi_k_k( napi_env env, napi_callback_info info, int16_t (*fcn)( int16_t ) ); | ||
| ``` | ||
| #### STDLIB_MATH_BASE_NAPI_MODULE_D_D( fcn ) | ||
| #### STDLIB_MATH_BASE_NAPI_MODULE_S_S( fcn ) | ||
| Macro for registering a Node-API module exporting an interface for invoking a unary function accepting and returning double-precision floating-point numbers. | ||
| Macro for registering a Node-API module exporting an interface for invoking a unary function accepting and returning 8-bit signed integers. | ||
| ```c | ||
| static double scale( const double x ) { | ||
| return x * 10.0; | ||
| #include <stdint.h> | ||
| static int8_t scale( const int8_t x ) { | ||
| return x * 10; | ||
| } | ||
@@ -476,3 +918,3 @@ | ||
| // Register a Node-API module: | ||
| STDLIB_MATH_BASE_NAPI_MODULE_D_D( scale ); | ||
| STDLIB_MATH_BASE_NAPI_MODULE_S_S( scale ); | ||
| ``` | ||
@@ -482,13 +924,18 @@ | ||
| - **fcn**: `double (*fcn)( double )` unary function. | ||
| - **fcn**: `int8_t (*fcn)( int8_t )` unary 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_F_F( fcn ) | ||
| #### stdlib_math_base_napi_s_s( env, info, fcn ) | ||
| Macro for registering a Node-API module exporting an interface for invoking a unary function accepting and returning single-precision floating-point numbers. | ||
| Invokes a unary function accepting and returning signed 8-bit integers. | ||
| ```c | ||
| static float scale( const float x ) { | ||
| return x * 10.0f; | ||
| #include <node_api.h> | ||
| #include <stdint.h> | ||
| // ... | ||
| static int8_t identity( const int8_t x ) { | ||
| return x; | ||
| } | ||
@@ -498,4 +945,41 @@ | ||
| /** | ||
| * Receives JavaScript callback invocation data. | ||
| * | ||
| * @param env environment under which the function is invoked | ||
| * @param info callback data | ||
| * @return Node-API value | ||
| */ | ||
| napi_value addon( napi_env env, napi_callback_info info ) { | ||
| return stdlib_math_base_napi_s_s( env, info, identity ); | ||
| } | ||
| // ... | ||
| ``` | ||
| The function accepts the following arguments: | ||
| - **env**: `[in] napi_env` environment under which the function is invoked. | ||
| - **info**: `[in] napi_callback_info` callback data. | ||
| - **fcn**: `[in] int8_t (*fcn)( int8_t )` unary function. | ||
| ```c | ||
| void stdlib_math_base_napi_s_s( napi_env env, napi_callback_info info, int8_t (*fcn)( int8_t ) ); | ||
| ``` | ||
| #### STDLIB_MATH_BASE_NAPI_MODULE_T_T( fcn ) | ||
| Macro for registering a Node-API module exporting an interface for invoking a unary function accepting and returning 16-bit unsigned integers. | ||
| ```c | ||
| #include <stdint.h> | ||
| static uint16_t scale( const uint16_t x ) { | ||
| return x * 10; | ||
| } | ||
| // ... | ||
| // Register a Node-API module: | ||
| STDLIB_MATH_BASE_NAPI_MODULE_F_F( scale ); | ||
| STDLIB_MATH_BASE_NAPI_MODULE_T_T( scale ); | ||
| ``` | ||
@@ -505,47 +989,55 @@ | ||
| - **fcn**: `float (*fcn)( float )` unary function. | ||
| - **fcn**: `uint16_t (*fcn)( uint16_t )` unary 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_Z_Z( fcn ) | ||
| #### stdlib_math_base_napi_t_t( env, info, fcn ) | ||
| Macro for registering a Node-API module exporting an interface for invoking a unary function accepting and returning double-precision complex floating-point numbers. | ||
| Invokes a unary function accepting and returning unsigned 16-bit integers. | ||
| ```c | ||
| #include "stdlib/complex/float64/ctor.h" | ||
| #include "stdlib/complex/float64/reim.h" | ||
| #include <node_api.h> | ||
| #include <stdint.h> | ||
| static stdlib_complex128_t scale( const stdlib_complex128_t x ) { | ||
| double re; | ||
| double im; | ||
| // ... | ||
| stdlib_complex128_reim( x, &re, &im ); | ||
| static uint16_t identity( const uint16_t x ) { | ||
| return x; | ||
| } | ||
| re *= 10.0; | ||
| im *= 10.0; | ||
| // ... | ||
| return stdlib_complex128( re, im ); | ||
| /** | ||
| * Receives JavaScript callback invocation data. | ||
| * | ||
| * @param env environment under which the function is invoked | ||
| * @param info callback data | ||
| * @return Node-API value | ||
| */ | ||
| napi_value addon( napi_env env, napi_callback_info info ) { | ||
| return stdlib_math_base_napi_t_t( env, info, identity ); | ||
| } | ||
| // ... | ||
| // Register a Node-API module: | ||
| STDLIB_MATH_BASE_NAPI_MODULE_Z_Z( scale ); | ||
| ``` | ||
| The macro expects the following arguments: | ||
| The function accepts the following arguments: | ||
| - **fcn**: `stdlib_complex128_t (*fcn)( stdlib_complex128_t )` unary function. | ||
| - **env**: `[in] napi_env` environment under which the function is invoked. | ||
| - **info**: `[in] napi_callback_info` callback data. | ||
| - **fcn**: `[in] uint16_t (*fcn)( uint16_t )` unary function. | ||
| When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration. | ||
| ```c | ||
| void stdlib_math_base_napi_t_t( napi_env env, napi_callback_info info, uint16_t (*fcn)( uint16_t ) ); | ||
| ``` | ||
| #### STDLIB_MATH_BASE_NAPI_MODULE_Z_D( fcn ) | ||
| #### STDLIB_MATH_BASE_NAPI_MODULE_U_U( fcn ) | ||
| Macro for registering a Node-API module exporting an interface for invoking a unary function accepting a double-precision complex floating-point number and returning a double-precision floating-point number. | ||
| Macro for registering a Node-API module exporting an interface for invoking a unary function accepting and returning 32-bit unsigned integers. | ||
| ```c | ||
| #include "stdlib/complex/float64/ctor.h" | ||
| #include <stdint.h> | ||
| static double fcn( const stdlib_complex128_t x ) { | ||
| // ... | ||
| static uint32_t scale( const uint32_t x ) { | ||
| return x * 10; | ||
| } | ||
@@ -556,3 +1048,3 @@ | ||
| // Register a Node-API module: | ||
| STDLIB_MATH_BASE_NAPI_MODULE_Z_D( fcn ); | ||
| STDLIB_MATH_BASE_NAPI_MODULE_U_U( scale ); | ||
| ``` | ||
@@ -562,30 +1054,61 @@ | ||
| - **fcn**: `double (*fcn)( stdlib_complex128_t )` unary function. | ||
| - **fcn**: `uint32_t (*fcn)( uint32_t )` unary 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_C_C( fcn ) | ||
| #### stdlib_math_base_napi_u_u( env, info, fcn ) | ||
| Macro for registering a Node-API module exporting an interface for invoking a unary function accepting and returning single-precision complex floating-point numbers. | ||
| Invokes a unary function accepting and returning unsigned 32-bit integers. | ||
| ```c | ||
| #include "stdlib/complex/float32/ctor.h" | ||
| #include "stdlib/complex/float32/reim.h" | ||
| #include <node_api.h> | ||
| #include <stdint.h> | ||
| static stdlib_complex64_t scale( const stdlib_complex64_t x ) { | ||
| float re; | ||
| float im; | ||
| // ... | ||
| stdlib_complex64_reim( x, &re, &im ); | ||
| static uint32_t identity( const uint32_t x ) { | ||
| return x; | ||
| } | ||
| re *= 10.0f; | ||
| im *= 10.0f; | ||
| // ... | ||
| return stdlib_complex64( re, im ); | ||
| /** | ||
| * Receives JavaScript callback invocation data. | ||
| * | ||
| * @param env environment under which the function is invoked | ||
| * @param info callback data | ||
| * @return Node-API value | ||
| */ | ||
| napi_value addon( napi_env env, napi_callback_info info ) { | ||
| return stdlib_math_base_napi_u_u( env, info, identity ); | ||
| } | ||
| // ... | ||
| ``` | ||
| The function accepts the following arguments: | ||
| - **env**: `[in] napi_env` environment under which the function is invoked. | ||
| - **info**: `[in] napi_callback_info` callback data. | ||
| - **fcn**: `[in] uint32_t (*fcn)( uint32_t )` unary function. | ||
| ```c | ||
| void stdlib_math_base_napi_u_u( napi_env env, napi_callback_info info, uint32_t (*fcn)( uint32_t ) ); | ||
| ``` | ||
| #### STDLIB_MATH_BASE_NAPI_MODULE_Z_D( fcn ) | ||
| Macro for registering a Node-API module exporting an interface for invoking a unary function accepting a double-precision complex floating-point number and returning a double-precision floating-point number. | ||
| ```c | ||
| #include "stdlib/complex/float64/ctor.h" | ||
| static double fcn( const stdlib_complex128_t x ) { | ||
| // ... | ||
| } | ||
| // ... | ||
| // Register a Node-API module: | ||
| STDLIB_MATH_BASE_NAPI_MODULE_C_C( scale ); | ||
| STDLIB_MATH_BASE_NAPI_MODULE_Z_D( fcn ); | ||
| ``` | ||
@@ -595,14 +1118,17 @@ | ||
| - **fcn**: `stdlib_complex64_t (*fcn)( stdlib_complex64_t )` unary function. | ||
| - **fcn**: `double (*fcn)( stdlib_complex128_t )` unary 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_C_F( fcn ) | ||
| #### stdlib_math_base_napi_z_d( env, info, fcn ) | ||
| Macro for registering a Node-API module exporting an interface for invoking a unary function accepting a single-precision complex floating-point number and returning a single-precision floating-point number. | ||
| Invokes a unary function accepting a double-precision complex floating-point number and returning a double-precision floating-point number. | ||
| ```c | ||
| #include "stdlib/complex/float32/ctor.h" | ||
| #include "stdlib/complex/float64/ctor.h" | ||
| #include <node_api.h> | ||
| static float fcn( const stdlib_complex64_t x ) { | ||
| // ... | ||
| static double fcn( const stdlib_complex128_t x ) { | ||
| // ... | ||
@@ -613,21 +1139,44 @@ } | ||
| // Register a Node-API module: | ||
| STDLIB_MATH_BASE_NAPI_MODULE_C_F( fcn ); | ||
| /** | ||
| * Receives JavaScript callback invocation data. | ||
| * | ||
| * @param env environment under which the function is invoked | ||
| * @param info callback data | ||
| * @return Node-API value | ||
| */ | ||
| napi_value addon( napi_env env, napi_callback_info info ) { | ||
| return stdlib_math_base_napi_z_d( env, info, fcn ); | ||
| } | ||
| // ... | ||
| ``` | ||
| The macro expects the following arguments: | ||
| The function accepts the following arguments: | ||
| - **fcn**: `float (*fcn)( stdlib_complex64_t )` unary function. | ||
| - **env**: `[in] napi_env` environment under which the function is invoked. | ||
| - **info**: `[in] napi_callback_info` callback data. | ||
| - **fcn**: `[in] double (*fcn)( stdlib_complex128_t )` unary function. | ||
| When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration. | ||
| ```c | ||
| void stdlib_math_base_napi_z_d( napi_env env, napi_callback_info info, double (*fcn)( stdlib_complex128_t ) ); | ||
| ``` | ||
| #### STDLIB_MATH_BASE_NAPI_MODULE_I_I( fcn ) | ||
| #### STDLIB_MATH_BASE_NAPI_MODULE_Z_Z( fcn ) | ||
| Macro for registering a Node-API module exporting an interface for invoking a unary function accepting and returning 32-bit signed integers. | ||
| Macro for registering a Node-API module exporting an interface for invoking a unary function accepting and returning double-precision complex floating-point numbers. | ||
| ```c | ||
| #include <stdint.h> | ||
| #include "stdlib/complex/float64/ctor.h" | ||
| #include "stdlib/complex/float64/reim.h" | ||
| static int32_t scale( const int32_t x ) { | ||
| return x * 10; | ||
| static stdlib_complex128_t scale( const stdlib_complex128_t x ) { | ||
| double re; | ||
| double im; | ||
| stdlib_complex128_reim( x, &re, &im ); | ||
| re *= 10.0; | ||
| im *= 10.0; | ||
| return stdlib_complex128( re, im ); | ||
| } | ||
@@ -638,3 +1187,3 @@ | ||
| // Register a Node-API module: | ||
| STDLIB_MATH_BASE_NAPI_MODULE_I_I( scale ); | ||
| STDLIB_MATH_BASE_NAPI_MODULE_Z_Z( scale ); | ||
| ``` | ||
@@ -644,15 +1193,18 @@ | ||
| - **fcn**: `int32_t (*fcn)( int32_t )` unary function. | ||
| - **fcn**: `stdlib_complex128_t (*fcn)( stdlib_complex128_t )` unary 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_I_D( fcn ) | ||
| #### stdlib_math_base_napi_z_z( env, info, fcn ) | ||
| Macro for registering a Node-API module exporting an interface for invoking a unary function accepting a signed 32-bit integer and returning a double-precision floating-point number. | ||
| Invokes a unary function accepting and returning double-precision complex floating-point numbers. | ||
| ```c | ||
| #include <stdint.h> | ||
| #include "stdlib/complex/float64/ctor.h" | ||
| #include <node_api.h> | ||
| static double scale( const int32_t x ) { | ||
| return x * 10.0; | ||
| // ... | ||
| static stdlib_complex128_t identity( const stdlib_complex128_t x ) { | ||
| return x; | ||
| } | ||
@@ -662,11 +1214,25 @@ | ||
| // Register a Node-API module: | ||
| STDLIB_MATH_BASE_NAPI_MODULE_I_D( scale ); | ||
| /** | ||
| * Receives JavaScript callback invocation data. | ||
| * | ||
| * @param env environment under which the function is invoked | ||
| * @param info callback data | ||
| * @return Node-API value | ||
| */ | ||
| napi_value addon( napi_env env, napi_callback_info info ) { | ||
| return stdlib_math_base_napi_z_z( env, info, identity ); | ||
| } | ||
| // ... | ||
| ``` | ||
| The macro expects the following arguments: | ||
| The function accepts the following arguments: | ||
| - **fcn**: `double (*fcn)( int32_t )` unary function. | ||
| - **env**: `[in] napi_env` environment under which the function is invoked. | ||
| - **info**: `[in] napi_callback_info` callback data. | ||
| - **fcn**: `[in] stdlib_complex128_t (*fcn)( stdlib_complex128_t )` unary function. | ||
| When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration. | ||
| ```c | ||
| void stdlib_math_base_napi_z_z( napi_env env, napi_callback_info info, stdlib_complex128_t (*fcn)( stdlib_complex128_t ) ); | ||
| ``` | ||
@@ -745,3 +1311,3 @@ </section> | ||
| Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. | ||
| Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors]. | ||
@@ -759,4 +1325,4 @@ </section> | ||
| [test-image]: https://github.com/stdlib-js/math-base-napi-unary/actions/workflows/test.yml/badge.svg?branch=v0.2.3 | ||
| [test-url]: https://github.com/stdlib-js/math-base-napi-unary/actions/workflows/test.yml?query=branch:v0.2.3 | ||
| [test-image]: https://github.com/stdlib-js/math-base-napi-unary/actions/workflows/test.yml/badge.svg?branch=v0.2.4 | ||
| [test-url]: https://github.com/stdlib-js/math-base-napi-unary/actions/workflows/test.yml?query=branch:v0.2.4 | ||
@@ -773,4 +1339,4 @@ [coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/math-base-napi-unary/main.svg | ||
| [chat-image]: https://img.shields.io/gitter/room/stdlib-js/stdlib.svg | ||
| [chat-url]: https://app.gitter.im/#/room/#stdlib-js_stdlib:gitter.im | ||
| [chat-image]: https://img.shields.io/badge/zulip-join_chat-brightgreen.svg | ||
| [chat-url]: https://stdlib.zulipchat.com | ||
@@ -777,0 +1343,0 @@ [stdlib]: https://github.com/stdlib-js/stdlib |
-601
| /** | ||
| * @license Apache-2.0 | ||
| * | ||
| * Copyright (c) 2020 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/unary.h" | ||
| #include "stdlib/complex/float64/ctor.h" | ||
| #include "stdlib/complex/float32/ctor.h" | ||
| #include "stdlib/complex/float64/reim.h" | ||
| #include "stdlib/complex/float32/reim.h" | ||
| #include <node_api.h> | ||
| #include <stdint.h> | ||
| #include <assert.h> | ||
| #include <stdbool.h> | ||
| /** | ||
| * Invokes a unary 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. | ||
| * | ||
| * @param env environment under which the function is invoked | ||
| * @param info callback data | ||
| * @param fcn unary function | ||
| * @return function return value as a Node-API double-precision floating-point number | ||
| */ | ||
| napi_value stdlib_math_base_napi_d_d( napi_env env, napi_callback_info info, double (*fcn)( double ) ) { | ||
| napi_status status; | ||
| size_t argc = 1; | ||
| napi_value argv[ 1 ]; | ||
| status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL ); | ||
| assert( status == napi_ok ); | ||
| if ( argc < 1 ) { | ||
| status = napi_throw_error( env, NULL, "invalid invocation. Must provide a number." ); | ||
| 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. Must provide a number." ); | ||
| assert( status == napi_ok ); | ||
| return NULL; | ||
| } | ||
| double x; | ||
| status = napi_get_value_double( env, argv[ 0 ], &x ); | ||
| assert( status == napi_ok ); | ||
| napi_value v; | ||
| status = napi_create_double( env, fcn( x ), &v ); | ||
| assert( status == napi_ok ); | ||
| return v; | ||
| } | ||
| /** | ||
| * Invokes a unary function accepting and returning single-precision floating-point numbers. | ||
| * | ||
| * ## Notes | ||
| * | ||
| * - This function expects that the callback `info` argument provides access to the following JavaScript arguments: | ||
| * | ||
| * - `x`: input value. | ||
| * | ||
| * @param env environment under which the function is invoked | ||
| * @param info callback data | ||
| * @param fcn unary function | ||
| * @return function return value as a Node-API double-precision floating-point number | ||
| */ | ||
| napi_value stdlib_math_base_napi_f_f( napi_env env, napi_callback_info info, float (*fcn)( float ) ) { | ||
| napi_status status; | ||
| size_t argc = 1; | ||
| napi_value argv[ 1 ]; | ||
| status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL ); | ||
| assert( status == napi_ok ); | ||
| if ( argc < 1 ) { | ||
| status = napi_throw_error( env, NULL, "invalid invocation. Must provide a number." ); | ||
| 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. Must provide a number." ); | ||
| assert( status == napi_ok ); | ||
| return NULL; | ||
| } | ||
| double x; | ||
| status = napi_get_value_double( env, argv[ 0 ], &x ); | ||
| assert( status == napi_ok ); | ||
| napi_value v; | ||
| status = napi_create_double( env, (double)fcn( (float)x ), &v ); | ||
| assert( status == napi_ok ); | ||
| return v; | ||
| } | ||
| /** | ||
| * Invokes a unary function accepting and returning double-precision complex floating-point numbers. | ||
| * | ||
| * ## Notes | ||
| * | ||
| * - This function expects that the callback `info` argument provides access to the following JavaScript arguments: | ||
| * | ||
| * - `x`: input value. | ||
| * | ||
| * @param env environment under which the function is invoked | ||
| * @param info callback data | ||
| * @param fcn unary function | ||
| * @return function return value as a Node-API complex-like object | ||
| */ | ||
| napi_value stdlib_math_base_napi_z_z( napi_env env, napi_callback_info info, stdlib_complex128_t (*fcn)( stdlib_complex128_t ) ) { | ||
| napi_status status; | ||
| size_t argc = 1; | ||
| napi_value argv[ 1 ]; | ||
| status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL ); | ||
| assert( status == napi_ok ); | ||
| if ( argc < 1 ) { | ||
| status = napi_throw_error( env, NULL, "invalid invocation. Must provide a complex number." ); | ||
| assert( status == napi_ok ); | ||
| return NULL; | ||
| } | ||
| bool hprop; | ||
| status = napi_has_named_property( env, argv[ 0 ], "re", &hprop ); | ||
| assert( status == napi_ok ); | ||
| if ( !hprop ) { | ||
| status = napi_throw_type_error( env, NULL, "invalid argument. Argument must have a real component." ); | ||
| assert( status == napi_ok ); | ||
| return NULL; | ||
| } | ||
| napi_value xre; | ||
| status = napi_get_named_property( env, argv[ 0 ], "re", &xre ); | ||
| assert( status == napi_ok ); | ||
| napi_valuetype xretype; | ||
| status = napi_typeof( env, xre, &xretype ); | ||
| assert( status == napi_ok ); | ||
| if ( xretype != napi_number ) { | ||
| status = napi_throw_type_error( env, NULL, "invalid argument. Argument must have a real component which is a number." ); | ||
| assert( status == napi_ok ); | ||
| return NULL; | ||
| } | ||
| status = napi_has_named_property( env, argv[ 0 ], "im", &hprop ); | ||
| assert( status == napi_ok ); | ||
| if ( !hprop ) { | ||
| status = napi_throw_type_error( env, NULL, "invalid argument. Argument must have an imaginary component." ); | ||
| assert( status == napi_ok ); | ||
| return NULL; | ||
| } | ||
| napi_value xim; | ||
| status = napi_get_named_property( env, argv[ 0 ], "im", &xim ); | ||
| assert( status == napi_ok ); | ||
| napi_valuetype ximtype; | ||
| status = napi_typeof( env, xim, &ximtype ); | ||
| assert( status == napi_ok ); | ||
| if ( ximtype != napi_number ) { | ||
| status = napi_throw_type_error( env, NULL, "invalid argument. Argument must have an imaginary component which a number." ); | ||
| assert( status == napi_ok ); | ||
| return NULL; | ||
| } | ||
| double re0; | ||
| status = napi_get_value_double( env, xre, &re0 ); | ||
| assert( status == napi_ok ); | ||
| double im0; | ||
| status = napi_get_value_double( env, xim, &im0 ); | ||
| assert( status == napi_ok ); | ||
| stdlib_complex128_t v = fcn( stdlib_complex128( re0, im0 ) ); | ||
| double re; | ||
| double im; | ||
| stdlib_complex128_reim( v, &re, &im ); | ||
| napi_value obj; | ||
| status = napi_create_object( env, &obj ); | ||
| assert( status == napi_ok ); | ||
| napi_value vre; | ||
| status = napi_create_double( env, re, &vre ); | ||
| assert( status == napi_ok ); | ||
| status = napi_set_named_property( env, obj, "re", vre ); | ||
| assert( status == napi_ok ); | ||
| napi_value vim; | ||
| status = napi_create_double( env, im, &vim ); | ||
| assert( status == napi_ok ); | ||
| status = napi_set_named_property( env, obj, "im", vim ); | ||
| assert( status == napi_ok ); | ||
| return obj; | ||
| } | ||
| /** | ||
| * Invokes a unary function accepting a double-precision complex floating-point number and returning a double-precision floating-point number. | ||
| * | ||
| * ## Notes | ||
| * | ||
| * - This function expects that the callback `info` argument provides access to the following JavaScript arguments: | ||
| * | ||
| * - `x`: input value. | ||
| * | ||
| * @param env environment under which the function is invoked | ||
| * @param info callback data | ||
| * @param fcn unary function | ||
| * @return function return value as a Node-API complex-like object | ||
| */ | ||
| napi_value stdlib_math_base_napi_z_d( napi_env env, napi_callback_info info, double (*fcn)( stdlib_complex128_t ) ) { | ||
| napi_status status; | ||
| size_t argc = 1; | ||
| napi_value argv[ 1 ]; | ||
| status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL ); | ||
| assert( status == napi_ok ); | ||
| if ( argc < 1 ) { | ||
| status = napi_throw_error( env, NULL, "invalid invocation. Must provide a complex number." ); | ||
| assert( status == napi_ok ); | ||
| return NULL; | ||
| } | ||
| bool hprop; | ||
| status = napi_has_named_property( env, argv[ 0 ], "re", &hprop ); | ||
| assert( status == napi_ok ); | ||
| if ( !hprop ) { | ||
| status = napi_throw_type_error( env, NULL, "invalid argument. Argument must have a real component." ); | ||
| assert( status == napi_ok ); | ||
| return NULL; | ||
| } | ||
| napi_value xre; | ||
| status = napi_get_named_property( env, argv[ 0 ], "re", &xre ); | ||
| assert( status == napi_ok ); | ||
| napi_valuetype xretype; | ||
| status = napi_typeof( env, xre, &xretype ); | ||
| assert( status == napi_ok ); | ||
| if ( xretype != napi_number ) { | ||
| status = napi_throw_type_error( env, NULL, "invalid argument. Argument must have a real component which is a number." ); | ||
| assert( status == napi_ok ); | ||
| return NULL; | ||
| } | ||
| status = napi_has_named_property( env, argv[ 0 ], "im", &hprop ); | ||
| assert( status == napi_ok ); | ||
| if ( !hprop ) { | ||
| status = napi_throw_type_error( env, NULL, "invalid argument. Argument must have an imaginary component." ); | ||
| assert( status == napi_ok ); | ||
| return NULL; | ||
| } | ||
| napi_value xim; | ||
| status = napi_get_named_property( env, argv[ 0 ], "im", &xim ); | ||
| assert( status == napi_ok ); | ||
| napi_valuetype ximtype; | ||
| status = napi_typeof( env, xim, &ximtype ); | ||
| assert( status == napi_ok ); | ||
| if ( ximtype != napi_number ) { | ||
| status = napi_throw_type_error( env, NULL, "invalid argument. Argument must have an imaginary component which a number." ); | ||
| assert( status == napi_ok ); | ||
| return NULL; | ||
| } | ||
| double re; | ||
| status = napi_get_value_double( env, xre, &re ); | ||
| assert( status == napi_ok ); | ||
| double im; | ||
| status = napi_get_value_double( env, xim, &im ); | ||
| assert( status == napi_ok ); | ||
| napi_value v; | ||
| status = napi_create_double( env, fcn( stdlib_complex128( re, im ) ), &v ); | ||
| assert( status == napi_ok ); | ||
| return v; | ||
| } | ||
| /** | ||
| * Invokes a unary function accepting and returning single-precision complex floating-point numbers. | ||
| * | ||
| * ## Notes | ||
| * | ||
| * - This function expects that the callback `info` argument provides access to the following JavaScript arguments: | ||
| * | ||
| * - `x`: input value. | ||
| * | ||
| * @param env environment under which the function is invoked | ||
| * @param info callback data | ||
| * @param fcn unary function | ||
| * @return function return value as a Node-API complex-like object | ||
| */ | ||
| napi_value stdlib_math_base_napi_c_c( napi_env env, napi_callback_info info, stdlib_complex64_t (*fcn)( stdlib_complex64_t ) ) { | ||
| napi_status status; | ||
| size_t argc = 1; | ||
| napi_value argv[ 1 ]; | ||
| status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL ); | ||
| assert( status == napi_ok ); | ||
| if ( argc < 1 ) { | ||
| status = napi_throw_error( env, NULL, "invalid invocation. Must provide a complex number." ); | ||
| assert( status == napi_ok ); | ||
| return NULL; | ||
| } | ||
| bool hprop; | ||
| status = napi_has_named_property( env, argv[ 0 ], "re", &hprop ); | ||
| assert( status == napi_ok ); | ||
| if ( !hprop ) { | ||
| status = napi_throw_type_error( env, NULL, "invalid argument. Argument must have a real component." ); | ||
| assert( status == napi_ok ); | ||
| return NULL; | ||
| } | ||
| napi_value xre; | ||
| status = napi_get_named_property( env, argv[ 0 ], "re", &xre ); | ||
| assert( status == napi_ok ); | ||
| napi_valuetype xretype; | ||
| status = napi_typeof( env, xre, &xretype ); | ||
| assert( status == napi_ok ); | ||
| if ( xretype != napi_number ) { | ||
| status = napi_throw_type_error( env, NULL, "invalid argument. Argument must have a real component which is a number." ); | ||
| assert( status == napi_ok ); | ||
| return NULL; | ||
| } | ||
| status = napi_has_named_property( env, argv[ 0 ], "im", &hprop ); | ||
| assert( status == napi_ok ); | ||
| if ( !hprop ) { | ||
| status = napi_throw_type_error( env, NULL, "invalid argument. Argument must have an imaginary component." ); | ||
| assert( status == napi_ok ); | ||
| return NULL; | ||
| } | ||
| napi_value xim; | ||
| status = napi_get_named_property( env, argv[ 0 ], "im", &xim ); | ||
| assert( status == napi_ok ); | ||
| napi_valuetype ximtype; | ||
| status = napi_typeof( env, xim, &ximtype ); | ||
| assert( status == napi_ok ); | ||
| if ( ximtype != napi_number ) { | ||
| status = napi_throw_type_error( env, NULL, "invalid argument. Argument must have an imaginary component which a number." ); | ||
| assert( status == napi_ok ); | ||
| return NULL; | ||
| } | ||
| double re0; | ||
| status = napi_get_value_double( env, xre, &re0 ); | ||
| assert( status == napi_ok ); | ||
| double im0; | ||
| status = napi_get_value_double( env, xim, &im0 ); | ||
| assert( status == napi_ok ); | ||
| stdlib_complex64_t v = fcn( stdlib_complex64( (float)re0, (float)im0 ) ); | ||
| float re; | ||
| float im; | ||
| stdlib_complex64_reim( v, &re, &im ); | ||
| napi_value obj; | ||
| status = napi_create_object( env, &obj ); | ||
| assert( status == napi_ok ); | ||
| napi_value vre; | ||
| status = napi_create_double( env, (double)re, &vre ); | ||
| assert( status == napi_ok ); | ||
| status = napi_set_named_property( env, obj, "re", vre ); | ||
| assert( status == napi_ok ); | ||
| napi_value vim; | ||
| status = napi_create_double( env, (double)im, &vim ); | ||
| assert( status == napi_ok ); | ||
| status = napi_set_named_property( env, obj, "im", vim ); | ||
| assert( status == napi_ok ); | ||
| return obj; | ||
| } | ||
| /** | ||
| * Invokes a unary function accepting a single-precision complex floating-point number and returning a single-precision floating-point number. | ||
| * | ||
| * ## Notes | ||
| * | ||
| * - This function expects that the callback `info` argument provides access to the following JavaScript arguments: | ||
| * | ||
| * - `x`: input value. | ||
| * | ||
| * @param env environment under which the function is invoked | ||
| * @param info callback data | ||
| * @param fcn unary function | ||
| * @return function return value as a Node-API complex-like object | ||
| */ | ||
| napi_value stdlib_math_base_napi_c_f( napi_env env, napi_callback_info info, float (*fcn)( stdlib_complex64_t ) ) { | ||
| napi_status status; | ||
| size_t argc = 1; | ||
| napi_value argv[ 1 ]; | ||
| status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL ); | ||
| assert( status == napi_ok ); | ||
| if ( argc < 1 ) { | ||
| status = napi_throw_error( env, NULL, "invalid invocation. Must provide a complex number." ); | ||
| assert( status == napi_ok ); | ||
| return NULL; | ||
| } | ||
| bool hprop; | ||
| status = napi_has_named_property( env, argv[ 0 ], "re", &hprop ); | ||
| assert( status == napi_ok ); | ||
| if ( !hprop ) { | ||
| status = napi_throw_type_error( env, NULL, "invalid argument. Argument must have a real component." ); | ||
| assert( status == napi_ok ); | ||
| return NULL; | ||
| } | ||
| napi_value xre; | ||
| status = napi_get_named_property( env, argv[ 0 ], "re", &xre ); | ||
| assert( status == napi_ok ); | ||
| napi_valuetype xretype; | ||
| status = napi_typeof( env, xre, &xretype ); | ||
| assert( status == napi_ok ); | ||
| if ( xretype != napi_number ) { | ||
| status = napi_throw_type_error( env, NULL, "invalid argument. Argument must have a real component which is a number." ); | ||
| assert( status == napi_ok ); | ||
| return NULL; | ||
| } | ||
| status = napi_has_named_property( env, argv[ 0 ], "im", &hprop ); | ||
| assert( status == napi_ok ); | ||
| if ( !hprop ) { | ||
| status = napi_throw_type_error( env, NULL, "invalid argument. Argument must have an imaginary component." ); | ||
| assert( status == napi_ok ); | ||
| return NULL; | ||
| } | ||
| napi_value xim; | ||
| status = napi_get_named_property( env, argv[ 0 ], "im", &xim ); | ||
| assert( status == napi_ok ); | ||
| napi_valuetype ximtype; | ||
| status = napi_typeof( env, xim, &ximtype ); | ||
| assert( status == napi_ok ); | ||
| if ( ximtype != napi_number ) { | ||
| status = napi_throw_type_error( env, NULL, "invalid argument. Argument must have an imaginary component which a number." ); | ||
| assert( status == napi_ok ); | ||
| return NULL; | ||
| } | ||
| double re; | ||
| status = napi_get_value_double( env, xre, &re ); | ||
| assert( status == napi_ok ); | ||
| double im; | ||
| status = napi_get_value_double( env, xim, &im ); | ||
| assert( status == napi_ok ); | ||
| napi_value v; | ||
| status = napi_create_double( env, (double)fcn( stdlib_complex64( (float)re, (float)im ) ), &v ); | ||
| assert( status == napi_ok ); | ||
| return v; | ||
| } | ||
| /** | ||
| * Invokes a unary function accepting and returning signed 32-bit integers. | ||
| * | ||
| * ## Notes | ||
| * | ||
| * - This function expects that the callback `info` argument provides access to the following JavaScript arguments: | ||
| * | ||
| * - `x`: input value. | ||
| * | ||
| * @param env environment under which the function is invoked | ||
| * @param info callback data | ||
| * @param fcn unary function | ||
| * @return function return value as a Node-API signed 32-bit integer | ||
| */ | ||
| napi_value stdlib_math_base_napi_i_i( napi_env env, napi_callback_info info, int32_t (*fcn)( int32_t ) ) { | ||
| napi_status status; | ||
| size_t argc = 1; | ||
| napi_value argv[ 1 ]; | ||
| status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL ); | ||
| assert( status == napi_ok ); | ||
| if ( argc < 1 ) { | ||
| status = napi_throw_error( env, NULL, "invalid invocation. Must provide a number." ); | ||
| 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. Must provide a number." ); | ||
| assert( status == napi_ok ); | ||
| return NULL; | ||
| } | ||
| int32_t x; | ||
| status = napi_get_value_int32( env, argv[ 0 ], &x ); | ||
| assert( status == napi_ok ); | ||
| napi_value v; | ||
| status = napi_create_int32( env, fcn( x ), &v ); | ||
| assert( status == napi_ok ); | ||
| return v; | ||
| } | ||
| /** | ||
| * Invokes a unary function accepting a signed 32-bit integer and returning a single-precision floating-point number. | ||
| * | ||
| * ## Notes | ||
| * | ||
| * - This function expects that the callback `info` argument provides access to the following JavaScript arguments: | ||
| * | ||
| * - `x`: input value. | ||
| * | ||
| * @param env environment under which the function is invoked | ||
| * @param info callback data | ||
| * @param fcn unary function | ||
| * @return function return value as a Node-API double-precision floating-point number | ||
| */ | ||
| napi_value stdlib_math_base_napi_i_d( napi_env env, napi_callback_info info, double (*fcn)( int32_t ) ) { | ||
| napi_status status; | ||
| size_t argc = 1; | ||
| napi_value argv[ 1 ]; | ||
| status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL ); | ||
| assert( status == napi_ok ); | ||
| if ( argc < 1 ) { | ||
| status = napi_throw_error( env, NULL, "invalid invocation. Must provide a number." ); | ||
| 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. Must provide a number." ); | ||
| assert( status == napi_ok ); | ||
| return NULL; | ||
| } | ||
| int32_t x; | ||
| status = napi_get_value_int32( env, argv[ 0 ], &x ); | ||
| assert( status == napi_ok ); | ||
| napi_value v; | ||
| status = napi_create_double( env, fcn( x ), &v ); | ||
| assert( status == napi_ok ); | ||
| return v; | ||
| } |
GitHub dependency
Supply chain riskContains a dependency which resolves to a GitHub URL. Dependencies fetched from GitHub specifiers are not immutable can be used to inject untrusted code or reduce the likelihood of a reproducible install.
Found 3 instances in 1 package
159031
98.77%50
194.12%219
9.5%1322
74.87%8
60%3
Infinity%