Skip to content

Commit bf703d6

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

File tree

33 files changed

+3019
-2140
lines changed

33 files changed

+3019
-2140
lines changed

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

Lines changed: 16 additions & 766 deletions
Large diffs are not rendered by default.
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2020 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
#ifndef STDLIB_MATH_BASE_NAPI_BINARY_CC_C_H
20+
#define STDLIB_MATH_BASE_NAPI_BINARY_CC_C_H
21+
22+
#include "stdlib/complex/float32/ctor.h"
23+
#include <node_api.h>
24+
#include <assert.h>
25+
26+
/**
27+
* Macro for registering a Node-API module exporting an interface invoking a binary function accepting and returning single-precision complex floating-point numbers.
28+
*
29+
* @param fcn binary function
30+
*
31+
* @example
32+
* #include "stdlib/complex/float32/ctor.h"
33+
* #include "stdlib/complex/float32/reim.h"
34+
*
35+
* static stdlib_complex64_t add( const stdlib_complex64_t x, const stdlib_complex64_t y ) {
36+
* float xre;
37+
* float xim;
38+
* float yre;
39+
* float yim;
40+
* float re;
41+
* float im;
42+
*
43+
* stdlib_complex64_reim( x, &xre, &xim );
44+
* stdlib_complex64_reim( y, &yre, &yim );
45+
*
46+
* re = xre + yre;
47+
* im = xim + yim;
48+
*
49+
* return stdlib_complex64( re, im );
50+
* }
51+
*
52+
* // ...
53+
*
54+
* // Register a Node-API module:
55+
* STDLIB_MATH_BASE_NAPI_MODULE_CC_C( add );
56+
*/
57+
#define STDLIB_MATH_BASE_NAPI_MODULE_CC_C( fcn ) \
58+
static napi_value stdlib_math_base_napi_cc_c_wrapper( \
59+
napi_env env, \
60+
napi_callback_info info \
61+
) { \
62+
return stdlib_math_base_napi_cc_c( env, info, fcn ); \
63+
}; \
64+
static napi_value stdlib_math_base_napi_cc_c_init( \
65+
napi_env env, \
66+
napi_value exports \
67+
) { \
68+
napi_value fcn; \
69+
napi_status status = napi_create_function( \
70+
env, \
71+
"exports", \
72+
NAPI_AUTO_LENGTH, \
73+
stdlib_math_base_napi_cc_c_wrapper, \
74+
NULL, \
75+
&fcn \
76+
); \
77+
assert( status == napi_ok ); \
78+
return fcn; \
79+
}; \
80+
NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_cc_c_init )
81+
82+
/*
83+
* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler.
84+
*/
85+
#ifdef __cplusplus
86+
extern "C" {
87+
#endif
88+
89+
/**
90+
* Invokes a binary function accepting and returning single-precision complex floating-point numbers.
91+
*/
92+
napi_value stdlib_math_base_napi_cc_c( napi_env env, napi_callback_info info, stdlib_complex64_t (*fcn)( stdlib_complex64_t, stdlib_complex64_t ) );
93+
94+
#ifdef __cplusplus
95+
}
96+
#endif
97+
98+
#endif // !STDLIB_MATH_BASE_NAPI_BINARY_CC_C_H
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2020 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
#ifndef STDLIB_MATH_BASE_NAPI_BINARY_CF_C_H
20+
#define STDLIB_MATH_BASE_NAPI_BINARY_CF_C_H
21+
22+
#include "stdlib/complex/float32/ctor.h"
23+
#include <node_api.h>
24+
#include <assert.h>
25+
26+
/**
27+
* 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.
28+
*
29+
* @param fcn binary function
30+
*
31+
* @example
32+
* #include "stdlib/complex/float32/ctor.h"
33+
* #include "stdlib/complex/float32/reim.h"
34+
*
35+
* static stdlib_complex64_t mul( const stdlib_complex64_t x, const float n ) {
36+
* float re;
37+
* float im;
38+
*
39+
* stdlib_complex64_reim( x, &re, &im );
40+
* return stdlib_complex64( re*n, im*n );
41+
* }
42+
*
43+
* // ...
44+
*
45+
* // Register a Node-API module:
46+
* STDLIB_MATH_BASE_NAPI_MODULE_CF_C( mul );
47+
*/
48+
#define STDLIB_MATH_BASE_NAPI_MODULE_CF_C( fcn ) \
49+
static napi_value stdlib_math_base_napi_cf_c_wrapper( \
50+
napi_env env, \
51+
napi_callback_info info \
52+
) { \
53+
return stdlib_math_base_napi_cf_c( env, info, fcn ); \
54+
}; \
55+
static napi_value stdlib_math_base_napi_cf_c_init( \
56+
napi_env env, \
57+
napi_value exports \
58+
) { \
59+
napi_value fcn; \
60+
napi_status status = napi_create_function( \
61+
env, \
62+
"exports", \
63+
NAPI_AUTO_LENGTH, \
64+
stdlib_math_base_napi_cf_c_wrapper, \
65+
NULL, \
66+
&fcn \
67+
); \
68+
assert( status == napi_ok ); \
69+
return fcn; \
70+
}; \
71+
NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_cf_c_init )
72+
73+
/*
74+
* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler.
75+
*/
76+
#ifdef __cplusplus
77+
extern "C" {
78+
#endif
79+
80+
/**
81+
* 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.
82+
*/
83+
napi_value stdlib_math_base_napi_cf_c( napi_env env, napi_callback_info info, stdlib_complex64_t (*fcn)( stdlib_complex64_t, float ) );
84+
85+
#ifdef __cplusplus
86+
}
87+
#endif
88+
89+
#endif // !STDLIB_MATH_BASE_NAPI_BINARY_CF_C_H
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2020 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
#ifndef STDLIB_MATH_BASE_NAPI_BINARY_CI_C_H
20+
#define STDLIB_MATH_BASE_NAPI_BINARY_CI_C_H
21+
22+
#include "stdlib/complex/float32/ctor.h"
23+
#include <node_api.h>
24+
#include <assert.h>
25+
#include <stdint.h>
26+
27+
/**
28+
* Macro for registering a Node-API module exporting an interface invoking a binary function accepting a single-precision complex floating-point number and a signed 32-bit integer and returning a single-precision complex floating-point number.
29+
*
30+
* @param fcn binary function
31+
*
32+
* @example
33+
* #include "stdlib/complex/float32/ctor.h"
34+
* #include "stdlib/complex/float32/reim.h"
35+
* #include <stdint.h>
36+
*
37+
* static stdlib_complex64_t mul( const stdlib_complex64_t x, const int32_t n ) {
38+
* float re;
39+
* float im;
40+
*
41+
* stdlib_complex64_reim( x, &re, &im );
42+
* return stdlib_complex64( re*n, im*n );
43+
* }
44+
*
45+
* // ...
46+
*
47+
* // Register a Node-API module:
48+
* STDLIB_MATH_BASE_NAPI_MODULE_CI_C( mul );
49+
*/
50+
#define STDLIB_MATH_BASE_NAPI_MODULE_CI_C( fcn ) \
51+
static napi_value stdlib_math_base_napi_ci_c_wrapper( \
52+
napi_env env, \
53+
napi_callback_info info \
54+
) { \
55+
return stdlib_math_base_napi_ci_c( env, info, fcn ); \
56+
}; \
57+
static napi_value stdlib_math_base_napi_ci_c_init( \
58+
napi_env env, \
59+
napi_value exports \
60+
) { \
61+
napi_value fcn; \
62+
napi_status status = napi_create_function( \
63+
env, \
64+
"exports", \
65+
NAPI_AUTO_LENGTH, \
66+
stdlib_math_base_napi_ci_c_wrapper, \
67+
NULL, \
68+
&fcn \
69+
); \
70+
assert( status == napi_ok ); \
71+
return fcn; \
72+
}; \
73+
NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_ci_c_init )
74+
75+
/*
76+
* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler.
77+
*/
78+
#ifdef __cplusplus
79+
extern "C" {
80+
#endif
81+
82+
/**
83+
* Invokes a binary function accepting a single-precision complex floating-point number and a signed 32-bit integer and returning a single-precision complex floating-point number.
84+
*/
85+
napi_value stdlib_math_base_napi_ci_c( napi_env env, napi_callback_info info, stdlib_complex64_t (*fcn)( stdlib_complex64_t, int32_t ) );
86+
87+
#ifdef __cplusplus
88+
}
89+
#endif
90+
91+
#endif // !STDLIB_MATH_BASE_NAPI_BINARY_CI_C_H
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2020 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
#ifndef STDLIB_MATH_BASE_NAPI_BINARY_DD_D_H
20+
#define STDLIB_MATH_BASE_NAPI_BINARY_DD_D_H
21+
22+
#include <node_api.h>
23+
#include <assert.h>
24+
25+
/**
26+
* Macro for registering a Node-API module exporting an interface invoking a binary function accepting and returning double-precision floating-point numbers.
27+
*
28+
* @param fcn binary function
29+
*
30+
* @example
31+
* static double add( const double x, const double y ) {
32+
* return x + y;
33+
* }
34+
*
35+
* // ...
36+
*
37+
* // Register a Node-API module:
38+
* STDLIB_MATH_BASE_NAPI_MODULE_DD_D( add );
39+
*/
40+
#define STDLIB_MATH_BASE_NAPI_MODULE_DD_D( fcn ) \
41+
static napi_value stdlib_math_base_napi_dd_d_wrapper( \
42+
napi_env env, \
43+
napi_callback_info info \
44+
) { \
45+
return stdlib_math_base_napi_dd_d( env, info, fcn ); \
46+
}; \
47+
static napi_value stdlib_math_base_napi_dd_d_init( \
48+
napi_env env, \
49+
napi_value exports \
50+
) { \
51+
napi_value fcn; \
52+
napi_status status = napi_create_function( \
53+
env, \
54+
"exports", \
55+
NAPI_AUTO_LENGTH, \
56+
stdlib_math_base_napi_dd_d_wrapper, \
57+
NULL, \
58+
&fcn \
59+
); \
60+
assert( status == napi_ok ); \
61+
return fcn; \
62+
}; \
63+
NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_dd_d_init )
64+
65+
/*
66+
* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler.
67+
*/
68+
#ifdef __cplusplus
69+
extern "C" {
70+
#endif
71+
72+
/**
73+
* Invokes a binary function accepting and returning double-precision floating-point numbers.
74+
*/
75+
napi_value stdlib_math_base_napi_dd_d( napi_env env, napi_callback_info info, double (*fcn)( double, double ) );
76+
77+
#ifdef __cplusplus
78+
}
79+
#endif
80+
81+
#endif // !STDLIB_MATH_BASE_NAPI_BINARY_DD_D_H

0 commit comments

Comments
 (0)