sassc 2.0.1 → 2.1.0.pre1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (200) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.gitmodules +1 -1
  4. data/.travis.yml +7 -3
  5. data/CHANGELOG.md +3 -0
  6. data/CODE_OF_CONDUCT.md +1 -1
  7. data/README.md +1 -1
  8. data/Rakefile +23 -8
  9. data/ext/extconf.rb +39 -0
  10. data/ext/libsass/.gitignore +1 -0
  11. data/ext/libsass/GNUmakefile.am +23 -39
  12. data/ext/libsass/Makefile +56 -91
  13. data/ext/libsass/Makefile.conf +16 -2
  14. data/ext/libsass/configure.ac +8 -12
  15. data/ext/libsass/include/sass/base.h +1 -0
  16. data/ext/libsass/include/sass/context.h +1 -1
  17. data/ext/libsass/src/GNUmakefile.am +1 -5
  18. data/ext/libsass/src/ast.cpp +747 -2010
  19. data/ext/libsass/src/ast.hpp +239 -2383
  20. data/ext/libsass/src/{to_c.cpp → ast2c.cpp} +22 -16
  21. data/ext/libsass/src/ast2c.hpp +39 -0
  22. data/ext/libsass/src/ast_def_macros.hpp +62 -10
  23. data/ext/libsass/src/ast_fwd_decl.cpp +1 -0
  24. data/ext/libsass/src/ast_fwd_decl.hpp +43 -165
  25. data/ext/libsass/src/ast_sel_cmp.cpp +909 -0
  26. data/ext/libsass/src/ast_sel_unify.cpp +280 -0
  27. data/ext/libsass/src/ast_selectors.cpp +1475 -0
  28. data/ext/libsass/src/ast_selectors.hpp +568 -0
  29. data/ext/libsass/src/ast_supports.cpp +130 -0
  30. data/ext/libsass/src/ast_supports.hpp +121 -0
  31. data/ext/libsass/src/ast_values.cpp +967 -0
  32. data/ext/libsass/src/ast_values.hpp +489 -0
  33. data/ext/libsass/src/backtrace.cpp +4 -0
  34. data/ext/libsass/src/base64vlq.cpp +3 -0
  35. data/ext/libsass/src/bind.cpp +18 -17
  36. data/ext/libsass/src/bind.hpp +3 -1
  37. data/ext/libsass/src/c2ast.cpp +64 -0
  38. data/ext/libsass/src/c2ast.hpp +14 -0
  39. data/ext/libsass/src/cencode.c +2 -2
  40. data/ext/libsass/src/check_nesting.cpp +52 -56
  41. data/ext/libsass/src/check_nesting.hpp +35 -34
  42. data/ext/libsass/src/color_maps.cpp +156 -153
  43. data/ext/libsass/src/color_maps.hpp +152 -152
  44. data/ext/libsass/src/constants.cpp +15 -0
  45. data/ext/libsass/src/constants.hpp +13 -0
  46. data/ext/libsass/src/context.cpp +24 -14
  47. data/ext/libsass/src/context.hpp +6 -6
  48. data/ext/libsass/src/cssize.cpp +69 -71
  49. data/ext/libsass/src/cssize.hpp +50 -50
  50. data/ext/libsass/src/debugger.hpp +117 -110
  51. data/ext/libsass/src/emitter.cpp +13 -12
  52. data/ext/libsass/src/emitter.hpp +13 -9
  53. data/ext/libsass/src/environment.cpp +15 -1
  54. data/ext/libsass/src/environment.hpp +6 -0
  55. data/ext/libsass/src/error_handling.cpp +36 -59
  56. data/ext/libsass/src/error_handling.hpp +29 -16
  57. data/ext/libsass/src/eval.cpp +302 -323
  58. data/ext/libsass/src/eval.hpp +64 -55
  59. data/ext/libsass/src/expand.cpp +94 -88
  60. data/ext/libsass/src/expand.hpp +33 -37
  61. data/ext/libsass/src/extend.cpp +38 -36
  62. data/ext/libsass/src/extend.hpp +15 -15
  63. data/ext/libsass/src/file.cpp +34 -2
  64. data/ext/libsass/src/fn_colors.cpp +594 -0
  65. data/ext/libsass/src/fn_colors.hpp +85 -0
  66. data/ext/libsass/src/fn_lists.cpp +284 -0
  67. data/ext/libsass/src/fn_lists.hpp +34 -0
  68. data/ext/libsass/src/fn_maps.cpp +94 -0
  69. data/ext/libsass/src/fn_maps.hpp +30 -0
  70. data/ext/libsass/src/fn_miscs.cpp +256 -0
  71. data/ext/libsass/src/fn_miscs.hpp +40 -0
  72. data/ext/libsass/src/fn_numbers.cpp +220 -0
  73. data/ext/libsass/src/fn_numbers.hpp +45 -0
  74. data/ext/libsass/src/fn_selectors.cpp +235 -0
  75. data/ext/libsass/src/fn_selectors.hpp +35 -0
  76. data/ext/libsass/src/fn_strings.cpp +254 -0
  77. data/ext/libsass/src/fn_strings.hpp +34 -0
  78. data/ext/libsass/src/fn_utils.cpp +156 -0
  79. data/ext/libsass/src/fn_utils.hpp +56 -0
  80. data/ext/libsass/src/inspect.cpp +101 -152
  81. data/ext/libsass/src/inspect.hpp +69 -73
  82. data/ext/libsass/src/json.cpp +2 -2
  83. data/ext/libsass/src/lexer.cpp +6 -3
  84. data/ext/libsass/src/listize.cpp +9 -11
  85. data/ext/libsass/src/listize.hpp +11 -7
  86. data/ext/libsass/src/memory/SharedPtr.cpp +2 -83
  87. data/ext/libsass/src/memory/SharedPtr.hpp +127 -143
  88. data/ext/libsass/src/node.cpp +13 -10
  89. data/ext/libsass/src/node.hpp +3 -3
  90. data/ext/libsass/src/operation.hpp +184 -144
  91. data/ext/libsass/src/operators.cpp +43 -17
  92. data/ext/libsass/src/operators.hpp +5 -5
  93. data/ext/libsass/src/output.cpp +21 -18
  94. data/ext/libsass/src/output.hpp +14 -21
  95. data/ext/libsass/src/parser.cpp +215 -183
  96. data/ext/libsass/src/parser.hpp +28 -24
  97. data/ext/libsass/src/plugins.cpp +5 -1
  98. data/ext/libsass/src/position.cpp +3 -0
  99. data/ext/libsass/src/prelexer.cpp +9 -3
  100. data/ext/libsass/src/prelexer.hpp +9 -9
  101. data/ext/libsass/src/remove_placeholders.cpp +14 -11
  102. data/ext/libsass/src/remove_placeholders.hpp +8 -9
  103. data/ext/libsass/src/sass.cpp +9 -3
  104. data/ext/libsass/src/sass.hpp +12 -9
  105. data/ext/libsass/src/sass2scss.cpp +45 -14
  106. data/ext/libsass/src/sass_context.cpp +18 -15
  107. data/ext/libsass/src/sass_functions.cpp +6 -3
  108. data/ext/libsass/src/sass_functions.hpp +1 -1
  109. data/ext/libsass/src/sass_util.cpp +3 -0
  110. data/ext/libsass/src/sass_values.cpp +21 -13
  111. data/ext/libsass/src/source_map.cpp +5 -2
  112. data/ext/libsass/src/source_map.hpp +2 -2
  113. data/ext/libsass/src/subset_map.cpp +4 -1
  114. data/ext/libsass/src/to_value.cpp +23 -21
  115. data/ext/libsass/src/to_value.hpp +18 -22
  116. data/ext/libsass/src/units.cpp +4 -0
  117. data/ext/libsass/src/units.hpp +1 -0
  118. data/ext/libsass/src/utf8/checked.h +12 -10
  119. data/ext/libsass/src/utf8/core.h +3 -0
  120. data/ext/libsass/src/utf8_string.cpp +3 -0
  121. data/ext/libsass/src/util.cpp +67 -75
  122. data/ext/libsass/src/util.hpp +64 -19
  123. data/ext/libsass/src/util_string.cpp +75 -0
  124. data/ext/libsass/src/util_string.hpp +19 -0
  125. data/ext/libsass/src/values.cpp +22 -13
  126. data/ext/libsass/src/values.hpp +2 -2
  127. data/ext/libsass/win/libsass.targets +30 -4
  128. data/ext/libsass/win/libsass.vcxproj.filters +82 -4
  129. data/lib/sassc.rb +24 -0
  130. data/lib/sassc/engine.rb +2 -2
  131. data/lib/sassc/native.rb +8 -1
  132. data/lib/sassc/version.rb +1 -1
  133. data/sassc.gemspec +19 -11
  134. data/test/engine_test.rb +26 -1
  135. data/test/native_test.rb +1 -1
  136. metadata +66 -72
  137. data/ext/Rakefile +0 -3
  138. data/ext/libsass/.github/CONTRIBUTING.md +0 -65
  139. data/ext/libsass/.github/ISSUE_TEMPLATE.md +0 -54
  140. data/ext/libsass/.travis.yml +0 -64
  141. data/ext/libsass/Readme.md +0 -104
  142. data/ext/libsass/SECURITY.md +0 -10
  143. data/ext/libsass/appveyor.yml +0 -91
  144. data/ext/libsass/docs/README.md +0 -20
  145. data/ext/libsass/docs/api-context-example.md +0 -45
  146. data/ext/libsass/docs/api-context-internal.md +0 -163
  147. data/ext/libsass/docs/api-context.md +0 -295
  148. data/ext/libsass/docs/api-doc.md +0 -215
  149. data/ext/libsass/docs/api-function-example.md +0 -67
  150. data/ext/libsass/docs/api-function-internal.md +0 -8
  151. data/ext/libsass/docs/api-function.md +0 -74
  152. data/ext/libsass/docs/api-importer-example.md +0 -112
  153. data/ext/libsass/docs/api-importer-internal.md +0 -20
  154. data/ext/libsass/docs/api-importer.md +0 -86
  155. data/ext/libsass/docs/api-value-example.md +0 -55
  156. data/ext/libsass/docs/api-value-internal.md +0 -76
  157. data/ext/libsass/docs/api-value.md +0 -154
  158. data/ext/libsass/docs/build-on-darwin.md +0 -27
  159. data/ext/libsass/docs/build-on-gentoo.md +0 -55
  160. data/ext/libsass/docs/build-on-windows.md +0 -139
  161. data/ext/libsass/docs/build-shared-library.md +0 -35
  162. data/ext/libsass/docs/build-with-autotools.md +0 -78
  163. data/ext/libsass/docs/build-with-makefiles.md +0 -68
  164. data/ext/libsass/docs/build-with-mingw.md +0 -107
  165. data/ext/libsass/docs/build-with-visual-studio.md +0 -90
  166. data/ext/libsass/docs/build.md +0 -97
  167. data/ext/libsass/docs/compatibility-plan.md +0 -48
  168. data/ext/libsass/docs/contributing.md +0 -17
  169. data/ext/libsass/docs/custom-functions-internal.md +0 -122
  170. data/ext/libsass/docs/dev-ast-memory.md +0 -223
  171. data/ext/libsass/docs/implementations.md +0 -56
  172. data/ext/libsass/docs/plugins.md +0 -47
  173. data/ext/libsass/docs/setup-environment.md +0 -68
  174. data/ext/libsass/docs/source-map-internals.md +0 -51
  175. data/ext/libsass/docs/trace.md +0 -26
  176. data/ext/libsass/docs/triage.md +0 -17
  177. data/ext/libsass/docs/unicode.md +0 -39
  178. data/ext/libsass/extconf.rb +0 -6
  179. data/ext/libsass/script/bootstrap +0 -13
  180. data/ext/libsass/script/branding +0 -10
  181. data/ext/libsass/script/ci-build-libsass +0 -134
  182. data/ext/libsass/script/ci-build-plugin +0 -62
  183. data/ext/libsass/script/ci-install-compiler +0 -6
  184. data/ext/libsass/script/ci-install-deps +0 -20
  185. data/ext/libsass/script/ci-report-coverage +0 -42
  186. data/ext/libsass/script/spec +0 -5
  187. data/ext/libsass/script/tap-driver +0 -652
  188. data/ext/libsass/script/tap-runner +0 -1
  189. data/ext/libsass/script/test-leaks.pl +0 -103
  190. data/ext/libsass/src/functions.cpp +0 -2234
  191. data/ext/libsass/src/functions.hpp +0 -198
  192. data/ext/libsass/src/to_c.hpp +0 -39
  193. data/ext/libsass/test/test_node.cpp +0 -94
  194. data/ext/libsass/test/test_paths.cpp +0 -28
  195. data/ext/libsass/test/test_selector_difference.cpp +0 -25
  196. data/ext/libsass/test/test_specificity.cpp +0 -25
  197. data/ext/libsass/test/test_subset_map.cpp +0 -472
  198. data/ext/libsass/test/test_superselector.cpp +0 -69
  199. data/ext/libsass/test/test_unification.cpp +0 -31
  200. data/lib/tasks/libsass.rb +0 -33
