1 /** 2 * Copyright (c) 2021-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_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_string.h" 21 #include "types/ets_primitives.h" 22 #include "types/ets_typeapi.h" 23 24 namespace ark::ets { 25 26 class EtsCoroutine; 27 28 class EtsTypeAPIParameter : public ObjectHeader { 29 public: 30 EtsTypeAPIParameter() = delete; 31 ~EtsTypeAPIParameter() = delete; 32 33 NO_COPY_SEMANTIC(EtsTypeAPIParameter); 34 NO_MOVE_SEMANTIC(EtsTypeAPIParameter); 35 36 static EtsTypeAPIParameter *Create(EtsCoroutine *etsCoroutine = EtsCoroutine::GetCurrent()); 37 AsObject()38 EtsObject *AsObject() 39 { 40 return EtsObject::FromCoreType(this); 41 } 42 AsObject()43 const EtsObject *AsObject() const 44 { 45 return EtsObject::FromCoreType(this); 46 } 47 FromEtsObject(EtsObject * field)48 static EtsTypeAPIParameter *FromEtsObject(EtsObject *field) 49 { 50 return reinterpret_cast<EtsTypeAPIParameter *>(field); 51 } 52 SetTypeDesc(EtsString * td)53 void SetTypeDesc(EtsString *td) 54 { 55 ObjectAccessor::SetObject(this, MEMBER_OFFSET(EtsTypeAPIParameter, td_), td->AsObject()->GetCoreType()); 56 } 57 SetName(EtsString * name)58 void SetName(EtsString *name) 59 { 60 ObjectAccessor::SetObject(this, MEMBER_OFFSET(EtsTypeAPIParameter, name_), name->AsObject()->GetCoreType()); 61 } 62 SetAttributes(EtsInt attr)63 void SetAttributes(EtsInt attr) 64 { 65 ObjectAccessor::SetPrimitive(this, MEMBER_OFFSET(EtsTypeAPIParameter, attr_), attr); 66 } 67 68 private: 69 ObjectPointer<EtsString> td_; 70 ObjectPointer<EtsString> name_; 71 FIELD_UNUSED EtsInt attr_; 72 }; 73 74 } // namespace ark::ets 75 76 #endif // PANDA_PLUGINS_ETS_TYPEAPI_PARAMETER_H 77