xref: /MusicPlayer2/scintilla/src/Catalogue.cxx (revision 443d2d2511be730d1b1dd3181942b7fa6539aa1a)
1 // Scintilla source code edit control
2 /** @file Catalogue.cxx
3  ** Lexer infrastructure.
4  ** Contains a list of LexerModules which can be searched to find a module appropriate for a
5  ** particular language.
6  **/
7 // Copyright 1998-2002 by Neil Hodgson <[email protected]>
8 // The License.txt file describes the conditions under which this software may be distributed.
9 
10 #include <cstdlib>
11 #include <cassert>
12 #include <cstring>
13 
14 #include <stdexcept>
15 #include <vector>
16 
17 #include "ILexer.h"
18 #include "Scintilla.h"
19 #include "SciLexer.h"
20 
21 #include "LexerModule.h"
22 #include "CatalogueModules.h"
23 #include "Catalogue.h"
24 
25 using namespace Scintilla;
26 
27 namespace {
28 
29 CatalogueModules catalogueDefault;
30 
31 }
32 
33 const LexerModule *Catalogue::Find(int language) {
34 	return catalogueDefault.Find(language);
35 }
36 
37 const LexerModule *Catalogue::Find(const char *languageName) noexcept {
38 	return catalogueDefault.Find(languageName);
39 }
40 
41 void Catalogue::AddLexerModule(LexerModule *plm) {
42 	catalogueDefault.AddLexerModule(plm);
43 }
44 
45 // To add or remove a lexer, add or remove its file and run LexGen.py.
46 
47 // Force a reference to all of the Scintilla lexers so that the linker will
48 // not remove the code of the lexers.
49 int Scintilla_LinkLexers() {
50 
51 	static int initialised = 0;
52 	if (initialised)
53 		return 0;
54 	initialised = 1;
55 
56 #if !defined(SCI_EMPTYCATALOGUE)
57 
58 // Shorten the code that declares a lexer and ensures it is linked in by calling a method.
59 #define LINK_LEXER(lexer) extern LexerModule lexer; catalogueDefault.AddLexerModule(&lexer);
60 
61 //++Autogenerated -- run scripts/LexGen.py to regenerate
62 //**\(\tLINK_LEXER(\*);\n\)
63 	LINK_LEXER(lmNull);
64 	LINK_LEXER(lmLyric);
65 
66 //--Autogenerated -- end of automatically generated section
67 
68 #endif
69 
70 	return 1;
71 }
72