• 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 #ifndef PANDA_PLUGINS_ETS_RUNTIME_TYPES_ETS_WEAK_REFERENCE_H
16 #define PANDA_PLUGINS_ETS_RUNTIME_TYPES_ETS_WEAK_REFERENCE_H
17 
18 #include "plugins/ets/runtime/types/ets_object.h"
19 
20 namespace ark::ets {
21 
22 namespace test {
23 class EtsFinalizableWeakRefTest;
24 }  // namespace test
25 
26 /// @class EtsWeakReference represent std.core.WeakRef class
27 class EtsWeakReference : public EtsObject {
28 public:
29     EtsWeakReference() = delete;
30     NO_COPY_SEMANTIC(EtsWeakReference);
31     NO_MOVE_SEMANTIC(EtsWeakReference);
32     ~EtsWeakReference() = delete;
33 
GetReferent()34     EtsObject *GetReferent() const
35     {
36         return referent_;
37     }
38 
39     void ClearReferent();
40 
41     void SetReferent(EtsObject *addr);
42 
43 private:
44     // Such field has the same layout as referent in std.core.WeakRef class
45     ObjectPointer<EtsObject> referent_;
46 
47     friend class test::EtsFinalizableWeakRefTest;
48 };
49 
50 }  // namespace ark::ets
51 
52 #endif  // PANDA_PLUGINS_ETS_RUNTIME_TYPES_ETS_WEAK_REFERENCE_H
53