Blame src/plugins.hpp

Packit Service 7770af
#ifndef SASS_PLUGINS_H
Packit Service 7770af
#define SASS_PLUGINS_H
Packit Service 7770af
Packit Service 7770af
#include <string>
Packit Service 7770af
#include <vector>
Packit Service 7770af
#include "utf8_string.hpp"
Packit Service 7770af
#include "sass/functions.h"
Packit Service 7770af
Packit Service 7770af
#ifdef _WIN32
Packit Service 7770af
Packit Service 7770af
  #define LOAD_LIB(var, path) HMODULE var = LoadLibraryW(UTF_8::convert_to_utf16(path).c_str())
Packit Service 7770af
  #define LOAD_LIB_WCHR(var, path_wide_str) HMODULE var = LoadLibraryW(path_wide_str.c_str())
Packit Service 7770af
  #define LOAD_LIB_FN(type, var, name) type var = (type) GetProcAddress(plugin, name)
Packit Service 7770af
  #define CLOSE_LIB(var) FreeLibrary(var)
Packit Service 7770af
Packit Service 7770af
  #ifndef dlerror
Packit Service 7770af
  #define dlerror() 0
Packit Service 7770af
  #endif
Packit Service 7770af
Packit Service 7770af
#else
Packit Service 7770af
Packit Service 7770af
  #define LOAD_LIB(var, path) void* var = dlopen(path.c_str(), RTLD_LAZY)
Packit Service 7770af
  #define LOAD_LIB_FN(type, var, name) type var = (type) dlsym(plugin, name)
Packit Service 7770af
  #define CLOSE_LIB(var) dlclose(var)
Packit Service 7770af
Packit Service 7770af
#endif
Packit Service 7770af
Packit Service 7770af
namespace Sass {
Packit Service 7770af
Packit Service 7770af
Packit Service 7770af
  class Plugins {
Packit Service 7770af
Packit Service 7770af
    public: // c-tor
Packit Service 7770af
      Plugins(void);
Packit Service 7770af
      ~Plugins(void);
Packit Service 7770af
Packit Service 7770af
    public: // methods
Packit Service 7770af
      // load one specific plugin
Packit Service 7770af
      bool load_plugin(const std::string& path);
Packit Service 7770af
      // load all plugins from a directory
Packit Service 7770af
      size_t load_plugins(const std::string& path);
Packit Service 7770af
Packit Service 7770af
    public: // public accessors
Packit Service 7770af
      const std::vector<Sass_Importer_Entry> get_headers(void) { return headers; }
Packit Service 7770af
      const std::vector<Sass_Importer_Entry> get_importers(void) { return importers; }
Packit Service 7770af
      const std::vector<Sass_Function_Entry> get_functions(void) { return functions; }
Packit Service 7770af
Packit Service 7770af
    private: // private vars
Packit Service 7770af
      std::vector<Sass_Importer_Entry> headers;
Packit Service 7770af
      std::vector<Sass_Importer_Entry> importers;
Packit Service 7770af
      std::vector<Sass_Function_Entry> functions;
Packit Service 7770af
Packit Service 7770af
  };
Packit Service 7770af
Packit Service 7770af
}
Packit Service 7770af
Packit Service 7770af
#endif