sassc 1.8.3 → 1.8.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (96) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +3 -1
  3. data/ext/libsass/.editorconfig +1 -1
  4. data/ext/libsass/.gitignore +1 -0
  5. data/ext/libsass/LICENSE +1 -1
  6. data/ext/libsass/Makefile +20 -14
  7. data/ext/libsass/Makefile.conf +0 -1
  8. data/ext/libsass/Readme.md +3 -1
  9. data/ext/libsass/appveyor.yml +19 -11
  10. data/ext/libsass/docs/api-importer-example.md +2 -1235
  11. data/ext/libsass/docs/build-with-autotools.md +10 -0
  12. data/ext/libsass/docs/build-with-makefiles.md +18 -0
  13. data/ext/libsass/include/sass/base.h +4 -1
  14. data/ext/libsass/include/sass/values.h +2 -1
  15. data/ext/libsass/src/ast.cpp +279 -346
  16. data/ext/libsass/src/ast.hpp +234 -60
  17. data/ext/libsass/src/base64vlq.cpp +1 -0
  18. data/ext/libsass/src/bind.cpp +35 -45
  19. data/ext/libsass/src/bind.hpp +1 -0
  20. data/ext/libsass/src/color_maps.cpp +1 -0
  21. data/ext/libsass/src/constants.cpp +4 -1
  22. data/ext/libsass/src/constants.hpp +2 -1
  23. data/ext/libsass/src/context.cpp +41 -31
  24. data/ext/libsass/src/context.hpp +10 -10
  25. data/ext/libsass/src/cssize.cpp +7 -4
  26. data/ext/libsass/src/cssize.hpp +1 -3
  27. data/ext/libsass/src/debugger.hpp +73 -14
  28. data/ext/libsass/src/emitter.cpp +37 -25
  29. data/ext/libsass/src/emitter.hpp +10 -9
  30. data/ext/libsass/src/environment.cpp +16 -5
  31. data/ext/libsass/src/environment.hpp +5 -3
  32. data/ext/libsass/src/error_handling.cpp +91 -14
  33. data/ext/libsass/src/error_handling.hpp +105 -4
  34. data/ext/libsass/src/eval.cpp +519 -330
  35. data/ext/libsass/src/eval.hpp +12 -13
  36. data/ext/libsass/src/expand.cpp +92 -56
  37. data/ext/libsass/src/expand.hpp +5 -3
  38. data/ext/libsass/src/extend.cpp +60 -51
  39. data/ext/libsass/src/extend.hpp +1 -3
  40. data/ext/libsass/src/file.cpp +37 -27
  41. data/ext/libsass/src/functions.cpp +78 -62
  42. data/ext/libsass/src/functions.hpp +1 -0
  43. data/ext/libsass/src/inspect.cpp +293 -64
  44. data/ext/libsass/src/inspect.hpp +2 -0
  45. data/ext/libsass/src/lexer.cpp +1 -0
  46. data/ext/libsass/src/listize.cpp +14 -15
  47. data/ext/libsass/src/listize.hpp +3 -5
  48. data/ext/libsass/src/memory_manager.cpp +1 -0
  49. data/ext/libsass/src/node.cpp +2 -3
  50. data/ext/libsass/src/operation.hpp +70 -71
  51. data/ext/libsass/src/output.cpp +28 -32
  52. data/ext/libsass/src/output.hpp +1 -2
  53. data/ext/libsass/src/parser.cpp +402 -183
  54. data/ext/libsass/src/parser.hpp +19 -9
  55. data/ext/libsass/src/plugins.cpp +1 -0
  56. data/ext/libsass/src/position.cpp +1 -0
  57. data/ext/libsass/src/prelexer.cpp +134 -56
  58. data/ext/libsass/src/prelexer.hpp +51 -3
  59. data/ext/libsass/src/remove_placeholders.cpp +35 -9
  60. data/ext/libsass/src/remove_placeholders.hpp +4 -3
  61. data/ext/libsass/src/sass.cpp +1 -0
  62. data/ext/libsass/src/sass.hpp +129 -0
  63. data/ext/libsass/src/sass_context.cpp +31 -14
  64. data/ext/libsass/src/sass_context.hpp +2 -31
  65. data/ext/libsass/src/sass_functions.cpp +1 -0
  66. data/ext/libsass/src/sass_interface.cpp +5 -6
  67. data/ext/libsass/src/sass_util.cpp +1 -2
  68. data/ext/libsass/src/sass_util.hpp +5 -5
  69. data/ext/libsass/src/sass_values.cpp +13 -10
  70. data/ext/libsass/src/source_map.cpp +4 -3
  71. data/ext/libsass/src/source_map.hpp +2 -2
  72. data/ext/libsass/src/subset_map.hpp +0 -1
  73. data/ext/libsass/src/to_c.cpp +1 -0
  74. data/ext/libsass/src/to_c.hpp +1 -3
  75. data/ext/libsass/src/to_value.cpp +3 -5
  76. data/ext/libsass/src/to_value.hpp +1 -1
  77. data/ext/libsass/src/units.cpp +96 -59
  78. data/ext/libsass/src/units.hpp +10 -8
  79. data/ext/libsass/src/utf8_string.cpp +5 -0
  80. data/ext/libsass/src/util.cpp +23 -156
  81. data/ext/libsass/src/util.hpp +10 -14
  82. data/ext/libsass/src/values.cpp +1 -0
  83. data/ext/libsass/test/test_node.cpp +2 -6
  84. data/ext/libsass/test/test_selector_difference.cpp +1 -3
  85. data/ext/libsass/test/test_specificity.cpp +0 -2
  86. data/ext/libsass/test/test_superselector.cpp +0 -2
  87. data/ext/libsass/test/test_unification.cpp +1 -3
  88. data/ext/libsass/win/libsass.targets +18 -5
  89. data/ext/libsass/win/libsass.vcxproj +9 -7
  90. data/ext/libsass/win/libsass.vcxproj.filters +148 -106
  91. data/lib/sassc/version.rb +1 -1
  92. data/test/engine_test.rb +12 -0
  93. data/test/native_test.rb +1 -1
  94. metadata +3 -4
  95. data/ext/libsass/src/to_string.cpp +0 -48
  96. data/ext/libsass/src/to_string.hpp +0 -38
