代码告警清理

Signed-off-by: yue <yueyan4@huawei.com>
This commit is contained in:
yue
2021-09-18 20:17:48 +08:00
parent 02009701d0
commit 31926f6a34
100 changed files with 2252 additions and 2019 deletions
+48 -8
View File
@@ -12,16 +12,34 @@
#include <unistd.h>
#include <unordered_set>
#include "util/logger.h"
namespace OHOS {
namespace HDI {
CppCodeEmitter::CppCodeEmitter(const AutoPtr<AST>& ast, const String& targetDirectory)
: LightRefCountBase(), ast_(ast), directory_(targetDirectory)
bool CppCodeEmitter::OutPut(const AutoPtr<AST>& ast, const String& targetDirectory)
{
if (ast_->GetASTFileType() == ASTFileType::AST_IFACE || ast_->GetASTFileType() == ASTFileType::AST_ICALLBACK) {
interface_ = ast_->GetInterfaceDef();
if (!Reset(ast, targetDirectory)) {
return false;
}
if (interface_ != nullptr) {
EmitCode();
return true;
}
bool CppCodeEmitter::Reset(const AutoPtr<AST>& ast, const String& targetDirectory)
{
if (ast == nullptr) {
return false;
}
if (targetDirectory.Equals("")) {
return false;
}
CleanData();
ast_ = ast;
if (ast_->GetASTFileType() == ASTFileType::AST_IFACE || ast_->GetASTFileType() == ASTFileType::AST_ICALLBACK) {
interface_ = ast_->GetInterfaceDef();
interfaceName_ = interface_->GetName();
interfaceFullName_ = interface_->GetNamespace()->ToString() + interfaceName_;
infName_ = interfaceName_.StartsWith("I") ? interfaceName_.Substring(1) : interfaceName_;
@@ -31,11 +49,33 @@ CppCodeEmitter::CppCodeEmitter(const AutoPtr<AST>& ast, const String& targetDire
stubName_ = infName_ + "Stub";
stubFullName_ = interface_->GetNamespace()->ToString() + stubName_;
ImplName_ = infName_ + "Service";
ImplFullName_ = interface_->GetNamespace()->ToString() + ImplName_;
} else {
implName_ = infName_ + "Service";
implFullName_ = interface_->GetNamespace()->ToString() + implName_;
} else if (ast_->GetASTFileType() == ASTFileType::AST_TYPES) {
infName_ = ast_->GetName();
}
if (!ResolveDirectory(targetDirectory)) {
return false;
}
return true;
}
void CppCodeEmitter::CleanData()
{
ast_ = nullptr;
interface_ = nullptr;
directory_ = "";
interfaceName_ = "";
interfaceFullName_ = "";
infName_ = "";
proxyName_ = "";
proxyFullName_ = "";
stubName_ = "";
stubFullName_ = "";
implName_ = "";
implFullName_ = "";
}
String CppCodeEmitter::FileName(const String& name)