sassc 2.3.0 → 2.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (116) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +1 -0
  3. data/CHANGELOG.md +5 -0
  4. data/ext/libsass/VERSION +1 -1
  5. data/ext/libsass/include/sass/context.h +3 -0
  6. data/ext/libsass/src/MurmurHash2.hpp +91 -0
  7. data/ext/libsass/src/ast.cpp +117 -117
  8. data/ext/libsass/src/ast.hpp +160 -162
  9. data/ext/libsass/src/ast_def_macros.hpp +10 -10
  10. data/ext/libsass/src/ast_fwd_decl.cpp +2 -2
  11. data/ext/libsass/src/ast_fwd_decl.hpp +61 -52
  12. data/ext/libsass/src/ast_helpers.hpp +5 -5
  13. data/ext/libsass/src/ast_sel_cmp.cpp +18 -18
  14. data/ext/libsass/src/ast_sel_super.cpp +52 -52
  15. data/ext/libsass/src/ast_sel_unify.cpp +16 -16
  16. data/ext/libsass/src/ast_sel_weave.cpp +62 -62
  17. data/ext/libsass/src/ast_selectors.cpp +87 -77
  18. data/ext/libsass/src/ast_selectors.hpp +72 -62
  19. data/ext/libsass/src/ast_supports.cpp +35 -35
  20. data/ext/libsass/src/ast_supports.hpp +29 -29
  21. data/ext/libsass/src/ast_values.cpp +58 -58
  22. data/ext/libsass/src/ast_values.hpp +75 -75
  23. data/ext/libsass/src/backtrace.cpp +9 -9
  24. data/ext/libsass/src/backtrace.hpp +5 -5
  25. data/ext/libsass/src/base64vlq.cpp +2 -2
  26. data/ext/libsass/src/base64vlq.hpp +1 -1
  27. data/ext/libsass/src/bind.cpp +17 -17
  28. data/ext/libsass/src/bind.hpp +1 -1
  29. data/ext/libsass/src/c2ast.cpp +3 -3
  30. data/ext/libsass/src/c2ast.hpp +1 -1
  31. data/ext/libsass/src/check_nesting.cpp +36 -36
  32. data/ext/libsass/src/check_nesting.hpp +2 -2
  33. data/ext/libsass/src/color_maps.cpp +5 -5
  34. data/ext/libsass/src/color_maps.hpp +1 -1
  35. data/ext/libsass/src/context.cpp +63 -60
  36. data/ext/libsass/src/context.hpp +33 -33
  37. data/ext/libsass/src/cssize.cpp +30 -29
  38. data/ext/libsass/src/cssize.hpp +13 -13
  39. data/ext/libsass/src/dart_helpers.hpp +5 -5
  40. data/ext/libsass/src/debugger.hpp +127 -128
  41. data/ext/libsass/src/emitter.cpp +12 -12
  42. data/ext/libsass/src/emitter.hpp +10 -10
  43. data/ext/libsass/src/environment.cpp +27 -27
  44. data/ext/libsass/src/environment.hpp +24 -24
  45. data/ext/libsass/src/error_handling.cpp +42 -42
  46. data/ext/libsass/src/error_handling.hpp +38 -50
  47. data/ext/libsass/src/eval.cpp +138 -132
  48. data/ext/libsass/src/eval.hpp +17 -17
  49. data/ext/libsass/src/eval_selectors.cpp +3 -3
  50. data/ext/libsass/src/expand.cpp +70 -64
  51. data/ext/libsass/src/expand.hpp +12 -12
  52. data/ext/libsass/src/extender.cpp +55 -53
  53. data/ext/libsass/src/extender.hpp +14 -14
  54. data/ext/libsass/src/file.cpp +66 -58
  55. data/ext/libsass/src/file.hpp +23 -25
  56. data/ext/libsass/src/fn_colors.cpp +9 -9
  57. data/ext/libsass/src/fn_lists.cpp +18 -18
  58. data/ext/libsass/src/fn_maps.cpp +3 -3
  59. data/ext/libsass/src/fn_miscs.cpp +15 -15
  60. data/ext/libsass/src/fn_numbers.cpp +7 -7
  61. data/ext/libsass/src/fn_selectors.cpp +8 -8
  62. data/ext/libsass/src/fn_strings.cpp +34 -22
  63. data/ext/libsass/src/fn_utils.cpp +29 -26
  64. data/ext/libsass/src/fn_utils.hpp +10 -10
  65. data/ext/libsass/src/inspect.cpp +35 -34
  66. data/ext/libsass/src/inspect.hpp +21 -21
  67. data/ext/libsass/src/lexer.cpp +3 -1
  68. data/ext/libsass/src/listize.cpp +2 -2
  69. data/ext/libsass/src/mapping.hpp +1 -0
  70. data/ext/libsass/src/memory.hpp +12 -0
  71. data/ext/libsass/src/memory/allocator.cpp +48 -0
  72. data/ext/libsass/src/memory/allocator.hpp +138 -0
  73. data/ext/libsass/src/memory/config.hpp +20 -0
  74. data/ext/libsass/src/memory/memory_pool.hpp +186 -0
  75. data/ext/libsass/src/memory/{SharedPtr.cpp → shared_ptr.cpp} +2 -2
  76. data/ext/libsass/src/memory/{SharedPtr.hpp → shared_ptr.hpp} +18 -6
  77. data/ext/libsass/src/operation.hpp +44 -44
  78. data/ext/libsass/src/operators.cpp +18 -18
  79. data/ext/libsass/src/operators.hpp +11 -11
  80. data/ext/libsass/src/ordered_map.hpp +18 -18
  81. data/ext/libsass/src/output.cpp +16 -16
  82. data/ext/libsass/src/output.hpp +5 -5
  83. data/ext/libsass/src/parser.cpp +327 -345
  84. data/ext/libsass/src/parser.hpp +77 -87
  85. data/ext/libsass/src/parser_selectors.cpp +6 -6
  86. data/ext/libsass/src/permutate.hpp +39 -15
  87. data/ext/libsass/src/plugins.cpp +7 -7
  88. data/ext/libsass/src/plugins.hpp +8 -8
  89. data/ext/libsass/src/position.cpp +7 -26
  90. data/ext/libsass/src/position.hpp +44 -21
  91. data/ext/libsass/src/remove_placeholders.cpp +4 -4
  92. data/ext/libsass/src/remove_placeholders.hpp +3 -3
  93. data/ext/libsass/src/sass.cpp +16 -15
  94. data/ext/libsass/src/sass.hpp +9 -5
  95. data/ext/libsass/src/sass_context.cpp +52 -34
  96. data/ext/libsass/src/sass_values.cpp +8 -10
  97. data/ext/libsass/src/settings.hpp +19 -0
  98. data/ext/libsass/src/source.cpp +69 -0
  99. data/ext/libsass/src/source.hpp +95 -0
  100. data/ext/libsass/src/source_data.hpp +32 -0
  101. data/ext/libsass/src/source_map.cpp +22 -18
  102. data/ext/libsass/src/source_map.hpp +12 -9
  103. data/ext/libsass/src/units.cpp +19 -19
  104. data/ext/libsass/src/units.hpp +8 -8
  105. data/ext/libsass/src/utf8_string.cpp +9 -10
  106. data/ext/libsass/src/utf8_string.hpp +7 -6
  107. data/ext/libsass/src/util.cpp +38 -38
  108. data/ext/libsass/src/util.hpp +18 -18
  109. data/ext/libsass/src/util_string.cpp +13 -13
  110. data/ext/libsass/src/util_string.hpp +9 -8
  111. data/ext/libsass/src/values.cpp +12 -12
  112. data/lib/sassc/native.rb +3 -5
  113. data/lib/sassc/version.rb +1 -1
  114. data/test/native_test.rb +4 -4
  115. metadata +14 -5
  116. data/lib/sassc/native/lib_c.rb +0 -21
