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 @@
+
+
+
+
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?
工具
-
-
+
+
运行
@@ -4212,26 +4212,26 @@ Are you really want to continue?
-
-
+
+
项目
-
-
+
+
监视
-
-
+
+
结构
-
-
+
+
文件
@@ -4240,69 +4240,69 @@ Are you really want to continue?
资源
-
-
-
-
-
+
+
+
+
+
调试
-
+
求值
-
+
调试主控台
-
+
调用栈
-
+
断点
-
+
局部变量
-
-
+
+
查找
-
+
历史:
-
+
重新查找
-
+
替换为:
-
+
替换
-
+
关闭
@@ -4313,7 +4313,7 @@ Are you really want to continue?
-
+
代码
@@ -4336,73 +4336,73 @@ Are you really want to continue?
新建
-
+
Ctrl+N
-
+
打开...
-
+
Ctrl+O
-
+
保存
-
+
Ctrl+S
-
+
另存为...
-
+
另存为
-
+
全部保存
-
+
Ctrl+Shift+S
-
+
选项
-
-
-
+
+
+
编译
-
-
+
+
工具输出
-
-
+
+
选择输入文件
@@ -4411,62 +4411,62 @@ Are you really want to continue?
...
-
+
工具面板
-
+
Git
-
+
选择
-
+
F9
-
+
F10
-
+
恢复
-
+
Ctrl+Z
-
+
重做
-
+
Ctrl+Y
-
+
剪切
-
+
Ctrl+X
-
+
@@ -4474,272 +4474,272 @@ Are you really want to continue?
复制
-
+
Ctrl+C
-
+
粘贴
-
+
Ctrl+V
-
+
选择全部
-
+
Ctrl+A
-
+
缩进
-
+
取消缩进
-
+
切换注释
-
+
Ctrl+/
-
+
全部收起
-
+
全部展开
-
+
使用ANSI编码
-
+
使用UTF-8编码
-
+
自动检测
-
+
转换为ANSI编码
-
+
转换为UTF-8编码
-
-
+
+
编译运行
-
+
F11
-
-
+
+
全部重编译
-
+
F12
-
+
停止执行
-
+
F6
-
+
F5
-
+
单步跳过
-
+
F7
-
+
单步进入
-
-
-
+
+
+
试题集
-
-
+
+
新建试题集
-
-
+
+
添加试题
-
-
+
+
删除试题
-
-
+
+
保存试题集
-
-
+
+
载入试题集
-
+
内存
-
+
Address:
地址表达式:
-
+
取消
-
-
+
+
TODO
-
-
+
+
书签
-
-
-
+
+
+
试题
-
-
+
+
添加试题案例
-
-
+
+
Remove Problem Set
删除试题集
-
-
+
+
打开答案源代码文件
-
-
+
+
Run Current Case
运行所有案例
-
+
测试案例验证选项
-
+
%v/%m
-
+
输出
-
+
输入
-
+
期望输出
@@ -4749,12 +4749,12 @@ Are you really want to continue?
帮助
-
+
重构
-
+
视图
@@ -4763,494 +4763,499 @@ Are you really want to continue?
工具窗口
-
+
主工具栏
-
+
编译器配置集
-
+
管理器
-
+
导入FPS试题集
-
+
导出FPS试题集
-
+
消息
-
+
在编辑器中打开文件
-
+
选择期望输出文件
-
+
忽略空格
-
+
新建C/C++文件
-
+
新建源代码文件
-
+
Tab
-
+
Shift+Tab
-
+
F8
-
+
单步跳出
-
+
Ctrl+F8
-
+
执行到光标处
-
+
Ctrl+F5
-
+
继续执行
-
+
F4
-
+
添加监视
-
+
打开CPU信息窗口...
-
+
退出
-
+
查找...
-
+
Ctrl+F
-
+
在文件中查找...
-
+
Ctrl+Shift+F
-
+
替换
-
+
Ctrl+R
-
+
查找下一个
-
+
F3
-
+
查找前一个
-
+
Shift+F3
-
+
删除监视值
-
+
Remove All
删除全部监视值
-
+
修改监视值
-
+
对代码重新排版
-
+
Ctrl+Shift+A
-
+
前一次编辑位置
-
+
Ctrl+Alt+Left
-
+
后一次编辑位置
-
+
Ctrl+Alt+Right
-
+
Ctrl+W
-
+
全部关闭
-
+
Ctrl+Shift+W
-
+
最大化编辑器
-
+
Ctrl+F11
-
+
下一窗口
-
+
Ctrl+Tab
-
+
前一窗口
-
+
Ctrl+Shift+Tab
-
+
切换断点
-
+
Ctrl+F4
-
+
删除所有断点
-
+
设置断点条件...
-
+
跳转到声明处
-
+
Ctrl+Shift+G
-
+
跳转到定义处
-
+
Ctrl+G
-
+
查找符号的引用
-
+
打开所在的文件夹
-
+
Ctrl+B
-
+
打开命令行窗口
-
+
文件属性...
-
+
关闭项目
-
+
项目属性
-
+
新建项目...
-
-
+
+
新建项目文件
-
+
F1
-
+
新建GNU汇编文件
-
+
+
+ GNU汇编器手册
+
+
+
向上移动选中的行
-
+
Ctrl+Shift+Up
-
+
向下移动选中的行
-
+
Ctrl+Shift+Down
-
+
转换为UTF-8 BOM编码
-
+
使用UTF-8 BOM编码
-
+
编译器选项...
-
+
切换管理器面板
-
+
Ctrl+F9
-
+
切换消息面板
-
+
Ctrl+F10
-
+
Raylib教程
-
+
选中当前单词
-
+
跳转到行...
-
+
新建模板...
-
+
从项目创建模板
-
+
跳转到代码段开始
-
+
Ctrl+Alt+Up
-
+
跳转到代码段结束
-
+
Ctrl+Alt+Down
-
+
切换头文件/源文件
-
+
切换头文件/源文件
-
+
生成汇编
-
+
删除行尾空格
-
+
切换只读模式
-
+
反馈与建议
-
+
使用说明
@@ -5264,194 +5269,194 @@ Are you really want to continue?
新建文件
-
+
添加到项目...
-
+
从项目删除
-
+
查看Makefile
-
+
清理构建文件
-
+
在浏览器中打开
-
+
在终端中打开
-
+
关于
-
+
重命名符号
-
+
Shift+F6
-
+
打印...
-
+
Ctrl+P
-
+
导出为RTF
-
+
导出为HTML
-
+
移动到其他视图
-
+
Ctrl+M
-
-
+
+
C++参考手册
-
+
C参考手册
-
+
显示全部工具面板
-
+
Create Repository
创建Git仓库
-
+
提交(Commit)
-
+
撤销(Revert)
-
+
回滚(Reset)
-
+
添加文件
-
+
还原(Restore)
-
+
官方网站
-
+
分支切换(Switch)
-
+
合并(Merge)
-
-
+
+
Log
显示日志(Log)
-
+
远程仓库...
-
+
取回(Fetch)
-
+
拉取(Pull)
-
+
推送(Push)
-
+
隐藏不支持的文件
-
+
切换块注释
-
+
Alt+Shift+A
-
+
匹配当前括号
-
+
Ctrl+]
@@ -5460,50 +5465,50 @@ Are you really want to continue?
工具窗口栏
-
+
状态栏
-
+
Ctrl+Backspace
-
+
中断
-
-
+
+
删除到单词开头
-
+
Ctrl+Shift+B
-
+
删除到单词结尾
-
+
Ctrl+Shift+E
-
+
Add Class...
新建类...
-
-
+
+
New Header
新建头文件...
@@ -5513,47 +5518,47 @@ Are you really want to continue?
插入行
-
+
删除当前行
-
+
Ctrl+D
-
+
复制当前行
-
+
Ctrl+E
-
+
删除当前单词
-
+
Ctrl+Shift+D
-
+
删除到行尾
-
+
Ctrl+Del
-
+
删除到行首
@@ -5562,27 +5567,27 @@ Are you really want to continue?
C/C++参考
-
+
EGE图形库手册
-
+
添加书签
-
+
删除书签
-
+
修改书签说明
-
+
在文件视图中定位
@@ -5591,7 +5596,7 @@ Are you really want to continue?
打开文件夹
-
+
运行参数...
@@ -5851,9 +5856,9 @@ Are you really want to continue?
模板%1已存在。是否覆盖?
-
-
-
+
+
+
@@ -6425,8 +6430,8 @@ Are you really want to continue?
第%1行
-
-
+
+
选择工作文件夹
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 @@
+
+
+
+
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