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_RUNTIME_ETS_FFI_CLASSES_ETS_BOX_CLASSES_H_ 17 #define PANDA_RUNTIME_ETS_FFI_CLASSES_ETS_BOX_CLASSES_H_ 18 19 #include "plugins/ets/runtime/types/ets_object.h" 20 21 namespace ark::ets { 22 23 template <typename T> 24 class EtsBoxPrimitive : public EtsObject { 25 public: 26 EtsBoxPrimitive() = delete; 27 ~EtsBoxPrimitive() = delete; 28 29 static EtsBoxPrimitive *Create(EtsCoroutine *coro, T value); 30 FromCoreType(EtsObject * obj)31 static constexpr EtsBoxPrimitive *FromCoreType(EtsObject *obj) 32 { 33 ASSERT(obj->GetClass()->IsBoxed()); 34 return static_cast<EtsBoxPrimitive<T> *>(obj); 35 } 36 GetValue()37 T GetValue() const 38 { 39 return value_; 40 } 41 SetValue(T value)42 void SetValue(T value) 43 { 44 value_ = value; 45 } 46 47 NO_COPY_SEMANTIC(EtsBoxPrimitive); 48 NO_MOVE_SEMANTIC(EtsBoxPrimitive); 49 50 private: 51 T value_; 52 }; 53 } // namespace ark::ets 54 55 #endif // PANDA_RUNTIME_ETS_FFI_CLASSES_ETS_BOX_CLASSES_H_ 56