diff options
| -rw-r--r-- | cocoa/PlatCocoa.mm | 41 | ||||
| -rw-r--r-- | doc/ScintillaDoc.html | 7 | ||||
| -rw-r--r-- | doc/ScintillaHistory.html | 11 | ||||
| -rw-r--r-- | scripts/HeaderOrder.txt | 1 |
4 files changed, 55 insertions, 5 deletions
diff --git a/cocoa/PlatCocoa.mm b/cocoa/PlatCocoa.mm index 52e5399a9..8f49d5eed 100644 --- a/cocoa/PlatCocoa.mm +++ b/cocoa/PlatCocoa.mm @@ -24,6 +24,7 @@ #include <map> #include <memory> +#include <dlfcn.h> #include <sys/time.h> #import <Foundation/NSGeometry.h> @@ -2097,6 +2098,43 @@ void Platform::Assert(const char *c, const char *file, int line) //----------------- DynamicLibrary ----------------------------------------------------------------- /** + * Platform-specific module loading and access. + * Uses POSIX calls dlopen, dlsym, dlclose. + */ + +class DynamicLibraryImpl : public DynamicLibrary { +protected: + void *m; +public: + explicit DynamicLibraryImpl(const char *modulePath) noexcept { + m = dlopen(modulePath, RTLD_LAZY); + } + // Deleted so DynamicLibraryImpl objects can not be copied. + DynamicLibraryImpl(const DynamicLibraryImpl&) = delete; + DynamicLibraryImpl(DynamicLibraryImpl&&) = delete; + DynamicLibraryImpl&operator=(const DynamicLibraryImpl&) = delete; + DynamicLibraryImpl&operator=(DynamicLibraryImpl&&) = delete; + + ~DynamicLibraryImpl() override { + if (m) + dlclose(m); + } + + // Use dlsym to get a pointer to the relevant function. + Function FindFunction(const char *name) override { + if (m) { + return dlsym(m, name); + } else { + return nullptr; + } + } + + bool IsValid() override { + return m != nullptr; + } +}; + +/** * Implements the platform specific part of library loading. * * @param modulePath The path to the module to load. @@ -2104,8 +2142,7 @@ void Platform::Assert(const char *c, const char *file, int line) */ DynamicLibrary* DynamicLibrary::Load(const char* /* modulePath */) { - // Not implemented. - return nullptr; + return static_cast<DynamicLibrary *>(new DynamicLibraryImpl(modulePath)); } //-------------------------------------------------------------------------------------------------- diff --git a/doc/ScintillaDoc.html b/doc/ScintillaDoc.html index 3efb7257f..fa247b35e 100644 --- a/doc/ScintillaDoc.html +++ b/doc/ScintillaDoc.html @@ -6830,9 +6830,10 @@ sptr_t CallScintilla(unsigned int iMessage, uptr_t wParam, sptr_t lParam){ styling and fold points for an unsupported language you can either do this in the container or better still, write your own lexer following the pattern of one of the existing ones.</p> - <p>Scintilla also supports external lexers. These are DLLs (on Windows) or .so modules (on GTK/Linux) that export three + <p>Scintilla also supports external lexers. These are DLLs (on Windows), .dylib modules (on macOS), + or .so modules (on GTK/Linux) that export three functions: <code>GetLexerCount</code>, <code>GetLexerName</code>, and - <code>GetLexerFactory</code>. See <code>externalLexer.cxx</code> for more.</p> + <code>GetLexerFactory</code>. See <code>ExternalLexer.cxx</code> for more information.</p> <a class="message" href="#SCI_SETLEXER">SCI_SETLEXER(int lexer)</a><br /> <a class="message" href="#SCI_GETLEXER">SCI_GETLEXER → int</a><br /> <a class="message" href="#SCI_SETLEXERLANGUAGE">SCI_SETLEXERLANGUAGE(<unused>, const char @@ -6895,7 +6896,7 @@ sptr_t CallScintilla(unsigned int iMessage, uptr_t wParam, sptr_t lParam){ <p><code>SCI_GETLEXERLANGUAGE</code> retrieves the name of the lexer.</p> <p><b id="SCI_LOADLEXERLIBRARY">SCI_LOADLEXERLIBRARY(<unused>, const char *path)</b><br /> - Load a lexer implemented in a shared library. This is a .so file on GTK/Linux or a .DLL file on Windows. + Load a lexer implemented in a shared library. This is a .so file on GTK/Linux, a .dylib file on macOS, or a .DLL file on Windows. </p> <p><b id="SCI_COLOURISE">SCI_COLOURISE(position start, position end)</b><br /> diff --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html index d3e2094c5..ea72b9ecb 100644 --- a/doc/ScintillaHistory.html +++ b/doc/ScintillaHistory.html @@ -554,6 +554,17 @@ </li> </ul> <h3> + <a href="https://sourceforge.net/projects/scintilla/files/scintilla/3.12.0/scintilla3120.zip/download">Release 3.12.0</a> + </h3> + <ul> + <li> + Released 07 December 2019. + </li> + <li> + SCI_LOADLEXERLIBRARY implemented on Cocoa. + </li> + </ul> + <h3> <a href="https://sourceforge.net/projects/scintilla/files/scintilla/3.11.2/scintilla3112.zip/download">Release 3.11.2</a> </h3> <ul> diff --git a/scripts/HeaderOrder.txt b/scripts/HeaderOrder.txt index 6f749579e..2242558ec 100644 --- a/scripts/HeaderOrder.txt +++ b/scripts/HeaderOrder.txt @@ -50,6 +50,7 @@ #include <sstream> // POSIX +#include <dlfcn.h> #include <sys/time.h> // GTK headers |
