1 // Scintilla source code edit control
2 /** @file ExternalLexer.h
3 ** Support external lexers in DLLs.
5 // Copyright 2001 Simon Steele <ss@pnotepad.org>, portions copyright Neil Hodgson.
6 // The License.txt file describes the conditions under which this software may be distributed.
8 #ifndef EXTERNALLEXER_H
9 #define EXTERNALLEXER_H
12 #define EXT_LEXER_DECL __stdcall
14 #define EXT_LEXER_DECL
21 typedef void*(EXT_LEXER_DECL
*GetLexerFunction
)(unsigned int Index
);
22 typedef int (EXT_LEXER_DECL
*GetLexerCountFn
)();
23 typedef void (EXT_LEXER_DECL
*GetLexerNameFn
)(unsigned int Index
, char *name
, int buflength
);
24 typedef LexerFactoryFunction(EXT_LEXER_DECL
*GetLexerFactoryFunction
)(unsigned int Index
);
26 /// Sub-class of LexerModule to use an external lexer.
27 class ExternalLexerModule
: public LexerModule
{
29 GetLexerFactoryFunction fneFactory
;
32 ExternalLexerModule(int language_
, LexerFunction fnLexer_
,
33 const char *languageName_
=0, LexerFunction fnFolder_
=0) :
34 LexerModule(language_
, fnLexer_
, 0, fnFolder_
),
36 strncpy(name
, languageName_
, sizeof(name
));
37 name
[sizeof(name
)-1] = '\0';
40 virtual void SetExternal(GetLexerFactoryFunction fFactory
, int index
);
43 /// LexerMinder points to an ExternalLexerModule - so we don't leak them.
46 ExternalLexerModule
*self
;
50 /// LexerLibrary exists for every External Lexer DLL, contains LexerMinders.
57 LexerLibrary(const char *ModuleName
);
62 std::string m_sModuleName
;
65 /// LexerManager manages external lexers, contains LexerLibrarys.
70 static LexerManager
*GetInstance();
71 static void DeleteInstance();
73 void Load(const char *path
);
78 static LexerManager
*theInstance
;
80 void LoadLexerLibrary(const char *module);