diff --git a/include/core/parseutil.h b/include/core/parseutil.h index 271d1247..00166821 100644 --- a/include/core/parseutil.h +++ b/include/core/parseutil.h @@ -54,9 +54,9 @@ public: QString readCIncbin(const QString &text, const QString &label); QMap readCIncbinMulti(const QString &filepath); QStringList readCIncbinArray(const QString &filename, const QString &label); - QMap readCDefinesByPrefix(const QString &filename, QStringList searchText); - QMap readCDefinesByName(const QString &filename, QStringList names); - QStringList readCDefineNames(const QString&, QStringList searchText); + QMap readCDefinesByPrefix(const QString &filename, const QStringList &searchText); + QMap readCDefinesByName(const QString &filename, const QStringList &names); + QStringList readCDefineNames(const QString&, const QStringList &searchText); QMap> readCStructs(const QString &, const QString & = "", const QHash = { }); QList getLabelMacros(const QList&, const QString&); QStringList getLabelValues(const QList&, const QString&); @@ -97,9 +97,14 @@ private: void recordErrors(const QStringList &errors); void logRecordedErrors(); QString createErrorMessage(const QString &message, const QString &expression); - QMap readCDefineExpressions(const QString &filename); - QMap filterCDefineExpressions(const QMap &allExpressions, QStringList searchText, bool fullMatch); - QMap evaluateCDefines(const QString &filename, const QStringList &searchText, bool fullMatch); + + struct ParsedDefines { + QMap expressions; // Map of all define names->expressions encountered + QStringList filteredNames; // Define names matching the search text in the order they were encountered in the file + }; + ParsedDefines readCDefines(const QString &filename, const QStringList &filterList, bool fullMatch); + QMap evaluateCDefines(const QString &filename, const QStringList &filterList, bool fullMatch); + bool defineNameMatchesFilter(const QString &name, const QStringList &filterList, bool fullMatch); static const QRegularExpression re_incScriptLabel; static const QRegularExpression re_globalIncScriptLabel; diff --git a/src/core/parseutil.cpp b/src/core/parseutil.cpp index f1d70219..4043ea17 100644 --- a/src/core/parseutil.cpp +++ b/src/core/parseutil.cpp @@ -15,7 +15,7 @@ const QRegularExpression ParseUtil::re_poryScriptLabel("\\b(script)(\\((global|l const QRegularExpression ParseUtil::re_globalPoryScriptLabel("\\b(script)(\\((global)\\))?\\s*\\b(?