From f142d93df48c3b9e07edd25425627ddeeb071520 Mon Sep 17 00:00:00 2001 From: Neil Date: Tue, 31 Dec 2019 15:50:48 +1100 Subject: Move collection of modules from Catalogue.cxx to CatalogueModules.h so it can be reused. --- src/Catalogue.cxx | 29 ++++++++++------------------- src/ScintillaBase.cxx | 3 +++ 2 files changed, 13 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/Catalogue.cxx b/src/Catalogue.cxx index a6aed901d..d9e0172d5 100644 --- a/src/Catalogue.cxx +++ b/src/Catalogue.cxx @@ -19,36 +19,27 @@ #include "SciLexer.h" #include "LexerModule.h" +#include "CatalogueModules.h" #include "Catalogue.h" using namespace Scintilla; -static std::vector lexerCatalogue; +namespace { + +CatalogueModules catalogueDefault; + +} const LexerModule *Catalogue::Find(int language) { - Scintilla_LinkLexers(); - for (const LexerModule *lm : lexerCatalogue) { - if (lm->GetLanguage() == language) { - return lm; - } - } - return nullptr; + return catalogueDefault.Find(language); } const LexerModule *Catalogue::Find(const char *languageName) { - Scintilla_LinkLexers(); - if (languageName) { - for (const LexerModule *lm : lexerCatalogue) { - if (lm->languageName && (0 == strcmp(lm->languageName, languageName))) { - return lm; - } - } - } - return nullptr; + return catalogueDefault.Find(languageName); } void Catalogue::AddLexerModule(LexerModule *plm) { - lexerCatalogue.push_back(plm); + catalogueDefault.AddLexerModule(plm); } // To add or remove a lexer, add or remove its file and run LexGen.py. @@ -63,7 +54,7 @@ int Scintilla_LinkLexers() { initialised = 1; // Shorten the code that declares a lexer and ensures it is linked in by calling a method. -#define LINK_LEXER(lexer) extern LexerModule lexer; Catalogue::AddLexerModule(&lexer); +#define LINK_LEXER(lexer) extern LexerModule lexer; catalogueDefault.AddLexerModule(&lexer); //++Autogenerated -- run scripts/LexGen.py to regenerate //**\(\tLINK_LEXER(\*);\n\) diff --git a/src/ScintillaBase.cxx b/src/ScintillaBase.cxx index c9eb18346..f165f92e2 100644 --- a/src/ScintillaBase.cxx +++ b/src/ScintillaBase.cxx @@ -73,6 +73,9 @@ ScintillaBase::ScintillaBase() { listType = 0; maxListWidth = 0; multiAutoCMode = SC_MULTIAUTOC_ONCE; +#ifdef SCI_LEXER + Scintilla_LinkLexers(); +#endif } ScintillaBase::~ScintillaBase() { -- cgit v1.2.3