• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright (c) 2023-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_PLUGINS_ETS_RUNTIME_INTEROP_JS_ETS_OBJECT_REFERENCE_H_
17 #define PANDA_PLUGINS_ETS_RUNTIME_INTEROP_JS_ETS_OBJECT_REFERENCE_H_
18 
19 #include "libpandabase/macros.h"
20 #include "libpandabase/utils/logger.h"
21 #include "plugins/ets/runtime/interop_js/interop_common.h"
22 #include <memory>
23 
24 namespace ark::mem {
25 class Reference;
26 }  // namespace ark::mem
27 
28 namespace ark::ets::interop::js::ets_proxy {
29 
30 class EtsObjectReferenceDeleter {
31 public:
32     constexpr EtsObjectReferenceDeleter() noexcept = default;
33     ~EtsObjectReferenceDeleter() noexcept = default;
34     EtsObjectReferenceDeleter(const EtsObjectReferenceDeleter &) noexcept = default;
35     EtsObjectReferenceDeleter &operator=(const EtsObjectReferenceDeleter &) noexcept = default;
36     DEFAULT_NOEXCEPT_MOVE_SEMANTIC(EtsObjectReferenceDeleter);
37 
operator()38     void operator()(mem::Reference *ref) const noexcept
39     {
40         INTEROP_LOG(FATAL) << "UniqueEtsObjectReference shouldn't delete automaticly, ref=" << ref;
41     }
42 };
43 
44 using UniqueEtsObjectReference = std::unique_ptr<mem::Reference, EtsObjectReferenceDeleter>;
45 
46 }  // namespace ark::ets::interop::js::ets_proxy
47 
48 #endif  // !PANDA_PLUGINS_ETS_RUNTIME_INTEROP_JS_ETS_OBJECT_REFERENCE_H_
49