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_NAMESPACE_H_ 17 #define PANDA_PLUGINS_ETS_RUNTIME_TYPES_ETS_NAMESPACE_H_ 18 19 #include "plugins/ets/runtime/types/ets_class.h" 20 #include "plugins/ets/runtime/types/ets_variable.h" 21 22 namespace ark::ets { 23 24 class EtsNamespace : private EtsClass { 25 public: AsClass()26 EtsClass *AsClass() 27 { 28 return this; 29 } 30 FromClass(EtsClass * cls)31 static EtsNamespace *FromClass(EtsClass *cls) 32 { 33 // NODE: Check that class is namespace, when #22400 is resolved 34 return static_cast<EtsNamespace *>(cls); 35 } 36 GetVariabe(const char * name)37 EtsVariable *GetVariabe(const char *name) 38 { 39 EtsField *field = GetStaticFieldIDByName(name, nullptr); 40 return EtsVariable::FromField(field); 41 } 42 GetFunction(const char * name,const char * signature)43 EtsMethod *GetFunction(const char *name, const char *signature) 44 { 45 return GetStaticMethod(name, signature); 46 } 47 }; 48 49 static_assert(sizeof(EtsNamespace) == sizeof(EtsClass)); 50 51 } // namespace ark::ets 52 53 #endif // PANDA_PLUGINS_ETS_RUNTIME_TYPES_ETS_NAMESPACE_H_ 54