1 /* 2 * Copyright (c) 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 OHOS_IDL_INTF_TYPE_CHECK_H 17 #define OHOS_IDL_INTF_TYPE_CHECK_H 18 19 #include "ast/ast.h" 20 #include "ast/ast_parameter.h" 21 #include "lexer/token.h" 22 23 namespace OHOS { 24 namespace Idl { 25 26 class IntfTypeChecker { 27 public: IntfTypeChecker(AutoPtr<AST> ast)28 IntfTypeChecker(AutoPtr<AST> ast) : ast_(ast){}; 29 30 ~IntfTypeChecker() = default; 31 32 bool CheckIntegrity(); 33 34 static bool CheckBasicType(Token token); 35 36 static bool CheckUserDefType(Token token); 37 38 static bool CheckMessageOption(std::string &messageOption); 39 40 static bool CheckSAPtrType(AutoPtr<ASTType> type); 41 42 private: 43 bool CheckIntfSaAst(); 44 45 bool CheckIntfSaAstTypes(); 46 47 bool CheckIntfSaAstMethods(); 48 49 bool CheckIntfHdiAst(); 50 51 bool CheckIntfHdiAstFileType(); 52 53 bool CheckIntfHdiAstTypes(); 54 55 bool CheckIntfHdiAstParam(AutoPtr<ASTParameter> param, size_t methodIdx, size_t paramIdx); 56 57 bool CheckInterfaceAst(); 58 59 bool CheckCallbackAst(); 60 61 bool CheckSmInterfaceAst(); 62 63 bool CheckIntfSmAstFileType(); 64 65 bool CheckIntfSmAstTypes(); 66 67 bool CheckIntfSmAst(); 68 69 AutoPtr<AST> ast_; 70 }; 71 } // namespace Idl 72 } // namespace OHOS 73 74 75 #endif // OHOS_IDL_INTF_TYPE_CHECK_H