• 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_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         return static_cast<EtsBoxPrimitive<T> *>(obj);
34     }
35 
GetValue()36     T GetValue() const
37     {
38         return value_;
39     }
40 
SetValue(T value)41     void SetValue(T value)
42     {
43         value_ = value;
44     }
45 
46     NO_COPY_SEMANTIC(EtsBoxPrimitive);
47     NO_MOVE_SEMANTIC(EtsBoxPrimitive);
48 
49 private:
50     T value_;
51 };
52 }  // namespace ark::ets
53 
54 #endif  // PANDA_RUNTIME_ETS_FFI_CLASSES_ETS_BOX_CLASSES_H_
55