@@ -25,9 +25,7 @@ namespace Sass {
25
25
  static Node subweave(Node& one, Node& two, Context& ctx);
26
26
  static Selector_List* extendSelectorList(Selector_List* pSelectorList, Context& ctx, ExtensionSubsetMap& subset_map, bool isReplace, bool& extendedSomething);
27
27
  Extend(Context&, ExtensionSubsetMap&);
28
- virtual ~Extend() { }
29
-
30
- using Operation<void>::operator();
28
+ ~Extend() { }
31
29
 
32
30
  void operator()(Block*);
33
31
  void operator()(Ruleset*);
@@ -1,19 +1,15 @@
1
1
  #ifdef _WIN32
2
- #ifdef __MINGW32__
3
- #ifndef off64_t
4
- #define off64_t _off64_t /* Workaround for http://sourceforge.net/p/mingw/bugs/2024/ */
5
- #endif
6
- #endif
7
- #include <direct.h>
8
- #define getcwd _getcwd
9
- #define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
2
+ # ifdef __MINGW32__
3
+ # ifndef off64_t
4
+ # define off64_t _off64_t /* Workaround for http://sourceforge.net/p/mingw/bugs/2024/ */
5
+ # endif
6
+ # endif
7
+ # include <direct.h>
8
+ # define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
10
9
  #else
11
- #include <unistd.h>
10
+ # include <unistd.h>
12
11
  #endif
13
- #ifdef _MSC_VER
14
- #define NOMINMAX
15
- #endif
16
-
12
+ #include "sass.hpp"
17
13
  #include <iostream>
18
14
  #include <fstream>
19
15
  #include <cctype>
@@ -27,15 +23,24 @@
27
23
  #include "sass2scss.h"
28
24
 
29
25
  #ifdef _WIN32
30
- #include <windows.h>
31
- #endif
32
-
33
- #ifndef FS_CASE_SENSITIVE
34
- #ifdef _WIN32
35
- #define FS_CASE_SENSITIVE 0
36
- #else
37
- #define FS_CASE_SENSITIVE 1
38
- #endif
26
+ # include <windows.h>
27
+
28
+ # ifdef _MSC_VER
29
+ # include <codecvt>
30
+ inline static std::string wstring_to_string(const std::wstring& wstr)
31
+ {
32
+ std::wstring_convert<std::codecvt_utf8<wchar_t>, wchar_t> wchar_converter;
33
+ return wchar_converter.to_bytes(wstr);
34
+ }
35
+ # else // mingw(/gcc) does not support C++11's codecvt yet.
36
+ inline static std::string wstring_to_string(const std::wstring &wstr)
37
+ {
38
+ int size_needed = WideCharToMultiByte(CP_UTF8, 0, &wstr[0], (int)wstr.size(), NULL, 0, NULL, NULL);
39
+ std::string strTo(size_needed, 0);
40
+ WideCharToMultiByte(CP_UTF8, 0, &wstr[0], (int)wstr.size(), &strTo[0], size_needed, NULL, NULL);
41
+ return strTo;
42
+ }
43
+ # endif
39
44
  #endif
40
45
 
41
46
  namespace Sass {
@@ -46,9 +51,12 @@ namespace Sass {
46
51
  std::string get_cwd()
47
52
  {
48
53
  const size_t wd_len = 1024;
49
- char wd[wd_len];
50
- std::string cwd = getcwd(wd, wd_len);
51
- #ifdef _WIN32
54
+ #ifndef _WIN32
55
+ char wd[wd_len];
56
+ std::string cwd = getcwd(wd, wd_len);
57
+ #else
58
+ wchar_t wd[wd_len];
59
+ std::string cwd = wstring_to_string(_wgetcwd(wd, wd_len));
52
60
  //convert backslashes to forward slashes
53
61
  replace(cwd.begin(), cwd.end(), '\\', '/');
54
62
  #endif
@@ -184,8 +192,10 @@ namespace Sass {
184
192
  if (l[l.length()-1] != '/') l += '/';
185
193
 
186
194
  while ((r.length() > 3) && ((r.substr(0, 3) == "../") || (r.substr(0, 3)) == "..\\")) {
187
- r = r.substr(3);
188
- size_t pos = find_last_folder_separator(l, l.length() - 2);
195
+ size_t L = l.length(), pos = find_last_folder_separator(l, L - 2);
196
+ bool is_slash = pos + 2 == L && (l[pos+1] == '/' || l[pos+1] == '\\');
197
+ bool is_self = pos + 3 == L && (l[pos+1] == '.');
198
+ if (!is_self && !is_slash) r = r.substr(3);
189
199
  l = l.substr(0, pos == std::string::npos ? pos : pos + 1);
190
200
  }
191
201
 
@@ -1,10 +1,10 @@
1
+ #include "sass.hpp"
1
2
  #include "functions.hpp"
2
3
  #include "ast.hpp"
3
4
  #include "context.hpp"
4
5
  #include "backtrace.hpp"
5
6
  #include "parser.hpp"
6
7
  #include "constants.hpp"
7
- #include "to_string.hpp"
8
8
  #include "inspect.hpp"
9
9
  #include "extend.hpp"
10
10
  #include "eval.hpp"
@@ -14,6 +14,7 @@
14
14
  #include "sass/base.h"
15
15
  #include "utf8.h"
16
16
 
17
+ #include <cstdint>
17
18
  #include <cstdlib>
18
19
  #include <cmath>
19
20
  #include <cctype>
@@ -155,7 +156,6 @@ namespace Sass {
155
156
 
156
157
  template <>
157
158
  Selector_List* get_arg_sel(const std::string& argname, Env& env, Signature sig, ParserState pstate, Backtrace* backtrace, Context& ctx) {
158
- To_String to_string(&ctx, false);
159
159
  Expression* exp = ARG(argname, Expression);
160
160
  if (exp->concrete_type() == Expression::NULL_VAL) {
161
161
  std::stringstream msg;
@@ -163,13 +163,15 @@ namespace Sass {
163
163
  msg << "a list of strings, or a list of lists of strings for `" << function_name(sig) << "'";
164
164
  error(msg.str(), pstate);
165
165
  }
166
- std::string exp_src = exp->perform(&to_string) + "{";
166
+ if (String_Constant* str =dynamic_cast<String_Constant*>(exp)) {
167
+ str->quote_mark(0);
168
+ }
169
+ std::string exp_src = exp->to_string(ctx.c_options) + "{";
167
170
  return Parser::parse_selector(exp_src.c_str(), ctx);
168
171
  }
169
172
 
170
173
  template <>
171
174
  Complex_Selector* get_arg_sel(const std::string& argname, Env& env, Signature sig, ParserState pstate, Backtrace* backtrace, Context& ctx) {
172
- To_String to_string(&ctx, false);
173
175
  Expression* exp = ARG(argname, Expression);
174
176
  if (exp->concrete_type() == Expression::NULL_VAL) {
175
177
  std::stringstream msg;
@@ -177,21 +179,26 @@ namespace Sass {
177
179
  msg << "a list of strings, or a list of lists of strings for `" << function_name(sig) << "'";
178
180
  error(msg.str(), pstate);
179
181
  }
180
- std::string exp_src = exp->perform(&to_string) + "{";
182
+ if (String_Constant* str =dynamic_cast<String_Constant*>(exp)) {
183
+ str->quote_mark(0);
184
+ }
185
+ std::string exp_src = exp->to_string(ctx.c_options) + "{";
181
186
  Selector_List* sel_list = Parser::parse_selector(exp_src.c_str(), ctx);
182
187
  return (sel_list->length() > 0) ? sel_list->first() : 0;
183
188
  }
184
189
 
185
190
  template <>
186
191
  Compound_Selector* get_arg_sel(const std::string& argname, Env& env, Signature sig, ParserState pstate, Backtrace* backtrace, Context& ctx) {
187
- To_String to_string(&ctx, false);
188
192
  Expression* exp = ARG(argname, Expression);
189
193
  if (exp->concrete_type() == Expression::NULL_VAL) {
190
194
  std::stringstream msg;
191
195
  msg << argname << ": null is not a string for `" << function_name(sig) << "'";
192
196
  error(msg.str(), pstate);
193
197
  }
194
- std::string exp_src = exp->perform(&to_string) + "{";
198
+ if (String_Constant* str =dynamic_cast<String_Constant*>(exp)) {
199
+ str->quote_mark(0);
200
+ }
201
+ std::string exp_src = exp->to_string(ctx.c_options) + "{";
195
202
  Selector_List* sel_list = Parser::parse_selector(exp_src.c_str(), ctx);
196
203
  return (sel_list->length() > 0) ? sel_list->first()->tail()->head() : 0;
197
204
  }
@@ -211,9 +218,9 @@ namespace Sass {
211
218
  return seed;
212
219
  }
213
220
  #else
214
- static std::random_device rd;
215
221
  uint64_t GetSeed()
216
222
  {
223
+ std::random_device rd;
217
224
  return rd();
218
225
  }
219
226
  #endif
@@ -311,9 +318,9 @@ namespace Sass {
311
318
 
312
319
  return SASS_MEMORY_NEW(ctx.mem, Color,
313
320
  pstate,
314
- Sass::round(w1*color1->r() + w2*color2->r()),
315
- Sass::round(w1*color1->g() + w2*color2->g()),
316
- Sass::round(w1*color1->b() + w2*color2->b()),
321
+ Sass::round(w1*color1->r() + w2*color2->r(), ctx.c_options.precision),
322
+ Sass::round(w1*color1->g() + w2*color2->g(), ctx.c_options.precision),
323
+ Sass::round(w1*color1->b() + w2*color2->b(), ctx.c_options.precision),
317
324
  color1->a()*p + color2->a()*(1-p));
318
325
  }
319
326
 
@@ -510,8 +517,7 @@ namespace Sass {
510
517
  // CSS3 filter function overload: pass literal through directly
511
518
  Number* amount = dynamic_cast<Number*>(env["$amount"]);
512
519
  if (!amount) {
513
- To_String to_string(&ctx);
514
- return SASS_MEMORY_NEW(ctx.mem, String_Quoted, pstate, "saturate(" + env["$color"]->perform(&to_string) + ")");
520
+ return SASS_MEMORY_NEW(ctx.mem, String_Quoted, pstate, "saturate(" + env["$color"]->to_string(ctx.c_options) + ")");
515
521
  }
516
522
 
517
523
  ARGR("$amount", Number, 0, 100);
@@ -571,8 +577,7 @@ namespace Sass {
571
577
  // CSS3 filter function overload: pass literal through directly
572
578
  Number* amount = dynamic_cast<Number*>(env["$color"]);
573
579
  if (amount) {
574
- To_String to_string(&ctx);
575
- return SASS_MEMORY_NEW(ctx.mem, String_Quoted, pstate, "grayscale(" + amount->perform(&to_string) + ")");
580
+ return SASS_MEMORY_NEW(ctx.mem, String_Quoted, pstate, "grayscale(" + amount->to_string(ctx.c_options) + ")");
576
581
  }
577
582
 
578
583
  Color* rgb_color = ARG("$color", Color);
@@ -608,8 +613,7 @@ namespace Sass {
608
613
  // CSS3 filter function overload: pass literal through directly
609
614
  Number* amount = dynamic_cast<Number*>(env["$color"]);
610
615
  if (amount) {
611
- To_String to_string(&ctx);
612
- return SASS_MEMORY_NEW(ctx.mem, String_Quoted, pstate, "invert(" + amount->perform(&to_string) + ")");
616
+ return SASS_MEMORY_NEW(ctx.mem, String_Quoted, pstate, "invert(" + amount->to_string(ctx.c_options) + ")");
613
617
  }
614
618
 
615
619
  Color* rgb_color = ARG("$color", Color);
@@ -636,8 +640,7 @@ namespace Sass {
636
640
  // CSS3 filter function overload: pass literal through directly
637
641
  Number* amount = dynamic_cast<Number*>(env["$color"]);
638
642
  if (amount) {
639
- To_String to_string(&ctx);
640
- return SASS_MEMORY_NEW(ctx.mem, String_Quoted, pstate, "opacity(" + amount->perform(&to_string) + ")");
643
+ return SASS_MEMORY_NEW(ctx.mem, String_Quoted, pstate, "opacity(" + amount->to_string(ctx.c_options) + ")");
641
644
  }
642
645
 
643
646
  return SASS_MEMORY_NEW(ctx.mem, Number, pstate, ARG("$color", Color)->a());
@@ -854,10 +857,10 @@ namespace Sass {
854
857
 
855
858
  std::stringstream ss;
856
859
  ss << '#' << std::setw(2) << std::setfill('0');
857
- ss << std::hex << std::setw(2) << static_cast<unsigned long>(Sass::round(a));
858
- ss << std::hex << std::setw(2) << static_cast<unsigned long>(Sass::round(r));
859
- ss << std::hex << std::setw(2) << static_cast<unsigned long>(Sass::round(g));
860
- ss << std::hex << std::setw(2) << static_cast<unsigned long>(Sass::round(b));
860
+ ss << std::hex << std::setw(2) << static_cast<unsigned long>(Sass::round(a, ctx.c_options.precision));
861
+ ss << std::hex << std::setw(2) << static_cast<unsigned long>(Sass::round(r, ctx.c_options.precision));
862
+ ss << std::hex << std::setw(2) << static_cast<unsigned long>(Sass::round(g, ctx.c_options.precision));
863
+ ss << std::hex << std::setw(2) << static_cast<unsigned long>(Sass::round(b, ctx.c_options.precision));
861
864
 
862
865
  std::string result(ss.str());
863
866
  for (size_t i = 0, L = result.length(); i < L; ++i) {
@@ -884,9 +887,11 @@ namespace Sass {
884
887
  return (Expression*) arg;
885
888
  }
886
889
  else {
887
- To_String to_string(&ctx, false, true);
888
- std::string val(arg->perform(&to_string));
890
+ Sass_Output_Style oldstyle = ctx.c_options.output_style;
891
+ ctx.c_options.output_style = SASS_STYLE_NESTED;
892
+ std::string val(arg->to_string(ctx.c_options));
889
893
  val = dynamic_cast<Null*>(arg) ? "null" : val;
894
+ ctx.c_options.output_style = oldstyle;
890
895
 
891
896
  deprecated_function("Passing " + val + ", a non-string value, to unquote()", pstate);
892
897
  return (Expression*) arg;
@@ -896,9 +901,8 @@ namespace Sass {
896
901
  Signature quote_sig = "quote($string)";
897
902
  BUILT_IN(sass_quote)
898
903
  {
899
- To_String to_string(&ctx);
900
904
  AST_Node* arg = env["$string"];
901
- std::string str(quote(arg->perform(&to_string), String_Constant::double_quote()));
905
+ std::string str(quote(arg->to_string(ctx.c_options), String_Constant::double_quote()));
902
906
  String_Quoted* result = SASS_MEMORY_NEW(ctx.mem, String_Quoted, pstate, str);
903
907
  result->is_delayed(true);
904
908
  return result;
@@ -1088,7 +1092,7 @@ namespace Sass {
1088
1092
  Number* n = ARG("$number", Number);
1089
1093
  Number* r = SASS_MEMORY_NEW(ctx.mem, Number, *n);
1090
1094
  r->pstate(pstate);
1091
- r->value(Sass::round(r->value()));
1095
+ r->value(Sass::round(r->value(), ctx.c_options.precision));
1092
1096
  return r;
1093
1097
  }
1094
1098
 
@@ -1128,10 +1132,13 @@ namespace Sass {
1128
1132
  List* arglist = ARG("$numbers", List);
1129
1133
  Number* least = 0;
1130
1134
  for (size_t i = 0, L = arglist->length(); i < L; ++i) {
1131
- Number* xi = dynamic_cast<Number*>(arglist->value_at_index(i));
1132
- if (!xi) error("`" + std::string(sig) + "` only takes numeric arguments", pstate);
1135
+ Expression* val = arglist->value_at_index(i);
1136
+ Number* xi = dynamic_cast<Number*>(val);
1137
+ if (!xi) {
1138
+ error("\"" + val->to_string(ctx.c_options) + "\" is not a number for `min'", pstate);
1139
+ }
1133
1140
  if (least) {
1134
- if (Eval::lt(xi, least)) least = xi;
1141
+ if (*xi < *least) least = xi;
1135
1142
  } else least = xi;
1136
1143
  }
1137
1144
  return least;
@@ -1143,10 +1150,13 @@ namespace Sass {
1143
1150
  List* arglist = ARG("$numbers", List);
1144
1151
  Number* greatest = 0;
1145
1152
  for (size_t i = 0, L = arglist->length(); i < L; ++i) {
1146
- Number* xi = dynamic_cast<Number*>(arglist->value_at_index(i));
1147
- if (!xi) error("`" + std::string(sig) + "` only takes numeric arguments", pstate);
1153
+ Expression* val = arglist->value_at_index(i);
1154
+ Number* xi = dynamic_cast<Number*>(val);
1155
+ if (!xi) {
1156
+ error("\"" + val->to_string(ctx.c_options) + "\" is not a number for `max'", pstate);
1157
+ }
1148
1158
  if (greatest) {
1149
- if (Eval::lt(greatest, xi)) greatest = xi;
1159
+ if (*greatest < *xi) greatest = xi;
1150
1160
  } else greatest = xi;
1151
1161
  }
1152
1162
  return greatest;
@@ -1231,7 +1241,7 @@ namespace Sass {
1231
1241
  double index = std::floor(n->value() < 0 ? len + n->value() : n->value() - 1);
1232
1242
  if (index < 0 || index > len - 1) error("index out of bounds for `" + std::string(sig) + "`", pstate);
1233
1243
  // return (*sl)[static_cast<int>(index)];
1234
- Listize listize(ctx);
1244
+ Listize listize(ctx.mem);
1235
1245
  return (*sl)[static_cast<int>(index)]->perform(&listize);
1236
1246
  }
1237
1247
  List* l = dynamic_cast<List*>(env["$list"]);
@@ -1326,7 +1336,7 @@ namespace Sass {
1326
1336
  List* l = dynamic_cast<List*>(env["$list"]);
1327
1337
  Expression* v = ARG("$val", Expression);
1328
1338
  if (Selector_List* sl = dynamic_cast<Selector_List*>(env["$list"])) {
1329
- Listize listize(ctx);
1339
+ Listize listize(ctx.mem);
1330
1340
  l = dynamic_cast<List*>(sl->perform(&listize));
1331
1341
  }
1332
1342
  String_Constant* sep = ARG("$separator", String_Constant);
@@ -1662,6 +1672,9 @@ namespace Sass {
1662
1672
  // MISCELLANEOUS FUNCTIONS
1663
1673
  //////////////////////////
1664
1674
 
1675
+ // value.check_deprecated_interp if value.is_a?(Sass::Script::Value::String)
1676
+ // unquoted_string(value.to_sass)
1677
+
1665
1678
  Signature inspect_sig = "inspect($value)";
1666
1679
  BUILT_IN(inspect)
1667
1680
  {
@@ -1673,23 +1686,23 @@ namespace Sass {
1673
1686
  } else if (v->concrete_type() == Expression::STRING) {
1674
1687
  return v;
1675
1688
  } else {
1676
- bool parentheses = v->concrete_type() == Expression::MAP ||
1677
- v->concrete_type() == Expression::LIST;
1689
+ // ToDo: fix to_sass for nested parentheses
1678
1690
  Sass_Output_Style old_style;
1679
- old_style = ctx.c_options->output_style;
1680
- ctx.c_options->output_style = SASS_STYLE_NESTED;
1681
- To_String to_string(&ctx, false);
1682
- std::string inspect = v->perform(&to_string);
1683
- if (inspect.empty() && parentheses) inspect = "()";
1684
- ctx.c_options->output_style = old_style;
1685
- return SASS_MEMORY_NEW(ctx.mem, String_Quoted, pstate, inspect);
1691
+ old_style = ctx.c_options.output_style;
1692
+ ctx.c_options.output_style = TO_SASS;
1693
+ Sass_Output_Options out(ctx.c_options);
1694
+ Emitter emitter(ctx.c_options);
1695
+ Inspect i(emitter);
1696
+ i.in_declaration = false;
1697
+ v->perform(&i);
1698
+ ctx.c_options.output_style = old_style;
1699
+ return SASS_MEMORY_NEW(ctx.mem, String_Quoted, pstate, i.get_buffer());
1686
1700
  }
1687
1701
  // return v;
1688
1702
  }
1689
1703
  Signature selector_nest_sig = "selector-nest($selectors...)";
1690
1704
  BUILT_IN(selector_nest)
1691
1705
  {
1692
- To_String to_string(&ctx, false);
1693
1706
  List* arglist = ARG("$selectors", List);
1694
1707
 
1695
1708
  // Not enough parameters
@@ -1706,7 +1719,10 @@ namespace Sass {
1706
1719
  msg << "a list of strings, or a list of lists of strings for 'selector-nest'";
1707
1720
  error(msg.str(), pstate);
1708
1721
  }
1709
- std::string exp_src = exp->perform(&to_string) + "{";
1722
+ if (String_Constant* str =dynamic_cast<String_Constant*>(exp)) {
1723
+ str->quote_mark(0);
1724
+ }
1725
+ std::string exp_src = exp->to_string(ctx.c_options) + "{";
1710
1726
  Selector_List* sel = Parser::parse_selector(exp_src.c_str(), ctx);
1711
1727
  parsedSelectors.push_back(sel);
1712
1728
  }
@@ -1731,14 +1747,13 @@ namespace Sass {
1731
1747
  result->elements(exploded);
1732
1748
  }
1733
1749
 
1734
- Listize listize(ctx);
1750
+ Listize listize(ctx.mem);
1735
1751
  return result->perform(&listize);
1736
1752
  }
1737
1753
 
1738
1754
  Signature selector_append_sig = "selector-append($selectors...)";
1739
1755
  BUILT_IN(selector_append)
1740
1756
  {
1741
- To_String to_string;
1742
1757
  List* arglist = ARG("$selectors", List);
1743
1758
 
1744
1759
  // Not enough parameters
@@ -1755,7 +1770,10 @@ namespace Sass {
1755
1770
  msg << "a list of strings, or a list of lists of strings for 'selector-append'";
1756
1771
  error(msg.str(), pstate);
1757
1772
  }
1758
- std::string exp_src = exp->perform(&to_string) + "{";
1773
+ if (String_Constant* str =dynamic_cast<String_Constant*>(exp)) {
1774
+ str->quote_mark(0);
1775
+ }
1776
+ std::string exp_src = exp->to_string() + "{";
1759
1777
  Selector_List* sel = Parser::parse_selector(exp_src.c_str(), ctx);
1760
1778
  parsedSelectors.push_back(sel);
1761
1779
  }
@@ -1790,9 +1808,9 @@ namespace Sass {
1790
1808
  // Must be a simple sequence
1791
1809
  if( childSeq->combinator() != Complex_Selector::Combinator::ANCESTOR_OF ) {
1792
1810
  std::string msg("Can't append `");
1793
- msg += childSeq->perform(&to_string);
1811
+ msg += childSeq->to_string();
1794
1812
  msg += "` to `";
1795
- msg += parentSeqClone->perform(&to_string);;
1813
+ msg += parentSeqClone->to_string();
1796
1814
  msg += "`";
1797
1815
  error(msg, pstate, backtrace);
1798
1816
  }
@@ -1801,9 +1819,9 @@ namespace Sass {
1801
1819
  Type_Selector* pType = dynamic_cast<Type_Selector*>(base->head()->first());
1802
1820
  if(pType && pType->name() == "*") {
1803
1821
  std::string msg("Can't append `");
1804
- msg += childSeq->perform(&to_string);
1822
+ msg += childSeq->to_string();
1805
1823
  msg += "` to `";
1806
- msg += parentSeqClone->perform(&to_string);;
1824
+ msg += parentSeqClone->to_string();
1807
1825
  msg += "`";
1808
1826
  error(msg, pstate, backtrace);
1809
1827
  }
@@ -1823,7 +1841,7 @@ namespace Sass {
1823
1841
  result->elements(newElements);
1824
1842
  }
1825
1843
 
1826
- Listize listize(ctx);
1844
+ Listize listize(ctx.mem);
1827
1845
  return result->perform(&listize);
1828
1846
  }
1829
1847
 
@@ -1834,7 +1852,7 @@ namespace Sass {
1834
1852
  Selector_List* selector2 = ARGSEL("$selector2", Selector_List, p_contextualize);
1835
1853
 
1836
1854
  Selector_List* result = selector1->unify_with(selector2, ctx);
1837
- Listize listize(ctx);
1855
+ Listize listize(ctx.mem);
1838
1856
  return result->perform(&listize);
1839
1857
  }
1840
1858
 
@@ -1843,12 +1861,11 @@ namespace Sass {
1843
1861
  {
1844
1862
  Compound_Selector* sel = ARGSEL("$selector", Compound_Selector, p_contextualize);
1845
1863
 
1846
- To_String to_string;
1847
1864
  List* l = SASS_MEMORY_NEW(ctx.mem, List, sel->pstate(), sel->length(), SASS_COMMA);
1848
1865
 
1849
1866
  for (size_t i = 0, L = sel->length(); i < L; ++i) {
1850
1867
  Simple_Selector* ss = (*sel)[i];
1851
- std::string ss_string = ss->perform(&to_string) ;
1868
+ std::string ss_string = ss->to_string() ;
1852
1869
 
1853
1870
  *l << SASS_MEMORY_NEW(ctx.mem, String_Quoted, ss->pstate(), ss_string);
1854
1871
  }
@@ -1869,7 +1886,7 @@ namespace Sass {
1869
1886
  bool extendedSomething;
1870
1887
  Selector_List* result = Extend::extendSelectorList(selector, ctx, subset_map, false, extendedSomething);
1871
1888
 
1872
- Listize listize(ctx);
1889
+ Listize listize(ctx.mem);
1873
1890
  return result->perform(&listize);
1874
1891
  }
1875
1892
 
@@ -1886,7 +1903,7 @@ namespace Sass {
1886
1903
  bool extendedSomething;
1887
1904
  Selector_List* result = Extend::extendSelectorList(selector, ctx, subset_map, true, extendedSomething);
1888
1905
 
1889
- Listize listize(ctx);
1906
+ Listize listize(ctx.mem);
1890
1907
  return result->perform(&listize);
1891
1908
  }
1892
1909
 
@@ -1895,14 +1912,13 @@ namespace Sass {
1895
1912
  {
1896
1913
  Selector_List* sel = ARGSEL("$selector", Selector_List, p_contextualize);
1897
1914
 
1898
- Listize listize(ctx);
1915
+ Listize listize(ctx.mem);
1899
1916
  return sel->perform(&listize);
1900
1917
  }
1901
1918
 
1902
1919
  Signature is_superselector_sig = "is-superselector($super, $sub)";
1903
1920
  BUILT_IN(is_superselector)
1904
1921
  {
1905
- To_String to_string(&ctx, false);
1906
1922
  Selector_List* sel_sup = ARGSEL("$super", Selector_List, p_contextualize);
1907
1923
  Selector_List* sel_sub = ARGSEL("$sub", Selector_List, p_contextualize);
1908
1924
  bool result = sel_sup->is_superselector_of(sel_sub);