/
smskmap.h
82 lines (75 loc) · 3.63 KB
/
smskmap.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/**
* @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.
*/
#ifndef STDLIB_STRIDED_NAPI_SMSKMAP_H
#define STDLIB_STRIDED_NAPI_SMSKMAP_H
#include <node_api.h>
#include <assert.h>
/**
* Macro for registering a Node-API module exporting a strided array interface for applying a unary callback to a single-precision floating-point strided input array according to a strided mask array and assigning results to a single-precision floating-point strided output array.
*
* @param clbk unary callback
*
* @example
* static float scale( const float x ) {
* return x * 10.0f;
* }
*
* // ...
*
* // Register a Node-API module:
* STDLIB_STRIDED_NAPI_MODULE_SMSKMAP( scale );
*/
#define STDLIB_STRIDED_NAPI_MODULE_SMSKMAP( clbk ) \
static napi_value stdlib_strided_napi_smskmap_wrapper( \
napi_env env, \
napi_callback_info info \
) { \
stdlib_strided_napi_smskmap( env, info, clbk ); \
return NULL; \
}; \
static napi_value stdlib_strided_napi_smskmap_init( \
napi_env env, \
napi_value exports \
) { \
napi_value fcn; \
napi_status status = napi_create_function( \
env, \
"exports", \
NAPI_AUTO_LENGTH, \
stdlib_strided_napi_smskmap_wrapper, \
NULL, \
&fcn \
); \
assert( status == napi_ok ); \
return fcn; \
}; \
NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_strided_napi_smskmap_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 strided array interface which applies a unary callback to a single-precision floating-point strided input array according to a strided mask array and assigns results to a single-precision floating-point strided output array.
*/
void stdlib_strided_napi_smskmap( napi_env env, napi_callback_info info, float (*fcn)( float ) );
#ifdef __cplusplus
}
#endif
#endif // !STDLIB_STRIDED_NAPI_SMSKMAP_H