Blame src/context.hpp

Packit Service 7770af
#ifndef SASS_CONTEXT_H
Packit Service 7770af
#define SASS_CONTEXT_H
Packit Service 7770af
Packit Service 7770af
#include <string>
Packit Service 7770af
#include <vector>
Packit Service 7770af
#include <map>
Packit Service 7770af
Packit Service 7770af
#define BUFFERSIZE 255
Packit Service 7770af
#include "b64/encode.h"
Packit Service 7770af
Packit Service 7770af
#include "ast_fwd_decl.hpp"
Packit Service 7770af
#include "kwd_arg_macros.hpp"
Packit Service 7770af
#include "ast_fwd_decl.hpp"
Packit Service 7770af
#include "sass_context.hpp"
Packit Service 7770af
#include "environment.hpp"
Packit Service 7770af
#include "source_map.hpp"
Packit Service 7770af
#include "subset_map.hpp"
Packit Service 7770af
#include "output.hpp"
Packit Service 7770af
#include "plugins.hpp"
Packit Service 7770af
#include "file.hpp"
Packit Service 7770af
Packit Service 7770af
Packit Service 7770af
struct Sass_Function;
Packit Service 7770af
Packit Service 7770af
namespace Sass {
Packit Service 7770af
Packit Service 7770af
  class Context {
Packit Service 7770af
  public:
Packit Service 7770af
    void import_url (Import_Ptr imp, std::string load_path, const std::string& ctx_path);
Packit Service 7770af
    bool call_headers(const std::string& load_path, const char* ctx_path, ParserState& pstate, Import_Ptr imp)
Packit Service 7770af
    { return call_loader(load_path, ctx_path, pstate, imp, c_headers, false); };
Packit Service 7770af
    bool call_importers(const std::string& load_path, const char* ctx_path, ParserState& pstate, Import_Ptr imp)
Packit Service 7770af
    { return call_loader(load_path, ctx_path, pstate, imp, c_importers, true); };
Packit Service 7770af
Packit Service 7770af
  private:
Packit Service 7770af
    bool call_loader(const std::string& load_path, const char* ctx_path, ParserState& pstate, Import_Ptr imp, std::vector<Sass_Importer_Entry> importers, bool only_one = true);
Packit Service 7770af
Packit Service 7770af
  public:
Packit Service 7770af
    const std::string CWD;
Packit Service 7770af
    struct Sass_Options& c_options;
Packit Service 7770af
    std::string entry_path;
Packit Service 7770af
    size_t head_imports;
Packit Service 7770af
    Plugins plugins;
Packit Service 7770af
    Output emitter;
Packit Service 7770af
Packit Service 7770af
    // generic ast node garbage container
Packit Service 7770af
    // used to avoid possible circular refs
Packit Service 7770af
    std::vector<AST_Node_Obj> ast_gc;
Packit Service 7770af
    // resources add under our control
Packit Service 7770af
    // these are guaranteed to be freed
Packit Service 7770af
    std::vector<char*> strings;
Packit Service 7770af
    std::vector<Resource> resources;
Packit Service 7770af
    std::map<const std::string, StyleSheet> sheets;
Packit Service 7770af
    Subset_Map subset_map;
Packit Service 7770af
    std::vector<Sass_Import_Entry> import_stack;
Packit Service 7770af
    std::vector<Sass_Callee> callee_stack;
Packit Service 7770af
Packit Service 7770af
    struct Sass_Compiler* c_compiler;
Packit Service 7770af
Packit Service 7770af
    // absolute paths to includes
Packit Service 7770af
    std::vector<std::string> included_files;
Packit Service 7770af
    // relative includes for sourcemap
Packit Service 7770af
    std::vector<std::string> srcmap_links;
Packit Service 7770af
    // vectors above have same size
Packit Service 7770af
Packit Service 7770af
    std::vector<std::string> plugin_paths; // relative paths to load plugins
Packit Service 7770af
    std::vector<std::string> include_paths; // lookup paths for includes
Packit Service 7770af
Packit Service 7770af
Packit Service 7770af
Packit Service 7770af
Packit Service 7770af
Packit Service 7770af
    void apply_custom_headers(Block_Obj root, const char* path, ParserState pstate);
Packit Service 7770af
Packit Service 7770af
    std::vector<Sass_Importer_Entry> c_headers;
Packit Service 7770af
    std::vector<Sass_Importer_Entry> c_importers;
Packit Service 7770af
    std::vector<Sass_Function_Entry> c_functions;
Packit Service 7770af
Packit Service 7770af
    void add_c_header(Sass_Importer_Entry header);
Packit Service 7770af
    void add_c_importer(Sass_Importer_Entry importer);
Packit Service 7770af
    void add_c_function(Sass_Function_Entry function);
Packit Service 7770af
Packit Service 7770af
    const std::string indent; // String to be used for indentation
Packit Service 7770af
    const std::string linefeed; // String to be used for line feeds
Packit Service 7770af
    const std::string input_path; // for relative paths in src-map
Packit Service 7770af
    const std::string output_path; // for relative paths to the output
Packit Service 7770af
    const std::string source_map_file; // path to source map file (enables feature)
Packit Service 7770af
    const std::string source_map_root; // path for sourceRoot property (pass-through)
Packit Service 7770af
Packit Service 7770af
    virtual ~Context();
Packit Service 7770af
    Context(struct Sass_Context&);
Packit Service 7770af
    virtual Block_Obj parse() = 0;
Packit Service 7770af
    virtual Block_Obj compile();
Packit Service 7770af
    virtual char* render(Block_Obj root);
Packit Service 7770af
    virtual char* render_srcmap();
Packit Service 7770af
Packit Service 7770af
    void register_resource(const Include&, const Resource&, ParserState* = 0);
Packit Service 7770af
    std::vector<Include> find_includes(const Importer& import);
Packit Service 7770af
    Include load_import(const Importer&, ParserState pstate);
Packit Service 7770af
Packit Service 7770af
    Sass_Output_Style output_style() { return c_options.output_style; };
Packit Service 7770af
    std::vector<std::string> get_included_files(bool skip = false, size_t headers = 0);
Packit Service 7770af
Packit Service 7770af
  private:
Packit Service 7770af
    void collect_plugin_paths(const char* paths_str);
Packit Service 7770af
    void collect_plugin_paths(string_list* paths_array);
Packit Service 7770af
    void collect_include_paths(const char* paths_str);
Packit Service 7770af
    void collect_include_paths(string_list* paths_array);
Packit Service 7770af
    std::string format_embedded_source_map();
Packit Service 7770af
    std::string format_source_mapping_url(const std::string& out_path);
Packit Service 7770af
Packit Service 7770af
Packit Service 7770af
    // void register_built_in_functions(Env* env);
Packit Service 7770af
    // void register_function(Signature sig, Native_Function f, Env* env);
Packit Service 7770af
    // void register_function(Signature sig, Native_Function f, size_t arity, Env* env);
Packit Service 7770af
    // void register_overload_stub(std::string name, Env* env);
Packit Service 7770af
Packit Service 7770af
  public:
Packit Service 7770af
    const std::string& cwd() { return CWD; };
Packit Service 7770af
  };
Packit Service 7770af
Packit Service 7770af
  class File_Context : public Context {
Packit Service 7770af
  public:
Packit Service 7770af
    File_Context(struct Sass_File_Context& ctx)
Packit Service 7770af
    : Context(ctx)
Packit Service 7770af
    { }
Packit Service 7770af
    virtual ~File_Context();
Packit Service 7770af
    virtual Block_Obj parse();
Packit Service 7770af
  };
Packit Service 7770af
Packit Service 7770af
  class Data_Context : public Context {
Packit Service 7770af
  public:
Packit Service 7770af
    char* source_c_str;
Packit Service 7770af
    char* srcmap_c_str;
Packit Service 7770af
    Data_Context(struct Sass_Data_Context& ctx)
Packit Service 7770af
    : Context(ctx)
Packit Service 7770af
    {
Packit Service 7770af
      source_c_str       = ctx.source_string;
Packit Service 7770af
      srcmap_c_str       = ctx.srcmap_string;
Packit Service 7770af
      ctx.source_string = 0; // passed away
Packit Service 7770af
      ctx.srcmap_string = 0; // passed away
Packit Service 7770af
    }
Packit Service 7770af
    virtual ~Data_Context();
Packit Service 7770af
    virtual Block_Obj parse();
Packit Service 7770af
  };
Packit Service 7770af
Packit Service 7770af
}
Packit Service 7770af
Packit Service 7770af
#endif