@@ -3,6 +3,7 @@
3
3
  #include "context.hpp"
4
4
  #include "output.hpp"
5
5
  #include "emitter.hpp"
6
+ #include "util_string.hpp"
6
7
  #include "utf8_string.hpp"
7
8
 
8
9
  namespace Sass {
@@ -47,11 +48,11 @@ namespace Sass {
47
48
  void Emitter::set_filename(const std::string& str)
48
49
  { wbuf.smap.file = str; }
49
50
 
50
- void Emitter::schedule_mapping(const AST_Node_Ptr node)
51
+ void Emitter::schedule_mapping(const AST_Node* node)
51
52
  { scheduled_mapping = node; }
52
- void Emitter::add_open_mapping(const AST_Node_Ptr node)
53
+ void Emitter::add_open_mapping(const AST_Node* node)
53
54
  { wbuf.smap.add_open_mapping(node); }
54
- void Emitter::add_close_mapping(const AST_Node_Ptr node)
55
+ void Emitter::add_close_mapping(const AST_Node* node)
55
56
  { wbuf.smap.add_close_mapping(node); }
56
57
  ParserState Emitter::remap(const ParserState& pstate)
57
58
  { return wbuf.smap.remap(pstate); }
@@ -134,13 +135,13 @@ namespace Sass {
134
135
  // write space/lf
135
136
  flush_schedules();
136
137
 
137
- if (in_comment && output_style() == COMPACT) {
138
- // unescape comment nodes
139
- std::string out = comment_to_string(text);
140
- // add to buffer
141
- wbuf.buffer += out;
142
- // account for data in source-maps
138
+ if (in_comment) {
139
+ std::string out = Util::normalize_newlines(text);
140
+ if (output_style() == COMPACT) {
141
+ out = comment_to_compact_string(out);
142
+ }
143
143
  wbuf.smap.append(Offset(out));
144
+ wbuf.buffer += std::move(out);
144
145
  } else {
145
146
  // add to buffer
146
147
  wbuf.buffer += text;
@@ -161,7 +162,7 @@ namespace Sass {
161
162
 
162
163
  // append some text or token to the buffer
163
164
  // this adds source-mappings for node start and end
164
- void Emitter::append_token(const std::string& text, const AST_Node_Ptr node)
165
+ void Emitter::append_token(const std::string& text, const AST_Node* node)
165
166
  {
166
167
  flush_schedules();
167
168
  add_open_mapping(node);
@@ -263,7 +264,7 @@ namespace Sass {
263
264
  }
264
265
  }
265
266
 
266
- void Emitter::append_scope_opener(AST_Node_Ptr node)
267
+ void Emitter::append_scope_opener(AST_Node* node)
267
268
  {
268
269
  scheduled_linefeed = 0;
269
270
  append_optional_space();
@@ -274,7 +275,7 @@ namespace Sass {
274
275
  // append_optional_space();
275
276
  ++ indentation;
276
277
  }
277
- void Emitter::append_scope_closer(AST_Node_Ptr node)
278
+ void Emitter::append_scope_closer(AST_Node* node)
278
279
  {
279
280
  -- indentation;
280
281
  scheduled_linefeed = 0;
@@ -1,8 +1,12 @@
1
1
  #ifndef SASS_EMITTER_H
2
2
  #define SASS_EMITTER_H
3
3
 
4
- #include <string>
4
+ // sass.hpp must go before all system headers to get the
5
+ // __EXTENSIONS__ fix on Solaris.
5
6
  #include "sass.hpp"
7
+
8
+ #include <string>
9
+
6
10
  #include "sass/base.h"
7
11
  #include "source_map.hpp"
8
12
  #include "ast_fwd_decl.hpp"
@@ -25,9 +29,9 @@ namespace Sass {
25
29
  // proxy methods for source maps
26
30
  void add_source_index(size_t idx);
27
31
  void set_filename(const std::string& str);
28
- void add_open_mapping(const AST_Node_Ptr node);
29
- void add_close_mapping(const AST_Node_Ptr node);
30
- void schedule_mapping(const AST_Node_Ptr node);
32
+ void add_open_mapping(const AST_Node* node);
33
+ void add_close_mapping(const AST_Node* node);
34
+ void schedule_mapping(const AST_Node* node);
31
35
  std::string render_srcmap(Context &ctx);
32
36
  ParserState remap(const ParserState& pstate);
33
37
 
@@ -37,8 +41,8 @@ namespace Sass {
37
41
  size_t scheduled_space;
38
42
  size_t scheduled_linefeed;
39
43
  bool scheduled_delimiter;
40
- AST_Node_Ptr scheduled_crutch;
41
- AST_Node_Ptr scheduled_mapping;
44
+ const AST_Node* scheduled_crutch;
45
+ const AST_Node* scheduled_mapping;
42
46
 
43
47
  public:
44
48
  // output strings different in custom css properties
@@ -75,7 +79,7 @@ namespace Sass {
75
79
  void append_wspace(const std::string& text);
76
80
  // append some text or token to the buffer
77
81
  // this adds source-mappings for node start and end
78
- void append_token(const std::string& text, const AST_Node_Ptr node);
82
+ void append_token(const std::string& text, const AST_Node* node);
79
83
  // query last appended character
80
84
  char last_char();
81
85
 
@@ -86,8 +90,8 @@ namespace Sass {
86
90
  void append_special_linefeed(void);
87
91
  void append_optional_linefeed(void);
88
92
  void append_mandatory_linefeed(void);
89
- void append_scope_opener(AST_Node_Ptr node = 0);
90
- void append_scope_closer(AST_Node_Ptr node = 0);
93
+ void append_scope_opener(AST_Node* node = 0);
94
+ void append_scope_closer(AST_Node* node = 0);
91
95
  void append_comma_separator(void);
92
96
  void append_colon_separator(void);
93
97
  void append_delimiter(void);
@@ -206,6 +206,20 @@ namespace Sass {
206
206
  }
207
207
  };
208
208
 
209
+ // use array access for getter and setter functions
210
+ template <typename T>
211
+ T& Environment<T>::get(const std::string& key)
212
+ {
213
+ auto cur = this;
214
+ while (cur) {
215
+ if (cur->has_local(key)) {
216
+ return cur->get_local(key);
217
+ }
218
+ cur = cur->parent_;
219
+ }
220
+ return get_local(key);
221
+ }
222
+
209
223
  // use array access for getter and setter functions
210
224
  template <typename T>
211
225
  T& Environment<T>::operator[](const std::string& key)
@@ -230,7 +244,7 @@ namespace Sass {
230
244
  for (typename environment_map<std::string, T>::iterator i = local_frame_.begin(); i != local_frame_.end(); ++i) {
231
245
  if (!ends_with(i->first, "[f]") && !ends_with(i->first, "[f]4") && !ends_with(i->first, "[f]2")) {
232
246
  std::cerr << prefix << std::string(indent, ' ') << i->first << " " << i->second;
233
- if (Value_Ptr val = Cast<Value>(i->second))
247
+ if (Value* val = Cast<Value>(i->second))
234
248
  { std::cerr << " : " << val->to_string(); }
235
249
  std::cerr << std::endl;
236
250
  }
@@ -7,6 +7,7 @@
7
7
 
8
8
  namespace Sass {
9
9
 
10
+ // this defeats the whole purpose of environment being templatable!!
10
11
  typedef environment_map<std::string, AST_Node_Obj>::iterator EnvIter;
11
12
 
12
13
  class EnvResult {
@@ -92,6 +93,10 @@ namespace Sass {
92
93
  // include all scopes available
93
94
  bool has(const std::string& key) const;
94
95
 
96
+ // look on the full stack for key
97
+ // include all scopes available
98
+ T& get(const std::string& key);
99
+
95
100
  // look on the full stack for key
96
101
  // include all scopes available
97
102
  EnvResult find(const std::string& key);
@@ -107,6 +112,7 @@ namespace Sass {
107
112
 
108
113
  // define typedef for our use case
109
114
  typedef Environment<AST_Node_Obj> Env;
115
+ typedef std::vector<Env*> EnvStack;
110
116
 
111
117
  }
112
118
 
@@ -1,4 +1,7 @@
1
+ // sass.hpp must go before all system headers to get the
2
+ // __EXTENSIONS__ fix on Solaris.
1
3
  #include "sass.hpp"
4
+
2
5
  #include "ast.hpp"
3
6
  #include "prelexer.hpp"
4
7
  #include "backtrace.hpp"
@@ -15,43 +18,38 @@ namespace Sass {
15
18
  prefix("Error"), pstate(pstate), traces(traces)
16
19
  { }
17
20
 
18
- InvalidSass::InvalidSass(ParserState pstate, Backtraces traces, std::string msg)
19
- : Base(pstate, msg, traces)
21
+ InvalidSass::InvalidSass(ParserState pstate, Backtraces traces, std::string msg, char* owned_src)
22
+ : Base(pstate, msg, traces), owned_src(owned_src)
20
23
  { }
21
24
 
22
25
 
23
- InvalidParent::InvalidParent(Selector_Ptr parent, Backtraces traces, Selector_Ptr selector)
26
+ InvalidParent::InvalidParent(Selector* parent, Backtraces traces, Selector* selector)
24
27
  : Base(selector->pstate(), def_msg, traces), parent(parent), selector(selector)
25
28
  {
26
- msg = "Invalid parent selector for \"";
27
- msg += selector->to_string(Sass_Inspect_Options());
28
- msg += "\": \"";
29
- msg += parent->to_string(Sass_Inspect_Options());
30
- msg += "\"";
29
+ msg = "Invalid parent selector for "
30
+ "\"" + selector->to_string(Sass_Inspect_Options()) + "\": "
31
+ "\"" + parent->to_string(Sass_Inspect_Options()) + "\"";
31
32
  }
32
33
 
33
- InvalidVarKwdType::InvalidVarKwdType(ParserState pstate, Backtraces traces, std::string name, const Argument_Ptr arg)
34
+ InvalidVarKwdType::InvalidVarKwdType(ParserState pstate, Backtraces traces, std::string name, const Argument* arg)
34
35
  : Base(pstate, def_msg, traces), name(name), arg(arg)
35
36
  {
36
- msg = "Variable keyword argument map must have string keys.\n";
37
- msg += name + " is not a string in " + arg->to_string() + ".";
37
+ msg = "Variable keyword argument map must have string keys.\n" +
38
+ name + " is not a string in " + arg->to_string() + ".";
38
39
  }
39
40
 
40
- InvalidArgumentType::InvalidArgumentType(ParserState pstate, Backtraces traces, std::string fn, std::string arg, std::string type, const Value_Ptr value)
41
+ InvalidArgumentType::InvalidArgumentType(ParserState pstate, Backtraces traces, std::string fn, std::string arg, std::string type, const Value* value)
41
42
  : Base(pstate, def_msg, traces), fn(fn), arg(arg), type(type), value(value)
42
43
  {
43
- msg = arg + ": \"";
44
+ msg = arg + ": \"";
44
45
  if (value) msg += value->to_string(Sass_Inspect_Options());
45
- msg += "\" is not a " + type;
46
- msg += " for `" + fn + "'";
46
+ msg += "\" is not a " + type + " for `" + fn + "'";
47
47
  }
48
48
 
49
49
  MissingArgument::MissingArgument(ParserState pstate, Backtraces traces, std::string fn, std::string arg, std::string fntype)
50
50
  : Base(pstate, def_msg, traces), fn(fn), arg(arg), fntype(fntype)
51
51
  {
52
- msg = fntype + " " + fn;
53
- msg += " is missing argument ";
54
- msg += arg + ".";
52
+ msg = fntype + " " + fn + " is missing argument " + arg + ".";
55
53
  }
56
54
 
57
55
  InvalidSyntax::InvalidSyntax(ParserState pstate, Backtraces traces, std::string msg)
@@ -65,87 +63,66 @@ namespace Sass {
65
63
  DuplicateKeyError::DuplicateKeyError(Backtraces traces, const Map& dup, const Expression& org)
66
64
  : Base(org.pstate(), def_msg, traces), dup(dup), org(org)
67
65
  {
68
- msg = "Duplicate key ";
69
- msg += dup.get_duplicate_key()->inspect();
70
- msg += " in map (";
71
- msg += org.inspect();
72
- msg += ").";
66
+ msg = "Duplicate key " + dup.get_duplicate_key()->inspect() + " in map (" + org.inspect() + ").";
73
67
  }
74
68
 
75
69
  TypeMismatch::TypeMismatch(Backtraces traces, const Expression& var, const std::string type)
76
70
  : Base(var.pstate(), def_msg, traces), var(var), type(type)
77
71
  {
78
- msg = var.to_string();
79
- msg += " is not an ";
80
- msg += type;
81
- msg += ".";
72
+ msg = var.to_string() + " is not an " + type + ".";
82
73
  }
83
74
 
84
75
  InvalidValue::InvalidValue(Backtraces traces, const Expression& val)
85
76
  : Base(val.pstate(), def_msg, traces), val(val)
86
77
  {
87
- msg = val.to_string();
88
- msg += " isn't a valid CSS value.";
78
+ msg = val.to_string() + " isn't a valid CSS value.";
89
79
  }
90
80
 
91
81
  StackError::StackError(Backtraces traces, const AST_Node& node)
92
82
  : Base(node.pstate(), def_msg, traces), node(node)
93
83
  {
94
- msg = "stack level too deep";
84
+ msg = "stack level too deep";
95
85
  }
96
86
 
97
87
  IncompatibleUnits::IncompatibleUnits(const Units& lhs, const Units& rhs)
98
88
  {
99
- msg = "Incompatible units: '";
100
- msg += rhs.unit();
101
- msg += "' and '";
102
- msg += lhs.unit();
103
- msg += "'.";
89
+ msg = "Incompatible units: '" + rhs.unit() + "' and '" + lhs.unit() + "'.";
104
90
  }
105
91
 
106
92
  IncompatibleUnits::IncompatibleUnits(const UnitType lhs, const UnitType rhs)
107
93
  {
108
- msg = "Incompatible units: '";
109
- msg += unit_to_string(rhs);
110
- msg += "' and '";
111
- msg += unit_to_string(lhs);
112
- msg += "'.";
94
+ msg = std::string("Incompatible units: '") + unit_to_string(rhs) + "' and '" + unit_to_string(lhs) + "'.";
113
95
  }
114
96
 
115
- AlphaChannelsNotEqual::AlphaChannelsNotEqual(Expression_Ptr_Const lhs, Expression_Ptr_Const rhs, enum Sass_OP op)
97
+ AlphaChannelsNotEqual::AlphaChannelsNotEqual(const Expression* lhs, const Expression* rhs, enum Sass_OP op)
116
98
  : OperationError(), lhs(lhs), rhs(rhs), op(op)
117
99
  {
118
- msg = "Alpha channels must be equal: ";
119
- msg += lhs->to_string({ NESTED, 5 });
120
- msg += " " + sass_op_to_name(op) + " ";
121
- msg += rhs->to_string({ NESTED, 5 });
122
- msg += ".";
100
+ msg = "Alpha channels must be equal: " +
101
+ lhs->to_string({ NESTED, 5 }) +
102
+ " " + sass_op_to_name(op) + " " +
103
+ rhs->to_string({ NESTED, 5 }) + ".";
123
104
  }
124
105
 
125
106
  ZeroDivisionError::ZeroDivisionError(const Expression& lhs, const Expression& rhs)
126
107
  : OperationError(), lhs(lhs), rhs(rhs)
127
108
  {
128
- msg = "divided by 0";
109
+ msg = "divided by 0";
129
110
  }
130
111
 
131
- UndefinedOperation::UndefinedOperation(Expression_Ptr_Const lhs, Expression_Ptr_Const rhs, enum Sass_OP op)
112
+ UndefinedOperation::UndefinedOperation(const Expression* lhs, const Expression* rhs, enum Sass_OP op)
132
113
  : OperationError(), lhs(lhs), rhs(rhs), op(op)
133
114
  {
134
- msg = def_op_msg + ": \"";
135
- msg += lhs->to_string({ NESTED, 5 });
136
- msg += " " + sass_op_to_name(op) + " ";
137
- msg += rhs->to_string({ TO_SASS, 5 });
138
- msg += "\".";
115
+ msg = def_op_msg + ": \"" +
116
+ lhs->to_string({ NESTED, 5 }) +
117
+ " " + sass_op_to_name(op) + " " +
118
+ rhs->to_string({ TO_SASS, 5 }) +
119
+ "\".";
139
120
  }
140
121
 
141
- InvalidNullOperation::InvalidNullOperation(Expression_Ptr_Const lhs, Expression_Ptr_Const rhs, enum Sass_OP op)
122
+ InvalidNullOperation::InvalidNullOperation(const Expression* lhs, const Expression* rhs, enum Sass_OP op)
142
123
  : UndefinedOperation(lhs, rhs, op)
143
124
  {
144
- msg = def_op_null_msg + ": \"";
145
- msg += lhs->inspect();
146
- msg += " " + sass_op_to_name(op) + " ";
147
- msg += rhs->inspect();
148
- msg += "\".";
125
+ msg = def_op_null_msg + ": \"" + lhs->inspect() + " " + sass_op_to_name(op) + " " + rhs->inspect() + "\".";
149
126
  }
150
127
 
151
128
  SassValueError::SassValueError(Backtraces traces, ParserState pstate, OperationError& err)
@@ -4,6 +4,7 @@
4
4
  #include <string>
5
5
  #include <sstream>
6
6
  #include <stdexcept>
7
+ #include "units.hpp"
7
8
  #include "position.hpp"
8
9
  #include "backtrace.hpp"
9
10
  #include "ast_fwd_decl.hpp"
@@ -36,16 +37,28 @@ namespace Sass {
36
37
 
37
38
  class InvalidSass : public Base {
38
39
  public:
39
- InvalidSass(ParserState pstate, Backtraces traces, std::string msg);
40
- virtual ~InvalidSass() throw() {};
40
+ InvalidSass(InvalidSass& other) : Base(other), owned_src(other.owned_src) {
41
+ // Assumes that `this` will outlive `other`.
42
+ other.owned_src = nullptr;
43
+ }
44
+
45
+ // Required because the copy constructor's argument is not const.
46
+ // Can't use `std::move` here because we build on Visual Studio 2013.
47
+ InvalidSass(InvalidSass &&other) : Base(other), owned_src(other.owned_src) {
48
+ other.owned_src = nullptr;
49
+ }
50
+
51
+ InvalidSass(ParserState pstate, Backtraces traces, std::string msg, char* owned_src = nullptr);
52
+ virtual ~InvalidSass() throw() { sass_free_memory(owned_src); };
53
+ char *owned_src;
41
54
  };
42
55
 
43
56
  class InvalidParent : public Base {
44
57
  protected:
45
- Selector_Ptr parent;
46
- Selector_Ptr selector;
58
+ Selector* parent;
59
+ Selector* selector;
47
60
  public:
48
- InvalidParent(Selector_Ptr parent, Backtraces traces, Selector_Ptr selector);
61
+ InvalidParent(Selector* parent, Backtraces traces, Selector* selector);
49
62
  virtual ~InvalidParent() throw() {};
50
63
  };
51
64
 
@@ -64,18 +77,18 @@ namespace Sass {
64
77
  std::string fn;
65
78
  std::string arg;
66
79
  std::string type;
67
- const Value_Ptr value;
80
+ const Value* value;
68
81
  public:
69
- InvalidArgumentType(ParserState pstate, Backtraces traces, std::string fn, std::string arg, std::string type, const Value_Ptr value = 0);
82
+ InvalidArgumentType(ParserState pstate, Backtraces traces, std::string fn, std::string arg, std::string type, const Value* value = 0);
70
83
  virtual ~InvalidArgumentType() throw() {};
71
84
  };
72
85
 
73
86
  class InvalidVarKwdType : public Base {
74
87
  protected:
75
88
  std::string name;
76
- const Argument_Ptr arg;
89
+ const Argument* arg;
77
90
  public:
78
- InvalidVarKwdType(ParserState pstate, Backtraces traces, std::string name, const Argument_Ptr arg = 0);
91
+ InvalidVarKwdType(ParserState pstate, Backtraces traces, std::string name, const Argument* arg = 0);
79
92
  virtual ~InvalidVarKwdType() throw() {};
80
93
  };
81
94
 
@@ -165,28 +178,28 @@ namespace Sass {
165
178
 
166
179
  class UndefinedOperation : public OperationError {
167
180
  protected:
168
- Expression_Ptr_Const lhs;
169
- Expression_Ptr_Const rhs;
181
+ const Expression* lhs;
182
+ const Expression* rhs;
170
183
  const Sass_OP op;
171
184
  public:
172
- UndefinedOperation(Expression_Ptr_Const lhs, Expression_Ptr_Const rhs, enum Sass_OP op);
185
+ UndefinedOperation(const Expression* lhs, const Expression* rhs, enum Sass_OP op);
173
186
  // virtual const char* errtype() const { return "Error"; }
174
187
  virtual ~UndefinedOperation() throw() {};
175
188
  };
176
189
 
177
190
  class InvalidNullOperation : public UndefinedOperation {
178
191
  public:
179
- InvalidNullOperation(Expression_Ptr_Const lhs, Expression_Ptr_Const rhs, enum Sass_OP op);
192
+ InvalidNullOperation(const Expression* lhs, const Expression* rhs, enum Sass_OP op);
180
193
  virtual ~InvalidNullOperation() throw() {};
181
194
  };
182
195
 
183
196
  class AlphaChannelsNotEqual : public OperationError {
184
197
  protected:
185
- Expression_Ptr_Const lhs;
186
- Expression_Ptr_Const rhs;
198
+ const Expression* lhs;
199
+ const Expression* rhs;
187
200
  const Sass_OP op;
188
201
  public:
189
- AlphaChannelsNotEqual(Expression_Ptr_Const lhs, Expression_Ptr_Const rhs, enum Sass_OP op);
202
+ AlphaChannelsNotEqual(const Expression* lhs, const Expression* rhs, enum Sass_OP op);
190
203
  // virtual const char* errtype() const { return "Error"; }
191
204
  virtual ~AlphaChannelsNotEqual() throw() {};
192
205
  };