Example #1
0
  Context::Context(Context::Data initializers)
  : mem(Memory_Manager<AST_Node>()),
    source_c_str    (initializers.source_c_str()),
    sources         (vector<const char*>()),
    include_paths   (initializers.include_paths()),
    queue           (vector<pair<string, const char*> >()),
    style_sheets    (map<string, Block*>()),
    source_map(File::base_name(initializers.entry_point())),
    image_path      (initializers.image_path()),
    source_comments (initializers.source_comments()),
    source_maps     (initializers.source_maps()),
    output_style    (initializers.output_style()),
    source_map_file (initializers.source_map_file()),
    names_to_colors (map<string, Color*>()),
    colors_to_names (map<int, string>())
  {
    cwd = get_cwd();
    
    collect_include_paths(initializers.include_paths_c_str());
    collect_include_paths(initializers.include_paths_array());

    setup_color_map();

    string entry_point = initializers.entry_point();
    if (!entry_point.empty()) {
      string result(add_file(entry_point));
      if (result.empty()) {
        throw entry_point;
      }
    }
  }
Example #2
0
  Context::Context(Context::Data initializers)
  : mem(Memory_Manager<AST_Node>()),
    source_c_str         (initializers.source_c_str()),
    sources              (vector<const char*>()),
    include_paths        (initializers.include_paths()),
    queue                (vector<pair<string, const char*> >()),
    style_sheets         (map<string, Block*>()),
    source_map           (resolve_relative_path(initializers.output_path(), initializers.source_map_file(), get_cwd())),
    c_functions          (vector<Sass_C_Function_Descriptor>()),
    image_path           (initializers.image_path()),
    output_path          (make_canonical_path(initializers.output_path())),
    source_comments      (initializers.source_comments()),
    output_style         (initializers.output_style()),
    source_map_file      (make_canonical_path(initializers.source_map_file())),
    omit_source_map_url  (initializers.omit_source_map_url()),
    names_to_colors      (map<string, Color*>()),
    colors_to_names      (map<int, string>()),
    precision            (initializers.precision()),
    subset_map           (Subset_Map<string, pair<Complex_Selector*, Compound_Selector*> >())
  {
    cwd = get_cwd();

    collect_include_paths(initializers.include_paths_c_str());
    collect_include_paths(initializers.include_paths_array());

    setup_color_map();

    string entry_point = initializers.entry_point();
    if (!entry_point.empty()) {
      string result(add_file(entry_point));
      if (result.empty()) {
        throw "File to read not found or unreadable: " + entry_point;
      }
    }
  }
Example #3
0
  Context::Context(Context::Data initializers)
  : mem(Memory_Manager<AST_Node>()),
    source_c_str            (initializers.source_c_str()),
    sources                 (vector<const char*>()),
    include_paths           (initializers.include_paths()),
    queue                   (vector<Sass_Queued>()),
    style_sheets            (map<string, Block*>()),
    source_map              (resolve_relative_path(initializers.output_path(), initializers.source_map_file(), get_cwd())),
    c_functions             (vector<Sass_C_Function_Callback>()),
    image_path              (initializers.image_path()),
    input_path              (make_canonical_path(initializers.input_path())),
    output_path             (make_canonical_path(initializers.output_path())),
    source_comments         (initializers.source_comments()),
    output_style            (initializers.output_style()),
    source_map_file         (make_canonical_path(initializers.source_map_file())),
    source_map_embed        (initializers.source_map_embed()),
    source_map_contents     (initializers.source_map_contents()),
    omit_source_map_url     (initializers.omit_source_map_url()),
    is_indented_syntax_src  (initializers.is_indented_syntax_src()),
    importer                (initializers.importer()),
    names_to_colors         (map<string, Color*>()),
    colors_to_names         (map<int, string>()),
    precision               (initializers.precision()),
    _skip_source_map_update (initializers._skip_source_map_update()),
    subset_map              (Subset_Map<string, pair<Complex_Selector*, Compound_Selector*> >())
  {
    cwd = get_cwd();

    // enforce some safe defaults
    // used to create relative file links
    if (input_path == "") input_path = "stdin";
    if (output_path == "") output_path = "stdout";

    include_paths.push_back(cwd);
    collect_include_paths(initializers.include_paths_c_str());
    collect_include_paths(initializers.include_paths_array());

    setup_color_map();

    string entry_point = initializers.entry_point();
    if (!entry_point.empty()) {
      string result(add_file(entry_point));
      if (result.empty()) {
        throw "File to read not found or unreadable: " + entry_point;
      }
    }
  }
Example #4
0
  Context::Context(Context::Data initializers)
  : // Output(this),
    head_imports(0),
    mem(Memory_Manager<AST_Node>()),
    c_options               (initializers.c_options()),
    c_compiler              (initializers.c_compiler()),
    source_c_str            (initializers.source_c_str()),
    sources                 (vector<const char*>()),
    plugin_paths            (initializers.plugin_paths()),
    include_paths           (initializers.include_paths()),
    queue                   (vector<Sass_Queued>()),
    style_sheets            (map<string, Block*>()),
    emitter (this),
    c_headers               (vector<Sass_Importer_Entry>()),
    c_importers             (vector<Sass_Importer_Entry>()),
    c_functions             (vector<Sass_Function_Entry>()),
    indent                  (initializers.indent()),
    linefeed                (initializers.linefeed()),
    input_path              (make_canonical_path(initializers.input_path())),
    output_path             (make_canonical_path(initializers.output_path())),
    source_comments         (initializers.source_comments()),
    output_style            (initializers.output_style()),
    source_map_file         (make_canonical_path(initializers.source_map_file())),
    source_map_root         (initializers.source_map_root()), // pass-through
    source_map_embed        (initializers.source_map_embed()),
    source_map_contents     (initializers.source_map_contents()),
    omit_source_map_url     (initializers.omit_source_map_url()),
    is_indented_syntax_src  (initializers.is_indented_syntax_src()),
    names_to_colors         (map<string, Color*>()),
    colors_to_names         (map<int, string>()),
    precision               (initializers.precision()),
    plugins(),
    subset_map              (Subset_Map<string, pair<Complex_Selector*, Compound_Selector*> >())
  {

    cwd = get_cwd();

    // enforce some safe defaults
    // used to create relative file links
    if (input_path == "") input_path = "stdin";
    if (output_path == "") output_path = "stdout";

    include_paths.push_back(cwd);
    collect_include_paths(initializers.include_paths_c_str());
    // collect_include_paths(initializers.include_paths_array());
    collect_plugin_paths(initializers.plugin_paths_c_str());
    // collect_plugin_paths(initializers.plugin_paths_array());

    setup_color_map();

    for (size_t i = 0, S = plugin_paths.size(); i < S; ++i) {
      plugins.load_plugins(plugin_paths[i]);
    }

    for(auto fn : plugins.get_functions()) {
      c_functions.push_back(fn);
    }
    for(auto fn : plugins.get_headers()) {
      c_headers.push_back(fn);
    }
    for(auto fn : plugins.get_importers()) {
      c_importers.push_back(fn);
    }

    sort (c_headers.begin(), c_headers.end(), sort_importers);
    sort (c_importers.begin(), c_importers.end(), sort_importers);
    string entry_point = initializers.entry_point();
    if (!entry_point.empty()) {
      string result(add_file(entry_point));
      if (result.empty()) {
        throw "File to read not found or unreadable: " + entry_point;
      }
    }

    emitter.set_filename(resolve_relative_path(output_path, source_map_file, cwd));

  }