| 1 |
// Lexilla lexer library |
| 2 |
/** @file Lexilla.h |
| 3 |
** Lexilla definitions for dynamic and static linking. |
| 4 |
** For C++, more features and type safety are available with the LexillaAccess module. |
| 5 |
**/ |
| 6 |
// Copyright 2020 by Neil Hodgson <[email protected]> |
| 7 |
// The License.txt file describes the conditions under which this software may be distributed. |
| 8 |
|
| 9 |
#ifndef LEXILLA_H |
| 10 |
#define LEXILLA_H |
| 11 |
|
| 12 |
// Define the default Lexilla shared library name for each platform |
| 13 |
#if defined(_WIN32) |
| 14 |
#define LEXILLA_LIB "lexilla" |
| 15 |
#define LEXILLA_EXTENSION ".dll" |
| 16 |
#else |
| 17 |
#define LEXILLA_LIB "liblexilla" |
| 18 |
#if defined(__APPLE__) |
| 19 |
#define LEXILLA_EXTENSION ".dylib" |
| 20 |
#else |
| 21 |
#define LEXILLA_EXTENSION ".so" |
| 22 |
#endif |
| 23 |
#endif |
| 24 |
|
| 25 |
// On Win32 use the stdcall calling convention otherwise use the standard calling convention |
| 26 |
#if defined(_WIN32) |
| 27 |
#define LEXILLA_CALL __stdcall |
| 28 |
#else |
| 29 |
#define LEXILLA_CALL |
| 30 |
#endif |
| 31 |
|
| 32 |
#if defined(__OBJC2__) |
| 33 |
// Objective C(++) treats '[' as a message expression. |
| 34 |
#define DEPRECATE_DEFINITION |
| 35 |
#elif defined(__cplusplus) |
| 36 |
#define DEPRECATE_DEFINITION [[deprecated]] |
| 37 |
#elif defined(__GNUC__) || defined(__clang__) |
| 38 |
#define DEPRECATE_DEFINITION __attribute__((deprecated)) |
| 39 |
#else |
| 40 |
// MSVC __declspec(deprecated) has different positioning rules to GCC so define to nothing |
| 41 |
#define DEPRECATE_DEFINITION |
| 42 |
#endif |
| 43 |
|
| 44 |
#if defined(__cplusplus) |
| 45 |
// Must have already included ILexer.h to have Scintilla::ILexer5 defined. |
| 46 |
using Scintilla::ILexer5; |
| 47 |
#else |
| 48 |
typedef void ILexer5; |
| 49 |
#endif |
| 50 |
|
| 51 |
typedef ILexer5 *(*LexerFactoryFunction)(void); |
| 52 |
|
| 53 |
#if defined(__cplusplus) |
| 54 |
namespace Lexilla { |
| 55 |
#endif |
| 56 |
|
| 57 |
typedef int (LEXILLA_CALL *GetLexerCountFn)(void); |
| 58 |
typedef void (LEXILLA_CALL *GetLexerNameFn)(unsigned int Index, char *name, int buflength); |
| 59 |
typedef LexerFactoryFunction(LEXILLA_CALL *GetLexerFactoryFn)(unsigned int Index); |
| 60 |
typedef ILexer5*(LEXILLA_CALL *CreateLexerFn)(const char *name); |
| 61 |
DEPRECATE_DEFINITION typedef const char *(LEXILLA_CALL *LexerNameFromIDFn)(int identifier); |
| 62 |
typedef const char *(LEXILLA_CALL *GetLibraryPropertyNamesFn)(void); |
| 63 |
typedef void(LEXILLA_CALL *SetLibraryPropertyFn)(const char *key, const char *value); |
| 64 |
typedef const char *(LEXILLA_CALL *GetNameSpaceFn)(void); |
| 65 |
|
| 66 |
#if defined(__cplusplus) |
| 67 |
} |
| 68 |
#endif |
| 69 |
|
| 70 |
#define LEXILLA_NAMESPACE_SEPARATOR '.' |
| 71 |
|
| 72 |
#define LEXILLA_GETLEXERCOUNT "GetLexerCount" |
| 73 |
#define LEXILLA_GETLEXERNAME "GetLexerName" |
| 74 |
#define LEXILLA_GETLEXERFACTORY "GetLexerFactory" |
| 75 |
#define LEXILLA_CREATELEXER "CreateLexer" |
| 76 |
#define LEXILLA_LEXERNAMEFROMID "LexerNameFromID" |
| 77 |
#define LEXILLA_GETLIBRARYPROPERTYNAMES "GetLibraryPropertyNames" |
| 78 |
#define LEXILLA_SETLIBRARYPROPERTY "SetLibraryProperty" |
| 79 |
#define LEXILLA_GETNAMESPACE "GetNameSpace" |
| 80 |
|
| 81 |
// Static linking prototypes |
| 82 |
|
| 83 |
#if defined(__cplusplus) |
| 84 |
extern "C" { |
| 85 |
#endif |
| 86 |
|
| 87 |
ILexer5 * LEXILLA_CALL CreateLexer(const char *name); |
| 88 |
int LEXILLA_CALL GetLexerCount(void); |
| 89 |
void LEXILLA_CALL GetLexerName(unsigned int index, char *name, int buflength); |
| 90 |
LexerFactoryFunction LEXILLA_CALL GetLexerFactory(unsigned int index); |
| 91 |
DEPRECATE_DEFINITION const char *LEXILLA_CALL LexerNameFromID(int identifier); |
| 92 |
const char * LEXILLA_CALL GetLibraryPropertyNames(void); |
| 93 |
void LEXILLA_CALL SetLibraryProperty(const char *key, const char *value); |
| 94 |
const char *LEXILLA_CALL GetNameSpace(void); |
| 95 |
|
| 96 |
#if defined(__cplusplus) |
| 97 |
} |
| 98 |
#endif |
| 99 |
|
| 100 |
#if defined(__cplusplus) |
| 101 |
namespace Lexilla { |
| 102 |
class LexerModule; |
| 103 |
} |
| 104 |
// Add a static lexer (in the same binary) to Lexilla's list |
| 105 |
void AddStaticLexerModule(const Lexilla::LexerModule *plm); |
| 106 |
#endif |
| 107 |
|
| 108 |
#endif |