|
396 | 396 | }; \ |
397 | 397 | NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_ci_c_init ) |
398 | 398 |
|
| 399 | +/** |
| 400 | +* Macro for registering a Node-API module exporting an interface invoking a binary function accepting a double-precision complex floating-point number and a double-precision floating-point number and returning a double-precision complex floating-point number. |
| 401 | +* |
| 402 | +* @param fcn binary function |
| 403 | +* |
| 404 | +* @example |
| 405 | +* #include "stdlib/complex/float64.h" |
| 406 | +* #include "stdlib/complex/reim.h" |
| 407 | +* |
| 408 | +* static stdlib_complex128_t mul( const stdlib_complex128_t x, const double n ) { |
| 409 | +* double re; |
| 410 | +* double im; |
| 411 | +* |
| 412 | +* stdlib_reim( x, &re, &im ); |
| 413 | +* return stdlib_complex128( re*n, im*n ); |
| 414 | +* } |
| 415 | +* |
| 416 | +* // ... |
| 417 | +* |
| 418 | +* // Register a Node-API module: |
| 419 | +* STDLIB_MATH_BASE_NAPI_MODULE_ZD_Z( mul ); |
| 420 | +*/ |
| 421 | +#define STDLIB_MATH_BASE_NAPI_MODULE_ZD_Z( fcn ) \ |
| 422 | + static napi_value stdlib_math_base_napi_zd_z_wrapper( \ |
| 423 | + napi_env env, \ |
| 424 | + napi_callback_info info \ |
| 425 | + ) { \ |
| 426 | + return stdlib_math_base_napi_zd_z( env, info, fcn ); \ |
| 427 | + }; \ |
| 428 | + static napi_value stdlib_math_base_napi_zd_z_init( \ |
| 429 | + napi_env env, \ |
| 430 | + napi_value exports \ |
| 431 | + ) { \ |
| 432 | + napi_value fcn; \ |
| 433 | + napi_status status = napi_create_function( \ |
| 434 | + env, \ |
| 435 | + "exports", \ |
| 436 | + NAPI_AUTO_LENGTH, \ |
| 437 | + stdlib_math_base_napi_zd_z_wrapper, \ |
| 438 | + NULL, \ |
| 439 | + &fcn \ |
| 440 | + ); \ |
| 441 | + assert( status == napi_ok ); \ |
| 442 | + return fcn; \ |
| 443 | + }; \ |
| 444 | + NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_zd_z_init ) |
| 445 | + |
| 446 | +/** |
| 447 | +* Macro for registering a Node-API module exporting an interface invoking a binary function accepting a single-precision complex floating-point number and a single-precision floating-point number and returning a single-precision complex floating-point number. |
| 448 | +* |
| 449 | +* @param fcn binary function |
| 450 | +* |
| 451 | +* @example |
| 452 | +* #include "stdlib/complex/float32.h" |
| 453 | +* #include "stdlib/complex/reimf.h" |
| 454 | +* |
| 455 | +* static stdlib_complex64_t mul( const stdlib_complex64_t x, const float n ) { |
| 456 | +* float re; |
| 457 | +* float im; |
| 458 | +* |
| 459 | +* stdlib_reimf( x, &re, &im ); |
| 460 | +* return stdlib_complex64( re*n, im*n ); |
| 461 | +* } |
| 462 | +* |
| 463 | +* // ... |
| 464 | +* |
| 465 | +* // Register a Node-API module: |
| 466 | +* STDLIB_MATH_BASE_NAPI_MODULE_CF_C( mul ); |
| 467 | +*/ |
| 468 | +#define STDLIB_MATH_BASE_NAPI_MODULE_CF_C( fcn ) \ |
| 469 | + static napi_value stdlib_math_base_napi_cf_c_wrapper( \ |
| 470 | + napi_env env, \ |
| 471 | + napi_callback_info info \ |
| 472 | + ) { \ |
| 473 | + return stdlib_math_base_napi_cf_c( env, info, fcn ); \ |
| 474 | + }; \ |
| 475 | + static napi_value stdlib_math_base_napi_cf_c_init( \ |
| 476 | + napi_env env, \ |
| 477 | + napi_value exports \ |
| 478 | + ) { \ |
| 479 | + napi_value fcn; \ |
| 480 | + napi_status status = napi_create_function( \ |
| 481 | + env, \ |
| 482 | + "exports", \ |
| 483 | + NAPI_AUTO_LENGTH, \ |
| 484 | + stdlib_math_base_napi_cf_c_wrapper, \ |
| 485 | + NULL, \ |
| 486 | + &fcn \ |
| 487 | + ); \ |
| 488 | + assert( status == napi_ok ); \ |
| 489 | + return fcn; \ |
| 490 | + }; \ |
| 491 | + NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_cf_c_init ) |
| 492 | + |
399 | 493 | /* |
400 | 494 | * If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. |
401 | 495 | */ |
@@ -443,6 +537,16 @@ napi_value stdlib_math_base_napi_zi_z( napi_env env, napi_callback_info info, st |
443 | 537 | */ |
444 | 538 | napi_value stdlib_math_base_napi_ci_c( napi_env env, napi_callback_info info, stdlib_complex64_t (*fcn)( stdlib_complex64_t, int32_t ) ); |
445 | 539 |
|
| 540 | +/** |
| 541 | +* Invokes a binary function accepting a double-precision complex floating-point number and a double-precision floating-point number and returning a double-precision complex floating-point number. |
| 542 | +*/ |
| 543 | +napi_value stdlib_math_base_napi_zd_z( napi_env env, napi_callback_info info, stdlib_complex128_t (*fcn)( stdlib_complex128_t, double ) ); |
| 544 | + |
| 545 | +/** |
| 546 | +* Invokes a binary function accepting a single-precision complex floating-point number and a single-precision floating-point number and returning a single-precision complex floating-point number. |
| 547 | +*/ |
| 548 | +napi_value stdlib_math_base_napi_cf_c( napi_env env, napi_callback_info info, stdlib_complex64_t (*fcn)( stdlib_complex64_t, float ) ); |
| 549 | + |
446 | 550 | #ifdef __cplusplus |
447 | 551 | } |
448 | 552 | #endif |
|
0 commit comments