diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/ExternalLexer.cxx | 40 | ||||
| -rw-r--r-- | src/ExternalLexer.h | 2 | ||||
| -rw-r--r-- | src/ScintillaBase.cxx | 2 |
3 files changed, 30 insertions, 14 deletions
diff --git a/src/ExternalLexer.cxx b/src/ExternalLexer.cxx index acb18339d..eae5806ee 100644 --- a/src/ExternalLexer.cxx +++ b/src/ExternalLexer.cxx @@ -39,6 +39,7 @@ int nextLanguage = SCLEX_AUTOMATIC + 1; typedef int (EXT_LEXER_DECL *GetLexerCountFn)(); typedef void (EXT_LEXER_DECL *GetLexerNameFn)(unsigned int Index, char *name, int buflength); typedef LexerFactoryFunction(EXT_LEXER_DECL *GetLexerFactoryFunction)(unsigned int Index); +typedef LexerFactoryFunction5(EXT_LEXER_DECL *GetLexerFactoryFunction5)(unsigned int Index); /// Generic function to convert from a void* to a function pointer. /// This avoids undefined and conditionally defined behaviour. @@ -54,15 +55,17 @@ T FunctionPointer(void *function) noexcept { class ExternalLexerModule : public LexerModule { protected: GetLexerFactoryFunction fneFactory; + GetLexerFactoryFunction5 fneFactory5; std::string name; public: ExternalLexerModule(int language_, LexerFunction fnLexer_, const char *languageName_=nullptr, LexerFunction fnFolder_=nullptr) : LexerModule(language_, fnLexer_, nullptr, fnFolder_), - fneFactory(nullptr), name(languageName_){ + fneFactory(nullptr), fneFactory5(nullptr), name(languageName_){ languageName = name.c_str(); } void SetExternal(GetLexerFactoryFunction fFactory, int index) noexcept; + void SetExternal(GetLexerFactoryFunction5 fFactory, int index) noexcept; }; /// LexerLibrary exists for every External Lexer DLL, contains ExternalLexerModules. @@ -70,7 +73,7 @@ class LexerLibrary { std::unique_ptr<DynamicLibrary> lib; std::vector<std::unique_ptr<ExternalLexerModule>> modules; public: - explicit LexerLibrary(const char *moduleName_); + explicit LexerLibrary(const char *moduleName_, bool iLexer5=false); ~LexerLibrary(); std::string moduleName; @@ -84,7 +87,7 @@ public: static LexerManager *GetInstance(); static void DeleteInstance() noexcept; - void Load(const char *path); + void Load(const char *path, bool iLexer5=false); void Clear() noexcept; private: @@ -111,13 +114,18 @@ void ExternalLexerModule::SetExternal(GetLexerFactoryFunction fFactory, int inde fnFactory = fFactory(index); } +void ExternalLexerModule::SetExternal(GetLexerFactoryFunction5 fFactory5, int index) noexcept { + fneFactory5 = fFactory5; + fnFactory5 = fFactory5(index); +} + //------------------------------------------ // // LexerLibrary // //------------------------------------------ -LexerLibrary::LexerLibrary(const char *moduleName_) { +LexerLibrary::LexerLibrary(const char *moduleName_, bool iLexer5) { // Load the DLL lib.reset(DynamicLibrary::Load(moduleName_)); if (lib->IsValid()) { @@ -127,9 +135,14 @@ LexerLibrary::LexerLibrary(const char *moduleName_) { if (GetLexerCount) { // Find functions in the DLL GetLexerNameFn GetLexerName = FunctionPointer<GetLexerNameFn>(lib->FindFunction("GetLexerName")); - GetLexerFactoryFunction fnFactory = FunctionPointer<GetLexerFactoryFunction>(lib->FindFunction("GetLexerFactory")); - - if (!GetLexerName || !fnFactory) { + GetLexerFactoryFunction fnFactory = nullptr; + GetLexerFactoryFunction5 fnFactory5 = nullptr; + if (!iLexer5) + fnFactory = FunctionPointer<GetLexerFactoryFunction>(lib->FindFunction("GetLexerFactory")); + else + fnFactory5 = FunctionPointer<GetLexerFactoryFunction5>(lib->FindFunction("GetLexerFactory")); + + if (!GetLexerName || (!fnFactory && !fnFactory5)) { return; } @@ -151,7 +164,10 @@ LexerLibrary::LexerLibrary(const char *moduleName_) { // The external lexer needs to know how to call into its DLL to // do its lexing and folding, we tell it here. - lex->SetExternal(fnFactory, i); + if (!iLexer5) + lex->SetExternal(fnFactory, i); + else + lex->SetExternal(fnFactory5, i); } } } @@ -186,12 +202,12 @@ LexerManager::~LexerManager() { Clear(); } -void LexerManager::Load(const char *path) { +void LexerManager::Load(const char *path, bool iLexer5) { for (const std::unique_ptr<LexerLibrary> &ll : libraries) { if (ll->moduleName == path) return; } - libraries.push_back(Sci::make_unique<LexerLibrary>(path)); + libraries.push_back(Sci::make_unique<LexerLibrary>(path, iLexer5)); } void LexerManager::Clear() noexcept { @@ -214,8 +230,8 @@ LMMinder minder; namespace Scintilla { -void ExternalLexerLoad(const char *path) { - LexerManager::GetInstance()->Load(path); +void ExternalLexerLoad(const char *path, bool iLexer5) { + LexerManager::GetInstance()->Load(path, iLexer5); } } diff --git a/src/ExternalLexer.h b/src/ExternalLexer.h index d0a615e31..736b91531 100644 --- a/src/ExternalLexer.h +++ b/src/ExternalLexer.h @@ -10,7 +10,7 @@ namespace Scintilla { -void ExternalLexerLoad(const char *path); +void ExternalLexerLoad(const char *path, bool iLexer5=false); } diff --git a/src/ScintillaBase.cxx b/src/ScintillaBase.cxx index 082cb82d5..09736d9f7 100644 --- a/src/ScintillaBase.cxx +++ b/src/ScintillaBase.cxx @@ -1103,7 +1103,7 @@ sptr_t ScintillaBase::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lPara return StringResult(lParam, DocumentLexState()->GetName()); case SCI_LOADLEXERLIBRARY: - ExternalLexerLoad(ConstCharPtrFromSPtr(lParam)); + ExternalLexerLoad(ConstCharPtrFromSPtr(lParam), wParam != 0); break; case SCI_PRIVATELEXERCALL: |
