Fix diff mistake (#3109)
[geany-mirror.git] / scintilla / lexilla / src / Lexilla.cxx
blob02fa855a048470018e7b72e03662353153d4f070
1 // Lexilla lexer library
2 /** @file Lexilla.cxx
3 ** Lexer infrastructure.
4 ** Provides entry points to shared library.
5 **/
6 // Copyright 2019 by Neil Hodgson <neilh@scintilla.org>
7 // The License.txt file describes the conditions under which this software may be distributed.
9 #include <cstring>
11 #include <vector>
12 #include <initializer_list>
14 #if _WIN32
15 #define EXPORT_FUNCTION __declspec(dllexport)
16 #define CALLING_CONVENTION __stdcall
17 #else
18 #define EXPORT_FUNCTION __attribute__((visibility("default")))
19 #define CALLING_CONVENTION
20 #endif
22 #include "ILexer.h"
24 #include "LexerModule.h"
25 #include "CatalogueModules.h"
27 using namespace Lexilla;
29 //++Autogenerated -- run lexilla/scripts/LexillaGen.py to regenerate
30 //**\(extern LexerModule \*;\n\)
31 extern LexerModule lmA68k;
32 extern LexerModule lmAbaqus;
33 extern LexerModule lmAda;
34 extern LexerModule lmAPDL;
35 extern LexerModule lmAs;
36 extern LexerModule lmAsciidoc;
37 extern LexerModule lmAsm;
38 extern LexerModule lmAsn1;
39 extern LexerModule lmASY;
40 extern LexerModule lmAU3;
41 extern LexerModule lmAVE;
42 extern LexerModule lmAVS;
43 extern LexerModule lmBaan;
44 extern LexerModule lmBash;
45 extern LexerModule lmBatch;
46 extern LexerModule lmBibTeX;
47 extern LexerModule lmBlitzBasic;
48 extern LexerModule lmBullant;
49 extern LexerModule lmCaml;
50 extern LexerModule lmCIL;
51 extern LexerModule lmClw;
52 extern LexerModule lmClwNoCase;
53 extern LexerModule lmCmake;
54 extern LexerModule lmCOBOL;
55 extern LexerModule lmCoffeeScript;
56 extern LexerModule lmConf;
57 extern LexerModule lmCPP;
58 extern LexerModule lmCPPNoCase;
59 extern LexerModule lmCsound;
60 extern LexerModule lmCss;
61 extern LexerModule lmD;
62 extern LexerModule lmDataflex;
63 extern LexerModule lmDiff;
64 extern LexerModule lmDMAP;
65 extern LexerModule lmDMIS;
66 extern LexerModule lmECL;
67 extern LexerModule lmEDIFACT;
68 extern LexerModule lmEiffel;
69 extern LexerModule lmEiffelkw;
70 extern LexerModule lmErlang;
71 extern LexerModule lmErrorList;
72 extern LexerModule lmESCRIPT;
73 extern LexerModule lmF77;
74 extern LexerModule lmFlagShip;
75 extern LexerModule lmForth;
76 extern LexerModule lmFortran;
77 extern LexerModule lmFreeBasic;
78 extern LexerModule lmFSharp;
79 extern LexerModule lmGAP;
80 extern LexerModule lmGDScript;
81 extern LexerModule lmGui4Cli;
82 extern LexerModule lmHaskell;
83 extern LexerModule lmHollywood;
84 extern LexerModule lmHTML;
85 extern LexerModule lmIHex;
86 extern LexerModule lmIndent;
87 extern LexerModule lmInno;
88 extern LexerModule lmJSON;
89 extern LexerModule lmJulia;
90 extern LexerModule lmKix;
91 extern LexerModule lmKVIrc;
92 extern LexerModule lmLatex;
93 extern LexerModule lmLISP;
94 extern LexerModule lmLiterateHaskell;
95 extern LexerModule lmLot;
96 extern LexerModule lmLout;
97 extern LexerModule lmLua;
98 extern LexerModule lmMagikSF;
99 extern LexerModule lmMake;
100 extern LexerModule lmMarkdown;
101 extern LexerModule lmMatlab;
102 extern LexerModule lmMaxima;
103 extern LexerModule lmMETAPOST;
104 extern LexerModule lmMMIXAL;
105 extern LexerModule lmModula;
106 extern LexerModule lmMSSQL;
107 extern LexerModule lmMySQL;
108 extern LexerModule lmNim;
109 extern LexerModule lmNimrod;
110 extern LexerModule lmNncrontab;
111 extern LexerModule lmNsis;
112 extern LexerModule lmNull;
113 extern LexerModule lmOctave;
114 extern LexerModule lmOpal;
115 extern LexerModule lmOScript;
116 extern LexerModule lmPascal;
117 extern LexerModule lmPB;
118 extern LexerModule lmPerl;
119 extern LexerModule lmPHPSCRIPT;
120 extern LexerModule lmPLM;
121 extern LexerModule lmPO;
122 extern LexerModule lmPOV;
123 extern LexerModule lmPowerPro;
124 extern LexerModule lmPowerShell;
125 extern LexerModule lmProgress;
126 extern LexerModule lmProps;
127 extern LexerModule lmPS;
128 extern LexerModule lmPureBasic;
129 extern LexerModule lmPython;
130 extern LexerModule lmR;
131 extern LexerModule lmRaku;
132 extern LexerModule lmREBOL;
133 extern LexerModule lmRegistry;
134 extern LexerModule lmRuby;
135 extern LexerModule lmRust;
136 extern LexerModule lmSAS;
137 extern LexerModule lmScriptol;
138 extern LexerModule lmSmalltalk;
139 extern LexerModule lmSML;
140 extern LexerModule lmSorc;
141 extern LexerModule lmSpecman;
142 extern LexerModule lmSpice;
143 extern LexerModule lmSQL;
144 extern LexerModule lmSrec;
145 extern LexerModule lmStata;
146 extern LexerModule lmSTTXT;
147 extern LexerModule lmTACL;
148 extern LexerModule lmTADS3;
149 extern LexerModule lmTAL;
150 extern LexerModule lmTCL;
151 extern LexerModule lmTCMD;
152 extern LexerModule lmTEHex;
153 extern LexerModule lmTeX;
154 extern LexerModule lmTxt2tags;
155 extern LexerModule lmVB;
156 extern LexerModule lmVBScript;
157 extern LexerModule lmVerilog;
158 extern LexerModule lmVHDL;
159 extern LexerModule lmVisualProlog;
160 extern LexerModule lmX12;
161 extern LexerModule lmXML;
162 extern LexerModule lmYAML;
164 //--Autogenerated -- end of automatically generated section
166 namespace {
168 CatalogueModules catalogueLexilla;
170 static void AddGeanyLexers()
172 catalogueLexilla.AddLexerModules({
173 &lmAbaqus,
174 &lmAda,
175 &lmAsm,
176 &lmBash,
177 &lmBatch,
178 &lmCaml,
179 &lmCmake,
180 &lmCOBOL,
181 &lmCoffeeScript,
182 &lmCPP,
183 &lmCss,
184 &lmD,
185 &lmDiff,
186 &lmErlang,
187 &lmF77,
188 &lmForth,
189 &lmFortran,
190 &lmFreeBasic,
191 &lmGDScript,
192 &lmHaskell,
193 &lmHTML,
194 &lmJulia,
195 &lmLatex,
196 &lmLISP,
197 &lmLua,
198 &lmMake,
199 &lmMarkdown,
200 &lmNsis,
201 &lmNull,
202 &lmOctave,
203 &lmPascal,
204 &lmPerl,
205 &lmPHPSCRIPT,
206 &lmPO,
207 &lmPowerShell,
208 &lmProps,
209 &lmPython,
210 &lmR,
211 &lmRuby,
212 &lmRust,
213 &lmSmalltalk,
214 &lmSQL,
215 &lmTCL,
216 &lmTxt2tags,
217 &lmVerilog,
218 &lmVHDL,
219 &lmXML,
220 &lmYAML,
224 void AddEachLexer() {
226 if (catalogueLexilla.Count() > 0) {
227 return;
230 AddGeanyLexers();
231 return;
233 catalogueLexilla.AddLexerModules({
234 //++Autogenerated -- run scripts/LexillaGen.py to regenerate
235 //**\(\t\t&\*,\n\)
236 &lmA68k,
237 &lmAbaqus,
238 &lmAda,
239 &lmAPDL,
240 &lmAs,
241 &lmAsciidoc,
242 &lmAsm,
243 &lmAsn1,
244 &lmASY,
245 &lmAU3,
246 &lmAVE,
247 &lmAVS,
248 &lmBaan,
249 &lmBash,
250 &lmBatch,
251 &lmBibTeX,
252 &lmBlitzBasic,
253 &lmBullant,
254 &lmCaml,
255 &lmCIL,
256 &lmClw,
257 &lmClwNoCase,
258 &lmCmake,
259 &lmCOBOL,
260 &lmCoffeeScript,
261 &lmConf,
262 &lmCPP,
263 &lmCPPNoCase,
264 &lmCsound,
265 &lmCss,
266 &lmD,
267 &lmDataflex,
268 &lmDiff,
269 &lmDMAP,
270 &lmDMIS,
271 &lmECL,
272 &lmEDIFACT,
273 &lmEiffel,
274 &lmEiffelkw,
275 &lmErlang,
276 &lmErrorList,
277 &lmESCRIPT,
278 &lmF77,
279 &lmFlagShip,
280 &lmForth,
281 &lmFortran,
282 &lmFreeBasic,
283 &lmFSharp,
284 &lmGAP,
285 &lmGDScript,
286 &lmGui4Cli,
287 &lmHaskell,
288 &lmHollywood,
289 &lmHTML,
290 &lmIHex,
291 &lmIndent,
292 &lmInno,
293 &lmJSON,
294 &lmJulia,
295 &lmKix,
296 &lmKVIrc,
297 &lmLatex,
298 &lmLISP,
299 &lmLiterateHaskell,
300 &lmLot,
301 &lmLout,
302 &lmLua,
303 &lmMagikSF,
304 &lmMake,
305 &lmMarkdown,
306 &lmMatlab,
307 &lmMaxima,
308 &lmMETAPOST,
309 &lmMMIXAL,
310 &lmModula,
311 &lmMSSQL,
312 &lmMySQL,
313 &lmNim,
314 &lmNimrod,
315 &lmNncrontab,
316 &lmNsis,
317 &lmNull,
318 &lmOctave,
319 &lmOpal,
320 &lmOScript,
321 &lmPascal,
322 &lmPB,
323 &lmPerl,
324 &lmPHPSCRIPT,
325 &lmPLM,
326 &lmPO,
327 &lmPOV,
328 &lmPowerPro,
329 &lmPowerShell,
330 &lmProgress,
331 &lmProps,
332 &lmPS,
333 &lmPureBasic,
334 &lmPython,
335 &lmR,
336 &lmRaku,
337 &lmREBOL,
338 &lmRegistry,
339 &lmRuby,
340 &lmRust,
341 &lmSAS,
342 &lmScriptol,
343 &lmSmalltalk,
344 &lmSML,
345 &lmSorc,
346 &lmSpecman,
347 &lmSpice,
348 &lmSQL,
349 &lmSrec,
350 &lmStata,
351 &lmSTTXT,
352 &lmTACL,
353 &lmTADS3,
354 &lmTAL,
355 &lmTCL,
356 &lmTCMD,
357 &lmTEHex,
358 &lmTeX,
359 &lmTxt2tags,
360 &lmVB,
361 &lmVBScript,
362 &lmVerilog,
363 &lmVHDL,
364 &lmVisualProlog,
365 &lmX12,
366 &lmXML,
367 &lmYAML,
369 //--Autogenerated -- end of automatically generated section
376 extern "C" {
378 EXPORT_FUNCTION int CALLING_CONVENTION GetLexerCount() {
379 AddEachLexer();
380 return catalogueLexilla.Count();
383 EXPORT_FUNCTION void CALLING_CONVENTION GetLexerName(unsigned int index, char *name, int buflength) {
384 AddEachLexer();
385 *name = 0;
386 const char *lexerName = catalogueLexilla.Name(index);
387 if (static_cast<size_t>(buflength) > strlen(lexerName)) {
388 strcpy(name, lexerName);
392 EXPORT_FUNCTION LexerFactoryFunction CALLING_CONVENTION GetLexerFactory(unsigned int index) {
393 AddEachLexer();
394 return catalogueLexilla.Factory(index);
397 EXPORT_FUNCTION Scintilla::ILexer5 * CALLING_CONVENTION CreateLexer(const char *name) {
398 AddEachLexer();
399 for (unsigned int i = 0; i < catalogueLexilla.Count(); i++) {
400 const char *lexerName = catalogueLexilla.Name(i);
401 if (0 == strcmp(lexerName, name)) {
402 return catalogueLexilla.Create(i);
405 return nullptr;
408 EXPORT_FUNCTION const char * CALLING_CONVENTION LexerNameFromID(int identifier) {
409 AddEachLexer();
410 const LexerModule *pModule = catalogueLexilla.Find(identifier);
411 if (pModule) {
412 return pModule->languageName;
413 } else {
414 return nullptr;
418 EXPORT_FUNCTION const char * CALLING_CONVENTION GetLibraryPropertyNames() {
419 return "";
422 EXPORT_FUNCTION void CALLING_CONVENTION SetLibraryProperty(const char *, const char *) {
423 // Null implementation
426 EXPORT_FUNCTION const char * CALLING_CONVENTION GetNameSpace() {
427 return "lexilla";
430 // Not exported from binary as LexerModule must be built exactly the same as
431 // modules listed above
432 void AddStaticLexerModule(LexerModule *plm) {
433 AddEachLexer();
434 catalogueLexilla.AddLexerModule(plm);