• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright (c) 2021-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_TYPEAPI_PARAMETER_H_
17 #define PANDA_PLUGINS_ETS_TYPEAPI_PARAMETER_H_
18 
19 #include "plugins/ets/runtime/types/ets_object.h"
20 #include "plugins/ets/runtime/types/ets_runtime_linker.h"
21 #include "plugins/ets/runtime/types/ets_string.h"
22 #include "plugins/ets/runtime/types/ets_primitives.h"
23 #include "plugins/ets/runtime/types/ets_typeapi.h"
24 #include "plugins/ets/runtime/types/ets_typeapi_type.h"
25 
26 namespace ark::ets {
27 
28 namespace test {
29 class EtsTypeAPITest;
30 }  // namespace test
31 
32 class EtsCoroutine;
33 
34 class EtsTypeAPIParameter : public ObjectHeader {
35 public:
36     EtsTypeAPIParameter() = delete;
37     ~EtsTypeAPIParameter() = delete;
38 
39     NO_COPY_SEMANTIC(EtsTypeAPIParameter);
40     NO_MOVE_SEMANTIC(EtsTypeAPIParameter);
41 
42     static EtsTypeAPIParameter *Create(EtsCoroutine *etsCoroutine = EtsCoroutine::GetCurrent());
43 
AsObject()44     EtsObject *AsObject()
45     {
46         return EtsObject::FromCoreType(this);
47     }
48 
AsObject()49     const EtsObject *AsObject() const
50     {
51         return EtsObject::FromCoreType(this);
52     }
53 
FromEtsObject(EtsObject * field)54     static EtsTypeAPIParameter *FromEtsObject(EtsObject *field)
55     {
56         return reinterpret_cast<EtsTypeAPIParameter *>(field);
57     }
58 
SetParameterType(EtsTypeAPIType * paramType)59     void SetParameterType(EtsTypeAPIType *paramType)
60     {
61         ASSERT(paramType != nullptr);
62         ObjectAccessor::SetObject(this, MEMBER_OFFSET(EtsTypeAPIParameter, paramType_),
63                                   paramType->AsObject()->GetCoreType());
64     }
65 
SetName(EtsString * name)66     void SetName(EtsString *name)
67     {
68         ASSERT(name != nullptr);
69         ObjectAccessor::SetObject(this, MEMBER_OFFSET(EtsTypeAPIParameter, name_), name->AsObject()->GetCoreType());
70     }
71 
SetAttributes(EtsInt attr)72     void SetAttributes(EtsInt attr)
73     {
74         ObjectAccessor::SetPrimitive(this, MEMBER_OFFSET(EtsTypeAPIParameter, attr_), attr);
75     }
76 
77 private:
78     ObjectPointer<EtsTypeAPIType> paramType_;
79     ObjectPointer<EtsString> name_;
80     FIELD_UNUSED EtsInt attr_;
81 
82     friend class test::EtsTypeAPITest;
83 };
84 
85 }  // namespace ark::ets
86 
87 #endif  // PANDA_PLUGINS_ETS_TYPEAPI_PARAMETER_H
88