- enhancement: Autowrap tool output text.

This commit is contained in:
Roy Qu 2023-08-13 15:41:17 +08:00
parent d2b0653504
commit 707358817c
10 changed files with 78 additions and 21 deletions

View File

@ -27,7 +27,7 @@ Red Panda C++ Version 2.24
- fix: Wrong compiler settings if xcode is not installed in mac os.
- enhancement: Name for new files will not be different from files openned.
- fix: Crash if close file while auto syntax checking.
- enhancement: Support sdcc compiler.
- enhancement: Support sdcc compiler. (Disabled in the distributed buildings)
- enhancement: Autowrap tool output text.
Red Panda C++ Version 2.23

View File

@ -6,6 +6,9 @@ CONFIG += nokey
# uncomment the following line to enable vcs (git) support
# CONFIG += ENABLE_VCS
# uncomment the following line to enable sdcc support
# CONFIG += ENABLE_SDCC
isEmpty(APP_NAME) {
APP_NAME = RedPandaCPP
}
@ -390,6 +393,10 @@ FORMS += \
widgets/searchinfiledialog.ui \
widgets/signalmessagedialog.ui
ENABLE_SDCC {
DEFINES += ENABLE_SDCC
}
ENABLE_VCS {
DEFINES += ENABLE_VCS

View File

@ -210,9 +210,11 @@ CompilerInfoManager::CompilerInfoManager()
compilerInfo->init();
mInfos.insert(CompilerType::GCC_UTF8, compilerInfo);
#ifdef ENABLE_SDCC
compilerInfo = std::make_shared<SDCCCompilerInfo>();
compilerInfo->init();
mInfos.insert(CompilerType::SDCC, compilerInfo);
#endif
}
PCompilerInfo CompilerInfoManager::getInfo(CompilerType compilerType)
@ -363,6 +365,7 @@ bool GCCUTF8CompilerInfo::supportStaticLink()
return true;
}
#ifdef ENABLE_SDCC
SDCCCompilerInfo::SDCCCompilerInfo():CompilerInfo(COMPILER_SDCC)
{
@ -440,3 +443,4 @@ void SDCCCompilerInfo::prepareCompilerOptions()
sl.append(QPair<QString,QString>("SDCC C2x","sdcc2x"));
addOption(SDCC_CMD_OPT_STD, QObject::tr("Language standard (-std)"), groupName, false, true, false, "-std-", sl);
}
#endif

View File

@ -8,7 +8,9 @@
#define COMPILER_CLANG "Clang"
#define COMPILER_GCC "GCC"
#define COMPILER_GCC_UTF8 "GCC_UTF8"
#ifdef ENABLE_SDCC
#define COMPILER_SDCC "SDCC"
#endif
#define C_CMD_OPT_STD "c_cmd_opt_std"
@ -46,8 +48,10 @@
#define CC_CMD_OPT_STOP_AFTER_PREPROCESSING "cc_cmd_opt_stop_after_preprocessing"
#define CC_CMD_OPT_USE_PIPE "cc_cmd_opt_use_pipe"
#ifdef ENABLE_SDCC
#define SDCC_CMD_OPT_PROCESSOR "sdcc_cmd_opt_processor"
#define SDCC_CMD_OPT_STD "sdcc_cmd_opt_std"
#endif
#define COMPILER_OPTION_ON "on"
#define COMPILER_OPTION_OFF ""
@ -56,7 +60,9 @@ enum class CompilerType {
GCC,
GCC_UTF8,
Clang,
#ifdef ENABLE_SDCC
SDCC,
#endif
Unknown
};
@ -161,6 +167,7 @@ public:
bool supportStaticLink() override;
};
#ifdef ENABLE_SDCC
class SDCCCompilerInfo: public CompilerInfo{
public:
SDCCCompilerInfo();
@ -172,6 +179,7 @@ public:
protected:
void prepareCompilerOptions() override;
};
#endif
#endif // COMPILERINFO_H

View File

