diff options
-rw-r--r-- | cocoa/ScintillaCocoa.mm | 1 | ||||
-rwxr-xr-x | gtk/ScintillaGTK.cxx | 3 | ||||
-rw-r--r-- | gtk/deps.mak | 1 | ||||
-rw-r--r-- | lexlib/CatalogueModules.h | 70 | ||||
-rw-r--r-- | lexlib/LexerModule.h | 2 | ||||
-rw-r--r-- | scripts/HeaderOrder.txt | 1 | ||||
-rw-r--r-- | src/Catalogue.cxx | 29 | ||||
-rw-r--r-- | src/ScintillaBase.cxx | 3 | ||||
-rw-r--r-- | win32/DepGen.py | 3 | ||||
-rw-r--r-- | win32/ScintillaWin.cxx | 3 | ||||
-rw-r--r-- | win32/deps.mak | 40 | ||||
-rw-r--r-- | win32/makefile | 5 | ||||
-rw-r--r-- | win32/nmdeps.mak | 40 | ||||
-rw-r--r-- | win32/scintilla.mak | 13 |
14 files changed, 90 insertions, 124 deletions
diff --git a/cocoa/ScintillaCocoa.mm b/cocoa/ScintillaCocoa.mm index fb401b74a..6c975beb3 100644 --- a/cocoa/ScintillaCocoa.mm +++ b/cocoa/ScintillaCocoa.mm @@ -423,7 +423,6 @@ ScintillaCocoa::~ScintillaCocoa() { * Core initialization of the control. Everything that needs to be set up happens here. */ void ScintillaCocoa::Init() { - Scintilla_LinkLexers(); // Tell Scintilla not to buffer: Quartz buffers drawing for us. WndProc(SCI_SETBUFFEREDDRAW, 0, 0); diff --git a/gtk/ScintillaGTK.cxx b/gtk/ScintillaGTK.cxx index 9e51f5c98..f8a2b5c9b 100755 --- a/gtk/ScintillaGTK.cxx +++ b/gtk/ScintillaGTK.cxx @@ -3030,9 +3030,6 @@ GType scintilla_object_get_type() { void ScintillaGTK::ClassInit(OBJECT_CLASS *object_class, GtkWidgetClass *widget_class, GtkContainerClass *container_class) { Platform_Initialise(); -#ifdef SCI_LEXER - Scintilla_LinkLexers(); -#endif atomUTF8 = gdk_atom_intern("UTF8_STRING", FALSE); atomString = GDK_SELECTION_TYPE_STRING; atomUriList = gdk_atom_intern("text/uri-list", FALSE); diff --git a/gtk/deps.mak b/gtk/deps.mak index d16f60afa..6970424bc 100644 --- a/gtk/deps.mak +++ b/gtk/deps.mak @@ -121,6 +121,7 @@ Catalogue.o: \ ../include/Scintilla.h \ ../include/SciLexer.h \ ../lexlib/LexerModule.h \ + ../lexlib/CatalogueModules.h \ ../src/Catalogue.h CellBuffer.o: \ ../src/CellBuffer.cxx \ diff --git a/lexlib/CatalogueModules.h b/lexlib/CatalogueModules.h new file mode 100644 index 000000000..1a170cf70 --- /dev/null +++ b/lexlib/CatalogueModules.h @@ -0,0 +1,70 @@ +// Scintilla source code edit control +/** @file CatalogueModules.h + ** Lexer infrastructure. + ** Contains a list of LexerModules which can be searched to find a module appropriate for a + ** particular language. + **/ +// Copyright 1998-2010 by Neil Hodgson <neilh@scintilla.org> +// The License.txt file describes the conditions under which this software may be distributed. + +#ifndef CATALOGUEMODULES_H +#define CATALOGUEMODULES_H + +namespace Scintilla { + +class CatalogueModules { + std::vector<LexerModule *> lexerCatalogue; +public: + const LexerModule *Find(int language) { + for (const LexerModule *lm : lexerCatalogue) { + if (lm->GetLanguage() == language) { + return lm; + } + } + return nullptr; + } + + const LexerModule *Find(const char *languageName) { + if (languageName) { + for (const LexerModule *lm : lexerCatalogue) { + if (lm->languageName && (0 == strcmp(lm->languageName, languageName))) { + return lm; + } + } + } + return nullptr; + } + + void AddLexerModule(LexerModule *plm) { + lexerCatalogue.push_back(plm); + } + + unsigned int Count() { + return static_cast<unsigned int>(lexerCatalogue.size()); + } + + const char *Name(unsigned int index) { + if (index < static_cast<unsigned int>(lexerCatalogue.size())) { + return lexerCatalogue[index]->languageName; + } else { + return ""; + } + } + + LexerFactoryFunction Factory(unsigned int index) { + // Works for object lexers but not for function lexers + return lexerCatalogue[index]->fnFactory; + } + + ILexer4 *Create(unsigned int index) { + const LexerModule *plm = lexerCatalogue[index]; + if (!plm) { + return nullptr; + } + return plm->Create(); + } +}; + +} + +#endif diff --git a/lexlib/LexerModule.h b/lexlib/LexerModule.h index a6dda61ed..96cff9645 100644 --- a/lexlib/LexerModule.h +++ b/lexlib/LexerModule.h @@ -65,7 +65,7 @@ public: virtual void Fold(Sci_PositionU startPos, Sci_Position lengthDoc, int initStyle, WordList *keywordlists[], Accessor &styler) const; - friend class Catalogue; + friend class CatalogueModules; }; inline int Maximum(int a, int b) { diff --git a/scripts/HeaderOrder.txt b/scripts/HeaderOrder.txt index 63f9978d3..23c16081a 100644 --- a/scripts/HeaderOrder.txt +++ b/scripts/HeaderOrder.txt @@ -105,6 +105,7 @@ #include "CharacterSet.h" #include "CharacterCategory.h" #include "LexerModule.h" +#include "CatalogueModules.h" #include "OptionSet.h" #include "SparseState.h" #include "SubStyles.h" 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<LexerModule *> 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() { diff --git a/win32/DepGen.py b/win32/DepGen.py index 3abf68936..c255574b0 100644 --- a/win32/DepGen.py +++ b/win32/DepGen.py @@ -22,9 +22,6 @@ def Generate(): # Add ScintillaBaseL as the same as ScintillaBase deps = Dependencies.InsertSynonym(deps, "ScintillaBase.o", "ScintillaBaseL.o") - # Add ScintillaWinL as the same as ScintillaWin - deps = Dependencies.InsertSynonym(deps, "ScintillaWin.o", "ScintillaWinL.o") - Dependencies.UpdateDependencies("../win32/deps.mak", deps, topComment) # Create the dependencies file for MSVC diff --git a/win32/ScintillaWin.cxx b/win32/ScintillaWin.cxx index bb99166c6..99a54c1aa 100644 --- a/win32/ScintillaWin.cxx +++ b/win32/ScintillaWin.cxx @@ -3465,9 +3465,6 @@ LRESULT PASCAL ScintillaWin::SWndProc( int Scintilla_RegisterClasses(void *hInstance) { Platform_Initialise(hInstance); const bool result = ScintillaWin::Register(static_cast<HINSTANCE>(hInstance)); -#ifdef SCI_LEXER - Scintilla_LinkLexers(); -#endif return result; } diff --git a/win32/deps.mak b/win32/deps.mak index b7f4024cd..4eed6cc45 100644 --- a/win32/deps.mak +++ b/win32/deps.mak @@ -55,45 +55,6 @@ ScintillaWin.o: \ PlatWin.h \ HanjaDic.h \ ScintillaWin.h -ScintillaWinL.o: \ - ScintillaWin.cxx \ - ../include/Platform.h \ - ../include/ILoader.h \ - ../include/Sci_Position.h \ - ../include/ILexer.h \ - ../include/Scintilla.h \ - ../lexlib/CharacterCategory.h \ - ../src/Position.h \ - ../src/UniqueString.h \ - ../src/SplitVector.h \ - ../src/Partitioning.h \ - ../src/RunStyles.h \ - ../src/ContractionState.h \ - ../src/CellBuffer.h \ - ../src/CallTip.h \ - ../src/KeyMap.h \ - ../src/Indicator.h \ - ../src/LineMarker.h \ - ../src/Style.h \ - ../src/ViewStyle.h \ - ../src/CharClassify.h \ - ../src/Decoration.h \ - ../src/CaseFolder.h \ - ../src/Document.h \ - ../src/CaseConvert.h \ - ../src/UniConversion.h \ - ../src/Selection.h \ - ../src/PositionCache.h \ - ../src/EditModel.h \ - ../src/MarginView.h \ - ../src/EditView.h \ - ../src/Editor.h \ - ../src/ElapsedPeriod.h \ - ../src/AutoComplete.h \ - ../src/ScintillaBase.h \ - PlatWin.h \ - HanjaDic.h \ - ScintillaWin.h AutoComplete.o: \ ../src/AutoComplete.cxx \ ../include/Platform.h \ @@ -125,6 +86,7 @@ Catalogue.o: \ ../include/Scintilla.h \ ../include/SciLexer.h \ ../lexlib/LexerModule.h \ + ../lexlib/CatalogueModules.h \ ../src/Catalogue.h CellBuffer.o: \ ../src/CellBuffer.cxx \ diff --git a/win32/makefile b/win32/makefile index 7aa1be716..30ae527fb 100644 --- a/win32/makefile +++ b/win32/makefile @@ -130,7 +130,7 @@ SCILEX_OBJS=\ HanjaDic.o \ PlatWin.o \ ScintillaBaseL.o \ - ScintillaWinL.o + ScintillaWin.o COMPONENT_OBJS = \ $(SRC_OBJS) \ @@ -162,9 +162,6 @@ include deps.mak ScintillaBaseL.o: $(CXX) $(CXX_ALL_FLAGS) $(CXXFLAGS) -D SCI_LEXER -c $< -o $@ -ScintillaWinL.o: - $(CXX) $(CXX_ALL_FLAGS) $(CXXFLAGS) -D SCI_LEXER -c $< -o $@ - ScintRes.o: ScintRes.rc $(WINDRES) ScintRes.rc $@ diff --git a/win32/nmdeps.mak b/win32/nmdeps.mak index f5610bb5b..c4fab693f 100644 --- a/win32/nmdeps.mak +++ b/win32/nmdeps.mak @@ -55,45 +55,6 @@ $(DIR_O)/ScintillaWin.obj: \ PlatWin.h \ HanjaDic.h \ ScintillaWin.h -$(DIR_O)/ScintillaWinL.obj: \ - ScintillaWin.cxx \ - ../include/Platform.h \ - ../include/ILoader.h \ - ../include/Sci_Position.h \ - ../include/ILexer.h \ - ../include/Scintilla.h \ - ../lexlib/CharacterCategory.h \ - ../src/Position.h \ - ../src/UniqueString.h \ - ../src/SplitVector.h \ - ../src/Partitioning.h \ - ../src/RunStyles.h \ - ../src/ContractionState.h \ - ../src/CellBuffer.h \ - ../src/CallTip.h \ - ../src/KeyMap.h \ - ../src/Indicator.h \ - ../src/LineMarker.h \ - ../src/Style.h \ - ../src/ViewStyle.h \ - ../src/CharClassify.h \ - ../src/Decoration.h \ - ../src/CaseFolder.h \ - ../src/Document.h \ - ../src/CaseConvert.h \ - ../src/UniConversion.h \ - ../src/Selection.h \ - ../src/PositionCache.h \ - ../src/EditModel.h \ - ../src/MarginView.h \ - ../src/EditView.h \ - ../src/Editor.h \ - ../src/ElapsedPeriod.h \ - ../src/AutoComplete.h \ - ../src/ScintillaBase.h \ - PlatWin.h \ - HanjaDic.h \ - ScintillaWin.h $(DIR_O)/AutoComplete.obj: \ ../src/AutoComplete.cxx \ ../include/Platform.h \ @@ -125,6 +86,7 @@ $(DIR_O)/Catalogue.obj: \ ../include/Scintilla.h \ ../include/SciLexer.h \ ../lexlib/LexerModule.h \ + ../lexlib/CatalogueModules.h \ ../src/Catalogue.h $(DIR_O)/CellBuffer.obj: \ ../src/CellBuffer.cxx \ diff --git a/win32/scintilla.mak b/win32/scintilla.mak index c5c9748a2..0e0f7558c 100644 --- a/win32/scintilla.mak +++ b/win32/scintilla.mak @@ -238,7 +238,7 @@ SCILEX_OBJS = \ $(DIR_O)\HanjaDic.obj \ $(DIR_O)\PlatWin.obj \ $(DIR_O)\ScintillaBaseL.obj \ - $(DIR_O)\ScintillaWinL.obj + $(DIR_O)\ScintillaWin.obj COMPONENT_OBJS = \ $(DIR_O)\HanjaDic.obj \ @@ -252,14 +252,6 @@ LEXCOMPONENT_OBJS = \ $(DIR_O)\ScintillaDLL.obj \ $(SCILEX_OBJS) -SOBJS = \ - $(SRC_OBJS) \ - $(DIR_O)\HanjaDic.obj \ - $(DIR_O)\PlatWin.obj \ - $(DIR_O)\ScintillaBase.obj \ - $(DIR_O)\ScintillaWin.obj \ - $(DIR_O)\ScintillaDLL.obj - $(DIR_O)\ScintRes.res : ScintRes.rc $(RC) -fo$@ $** @@ -287,9 +279,6 @@ $(LIBSCI): $(SCILEX_OBJS) $(DIR_O)\ScintillaBaseL.obj: ..\src\ScintillaBase.cxx $(CXX) $(CXXFLAGS) -DSCI_LEXER -c $(NAME)$@ ..\src\ScintillaBase.cxx -$(DIR_O)\ScintillaWinL.obj: ScintillaWin.cxx - $(CXX) $(CXXFLAGS) -DSCI_LEXER -c $(NAME)$@ ScintillaWin.cxx - # Dependencies !IF EXISTS(nmdeps.mak) |