1 /** 2 * Copyright (c) 2023 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 panda::ets { 21 22 /// @class EtsWeakReference represent std.core.WeakRef class 23 class EtsWeakReference : public EtsObject { 24 public: 25 EtsWeakReference() = delete; 26 NO_COPY_SEMANTIC(EtsWeakReference); 27 NO_MOVE_SEMANTIC(EtsWeakReference); 28 ~EtsWeakReference() = delete; 29 GetReferent()30 EtsObject *GetReferent() const 31 { 32 return referent_; 33 } 34 ClearReferent()35 void ClearReferent() 36 { 37 referent_ = nullptr; 38 } 39 40 private: 41 // Such field has the same layout as referent in std.core.WeakRef class 42 ObjectPointer<EtsObject> referent_; 43 }; 44 45 } // namespace panda::ets 46 47 #endif // PANDA_PLUGINS_ETS_RUNTIME_TYPES_ETS_WEAK_REFERENCE_H 48