diff --git a/NEWS.md b/NEWS.md index 56320fb6..bdbcbf15 100644 --- a/NEWS.md +++ b/NEWS.md @@ -20,6 +20,10 @@ Red Panda C++ Version 2.12 - fix: If current editor is empty, parser will parse the file's content on the disk instead from the editor. - fix: Can't show completion when cursor is after "char[" - change: Don't confirm rebuild/recompile when run/debug. + - fix: Can't parse enum values. + - fix: Can't correctly show enum values in the class browser. + - fix: Can't correctly create project, if template's encoding setting is not valid. + - enhancement: Add "embed assembly" template. Red Panda C++ Version 2.11 diff --git a/RedPandaIDE/mainwindow.cpp b/RedPandaIDE/mainwindow.cpp index fffdbe4d..862133f5 100644 --- a/RedPandaIDE/mainwindow.cpp +++ b/RedPandaIDE/mainwindow.cpp @@ -9456,3 +9456,9 @@ void MainWindow::on_actionNew_GAS_File_triggered() newEditor("s"); } + +void MainWindow::on_actionGNU_Assembler_Manual_triggered() +{ + QDesktopServices::openUrl(QUrl("https://sourceware.org/binutils/docs/as/index.html")); +} + diff --git a/RedPandaIDE/mainwindow.h b/RedPandaIDE/mainwindow.h index 41a4db85..1d113939 100644 --- a/RedPandaIDE/mainwindow.h +++ b/RedPandaIDE/mainwindow.h @@ -777,6 +777,8 @@ private slots: void on_actionNew_GAS_File_triggered(); + void on_actionGNU_Assembler_Manual_triggered(); + private: Ui::MainWindow *ui; bool mFullInitialized; diff --git a/RedPandaIDE/mainwindow.ui b/RedPandaIDE/mainwindow.ui index 0ea34e90..60de487d 100644 --- a/RedPandaIDE/mainwindow.ui +++ b/RedPandaIDE/mainwindow.ui @@ -270,6 +270,7 @@ + @@ -3332,6 +3333,11 @@ New GAS File + + + GNU Assembler Manual + + diff --git a/RedPandaIDE/parser/cppparser.cpp b/RedPandaIDE/parser/cppparser.cpp index 13855c06..06edb7c2 100644 --- a/RedPandaIDE/parser/cppparser.cpp +++ b/RedPandaIDE/parser/cppparser.cpp @@ -1535,16 +1535,9 @@ QStringList CppParser::sortFilesByIncludeRelations(const QSet &files) continue; //already removed in interalInvalidateFiles //mPreprocessor.removeScannedFile(file); - QStringList buffer; - if (mOnGetFileStream) { - mOnGetFileStream(file,buffer); - //prevent preprocessor to read file - if (buffer.isEmpty()) - buffer.append(QString()); - } //we only use local include relations mPreprocessor.setScanOptions(false, true); - mPreprocessor.preprocess(file,buffer); + mPreprocessor.preprocess(file); mPreprocessor.clearTempResults(); } @@ -2267,8 +2260,11 @@ void CppParser::handleEnum(bool isTypedef) QString args; if (mTokenizer[mIndex]->text!='}') { while ((mIndex < mTokenizer.tokenCount()) && - !isblockChar(mTokenizer[mIndex]->text[0])) { - if (!mTokenizer[mIndex]->text.startsWith(',')) { + mTokenizer[mIndex]->text!='}') { + if (mTokenizer[mIndex]->text=="=") { + mIndex=indexOfNextPeriodOrSemicolon(mIndex); + continue; + } else if (tokenIsIdentifier(mTokenizer[mIndex]->text)) { cmd = mTokenizer[mIndex]->text; args = ""; if (isEnumClass) { @@ -3793,60 +3789,46 @@ void CppParser::internalParse(const QString &fileName) // if (!isCfile(fileName) && !isHfile(fileName)) // support only known C/C++ files // return; - QStringList buffer; - if (mOnGetFileStream) { - mOnGetFileStream(fileName,buffer); - //prevent preprocessor to read file - if (buffer.isEmpty()) - buffer.append(QString()); - } - // Preprocess the file... - { - auto action = finally([this]{ - mTokenizer.clear(); - }); - // Let the preprocessor augment the include records -// mPreprocessor.setIncludesList(mIncludesList); -// mPreprocessor.setScannedFileList(mScannedFiles); -// mPreprocessor.setIncludePaths(mIncludePaths); -// mPreprocessor.setProjectIncludePaths(mProjectIncludePaths); - mPreprocessor.setScanOptions(mParseGlobalHeaders, mParseLocalHeaders); - mPreprocessor.preprocess(fileName, buffer); + auto action = finally([this]{ + mTokenizer.clear(); + }); + // Let the preprocessor augment the include records + mPreprocessor.setScanOptions(mParseGlobalHeaders, mParseLocalHeaders); + mPreprocessor.preprocess(fileName); - QStringList preprocessResult = mPreprocessor.result(); + QStringList preprocessResult = mPreprocessor.result(); #ifdef QT_DEBUG // stringsToFile(mPreprocessor.result(),QString("r:\\preprocess-%1.txt").arg(extractFileName(fileName))); // mPreprocessor.dumpDefinesTo("r:\\defines.txt"); // mPreprocessor.dumpIncludesListTo("r:\\includes.txt"); #endif - //reduce memory usage - mPreprocessor.clearTempResults(); + //reduce memory usage + mPreprocessor.clearTempResults(); - // Tokenize the preprocessed buffer file - mTokenizer.tokenize(preprocessResult); - //reduce memory usage - preprocessResult.clear(); - if (mTokenizer.tokenCount() == 0) - return; + // Tokenize the preprocessed buffer file + mTokenizer.tokenize(preprocessResult); + //reduce memory usage + preprocessResult.clear(); + if (mTokenizer.tokenCount() == 0) + return; #ifdef QT_DEBUG // mTokenizer.dumpTokens(QString("r:\\tokens-%1.txt").arg(extractFileName(fileName))); #endif #ifdef QT_DEBUG lastIndex = -1; #endif - // Process the token list - while(true) { - if (!handleStatement()) - break; - } + // Process the token list + while(true) { + if (!handleStatement()) + break; + } #ifdef QT_DEBUG // mStatementList.dumpAll(QString("r:\\all-stats-%1.txt").arg(extractFileName(fileName))); // mStatementList.dump(QString("r:\\stats-%1.txt").arg(extractFileName(fileName))); #endif - //reduce memory usage - internalClear(); - } + //reduce memory usage + internalClear(); } void CppParser::inheritClassStatement(const PStatement& derived, bool isStruct, @@ -5732,7 +5714,6 @@ int CppParser::parserId() const void CppParser::setOnGetFileStream(const GetFileStreamCallBack &newOnGetFileStream) { - mOnGetFileStream = newOnGetFileStream; mPreprocessor.setOnGetFileStream(newOnGetFileStream); } diff --git a/RedPandaIDE/parser/cppparser.h b/RedPandaIDE/parser/cppparser.h index a9dfdf81..b9e0e403 100644 --- a/RedPandaIDE/parser/cppparser.h +++ b/RedPandaIDE/parser/cppparser.h @@ -671,7 +671,6 @@ private: #else QMutex mMutex; #endif - GetFileStreamCallBack mOnGetFileStream; QMap mCppKeywords; QSet mCppTypeKeywords; }; diff --git a/RedPandaIDE/parser/cpppreprocessor.cpp b/RedPandaIDE/parser/cpppreprocessor.cpp index 9cf5e7e2..e9591c0a 100644 --- a/RedPandaIDE/parser/cpppreprocessor.cpp +++ b/RedPandaIDE/parser/cpppreprocessor.cpp @@ -155,12 +155,12 @@ void CppPreprocessor::setScanOptions(bool parseSystem, bool parseLocal) mParseLocal=parseLocal; } -void CppPreprocessor::preprocess(const QString &fileName, QStringList buffer) +void CppPreprocessor::preprocess(const QString &fileName) { clearTempResults(); mFileName = fileName; mDefines = mHardDefines; - openInclude(fileName, buffer); + openInclude(fileName); // StringsToFile(mBuffer,"f:\\buffer.txt"); preprocessBuffer(); // StringsToFile(mBuffer,"f:\\buffer.txt"); @@ -456,11 +456,7 @@ void CppPreprocessor::handleInclude(const QString &line, bool fromNext) return; PFileIncludes oldCurrentIncludes = mCurrentIncludes; - QStringList buffer; - if (mOnGetFileStream) { - mOnGetFileStream(fileName,buffer); - } - openInclude(fileName, buffer); + openInclude(fileName); } void CppPreprocessor::handlePreprocessor(const QString &value) @@ -659,7 +655,7 @@ void CppPreprocessor::removeGCCAttribute(const QString &line, QString &newLine, } } -void CppPreprocessor::openInclude(const QString &fileName, QStringList bufferedText) +void CppPreprocessor::openInclude(const QString &fileName) { if (mIncludes.size()>0) { PParsedFile topFile = mIncludes.front(); @@ -719,7 +715,8 @@ void CppPreprocessor::openInclude(const QString &fileName, QStringList bufferedT // Only load up the file if we are allowed to parse it bool isSystemFile = isSystemHeaderFile(fileName, mIncludePaths) || isSystemHeaderFile(fileName, mProjectIncludePaths); if ((mParseSystem && isSystemFile) || (mParseLocal && !isSystemFile)) { - if (!bufferedText.isEmpty()) { + QStringList bufferedText; + if (mOnGetFileStream && mOnGetFileStream(fileName,bufferedText)) { parsedFile->buffer = bufferedText; } else { parsedFile->buffer = readFileToLines(fileName); diff --git a/RedPandaIDE/parser/cpppreprocessor.h b/RedPandaIDE/parser/cpppreprocessor.h index 0dccbecb..3a6e8582 100644 --- a/RedPandaIDE/parser/cpppreprocessor.h +++ b/RedPandaIDE/parser/cpppreprocessor.h @@ -70,7 +70,7 @@ public: void getDefineParts(const QString& input, QString &name, QString &args, QString &value); void addHardDefineByLine(const QString& line); void setScanOptions(bool parseSystem, bool parseLocal); - void preprocess(const QString& fileName, QStringList buffer = QStringList()); + void preprocess(const QString& fileName); void dumpDefinesTo(const QString& fileName) const; void dumpIncludesListTo(const QString& fileName) const; @@ -122,7 +122,7 @@ private: PParsedFile getInclude(int index) const { return mIncludes[index]; } - void openInclude(const QString& fileName, QStringList bufferedText=QStringList()); + void openInclude(const QString& fileName); void closeInclude(); // branch stuff diff --git a/RedPandaIDE/project.cpp b/RedPandaIDE/project.cpp index c395078a..5315eadb 100644 --- a/RedPandaIDE/project.cpp +++ b/RedPandaIDE/project.cpp @@ -921,6 +921,13 @@ bool Project::assignTemplate(const std::shared_ptr aTemplate, b updateCompilerSetType(); mOptions.icon = aTemplate->icon(); + QTextCodec* codec=QTextCodec::codecForName(mOptions.encoding); + if (!codec) + mOptions.encoding=ENCODING_SYSTEM_DEFAULT; + codec=QTextCodec::codecForName(mOptions.execEncoding); + if (!codec) + mOptions.execEncoding=ENCODING_SYSTEM_DEFAULT; + // Copy icon to project directory if (!mOptions.icon.isEmpty()) { QString originIcon = cleanPath(QFileInfo(aTemplate->fileName()).absoluteDir().absoluteFilePath(mOptions.icon)); diff --git a/RedPandaIDE/translations/RedPandaIDE_pt_BR.ts b/RedPandaIDE/translations/RedPandaIDE_pt_BR.ts index 7b5333b6..843c5e39 100644 --- a/RedPandaIDE/translations/RedPandaIDE_pt_BR.ts +++ b/RedPandaIDE/translations/RedPandaIDE_pt_BR.ts @@ -4992,6 +4992,10 @@ Please check detail info in "Tools Output" panel. + + GNU Assembler Manual + + NewClassDialog diff --git a/RedPandaIDE/translations/RedPandaIDE_zh_CN.ts b/RedPandaIDE/translations/RedPandaIDE_zh_CN.ts index 4a2f547c..ef6833be 100644 --- a/RedPandaIDE/translations/RedPandaIDE_zh_CN.ts +++ b/RedPandaIDE/translations/RedPandaIDE_zh_CN.ts @@ -4175,8 +4175,8 @@ Are you really want to continue? 小熊猫C++ - - + + @@ -4200,8 +4200,8 @@ Are you really want to continue? 工具 - - + + Run 运行 @@ -4212,26 +4212,26 @@ Are you really want to continue? - - + + Project 项目 - - + + Watch 监视 - - + + Structure 结构 - - + + Files 文件 @@ -4240,69 +4240,69 @@ Are you really want to continue? 资源 - - - - - + + + + + Debug 调试 - + Evaluate: 求值 - + Debug Console 调试主控台 - + Call Stack 调用栈 - + Breakpoints 断点 - + Locals 局部变量 - - + + Search 查找 - + History: 历史: - + Search Again 重新查找 - + Replace with: 替换为: - + Replace 替换 - + Close 关闭 @@ -4313,7 +4313,7 @@ Are you really want to continue? - + Code 代码 @@ -4336,73 +4336,73 @@ Are you really want to continue? 新建 - + Ctrl+N Ctrl+N - + Open... 打开... - + Ctrl+O Ctrl+O - + Save 保存 - + Ctrl+S Ctrl+S - + Save As... 另存为... - + Save As 另存为 - + Save All 全部保存 - + Ctrl+Shift+S Ctrl+Shift+S - + Options 选项 - - - + + + Compile 编译 - - + + Tools Output 工具输出 - - + + Choose Input File 选择输入文件 @@ -4411,62 +4411,62 @@ Are you really want to continue? ... - + Tool Panels 工具面板 - + Git Git - + Selection 选择 - + F9 F9 - + F10 F10 - + Undo 恢复 - + Ctrl+Z Ctrl+Z - + Redo 重做 - + Ctrl+Y Ctrl+Y - + Cut 剪切 - + Ctrl+X Ctrl+X - + @@ -4474,272 +4474,272 @@ Are you really want to continue? 复制 - + Ctrl+C Ctrl+C - + Paste 粘贴 - + Ctrl+V Ctrl+V - + Select All 选择全部 - + Ctrl+A Ctrl+A - + Indent 缩进 - + UnIndent 取消缩进 - + Toggle Comment 切换注释 - + Ctrl+/ Ctrl+/ - + Collapse All 全部收起 - + Uncollapse All 全部展开 - + Encode in ANSI 使用ANSI编码 - + Encode in UTF-8 使用UTF-8编码 - + Auto Detect 自动检测 - + Convert to ANSI 转换为ANSI编码 - + Convert to UTF-8 转换为UTF-8编码 - - + + Compile & Run 编译运行 - + F11 F11 - - + + Rebuild All 全部重编译 - + F12 F12 - + Stop Execution 停止执行 - + F6 F6 - + F5 F5 - + Step Over 单步跳过 - + F7 F7 - + Step Into 单步进入 - - - + + + Problem Set 试题集 - - + + New Problem Set 新建试题集 - - + + Add Problem 添加试题 - - + + Remove Problem 删除试题 - - + + Save Problem Set 保存试题集 - - + + Load Problem Set 载入试题集 - + Memory 内存 - + Address Expression: Address: 地址表达式: - + Cancel 取消 - - + + TODO TODO - - + + Bookmark 书签 - - - + + + Problem 试题 - - + + Add Probem Case 添加试题案例 - - + + Remove Problem Case Remove Problem Set 删除试题集 - - + + Open Anwser Source File 打开答案源代码文件 - - + + Run All Cases Run Current Case 运行所有案例 - + Problem Cases Validation Options 测试案例验证选项 - + %v/%m %v/%m - + Output 输出 - + Input 输入 - + Expected 期望输出 @@ -4749,12 +4749,12 @@ Are you really want to continue? 帮助 - + Refactor 重构 - + View 视图 @@ -4763,494 +4763,499 @@ Are you really want to continue? 工具窗口 - + Main 主工具栏 - + Compiler Set 编译器配置集 - + Explorer 管理器 - + Import FPS Problem Set 导入FPS试题集 - + Export FPS Problem Set 导出FPS试题集 - + Messages 消息 - + Open file in editors 在编辑器中打开文件 - + Choose Expected Output File 选择期望输出文件 - + Ignore Spaces 忽略空格 - + New C/C++ File 新建C/C++文件 - + New Source File 新建源代码文件 - + Tab Tab - + Shift+Tab Shift+Tab - + F8 F8 - + Step Out 单步跳出 - + Ctrl+F8 Ctrl+F8 - + Run To Cursor 执行到光标处 - + Ctrl+F5 Ctrl+F5 - + Continue 继续执行 - + F4 F4 - + Add Watch... 添加监视 - + View CPU Window... 打开CPU信息窗口... - + Exit 退出 - + Find... 查找... - + Ctrl+F Ctrl+F - + Find in Files... 在文件中查找... - + Ctrl+Shift+F Ctrl+Shift+F - + Replace... 替换 - + Ctrl+R Ctrl+R - + Find Next 查找下一个 - + F3 F3 - + Find Previous 查找前一个 - + Shift+F3 Shift+F3 - + Remove Watch 删除监视值 - + Remove All Watches Remove All 删除全部监视值 - + Modify Watch... 修改监视值 - + Reformat Code 对代码重新排版 - + Ctrl+Shift+A Ctrl+Shift+A - + Go back 前一次编辑位置 - + Ctrl+Alt+Left Ctrl+Alt+Left - + Forward 后一次编辑位置 - + Ctrl+Alt+Right Ctrl+Alt+Right - + Ctrl+W Ctrl+W - + Close All 全部关闭 - + Ctrl+Shift+W Ctrl+Shift+W - + Maximize Editor 最大化编辑器 - + Ctrl+F11 Ctrl+F11 - + Next 下一窗口 - + Ctrl+Tab Ctrl+Tab - + Previous 前一窗口 - + Ctrl+Shift+Tab Ctrl+Shift+Tab - + Toggle breakpoint 切换断点 - + Ctrl+F4 Ctrl+F4 - + Clear all breakpoints 删除所有断点 - + Breakpoint property... 设置断点条件... - + Goto Declaration 跳转到声明处 - + Ctrl+Shift+G Ctrl+Shift+G - + Goto Definition 跳转到定义处 - + Ctrl+G Ctrl+G - + Find references 查找符号的引用 - + Open containing folder 打开所在的文件夹 - + Ctrl+B Ctrl+B - + Open a terminal here 打开命令行窗口 - + File Properties... 文件属性... - + Close Project 关闭项目 - + Project options 项目属性 - + New Project... 新建项目... - - + + New Project File 新建项目文件 - + F1 F1 - + New GAS File 新建GNU汇编文件 - + + GNU Assembler Manual + GNU汇编器手册 + + + Move Selection Up 向上移动选中的行 - + Ctrl+Shift+Up Ctrl+Shift+Up - + Move Selection Down 向下移动选中的行 - + Ctrl+Shift+Down Ctrl+Shift+Down - + Convert to UTF-8 BOM 转换为UTF-8 BOM编码 - + Encode in UTF-8 BOM 使用UTF-8 BOM编码 - + Compiler Options... 编译器选项... - + Toggle Explorer Panel 切换管理器面板 - + Ctrl+F9 Ctrl+F9 - + Toggle Messages Panel 切换消息面板 - + Ctrl+F10 Ctrl+F10 - + Raylib Manual Raylib教程 - + Select Word 选中当前单词 - + Go to Line... 跳转到行... - + New Template... 新建模板... - + New Template from Project 从项目创建模板 - + Goto block start 跳转到代码段开始 - + Ctrl+Alt+Up Ctrl+Alt+Up - + Goto block end 跳转到代码段结束 - + Ctrl+Alt+Down Ctrl+Alt+Down - + Switch header/source 切换头文件/源文件 - + Switch Header/Source 切换头文件/源文件 - + Generate Assembly 生成汇编 - + Trim trailing spaces 删除行尾空格 - + Toggle Readonly 切换只读模式 - + Submit Issues 反馈与建议 - + Document 使用说明 @@ -5264,194 +5269,194 @@ Are you really want to continue? 新建文件 - + Add to project... 添加到项目... - + Remove from project 从项目删除 - + View Makefile 查看Makefile - + Clean 清理构建文件 - + Open Folder in Explorer 在浏览器中打开 - + Open In Terminal 在终端中打开 - + About 关于 - + Rename Symbol 重命名符号 - + Shift+F6 Shift+F6 - + Print... 打印... - + Ctrl+P Ctrl+P - + Export As RTF 导出为RTF - + Export As HTML 导出为HTML - + Move To Other View 移动到其他视图 - + Ctrl+M Ctrl+M - - + + C++ Reference C++参考手册 - + C Reference C参考手册 - + Show Tool Panels 显示全部工具面板 - + Create Git Repository Create Repository 创建Git仓库 - + Commit 提交(Commit) - + Revert 撤销(Revert) - + Reset 回滚(Reset) - + Add Files 添加文件 - + Restore 还原(Restore) - + Website 官方网站 - + Branch/Switch 分支切换(Switch) - + Merge 合并(Merge) - - + + Show Log Log 显示日志(Log) - + Remotes... 远程仓库... - + Fetch 取回(Fetch) - + Pull 拉取(Pull) - + Push 推送(Push) - + Hide Non Support Files 隐藏不支持的文件 - + Toggle Block Comment 切换块注释 - + Alt+Shift+A Alt+Shift+A - + Match Bracket 匹配当前括号 - + Ctrl+] Ctrl+] @@ -5460,50 +5465,50 @@ Are you really want to continue? 工具窗口栏 - + Status Bar 状态栏 - + Ctrl+Backspace Ctrl+Backspace - + Interrupt 中断 - - + + Delete To Word Begin 删除到单词开头 - + Ctrl+Shift+B Ctrl+Shift+B - + Delete to Word End 删除到单词结尾 - + Ctrl+Shift+E Ctrl+Shift+E - + New Class... Add Class... 新建类... - - + + New Header... New Header 新建头文件... @@ -5513,47 +5518,47 @@ Are you really want to continue? 插入行 - + Delete Line 删除当前行 - + Ctrl+D Ctrl+D - + Duplicate Line 复制当前行 - + Ctrl+E Ctrl+E - + Delete Word 删除当前单词 - + Ctrl+Shift+D Ctrl+Shift+D - + Delete to EOL 删除到行尾 - + Ctrl+Del Ctrl+Del - + Delete to BOL 删除到行首 @@ -5562,27 +5567,27 @@ Are you really want to continue? C/C++参考 - + EGE Manual EGE图形库手册 - + Add Bookmark 添加书签 - + Remove Bookmark 删除书签 - + Modify Bookmark Description 修改书签说明 - + Locate in Files View 在文件视图中定位 @@ -5591,7 +5596,7 @@ Are you really want to continue? 打开文件夹 - + Running Parameters... 运行参数... @@ -5851,9 +5856,9 @@ Are you really want to continue? 模板%1已存在。是否覆盖? - - - + + + @@ -6425,8 +6430,8 @@ Are you really want to continue? 第%1行 - - + + Choose Working Folder 选择工作文件夹 diff --git a/RedPandaIDE/translations/RedPandaIDE_zh_TW.ts b/RedPandaIDE/translations/RedPandaIDE_zh_TW.ts index 385dd4e6..92396185 100644 --- a/RedPandaIDE/translations/RedPandaIDE_zh_TW.ts +++ b/RedPandaIDE/translations/RedPandaIDE_zh_TW.ts @@ -4781,6 +4781,10 @@ Please check detail info in "Tools Output" panel. + + GNU Assembler Manual + + NewClassDialog diff --git a/RedPandaIDE/widgets/classbrowser.cpp b/RedPandaIDE/widgets/classbrowser.cpp index 780afb1d..08b688a3 100644 --- a/RedPandaIDE/widgets/classbrowser.cpp +++ b/RedPandaIDE/widgets/classbrowser.cpp @@ -260,14 +260,13 @@ PClassBrowserNode ClassBrowserModel::addChild(ClassBrowserNode *node, const PSta .arg(statement->noNameArgs) .arg((int)statement->kind),newNode); mProcessedStatements.insert(statement.get()); - if (statement->kind == StatementKind::skClass - || statement->kind == StatementKind::skNamespace) { + if (isScopeStatement(statement)) { mScopeNodes.insert(statement->fullName,newNode); } //don't show enum type's children values (they are displayed in parent scope) - if (statement->kind != StatementKind::skEnumType) { +// if (statement->kind != StatementKind::skEnumType) { filterChildren(newNode.get(), statement->children); - } +// } return newNode; } @@ -373,7 +372,7 @@ void ClassBrowserModel::filterChildren(ClassBrowserNode *node, const StatementMa if (dummyNode) parentNode = dummyNode; } - if (statement->kind == StatementKind::skNamespace || statement->kind == StatementKind::skClass) { + if (isScopeStatement(statement)) { //PStatement dummy = mDummyStatements.value(statement->fullName,PStatement()); PClassBrowserNode scopeNode = mScopeNodes.value(statement->fullName,PClassBrowserNode()); if (!scopeNode) { @@ -415,8 +414,7 @@ ClassBrowserNode* ClassBrowserModel::getParentNode(const PStatement &parentState return nullptr; if (!parentStatement) return mRoot; - if (parentStatement->kind!=skClass - && parentStatement->kind!=skNamespace) { + if (!isScopeStatement(parentStatement)) { return mRoot; } PClassBrowserNode parentNode = mScopeNodes.value(parentStatement->fullName,PClassBrowserNode()); @@ -428,6 +426,19 @@ ClassBrowserNode* ClassBrowserModel::getParentNode(const PStatement &parentState return parentNode.get(); } +bool ClassBrowserModel::isScopeStatement(const PStatement &statement) +{ + switch(statement->kind) { + case StatementKind::skClass: + case StatementKind::skNamespace: + case StatementKind::skEnumClassType: + case StatementKind::skEnumType: + return true; + default: + return false; + } +} + QModelIndex ClassBrowserModel::modelIndexForStatement(const QString &key) { QMutexLocker locker(&mMutex); diff --git a/RedPandaIDE/widgets/classbrowser.h b/RedPandaIDE/widgets/classbrowser.h index c42e037c..ef4db137 100644 --- a/RedPandaIDE/widgets/classbrowser.h +++ b/RedPandaIDE/widgets/classbrowser.h @@ -75,6 +75,7 @@ private: void filterChildren(ClassBrowserNode * node, const StatementMap& statements); PStatement createDummy(const PStatement& statement); ClassBrowserNode* getParentNode(const PStatement &parentStatement, int depth); + bool isScopeStatement(const PStatement& statement); private: ClassBrowserNode * mRoot; QHash mDummyStatements; diff --git a/libs/qsynedit/qsynedit/qsynedit.cpp b/libs/qsynedit/qsynedit/qsynedit.cpp index 9bf957da..306d139d 100644 --- a/libs/qsynedit/qsynedit/qsynedit.cpp +++ b/libs/qsynedit/qsynedit/qsynedit.cpp @@ -1615,16 +1615,15 @@ int QSynEdit::calcIndentSpaces(int line, const QString& lineText, bool addIndent QString firstToken = mSyntaxer->getToken(); PTokenAttribute attr = mSyntaxer->getTokenAttribute(); if ( - ( (attr->tokenType() == TokenType::Keyword + (attr->tokenType() == TokenType::Keyword && ( firstToken == "public" || firstToken == "private" || firstToken == "protected" || firstToken == "case" || firstToken == "default" ) - ) - || (attr->tokenType() == TokenType::Identifier)) - && lineText.endsWith(':') - ) { + ) + && lineText.endsWith(':') + ) { // public: private: protecte: case: should indents like it's parent statement mSyntaxer->setState(rangePreceeding); mSyntaxer->setLine("}",line-1); diff --git a/platform/linux/templates/C_Embed_GAS/app.ico b/platform/linux/templates/C_Embed_GAS/app.ico new file mode 100644 index 00000000..b41b95cf Binary files /dev/null and b/platform/linux/templates/C_Embed_GAS/app.ico differ diff --git a/platform/linux/templates/C_Embed_GAS/info.template b/platform/linux/templates/C_Embed_GAS/info.template new file mode 100644 index 00000000..a9e1c108 --- /dev/null +++ b/platform/linux/templates/C_Embed_GAS/info.template @@ -0,0 +1,22 @@ +[Template] +Ver = 3 +Name = Inline ASM +Category = Assembly +Description = A simple c program with inline assembly instructions +Name[zh_CN] = 内联汇编 +Category[zh_CN] = 汇编 +Description[zh_CN] = 简单的C内联汇编程序示例 +Icon = app.ico + + +[Project] +Type = 1 +IsCpp = 0 +Encoding = SYSTEM +ClassBrowserType = 0 +UnitCount = 1 + + +[Unit0] +CName=main.c +C=main.c diff --git a/platform/linux/templates/C_Embed_GAS/main.c b/platform/linux/templates/C_Embed_GAS/main.c new file mode 100644 index 00000000..fee19577 --- /dev/null +++ b/platform/linux/templates/C_Embed_GAS/main.c @@ -0,0 +1,22 @@ +#include + +int add(int x,int y) { + int result; + asm ( + "movl %%eax, %1 \n" + "addl %%eax, %2 \n" + "movl %0, %%eax \n" + :"=m"(result) //output operands used in the instructions + :"m"(x),"m"(y) //input operands used in the instructions + :"eax" //registers changed by the assembler instructions + ); + return x+y; +} + +int main() { + int a,b,c; + scanf("%d,%d",&a,&b); + c=a+b; + printf("%d\n",c); + return 0; +} \ No newline at end of file diff --git a/platform/windows/templates-win64/Hello_GAS/main.s b/platform/windows/templates-win64/Hello_GAS/main.s index 20b0a580..18ad8886 100644 --- a/platform/windows/templates-win64/Hello_GAS/main.s +++ b/platform/windows/templates-win64/Hello_GAS/main.s @@ -2,13 +2,19 @@ .text: main: - # the x64 calling convention requires you to allocate 32 bytes of shadow space before each call - # https://stackoverflow.com/questions/30190132/what-is-the-shadow-space-in-x64-assembly/ - sub $32, %rsp # allocate shadow space - leaq fmt(%rip), %rcx # first parameter - leaq msg(%rip), %rdx # second parameter + # Microsoft X86_64 Calling convention: + # - The first four integer or pointer parameters are passed in the rcx, rdx, r8, and r9 registers. + # - The first four floating-point parameters are passed in the first four SSE registers, xmm0-xmm3. + # - The caller reserves space on the stack for arguments passed in registers. The called function can use this space to spill the contents of registers to the stack. + # - Any additional arguments are passed on the stack. + # - An integer or pointer return value is returned in the rax register, while a floating-point return value is returned in xmm0. + # see https://learn.microsoft.com/en-us/windows-hardware/drivers/debugger/x64-architecture + + sub $32, %rsp # reserve stack space for the call + leaq fmt(%rip), %rcx # first parameter + leaq msg(%rip), %rdx # second parameter call printf - add $32, %rsp # remove shadow space + add $32, %rsp # restore stack space xor %eax,%eax # set 0 as exit code ret diff --git a/platform/windows/templates-win64/Hello_NASM/main.asm b/platform/windows/templates-win64/Hello_NASM/main.asm index 53958bfc..5830e25a 100644 --- a/platform/windows/templates-win64/Hello_NASM/main.asm +++ b/platform/windows/templates-win64/Hello_NASM/main.asm @@ -8,13 +8,19 @@ fmt: db "%s", 10, 0 ; The printf format, "\n",'0' section .text: main: -; the x64 calling convention requires you to allocate 32 bytes of shadow space before each call -; https://stackoverflow.com/questions/30190132/what-is-the-shadow-space-in-x64-assembly/ - sub rsp, 32 ; allocate shadow space + ; Microsoft X86_64 Calling convention: + ; - The first four integer or pointer parameters are passed in the rcx, rdx, r8, and r9 registers. + ; - The first four floating-point parameters are passed in the first four SSE registers, xmm0-xmm3. + ; - The caller reserves space on the stack for arguments passed in registers. The called function can use this space to spill the contents of registers to the stack. + ; - Any additional arguments are passed on the stack. + ; - An integer or pointer return value is returned in the rax register, while a floating-point return value is returned in xmm0. + ; see https://learn.microsoft.com/en-us/windows-hardware/drivers/debugger/x64-architecture + + sub rsp, 32 ; reserve stack space for call lea rcx, [rel fmt] ; first parameter lea rdx, [rel msg] ; secodng parameter - call printf + call printf + add rsp,32 ; restore stack - add rsp,32 ; remove shadow space mov eax,0 ; exit code ret \ No newline at end of file diff --git a/platform/windows/templates/C_Embed_GAS/app.ico b/platform/windows/templates/C_Embed_GAS/app.ico new file mode 100644 index 00000000..b41b95cf Binary files /dev/null and b/platform/windows/templates/C_Embed_GAS/app.ico differ diff --git a/platform/windows/templates/C_Embed_GAS/info.template b/platform/windows/templates/C_Embed_GAS/info.template new file mode 100644 index 00000000..a9e1c108 --- /dev/null +++ b/platform/windows/templates/C_Embed_GAS/info.template @@ -0,0 +1,22 @@ +[Template] +Ver = 3 +Name = Inline ASM +Category = Assembly +Description = A simple c program with inline assembly instructions +Name[zh_CN] = 内联汇编 +Category[zh_CN] = 汇编 +Description[zh_CN] = 简单的C内联汇编程序示例 +Icon = app.ico + + +[Project] +Type = 1 +IsCpp = 0 +Encoding = SYSTEM +ClassBrowserType = 0 +UnitCount = 1 + + +[Unit0] +CName=main.c +C=main.c diff --git a/platform/windows/templates/C_Embed_GAS/main.c b/platform/windows/templates/C_Embed_GAS/main.c new file mode 100644 index 00000000..fee19577 --- /dev/null +++ b/platform/windows/templates/C_Embed_GAS/main.c @@ -0,0 +1,22 @@ +#include + +int add(int x,int y) { + int result; + asm ( + "movl %%eax, %1 \n" + "addl %%eax, %2 \n" + "movl %0, %%eax \n" + :"=m"(result) //output operands used in the instructions + :"m"(x),"m"(y) //input operands used in the instructions + :"eax" //registers changed by the assembler instructions + ); + return x+y; +} + +int main() { + int a,b,c; + scanf("%d,%d",&a,&b); + c=a+b; + printf("%d\n",c); + return 0; +} \ No newline at end of file