/* * Copyright (c) 2024 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef OHOS_IDL_HDI_CODE_EMITTER_H #define OHOS_IDL_HDI_CODE_EMITTER_H #include "codegen/code_emitter.h" #include "hdi_type_emitter.h" namespace OHOS { namespace Idl { class HDICodeEmitter : public CodeEmitter { public: using TypeEmitterMap = std::unordered_map>; ~HDICodeEmitter() override = default; bool OutPut(const AutoPtr &ast, const std::string &targetDirectory, GenMode mode) override; virtual void EmitUtilMethods(StringBuilder &sb, bool isDecl); protected: bool Reset(const AutoPtr &ast, const std::string &targetDirectory, GenMode mode); void CleanData(); AutoPtr GetTypeEmitter(AutoPtr astType) const; void EmitInterfaceBuffSizeMacro(StringBuilder &sb) const; void EmitUtilMethodMap(StringBuilder &sb, const UtilMethodMap &methods); GenMode mode_ = GenMode::IPC; std::string implName_; std::string implFullName_; std::string majorVerName_; std::string minorVerName_; std::string flagOfSetMemName_; std::string optionName_; private: std::string GetNameWithNamespace(AutoPtr space, std::string name) const; AutoPtr NewTypeEmitter(AutoPtr astType) const; AutoPtr NewMapTypeEmitter(AutoPtr astType) const; AutoPtr NewArrayTypeEmitter(AutoPtr astType) const; AutoPtr NewListTypeEmitter(AutoPtr astType) const; AutoPtr NewEnumTypeEmitter(AutoPtr astType) const; AutoPtr NewStructTypeEmitter(AutoPtr astType) const; AutoPtr NewUnionTypeEmitter(AutoPtr astType) const; AutoPtr NewSmqTypeEmitter(AutoPtr astType) const; static TypeEmitterMap basicEmitters_; }; } // namespace Idl } // namespace OHOS #endif // OHOS_IDL_CODE_EMITTER_H