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