1 | #ifndef SASS_PLUGINS_H |
2 | #define SASS_PLUGINS_H |
3 | |
4 | #include <string> |
5 | #include <vector> |
6 | #include "utf8_string.hpp" |
7 | #include "sass/functions.h" |
8 | |
9 | #ifdef _WIN32 |
10 | |
11 | #define LOAD_LIB(var, path) HMODULE var = LoadLibraryW(UTF_8::convert_to_utf16(path).c_str()) |
12 | #define LOAD_LIB_WCHR(var, path_wide_str) HMODULE var = LoadLibraryW(path_wide_str.c_str()) |
13 | #define LOAD_LIB_FN(type, var, name) type var = (type) GetProcAddress(plugin, name) |
14 | #define CLOSE_LIB(var) FreeLibrary(var) |
15 | |
16 | #ifndef dlerror |
17 | #define dlerror() 0 |
18 | #endif |
19 | |
20 | #else |
21 | |
22 | #define LOAD_LIB(var, path) void* var = dlopen(path.c_str(), RTLD_LAZY) |
23 | #define LOAD_LIB_FN(type, var, name) type var = (type) dlsym(plugin, name) |
24 | #define CLOSE_LIB(var) dlclose(var) |
25 | |
26 | #endif |
27 | |
28 | namespace Sass { |
29 | |
30 | |
31 | class Plugins { |
32 | |
33 | public: // c-tor |
34 | Plugins(void); |
35 | ~Plugins(void); |
36 | |
37 | public: // methods |
38 | // load one specific plugin |
39 | bool load_plugin(const sass::string& path); |
40 | // load all plugins from a directory |
41 | size_t load_plugins(const sass::string& path); |
42 | |
43 | public: // public accessors |
44 | const sass::vector<Sass_Importer_Entry> (void) { return headers; } |
45 | const sass::vector<Sass_Importer_Entry> get_importers(void) { return importers; } |
46 | const sass::vector<Sass_Function_Entry> get_functions(void) { return functions; } |
47 | |
48 | private: // private vars |
49 | sass::vector<Sass_Importer_Entry> ; |
50 | sass::vector<Sass_Importer_Entry> importers; |
51 | sass::vector<Sass_Function_Entry> functions; |
52 | |
53 | }; |
54 | |
55 | } |
56 | |
57 | #endif |
58 | |