• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright (c) 2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef PANDA_NAPI_IMPL_H
17 #define PANDA_NAPI_IMPL_H
18 
19 #include <node_api.h>
20 #include <node_api_types.h>
21 #include "detail/enumerate_napi.h"
22 
23 namespace ark::ets::interop::js {
24 
25 struct NapiImpl {
26     // NOLINTBEGIN(cppcoreguidelines-macro-usage)
InitNapiNapiImpl27     static void InitNapi()
28     {
29         NapiImpl impl;
30 // CC-OFFNXT(G.PRE.09) code generation
31 #define NAPI_METHOD(name, ...) impl.name = ::name;
32         ENUMERATE_NAPI(NAPI_METHOD)
33 #undef NAPI_METHOD
34 
35         Init(impl);
36     }
37 
38 // CC-OFFNXT(G.PRE.09) code generation
39 #define NAPI_METHOD(name, ...) napi_status (*name)(PARAMS_PAIR(__VA_ARGS__)) = nullptr;
40 
41     ENUMERATE_NAPI(NAPI_METHOD)
42 
43 #undef NAPI_METHOD
44 
45 private:
46     PANDA_PUBLIC_API static void Init(NapiImpl impl);
47     // NOLINTEND(cppcoreguidelines-macro-usage)
48 };
49 
50 }  // namespace ark::ets::interop::js
51 #endif  // PANDA_NAPI_IMPL_H
52