@ -2968,11 +2968,13 @@ void Editor::initParser()
ParserLanguage Editor::calcParserLanguage()
{
#ifdef ENABLE_SDCC
if (!inProject()
&& pSettings->compilerSets().defaultSet()
&& pSettings->compilerSets().defaultSet()->compilerType()==CompilerType::SDCC) {
return ParserLanguage::SDCC;
}
#endif
return mUseCppSyntax?ParserLanguage::CPlusPlus:ParserLanguage::C;
}
@ -3476,12 +3478,14 @@ void Editor::showCompletion(const QString& preWord,bool autoComplete, CodeComple
case ParserLanguage::C:
keywords = CKeywords;
break;
#ifdef ENABLE_SDCC
case ParserLanguage::SDCC:
keywords = CKeywords;
foreach (const QString& keyword, SDCCKeywords.keys()) {
keywords.insert(keyword);
}
break;
#endif
}
if (pSettings->editor().enableCustomCTypeKeywords()) {
foreach (const QString& keyword, pSettings->editor().customCTypeKeywords()) {
@ -5244,6 +5248,7 @@ void Editor::applySettings()
set.insert(s);
((QSynedit::CppSyntaxer*)(syntaxer().get()))->setCustomTypeKeywords(set);
}
#ifdef ENABLE_SDCC
} else if (!inProject() && pSettings->compilerSets().defaultSet()
&& pSettings->compilerSets().defaultSet()->compilerType()==CompilerType::SDCC) {
if (syntaxer() && syntaxer()->language() == QSynedit::ProgrammingLanguage::CPP) {
@ -5252,6 +5257,7 @@ void Editor::applySettings()
set.insert(s);
((QSynedit::CppSyntaxer*)(syntaxer().get()))->setCustomTypeKeywords(set);
}
#endif
} else {
if (syntaxer() && syntaxer()->language() == QSynedit::ProgrammingLanguage::CPP) {
((QSynedit::CppSyntaxer*)(syntaxer().get()))->setCustomTypeKeywords(QSet<QString>());

View File

@ -2188,6 +2188,7 @@ void CppParser::checkAndHandleMethodOrVar(KeywordType keywordType)
isStatic);
return;
} else if (mTokenizer[mIndex + 1]->text == '(') {
#ifdef ENABLE_SDCC
if (mLanguage==ParserLanguage::SDCC && mTokenizer[mIndex]->text=="__at") {
if (!sName.isEmpty()) {
sType = sType+" "+sName;
@ -2204,7 +2205,7 @@ void CppParser::checkAndHandleMethodOrVar(KeywordType keywordType)
mIndex=idx+1;
continue;
}
#endif
if (mIndex+2<tokenCount && mTokenizer[mIndex+2]->text == '*') {
//foo(*blabla), it's a function pointer var
handleVar(sType+" "+sName,isExtern,isStatic);
@ -6421,15 +6422,14 @@ void CppParser::setLanguage(ParserLanguage newLanguage)
{
if (mLanguage != newLanguage) {
mLanguage = newLanguage;
mCppKeywords = CppKeywords;
mCppTypeKeywords = CppTypeKeywords;
#ifdef ENABLE_SDCC
if (mLanguage == ParserLanguage::SDCC) {
mCppKeywords = CppKeywords;
mCppTypeKeywords = CppTypeKeywords;
mCppKeywords.insert(SDCCKeywords);
mCppTypeKeywords.unite(SDCCTypeKeywords);
} else {
mCppKeywords = CppKeywords;
mCppTypeKeywords = CppTypeKeywords;
}
#endif
}
}

View File

@ -26,8 +26,10 @@
QStringList CppDirectives;
QStringList JavadocTags;
QMap<QString,KeywordType> CppKeywords;
#ifdef ENABLE_SDCC
QMap<QString,KeywordType> SDCCKeywords;
QSet<QString> SDCCTypeKeywords;
#endif
QSet<QString> CppControlKeyWords;
QSet<QString> CppTypeKeywords;
QSet<QString> CKeywords;
@ -165,6 +167,7 @@ void initParser()
CppKeywords.insert("void",KeywordType::None);
CppKeywords.insert("wchar_t",KeywordType::None);
#ifdef ENABLE_SDCC
SDCCKeywords.insert("__sfr",KeywordType::None);
SDCCKeywords.insert("__sfr16",KeywordType::None);
SDCCKeywords.insert("__sfr32",KeywordType::None);
@ -185,7 +188,7 @@ void initParser()
SDCCTypeKeywords.insert("__sfr32");
SDCCTypeKeywords.insert("__sbit");
SDCCTypeKeywords.insert("__bit");
#endif
// type keywords
CppTypeKeywords.insert("auto");
CppTypeKeywords.insert("bool");

View File

@ -27,7 +27,9 @@ using GetFileStreamCallBack = std::function<bool (const QString&, QStringList&)>
enum ParserLanguage {
C,
CPlusPlus,
SDCC
#ifdef ENABLE_SDCC
SDCC,
#endif
};
struct CodeSnippet {
@ -304,8 +306,10 @@ using PFileIncludes = std::shared_ptr<FileIncludes>;
extern QStringList CppDirectives;
extern QStringList JavadocTags;
extern QMap<QString,KeywordType> CppKeywords;
#ifdef ENABLE_SDCC
extern QMap<QString,KeywordType> SDCCKeywords;
extern QSet<QString> SDCCTypeKeywords;
#endif
extern QSet<QString> CppControlKeyWords;
extern QSet<QString> CKeywords;
extern QSet<QString> CppTypeKeywords;

View File

@ -1713,10 +1713,11 @@ Settings::CompilerSet::CompilerSet(const QString& compilerFolder, const QString&
setUserInput();
#ifdef ENABLE_SDCC
if (mCompilerType == CompilerType::SDCC) {
mExecutableSuffix = "ihx";
}
#endif
mFullLoaded = true;
} else {
mFullLoaded = false;
@ -2164,11 +2165,16 @@ static void addExistingDirectory(QStringList& dirs, const QString& directory) {
void Settings::CompilerSet::setProperties(const QString& binDir, const QString& c_prog)
{
#ifdef ENABLE_SDCC
if (c_prog == SDCC_PROGRAM) {
setSDCCProperties(binDir,c_prog);
} else {
#endif
setGCCProperties(binDir,c_prog);
#ifdef ENABLE_SDCC
}
#endif
}
void Settings::CompilerSet::setGCCProperties(const QString& binDir, const QString& c_prog)
@ -2296,6 +2302,7 @@ void Settings::CompilerSet::setGCCProperties(const QString& binDir, const QStrin
}
}
#ifdef ENABLE_SDCC
void Settings::CompilerSet::setSDCCProperties(const QString& binDir, const QString& c_prog)
{
// We have tested before the call
@ -2315,7 +2322,6 @@ void Settings::CompilerSet::setSDCCProperties(const QString& binDir, const QStri
delimPos++;
QString triplet = output.mid(0,delimPos);
qDebug()<<triplet;
QRegularExpression re("\\s+(\\d+\\.\\d+\\.\\d+)\\s+");
QRegularExpressionMatch match = re.match(triplet);
if (match.hasMatch())
@ -2328,6 +2334,7 @@ void Settings::CompilerSet::setSDCCProperties(const QString& binDir, const QStri
addExistingDirectory(mBinDirs, binDir);
}
#endif
QStringList Settings::CompilerSet::defines(bool isCpp) {
// get default defines
@ -2336,10 +2343,12 @@ QStringList Settings::CompilerSet::defines(bool isCpp) {
arguments.append("-E");
arguments.append("-x");
QString key;
#ifdef ENABLE_SDCC
if (mCompilerType==CompilerType::SDCC) {
arguments.append("c");
key=SDCC_CMD_OPT_PROCESSOR;
} else {
#endif
if (isCpp) {
arguments.append("c++");
key=CC_CMD_OPT_STD;
@ -2347,7 +2356,9 @@ QStringList Settings::CompilerSet::defines(bool isCpp) {
arguments.append("c");
key=C_CMD_OPT_STD;
}
#ifdef ENABLE_SDCC
}
#endif
//language standard
PCompilerOption pOption = CompilerInfoManager::getCompilerOption(compilerType(), key);
if (pOption) {
@ -2374,11 +2385,7 @@ QStringList Settings::CompilerSet::defines(bool isCpp) {
void Settings::CompilerSet::setExecutables()
{
if (mCompilerType == CompilerType::SDCC) {
mCCompiler = findProgramInBinDirs(SDCC_PROGRAM);
if (mCCompiler.isEmpty())
mCCompiler = findProgramInBinDirs(SDCC_PROGRAM);
} else if (mCompilerType == CompilerType::Clang) {
if (mCompilerType == CompilerType::Clang) {
mCCompiler = findProgramInBinDirs(CLANG_PROGRAM);
mCppCompiler = findProgramInBinDirs(CLANG_CPP_PROGRAM);
mDebugger = findProgramInBinDirs(GDB_PROGRAM);
@ -2392,10 +2399,12 @@ void Settings::CompilerSet::setExecutables()
mCCompiler = findProgramInBinDirs(GCC_PROGRAM);
if (mCppCompiler.isEmpty())
mCppCompiler = findProgramInBinDirs(GPP_PROGRAM);
// if (mDebugger.isEmpty())
// mDebugger = findProgramInBinDirs(GDB_PROGRAM);
// if (mDebugServer.isEmpty())
// mDebugServer = findProgramInBinDirs(GDB_SERVER_PROGRAM);
#ifdef ENABLE_SDCC
} else if (mCompilerType == CompilerType::SDCC) {
mCCompiler = findProgramInBinDirs(SDCC_PROGRAM);
if (mCCompiler.isEmpty())
mCCompiler = findProgramInBinDirs(SDCC_PROGRAM);
#endif
} else {
mCCompiler = findProgramInBinDirs(GCC_PROGRAM);
mCppCompiler = findProgramInBinDirs(GPP_PROGRAM);
@ -2408,11 +2417,15 @@ void Settings::CompilerSet::setExecutables()
void Settings::CompilerSet::setDirectories(const QString& binDir)
{
#ifdef ENABLE_SDCC
if (mCompilerType == CompilerType::SDCC) {
setSDCCDirectories(binDir);
} else {
#endif
setGCCDirectories(binDir);
#ifdef ENABLE_SDCC
}
#endif
}
void Settings::CompilerSet::setGCCDirectories(const QString& binDir)
@ -2557,6 +2570,7 @@ void Settings::CompilerSet::setGCCDirectories(const QString& binDir)
}
}
#ifdef ENABLE_SDCC
void Settings::CompilerSet::setSDCCDirectories(const QString& binDir)
{
QString folder = QFileInfo(binDir).absolutePath();
@ -2612,6 +2626,7 @@ void Settings::CompilerSet::setSDCCDirectories(const QString& binDir)
}
}
#endif
int Settings::CompilerSet::mainVersion() const
{
@ -2650,10 +2665,14 @@ void Settings::CompilerSet::setUserInput()
{
mUseCustomCompileParams = false;
mUseCustomLinkParams = false;
#ifdef ENABLE_SDCC
if (mCompilerType==CompilerType::SDCC) {
mAutoAddCharsetParams = false;
mStaticLink = false;
} else {
#else
{
#endif
mAutoAddCharsetParams = true;
mStaticLink = true;
}
@ -3004,10 +3023,12 @@ bool Settings::CompilerSets::addSets(const QString &folder)
addSets(folder,CLANG_PROGRAM);
return true;
}
#ifdef ENABLE_SDCC
if (fileExists(folder, SDCC_PROGRAM)) {
addSets(folder,SDCC_PROGRAM);
return true;
}
#endif
return false;
}
@ -3342,8 +3363,10 @@ Settings::PCompilerSet Settings::CompilerSets::loadSet(int index)
pSet->setCompilerType(CompilerType::GCC);
} else if (temp==COMPILER_GCC_UTF8) {
pSet->setCompilerType(CompilerType::GCC_UTF8);
#ifdef ENABLE_SDCC
} else if (temp==COMPILER_SDCC) {
pSet->setCompilerType(CompilerType::SDCC);
#endif
} else {
pSet->setCompilerType((CompilerType)mSettings->mSettings.value("CompilerType").toInt());
}

View File

@ -1442,10 +1442,12 @@ public:
private:
void setGCCProperties(const QString& binDir, const QString& c_prog);
void setSDCCProperties(const QString& binDir, const QString& c_prog);
void setDirectories(const QString& binDir);
void setGCCDirectories(const QString& binDir);
#ifdef ENABLE_SDCC
void setSDCCProperties(const QString& binDir, const QString& c_prog);
void setSDCCDirectories(const QString& binDir);
#endif
//load hard defines
void setExecutables();
void setUserInput();