@@ -12,7 +12,7 @@ namespace Sass {
12
12
 
13
13
  class CheckNesting : public Operation_CRTP<Statement*, CheckNesting> {
14
14
 
15
- std::vector<Statement*> parents;
15
+ sass::vector<Statement*> parents;
16
16
  Backtraces traces;
17
17
  Statement* parent;
18
18
  Definition* current_mixin_definition;
@@ -33,7 +33,7 @@ namespace Sass {
33
33
  Statement* s = Cast<Statement>(x);
34
34
  if (s && this->should_visit(s)) {
35
35
  Block* b1 = Cast<Block>(s);
36
- Has_Block* b2 = Cast<Has_Block>(s);
36
+ ParentStatement* b2 = Cast<ParentStatement>(s);
37
37
  if (b1 || b2) return visit_children(s);
38
38
  }
39
39
  return s;
@@ -162,7 +162,7 @@ namespace Sass {
162
162
  }
163
163
 
164
164
  namespace Colors {
165
- const ParserState color_table("[COLOR TABLE]");
165
+ const SourceSpan color_table("[COLOR TABLE]");
166
166
  const Color_RGBA aliceblue(color_table, 240, 248, 255, 1);
167
167
  const Color_RGBA antiquewhite(color_table, 250, 235, 215, 1);
168
168
  const Color_RGBA cyan(color_table, 0, 255, 255, 1);
@@ -456,7 +456,7 @@ namespace Sass {
456
456
  { 102 * 0x10000 + 51 * 0x100 + 153, ColorNames::rebeccapurple }
457
457
  };
458
458
 
459
- static const auto *const names_to_colors = new std::unordered_map<std::string, const Color_RGBA*>
459
+ static const auto *const names_to_colors = new std::unordered_map<sass::string, const Color_RGBA*>
460
460
  {
461
461
  { ColorNames::aliceblue, &Colors::aliceblue },
462
462
  { ColorNames::antiquewhite, &Colors::antiquewhite },
@@ -611,13 +611,13 @@ namespace Sass {
611
611
 
612
612
  const Color_RGBA* name_to_color(const char* key)
613
613
  {
614
- return name_to_color(std::string(key));
614
+ return name_to_color(sass::string(key));
615
615
  }
616
616
 
617
- const Color_RGBA* name_to_color(const std::string& key)
617
+ const Color_RGBA* name_to_color(const sass::string& key)
618
618
  {
619
619
  // case insensitive lookup. See #2462
620
- std::string lower = key;
620
+ sass::string lower = key;
621
621
  Util::ascii_str_tolower(&lower);
622
622
 
623
623
  auto p = names_to_colors->find(lower);
@@ -313,7 +313,7 @@ namespace Sass {
313
313
  }
314
314
 
315
315
  const Color_RGBA* name_to_color(const char*);
316
- const Color_RGBA* name_to_color(const std::string&);
316
+ const Color_RGBA* name_to_color(const sass::string&);
317
317
  const char* color_to_name(const int);
318
318
  const char* color_to_name(const Color_RGBA&);
319
319
  const char* color_to_name(const double);
@@ -17,6 +17,7 @@
17
17
  #include "expand.hpp"
18
18
  #include "parser.hpp"
19
19
  #include "cssize.hpp"
20
+ #include "source.hpp"
20
21
 
21
22
  namespace Sass {
22
23
  using namespace Constants;
@@ -26,13 +27,13 @@ namespace Sass {
26
27
  inline bool sort_importers (const Sass_Importer_Entry& i, const Sass_Importer_Entry& j)
27
28
  { return sass_importer_get_priority(i) > sass_importer_get_priority(j); }
28
29
 
29
- static std::string safe_input(const char* in_path)
30
+ static sass::string safe_input(const char* in_path)
30
31
  {
31
32
  if (in_path == nullptr || in_path[0] == '\0') return "stdin";
32
33
  return in_path;
33
34
  }
34
35
 
35
- static std::string safe_output(const char* out_path, std::string input_path)
36
+ static sass::string safe_output(const char* out_path, sass::string input_path)
36
37
  {
37
38
  if (out_path == nullptr || out_path[0] == '\0') {
38
39
  if (input_path.empty()) return "stdout";
@@ -59,9 +60,9 @@ namespace Sass {
59
60
  extender(Extender::NORMAL, traces),
60
61
  c_compiler(NULL),
61
62
 
62
- c_headers (std::vector<Sass_Importer_Entry>()),
63
- c_importers (std::vector<Sass_Importer_Entry>()),
64
- c_functions (std::vector<Sass_Function_Entry>()),
63
+ c_headers (sass::vector<Sass_Importer_Entry>()),
64
+ c_importers (sass::vector<Sass_Importer_Entry>()),
65
+ c_functions (sass::vector<Sass_Function_Entry>()),
65
66
 
66
67
  indent (safe_str(c_options.indent, " ")),
67
68
  linefeed (safe_str(c_options.linefeed, "\n")),
@@ -155,7 +156,7 @@ namespace Sass {
155
156
  const char* end = Prelexer::find_first<PATH_SEP>(beg);
156
157
 
157
158
  while (end) {
158
- std::string path(beg, end - beg);
159
+ sass::string path(beg, end - beg);
159
160
  if (!path.empty()) {
160
161
  if (*path.rbegin() != '/') path += '/';
161
162
  include_paths.push_back(path);
@@ -164,7 +165,7 @@ namespace Sass {
164
165
  end = Prelexer::find_first<PATH_SEP>(beg);
165
166
  }
166
167
 
167
- std::string path(beg);
168
+ sass::string path(beg);
168
169
  if (!path.empty()) {
169
170
  if (*path.rbegin() != '/') path += '/';
170
171
  include_paths.push_back(path);
@@ -188,7 +189,7 @@ namespace Sass {
188
189
  const char* end = Prelexer::find_first<PATH_SEP>(beg);
189
190
 
190
191
  while (end) {
191
- std::string path(beg, end - beg);
192
+ sass::string path(beg, end - beg);
192
193
  if (!path.empty()) {
193
194
  if (*path.rbegin() != '/') path += '/';
194
195
  plugin_paths.push_back(path);
@@ -197,7 +198,7 @@ namespace Sass {
197
198
  end = Prelexer::find_first<PATH_SEP>(beg);
198
199
  }
199
200
 
200
- std::string path(beg);
201
+ sass::string path(beg);
201
202
  if (!path.empty()) {
202
203
  if (*path.rbegin() != '/') path += '/';
203
204
  plugin_paths.push_back(path);
@@ -216,17 +217,17 @@ namespace Sass {
216
217
 
217
218
  // resolve the imp_path in base_path or include_paths
218
219
  // looks for alternatives and returns a list from one directory
219
- std::vector<Include> Context::find_includes(const Importer& import)
220
+ sass::vector<Include> Context::find_includes(const Importer& import)
220
221
  {
221
222
  // make sure we resolve against an absolute path
222
- std::string base_path(rel2abs(import.base_path));
223
+ sass::string base_path(rel2abs(import.base_path));
223
224
  // first try to resolve the load path relative to the base path
224
- std::vector<Include> vec(resolve_includes(base_path, import.imp_path));
225
+ sass::vector<Include> vec(resolve_includes(base_path, import.imp_path));
225
226
  // then search in every include path (but only if nothing found yet)
226
227
  for (size_t i = 0, S = include_paths.size(); vec.size() == 0 && i < S; ++i)
227
228
  {
228
229
  // call resolve_includes and individual base path and append all results
229
- std::vector<Include> resolved(resolve_includes(include_paths[i], import.imp_path));
230
+ sass::vector<Include> resolved(resolve_includes(include_paths[i], import.imp_path));
230
231
  if (resolved.size()) vec.insert(vec.end(), resolved.begin(), resolved.end());
231
232
  }
232
233
  // return vector
@@ -273,22 +274,22 @@ namespace Sass {
273
274
 
274
275
  // get pointer to the loaded content
275
276
  const char* contents = resources[idx].contents;
276
- // keep a copy of the path around (for parserstates)
277
- // ToDo: we clean it, but still not very elegant!?
278
- strings.push_back(sass_copy_c_string(inc.abs_path.c_str()));
277
+ SourceFileObj source = SASS_MEMORY_NEW(SourceFile,
278
+ inc.abs_path.c_str(), contents, idx);
279
+
279
280
  // create the initial parser state from resource
280
- ParserState pstate(strings.back(), contents, idx);
281
+ SourceSpan pstate(source);
281
282
 
282
283
  // check existing import stack for possible recursion
283
284
  for (size_t i = 0; i < import_stack.size() - 2; ++i) {
284
285
  auto parent = import_stack[i];
285
286
  if (std::strcmp(parent->abs_path, import->abs_path) == 0) {
286
- std::string cwd(File::get_cwd());
287
+ sass::string cwd(File::get_cwd());
287
288
  // make path relative to the current directory
288
- std::string stack("An @import loop has been found:");
289
+ sass::string stack("An @import loop has been found:");
289
290
  for (size_t n = 1; n < i + 2; ++n) {
290
- stack += "\n " + std::string(File::abs2rel(import_stack[n]->abs_path, cwd, cwd)) +
291
- " imports " + std::string(File::abs2rel(import_stack[n+1]->abs_path, cwd, cwd));
291
+ stack += "\n " + sass::string(File::abs2rel(import_stack[n]->abs_path, cwd, cwd)) +
292
+ " imports " + sass::string(File::abs2rel(import_stack[n+1]->abs_path, cwd, cwd));
292
293
  }
293
294
  // implement error throw directly until we
294
295
  // decided how to handle full stack traces
@@ -298,7 +299,7 @@ namespace Sass {
298
299
  }
299
300
 
300
301
  // create a parser instance from the given c_str buffer
301
- Parser p(Parser::from_c_str(contents, *this, traces, pstate));
302
+ Parser p(source, *this, traces);
302
303
  // do not yet dispose these buffers
303
304
  sass_import_take_source(import);
304
305
  sass_import_take_srcmap(import);
@@ -309,7 +310,7 @@ namespace Sass {
309
310
  // remove current stack frame
310
311
  import_stack.pop_back();
311
312
  // create key/value pair for ast node
312
- std::pair<const std::string, StyleSheet>
313
+ std::pair<const sass::string, StyleSheet>
313
314
  ast_pair(inc.abs_path, { res, root });
314
315
  // register resulting resource
315
316
  sheets.insert(ast_pair);
@@ -317,7 +318,7 @@ namespace Sass {
317
318
 
318
319
  // register include with resolved path and its content
319
320
  // memory of the resources will be freed by us on exit
320
- void Context::register_resource(const Include& inc, const Resource& res, ParserState& prstate)
321
+ void Context::register_resource(const Include& inc, const Resource& res, SourceSpan& prstate)
321
322
  {
322
323
  traces.push_back(Backtrace(prstate));
323
324
  register_resource(inc, res);
@@ -325,16 +326,16 @@ namespace Sass {
325
326
  }
326
327
 
327
328
  // Add a new import to the context (called from `import_url`)
328
- Include Context::load_import(const Importer& imp, ParserState pstate)
329
+ Include Context::load_import(const Importer& imp, SourceSpan pstate)
329
330
  {
330
331
 
331
332
  // search for valid imports (ie. partials) on the filesystem
332
333
  // this may return more than one valid result (ambiguous imp_path)
333
- const std::vector<Include> resolved(find_includes(imp));
334
+ const sass::vector<Include> resolved(find_includes(imp));
334
335
 
335
336
  // error nicely on ambiguous imp_path
336
337
  if (resolved.size() > 1) {
337
- std::stringstream msg_stream;
338
+ sass::ostream msg_stream;
338
339
  msg_stream << "It's not clear which file to import for ";
339
340
  msg_stream << "'@import \"" << imp.imp_path << "\"'." << "\n";
340
341
  msg_stream << "Candidates:" << "\n";
@@ -364,16 +365,16 @@ namespace Sass {
364
365
 
365
366
  }
366
367
 
367
- void Context::import_url (Import* imp, std::string load_path, const std::string& ctx_path) {
368
+ void Context::import_url (Import* imp, sass::string load_path, const sass::string& ctx_path) {
368
369
 
369
- ParserState pstate(imp->pstate());
370
- std::string imp_path(unquote(load_path));
371
- std::string protocol("file");
370
+ SourceSpan pstate(imp->pstate());
371
+ sass::string imp_path(unquote(load_path));
372
+ sass::string protocol("file");
372
373
 
373
374
  using namespace Prelexer;
374
375
  if (const char* proto = sequence< identifier, exactly<':'>, exactly<'/'>, exactly<'/'> >(imp_path.c_str())) {
375
376
 
376
- protocol = std::string(imp_path.c_str(), proto - 3);
377
+ protocol = sass::string(imp_path.c_str(), proto - 3);
377
378
  // if (protocol.compare("file") && true) { }
378
379
  }
379
380
 
@@ -387,7 +388,7 @@ namespace Sass {
387
388
  Argument_Obj loc_arg = SASS_MEMORY_NEW(Argument, pstate, loc);
388
389
  Arguments_Obj loc_args = SASS_MEMORY_NEW(Arguments, pstate);
389
390
  loc_args->append(loc_arg);
390
- Function_Call* new_url = SASS_MEMORY_NEW(Function_Call, pstate, std::string("url"), loc_args);
391
+ Function_Call* new_url = SASS_MEMORY_NEW(Function_Call, pstate, sass::string("url"), loc_args);
391
392
  imp->urls().push_back(new_url);
392
393
  }
393
394
  else {
@@ -403,7 +404,7 @@ namespace Sass {
403
404
 
404
405
 
405
406
  // call custom importers on the given (unquoted) load_path and eventually parse the resulting style_sheet
406
- bool Context::call_loader(const std::string& load_path, const char* ctx_path, ParserState& pstate, Import* imp, std::vector<Sass_Importer_Entry> importers, bool only_one)
407
+ bool Context::call_loader(const sass::string& load_path, const char* ctx_path, SourceSpan& pstate, Import* imp, sass::vector<Sass_Importer_Entry> importers, bool only_one)
407
408
  {
408
409
  // unique counter
409
410
  size_t count = 0;
@@ -421,9 +422,9 @@ namespace Sass {
421
422
  Sass_Import_List it_includes = includes;
422
423
  while (*it_includes) { ++count;
423
424
  // create unique path to use as key
424
- std::string uniq_path = load_path;
425
+ sass::string uniq_path = load_path;
425
426
  if (!only_one && count) {
426
- std::stringstream path_strm;
427
+ sass::ostream path_strm;
427
428
  path_strm << uniq_path << ":" << count;
428
429
  uniq_path = path_strm.str();
429
430
  }
@@ -440,14 +441,14 @@ namespace Sass {
440
441
  // it may (or may not) override the line and column info
441
442
  if (const char* err_message = sass_import_get_error_message(include_ent)) {
442
443
  if (source || srcmap) register_resource({ importer, uniq_path }, { source, srcmap }, pstate);
443
- if (line == std::string::npos && column == std::string::npos) error(err_message, pstate, traces);
444
- else error(err_message, ParserState(ctx_path, source, Position(line, column)), traces);
444
+ if (line == sass::string::npos && column == sass::string::npos) error(err_message, pstate, traces);
445
+ else { error(err_message, { pstate.source, { line, column } }, traces); }
445
446
  }
446
447
  // content for import was set
447
448
  else if (source) {
448
449
  // resolved abs_path should be set by custom importer
449
450
  // use the created uniq_path as fallback (maybe enforce)
450
- std::string path_key(abs_path ? abs_path : uniq_path);
451
+ sass::string path_key(abs_path ? abs_path : uniq_path);
451
452
  // create the importer struct
452
453
  Include include(importer, path_key);
453
454
  // attach information to AST node
@@ -484,7 +485,7 @@ namespace Sass {
484
485
 
485
486
  void register_function(Context&, Signature sig, Native_Function f, Env* env);
486
487
  void register_function(Context&, Signature sig, Native_Function f, size_t arity, Env* env);
487
- void register_overload_stub(Context&, std::string name, Env* env);
488
+ void register_overload_stub(Context&, sass::string name, Env* env);
488
489
  void register_built_in_functions(Context&, Env* env);
489
490
  void register_c_functions(Context&, Env* env, Sass_Function_List);
490
491
  void register_c_function(Context&, Env* env, Sass_Function_Entry);
@@ -517,7 +518,7 @@ namespace Sass {
517
518
  return sass_copy_c_string(emitted.buffer.c_str());
518
519
  }
519
520
 
520
- void Context::apply_custom_headers(Block_Obj root, const char* ctx_path, ParserState pstate)
521
+ void Context::apply_custom_headers(Block_Obj root, const char* ctx_path, SourceSpan pstate)
521
522
  {
522
523
  // create a custom import to resolve headers
523
524
  Import_Obj imp = SASS_MEMORY_NEW(Import, pstate);
@@ -542,7 +543,7 @@ namespace Sass {
542
543
 
543
544
  // create absolute path from input filename
544
545
  // ToDo: this should be resolved via custom importers
545
- std::string abs_path(rel2abs(input_path, CWD));
546
+ sass::string abs_path(rel2abs(input_path, CWD));
546
547
 
547
548
  // try to load the entry file
548
549
  char* contents = read_file(abs_path);
@@ -557,7 +558,9 @@ namespace Sass {
557
558
  }
558
559
 
559
560
  // abort early if no content could be loaded (various reasons)
560
- if (!contents) throw std::runtime_error("File to read not found or unreadable: " + input_path);
561
+ if (!contents) throw std::runtime_error(
562
+ "File to read not found or unreadable: "
563
+ + std::string(input_path.c_str()));
561
564
 
562
565
  // store entry path
563
566
  entry_path = abs_path;
@@ -600,7 +603,7 @@ namespace Sass {
600
603
  entry_path = input_path.empty() ? "stdin" : input_path;
601
604
 
602
605
  // ToDo: this may be resolved via custom importers
603
- std::string abs_path(rel2abs(entry_path));
606
+ sass::string abs_path(rel2abs(entry_path));
604
607
  char* abs_path_c_str = sass_copy_c_string(abs_path.c_str());
605
608
  strings.push_back(abs_path_c_str);
606
609
 
@@ -670,38 +673,38 @@ namespace Sass {
670
673
  }
671
674
  // EO compile
672
675
 
673
- std::string Context::format_embedded_source_map()
676
+ sass::string Context::format_embedded_source_map()
674
677
  {
675
- std::string map = emitter.render_srcmap(*this);
676
- std::istringstream is( map );
677
- std::ostringstream buffer;
678
+ sass::string map = emitter.render_srcmap(*this);
679
+ sass::istream is( map.c_str() );
680
+ sass::ostream buffer;
678
681
  base64::encoder E;
679
682
  E.encode(is, buffer);
680
- std::string url = "data:application/json;base64," + buffer.str();
683
+ sass::string url = "data:application/json;base64," + buffer.str();
681
684
  url.erase(url.size() - 1);
682
685
  return "/*# sourceMappingURL=" + url + " */";
683
686
  }
684
687
 
685
- std::string Context::format_source_mapping_url(const std::string& file)
688
+ sass::string Context::format_source_mapping_url(const sass::string& file)
686
689
  {
687
- std::string url = abs2rel(file, output_path, CWD);
690
+ sass::string url = abs2rel(file, output_path, CWD);
688
691
  return "/*# sourceMappingURL=" + url + " */";
689
692
  }
690
693
 
691
694
  char* Context::render_srcmap()
692
695
  {
693
696
  if (source_map_file == "") return 0;
694
- std::string map = emitter.render_srcmap(*this);
697
+ sass::string map = emitter.render_srcmap(*this);
695
698
  return sass_copy_c_string(map.c_str());
696
699
  }
697
700
 
698
701
 
699
702
  // for data context we want to start after "stdin"
700
703
  // we probably always want to skip the header includes?
701
- std::vector<std::string> Context::get_included_files(bool skip, size_t headers)
704
+ sass::vector<sass::string> Context::get_included_files(bool skip, size_t headers)
702
705
  {
703
706
  // create a copy of the vector for manipulations
704
- std::vector<std::string> includes = included_files;
707
+ sass::vector<sass::string> includes = included_files;
705
708
  if (includes.size() == 0) return includes;
706
709
  if (skip) { includes.erase( includes.begin(), includes.begin() + 1 + headers); }
707
710
  else { includes.erase( includes.begin() + 1, includes.begin() + 1 + headers); }
@@ -720,20 +723,20 @@ namespace Sass {
720
723
  void register_function(Context& ctx, Signature sig, Native_Function f, size_t arity, Env* env)
721
724
  {
722
725
  Definition* def = make_native_function(sig, f, ctx);
723
- std::stringstream ss;
726
+ sass::ostream ss;
724
727
  ss << def->name() << "[f]" << arity;
725
728
  def->environment(env);
726
729
  (*env)[ss.str()] = def;
727
730
  }
728
731
 
729
- void register_overload_stub(Context& ctx, std::string name, Env* env)
732
+ void register_overload_stub(Context& ctx, sass::string name, Env* env)
730
733
  {
731
734
  Definition* stub = SASS_MEMORY_NEW(Definition,
732
- ParserState("[built-in function]"),
733
- 0,
735
+ SourceSpan{ "[built-in function]" },
736
+ nullptr,
734
737
  name,
735
- {},
736
- 0,
738
+ Parameters_Obj{},
739
+ nullptr,
737
740
  true);
738
741
  (*env)[name + "[f]"] = stub;
739
742
  }
@@ -19,19 +19,19 @@ namespace Sass {
19
19
 
20
20
  class Context {
21
21
  public:
22
- void import_url (Import* imp, std::string load_path, const std::string& ctx_path);
23
- bool call_headers(const std::string& load_path, const char* ctx_path, ParserState& pstate, Import* imp)
22
+ void import_url (Import* imp, sass::string load_path, const sass::string& ctx_path);
23
+ bool call_headers(const sass::string& load_path, const char* ctx_path, SourceSpan& pstate, Import* imp)
24
24
  { return call_loader(load_path, ctx_path, pstate, imp, c_headers, false); };
25
- bool call_importers(const std::string& load_path, const char* ctx_path, ParserState& pstate, Import* imp)
25
+ bool call_importers(const sass::string& load_path, const char* ctx_path, SourceSpan& pstate, Import* imp)
26
26
  { return call_loader(load_path, ctx_path, pstate, imp, c_importers, true); };
27
27
 
28
28
  private:
29
- bool call_loader(const std::string& load_path, const char* ctx_path, ParserState& pstate, Import* imp, std::vector<Sass_Importer_Entry> importers, bool only_one = true);
29
+ bool call_loader(const sass::string& load_path, const char* ctx_path, SourceSpan& pstate, Import* imp, sass::vector<Sass_Importer_Entry> importers, bool only_one = true);
30
30
 
31
31
  public:
32
- const std::string CWD;
32
+ const sass::string CWD;
33
33
  struct Sass_Options& c_options;
34
- std::string entry_path;
34
+ sass::string entry_path;
35
35
  size_t head_imports;
36
36
  Plugins plugins;
37
37
  Output emitter;
@@ -41,41 +41,41 @@ namespace Sass {
41
41
  CallStack ast_gc;
42
42
  // resources add under our control
43
43
  // these are guaranteed to be freed
44
- std::vector<char*> strings;
45
- std::vector<Resource> resources;
46
- std::map<const std::string, StyleSheet> sheets;
44
+ sass::vector<char*> strings;
45
+ sass::vector<Resource> resources;
46
+ std::map<const sass::string, StyleSheet> sheets;
47
47
  ImporterStack import_stack;
48
- std::vector<Sass_Callee> callee_stack;
49
- std::vector<Backtrace> traces;
48
+ sass::vector<Sass_Callee> callee_stack;
49
+ sass::vector<Backtrace> traces;
50
50
  Extender extender;
51
51
 
52
52
  struct Sass_Compiler* c_compiler;
53
53
 
54
54
  // absolute paths to includes
55
- std::vector<std::string> included_files;
55
+ sass::vector<sass::string> included_files;
56
56
  // relative includes for sourcemap
57
- std::vector<std::string> srcmap_links;
57
+ sass::vector<sass::string> srcmap_links;
58
58
  // vectors above have same size
59
59
 
60
- std::vector<std::string> plugin_paths; // relative paths to load plugins
61
- std::vector<std::string> include_paths; // lookup paths for includes
60
+ sass::vector<sass::string> plugin_paths; // relative paths to load plugins
61
+ sass::vector<sass::string> include_paths; // lookup paths for includes
62
62
 
63
- void apply_custom_headers(Block_Obj root, const char* path, ParserState pstate);
63
+ void apply_custom_headers(Block_Obj root, const char* path, SourceSpan pstate);
64
64
 
65
- std::vector<Sass_Importer_Entry> c_headers;
66
- std::vector<Sass_Importer_Entry> c_importers;
67
- std::vector<Sass_Function_Entry> c_functions;
65
+ sass::vector<Sass_Importer_Entry> c_headers;
66
+ sass::vector<Sass_Importer_Entry> c_importers;
67
+ sass::vector<Sass_Function_Entry> c_functions;
68
68
 
69
69
  void add_c_header(Sass_Importer_Entry header);
70
70
  void add_c_importer(Sass_Importer_Entry importer);
71
71
  void add_c_function(Sass_Function_Entry function);
72
72
 
73
- const std::string indent; // String to be used for indentation
74
- const std::string linefeed; // String to be used for line feeds
75
- const std::string input_path; // for relative paths in src-map
76
- const std::string output_path; // for relative paths to the output
77
- const std::string source_map_file; // path to source map file (enables feature)
78
- const std::string source_map_root; // path for sourceRoot property (pass-through)
73
+ const sass::string indent; // String to be used for indentation
74
+ const sass::string linefeed; // String to be used for line feeds
75
+ const sass::string input_path; // for relative paths in src-map
76
+ const sass::string output_path; // for relative paths to the output
77
+ const sass::string source_map_file; // path to source map file (enables feature)
78
+ const sass::string source_map_root; // path for sourceRoot property (pass-through)
79
79
 
80
80
  virtual ~Context();
81
81
  Context(struct Sass_Context&);
@@ -85,29 +85,29 @@ namespace Sass {
85
85
  virtual char* render_srcmap();
86
86
 
87
87
  void register_resource(const Include&, const Resource&);
88
- void register_resource(const Include&, const Resource&, ParserState&);
89
- std::vector<Include> find_includes(const Importer& import);
90
- Include load_import(const Importer&, ParserState pstate);
88
+ void register_resource(const Include&, const Resource&, SourceSpan&);
89
+ sass::vector<Include> find_includes(const Importer& import);
90
+ Include load_import(const Importer&, SourceSpan pstate);
91
91
 
92
92
  Sass_Output_Style output_style() { return c_options.output_style; };
93
- std::vector<std::string> get_included_files(bool skip = false, size_t headers = 0);
93
+ sass::vector<sass::string> get_included_files(bool skip = false, size_t headers = 0);
94
94
 
95
95
  private:
96
96
  void collect_plugin_paths(const char* paths_str);
97
97
  void collect_plugin_paths(string_list* paths_array);
98
98
  void collect_include_paths(const char* paths_str);
99
99
  void collect_include_paths(string_list* paths_array);
100
- std::string format_embedded_source_map();
101
- std::string format_source_mapping_url(const std::string& out_path);
100
+ sass::string format_embedded_source_map();
101
+ sass::string format_source_mapping_url(const sass::string& out_path);
102
102
 
103
103
 
104
104
  // void register_built_in_functions(Env* env);
105
105
  // void register_function(Signature sig, Native_Function f, Env* env);
106
106
  // void register_function(Signature sig, Native_Function f, size_t arity, Env* env);
107
- // void register_overload_stub(std::string name, Env* env);
107
+ // void register_overload_stub(sass::string name, Env* env);
108
108
 
109
109
  public:
110
- const std::string& cwd() { return CWD; };
110
+ const sass::string& cwd() { return CWD; };
111
111
  };
112
112
 
113
113
  class File_Context : public Context {