• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright (c) 2025 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_PLUGINS_ETS_RUNTIME_TYPES_ETS_TYPEAPI_TYPE_H
17 #define PANDA_PLUGINS_ETS_RUNTIME_TYPES_ETS_TYPEAPI_TYPE_H
18 
19 #include "mem/object_pointer.h"
20 #include "plugins/ets/runtime/types/ets_object.h"
21 #include "plugins/ets/runtime/types/ets_runtime_linker.h"
22 #include "plugins/ets/runtime/types/ets_string.h"
23 
24 namespace ark::ets {
25 
26 namespace test {
27 class EtsTypeAPITest;
28 }  // namespace test
29 
30 class EtsCoroutine;
31 
32 class EtsTypeAPIType : public EtsObject {
33 public:
34     EtsTypeAPIType() = delete;
35     ~EtsTypeAPIType() = delete;
36 
37     NO_COPY_SEMANTIC(EtsTypeAPIType);
38     NO_MOVE_SEMANTIC(EtsTypeAPIType);
39 
AsObject()40     EtsObject *AsObject()
41     {
42         return this;
43     }
44 
AsObject()45     const EtsObject *AsObject() const
46     {
47         return this;
48     }
49 
FromEtsObject(EtsObject * type)50     static EtsTypeAPIType *FromEtsObject(EtsObject *type)
51     {
52         return reinterpret_cast<EtsTypeAPIType *>(type);
53     }
54 
FromCoreType(ObjectHeader * objectHeader)55     static EtsTypeAPIType *FromCoreType(ObjectHeader *objectHeader)
56     {
57         return reinterpret_cast<EtsTypeAPIType *>(objectHeader);
58     }
59 
GetContextLinker()60     EtsRuntimeLinker *GetContextLinker() const
61     {
62         return EtsRuntimeLinker::FromCoreType(
63             ObjectAccessor::GetObject(this, MEMBER_OFFSET(EtsTypeAPIType, contextLinker_)));
64     }
65 
GetRuntimeTypeDescriptor()66     EtsString *GetRuntimeTypeDescriptor() const
67     {
68         return EtsString::FromEtsObject(
69             EtsObject::FromCoreType(ObjectAccessor::GetObject(this, MEMBER_OFFSET(EtsTypeAPIType, td_))));
70     }
71 
72 private:
73     ObjectPointer<EtsString> td_;
74     ObjectPointer<EtsRuntimeLinker> contextLinker_;
75 
76     friend class test::EtsTypeAPITest;
77 };
78 
79 }  // namespace ark::ets
80 
81 #endif  // PANDA_PLUGINS_ETS_RUNTIME_TYPES_ETS_TYPEAPI_TYPE_H
82