sassc 2.0.0 → 2.4.0

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 (260) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -0
  3. data/.gitmodules +1 -1
  4. data/.travis.yml +9 -3
  5. data/CHANGELOG.md +36 -0
  6. data/CODE_OF_CONDUCT.md +1 -1
  7. data/README.md +1 -1
  8. data/Rakefile +43 -7
  9. data/ext/depend +4 -0
  10. data/ext/extconf.rb +92 -0
  11. data/ext/libsass/VERSION +1 -0
  12. data/ext/libsass/include/sass/base.h +9 -1
  13. data/ext/libsass/include/sass/context.h +5 -1
  14. data/ext/libsass/src/MurmurHash2.hpp +91 -0
  15. data/ext/libsass/src/ast.cpp +755 -2028
  16. data/ext/libsass/src/ast.hpp +492 -2477
  17. data/ext/libsass/src/{to_c.cpp → ast2c.cpp} +22 -16
  18. data/ext/libsass/src/ast2c.hpp +39 -0
  19. data/ext/libsass/src/ast_def_macros.hpp +70 -10
  20. data/ext/libsass/src/ast_fwd_decl.cpp +5 -3
  21. data/ext/libsass/src/ast_fwd_decl.hpp +107 -296
  22. data/ext/libsass/src/ast_helpers.hpp +292 -0
  23. data/ext/libsass/src/ast_sel_cmp.cpp +396 -0
  24. data/ext/libsass/src/ast_sel_super.cpp +539 -0
  25. data/ext/libsass/src/ast_sel_unify.cpp +275 -0
  26. data/ext/libsass/src/ast_sel_weave.cpp +616 -0
  27. data/ext/libsass/src/ast_selectors.cpp +1043 -0
  28. data/ext/libsass/src/ast_selectors.hpp +522 -0
  29. data/ext/libsass/src/ast_supports.cpp +114 -0
  30. data/ext/libsass/src/ast_supports.hpp +121 -0
  31. data/ext/libsass/src/ast_values.cpp +1154 -0
  32. data/ext/libsass/src/ast_values.hpp +498 -0
  33. data/ext/libsass/src/backtrace.cpp +11 -7
  34. data/ext/libsass/src/backtrace.hpp +5 -5
  35. data/ext/libsass/src/base64vlq.cpp +5 -2
  36. data/ext/libsass/src/base64vlq.hpp +1 -1
  37. data/ext/libsass/src/bind.cpp +35 -34
  38. data/ext/libsass/src/bind.hpp +3 -1
  39. data/ext/libsass/src/c2ast.cpp +64 -0
  40. data/ext/libsass/src/c2ast.hpp +14 -0
  41. data/ext/libsass/src/cencode.c +4 -6
  42. data/ext/libsass/src/check_nesting.cpp +83 -88
  43. data/ext/libsass/src/check_nesting.hpp +39 -34
  44. data/ext/libsass/src/color_maps.cpp +168 -164
  45. data/ext/libsass/src/color_maps.hpp +152 -160
  46. data/ext/libsass/src/constants.cpp +20 -0
  47. data/ext/libsass/src/constants.hpp +19 -0
  48. data/ext/libsass/src/context.cpp +104 -121
  49. data/ext/libsass/src/context.hpp +43 -55
  50. data/ext/libsass/src/cssize.cpp +103 -188
  51. data/ext/libsass/src/cssize.hpp +45 -51
  52. data/ext/libsass/src/dart_helpers.hpp +199 -0
  53. data/ext/libsass/src/debugger.hpp +524 -361
  54. data/ext/libsass/src/emitter.cpp +26 -26
  55. data/ext/libsass/src/emitter.hpp +20 -18
  56. data/ext/libsass/src/environment.cpp +41 -27
  57. data/ext/libsass/src/environment.hpp +33 -22
  58. data/ext/libsass/src/error_handling.cpp +92 -94
  59. data/ext/libsass/src/error_handling.hpp +73 -50
  60. data/ext/libsass/src/eval.cpp +380 -515
  61. data/ext/libsass/src/eval.hpp +64 -57
  62. data/ext/libsass/src/eval_selectors.cpp +75 -0
  63. data/ext/libsass/src/expand.cpp +322 -263
  64. data/ext/libsass/src/expand.hpp +55 -39
  65. data/ext/libsass/src/extender.cpp +1188 -0
  66. data/ext/libsass/src/extender.hpp +399 -0
  67. data/ext/libsass/src/extension.cpp +43 -0
  68. data/ext/libsass/src/extension.hpp +89 -0
  69. data/ext/libsass/src/file.cpp +134 -88
  70. data/ext/libsass/src/file.hpp +28 -37
  71. data/ext/libsass/src/fn_colors.cpp +596 -0
  72. data/ext/libsass/src/fn_colors.hpp +85 -0
  73. data/ext/libsass/src/fn_lists.cpp +285 -0
  74. data/ext/libsass/src/fn_lists.hpp +34 -0
  75. data/ext/libsass/src/fn_maps.cpp +94 -0
  76. data/ext/libsass/src/fn_maps.hpp +30 -0
  77. data/ext/libsass/src/fn_miscs.cpp +244 -0
  78. data/ext/libsass/src/fn_miscs.hpp +40 -0
  79. data/ext/libsass/src/fn_numbers.cpp +227 -0
  80. data/ext/libsass/src/fn_numbers.hpp +45 -0
  81. data/ext/libsass/src/fn_selectors.cpp +205 -0
  82. data/ext/libsass/src/fn_selectors.hpp +35 -0
  83. data/ext/libsass/src/fn_strings.cpp +268 -0
  84. data/ext/libsass/src/fn_strings.hpp +34 -0
  85. data/ext/libsass/src/fn_utils.cpp +158 -0
  86. data/ext/libsass/src/fn_utils.hpp +62 -0
  87. data/ext/libsass/src/inspect.cpp +253 -266
  88. data/ext/libsass/src/inspect.hpp +72 -74
  89. data/ext/libsass/src/json.cpp +2 -2
  90. data/ext/libsass/src/lexer.cpp +25 -84
  91. data/ext/libsass/src/lexer.hpp +5 -16
  92. data/ext/libsass/src/listize.cpp +27 -43
  93. data/ext/libsass/src/listize.hpp +14 -11
  94. data/ext/libsass/src/mapping.hpp +1 -0
  95. data/ext/libsass/src/memory.hpp +12 -0
  96. data/ext/libsass/src/memory/allocator.cpp +48 -0
  97. data/ext/libsass/src/memory/allocator.hpp +138 -0
  98. data/ext/libsass/src/memory/config.hpp +20 -0
  99. data/ext/libsass/src/memory/memory_pool.hpp +186 -0
  100. data/ext/libsass/src/memory/shared_ptr.cpp +33 -0
  101. data/ext/libsass/src/memory/shared_ptr.hpp +332 -0
  102. data/ext/libsass/src/operation.hpp +193 -143
  103. data/ext/libsass/src/operators.cpp +56 -29
  104. data/ext/libsass/src/operators.hpp +11 -11
  105. data/ext/libsass/src/ordered_map.hpp +112 -0
  106. data/ext/libsass/src/output.cpp +59 -75
  107. data/ext/libsass/src/output.hpp +15 -22
  108. data/ext/libsass/src/parser.cpp +662 -818
  109. data/ext/libsass/src/parser.hpp +96 -100
  110. data/ext/libsass/src/parser_selectors.cpp +189 -0
  111. data/ext/libsass/src/permutate.hpp +164 -0
  112. data/ext/libsass/src/plugins.cpp +12 -8
  113. data/ext/libsass/src/plugins.hpp +8 -8
  114. data/ext/libsass/src/position.cpp +10 -26
  115. data/ext/libsass/src/position.hpp +44 -21
  116. data/ext/libsass/src/prelexer.cpp +14 -8
  117. data/ext/libsass/src/prelexer.hpp +9 -9
  118. data/ext/libsass/src/remove_placeholders.cpp +59 -57
  119. data/ext/libsass/src/remove_placeholders.hpp +20 -18
  120. data/ext/libsass/src/sass.cpp +25 -18
  121. data/ext/libsass/src/sass.hpp +22 -14
  122. data/ext/libsass/src/sass2scss.cpp +49 -18
  123. data/ext/libsass/src/sass_context.cpp +104 -132
  124. data/ext/libsass/src/sass_context.hpp +2 -2
  125. data/ext/libsass/src/sass_functions.cpp +7 -4
  126. data/ext/libsass/src/sass_functions.hpp +1 -1
  127. data/ext/libsass/src/sass_values.cpp +26 -21
  128. data/ext/libsass/src/settings.hpp +19 -0
  129. data/ext/libsass/src/source.cpp +69 -0
  130. data/ext/libsass/src/source.hpp +95 -0
  131. data/ext/libsass/src/source_data.hpp +32 -0
  132. data/ext/libsass/src/source_map.cpp +27 -20
  133. data/ext/libsass/src/source_map.hpp +14 -11
  134. data/ext/libsass/src/stylesheet.cpp +22 -0
  135. data/ext/libsass/src/stylesheet.hpp +57 -0
  136. data/ext/libsass/src/to_value.cpp +24 -22
  137. data/ext/libsass/src/to_value.hpp +18 -22
  138. data/ext/libsass/src/units.cpp +28 -22
  139. data/ext/libsass/src/units.hpp +9 -8
  140. data/ext/libsass/src/utf8/checked.h +12 -10
  141. data/ext/libsass/src/utf8/core.h +3 -0
  142. data/ext/libsass/src/utf8_string.cpp +12 -10
  143. data/ext/libsass/src/utf8_string.hpp +7 -6
  144. data/ext/libsass/src/util.cpp +97 -107
  145. data/ext/libsass/src/util.hpp +74 -30
  146. data/ext/libsass/src/util_string.cpp +125 -0
  147. data/ext/libsass/src/util_string.hpp +73 -0
  148. data/ext/libsass/src/values.cpp +33 -24
  149. data/ext/libsass/src/values.hpp +2 -2
  150. data/lib/sassc.rb +24 -0
  151. data/lib/sassc/engine.rb +7 -5
  152. data/lib/sassc/functions_handler.rb +11 -13
  153. data/lib/sassc/native.rb +10 -9
  154. data/lib/sassc/native/native_functions_api.rb +0 -5
  155. data/lib/sassc/script.rb +4 -6
  156. data/lib/sassc/version.rb +1 -1
  157. data/sassc.gemspec +32 -12
  158. data/test/engine_test.rb +32 -2
  159. data/test/functions_test.rb +38 -1
  160. data/test/native_test.rb +4 -4
  161. metadata +95 -109
  162. data/ext/Rakefile +0 -3
  163. data/ext/libsass/.editorconfig +0 -15
  164. data/ext/libsass/.gitattributes +0 -2
  165. data/ext/libsass/.github/CONTRIBUTING.md +0 -65
  166. data/ext/libsass/.github/ISSUE_TEMPLATE.md +0 -54
  167. data/ext/libsass/.gitignore +0 -85
  168. data/ext/libsass/.travis.yml +0 -64
  169. data/ext/libsass/COPYING +0 -25
  170. data/ext/libsass/GNUmakefile.am +0 -88
  171. data/ext/libsass/INSTALL +0 -1
  172. data/ext/libsass/LICENSE +0 -25
  173. data/ext/libsass/Makefile +0 -351
  174. data/ext/libsass/Makefile.conf +0 -55
  175. data/ext/libsass/Readme.md +0 -104
  176. data/ext/libsass/SECURITY.md +0 -10
  177. data/ext/libsass/appveyor.yml +0 -91
  178. data/ext/libsass/configure.ac +0 -138
  179. data/ext/libsass/contrib/libsass.spec +0 -66
  180. data/ext/libsass/docs/README.md +0 -20
  181. data/ext/libsass/docs/api-context-example.md +0 -45
  182. data/ext/libsass/docs/api-context-internal.md +0 -163
  183. data/ext/libsass/docs/api-context.md +0 -295
  184. data/ext/libsass/docs/api-doc.md +0 -215
  185. data/ext/libsass/docs/api-function-example.md +0 -67
  186. data/ext/libsass/docs/api-function-internal.md +0 -8
  187. data/ext/libsass/docs/api-function.md +0 -74
  188. data/ext/libsass/docs/api-importer-example.md +0 -112
  189. data/ext/libsass/docs/api-importer-internal.md +0 -20
  190. data/ext/libsass/docs/api-importer.md +0 -86
  191. data/ext/libsass/docs/api-value-example.md +0 -55
  192. data/ext/libsass/docs/api-value-internal.md +0 -76
  193. data/ext/libsass/docs/api-value.md +0 -154
  194. data/ext/libsass/docs/build-on-darwin.md +0 -27
  195. data/ext/libsass/docs/build-on-gentoo.md +0 -55
  196. data/ext/libsass/docs/build-on-windows.md +0 -139
  197. data/ext/libsass/docs/build-shared-library.md +0 -35
  198. data/ext/libsass/docs/build-with-autotools.md +0 -78
  199. data/ext/libsass/docs/build-with-makefiles.md +0 -68
  200. data/ext/libsass/docs/build-with-mingw.md +0 -107
  201. data/ext/libsass/docs/build-with-visual-studio.md +0 -90
  202. data/ext/libsass/docs/build.md +0 -97
  203. data/ext/libsass/docs/compatibility-plan.md +0 -48
  204. data/ext/libsass/docs/contributing.md +0 -17
  205. data/ext/libsass/docs/custom-functions-internal.md +0 -122
  206. data/ext/libsass/docs/dev-ast-memory.md +0 -223
  207. data/ext/libsass/docs/implementations.md +0 -56
  208. data/ext/libsass/docs/plugins.md +0 -47
  209. data/ext/libsass/docs/setup-environment.md +0 -68
  210. data/ext/libsass/docs/source-map-internals.md +0 -51
  211. data/ext/libsass/docs/trace.md +0 -26
  212. data/ext/libsass/docs/triage.md +0 -17
  213. data/ext/libsass/docs/unicode.md +0 -39
  214. data/ext/libsass/extconf.rb +0 -6
  215. data/ext/libsass/include/sass/version.h.in +0 -12
  216. data/ext/libsass/m4/.gitkeep +0 -0
  217. data/ext/libsass/m4/m4-ax_cxx_compile_stdcxx_11.m4 +0 -167
  218. data/ext/libsass/res/resource.rc +0 -35
  219. data/ext/libsass/script/bootstrap +0 -13
  220. data/ext/libsass/script/branding +0 -10
  221. data/ext/libsass/script/ci-build-libsass +0 -134
  222. data/ext/libsass/script/ci-build-plugin +0 -62
  223. data/ext/libsass/script/ci-install-compiler +0 -6
  224. data/ext/libsass/script/ci-install-deps +0 -20
  225. data/ext/libsass/script/ci-report-coverage +0 -42
  226. data/ext/libsass/script/spec +0 -5
  227. data/ext/libsass/script/tap-driver +0 -652
  228. data/ext/libsass/script/tap-runner +0 -1
  229. data/ext/libsass/script/test-leaks.pl +0 -103
  230. data/ext/libsass/src/GNUmakefile.am +0 -54
  231. data/ext/libsass/src/extend.cpp +0 -2130
  232. data/ext/libsass/src/extend.hpp +0 -86
  233. data/ext/libsass/src/functions.cpp +0 -2234
  234. data/ext/libsass/src/functions.hpp +0 -198
  235. data/ext/libsass/src/memory/SharedPtr.cpp +0 -114
  236. data/ext/libsass/src/memory/SharedPtr.hpp +0 -206
  237. data/ext/libsass/src/node.cpp +0 -319
  238. data/ext/libsass/src/node.hpp +0 -118
  239. data/ext/libsass/src/paths.hpp +0 -71
  240. data/ext/libsass/src/sass_util.cpp +0 -149
  241. data/ext/libsass/src/sass_util.hpp +0 -256
  242. data/ext/libsass/src/subset_map.cpp +0 -55
  243. data/ext/libsass/src/subset_map.hpp +0 -76
  244. data/ext/libsass/src/support/libsass.pc.in +0 -11
  245. data/ext/libsass/src/to_c.hpp +0 -39
  246. data/ext/libsass/test/test_node.cpp +0 -94
  247. data/ext/libsass/test/test_paths.cpp +0 -28
  248. data/ext/libsass/test/test_selector_difference.cpp +0 -25
  249. data/ext/libsass/test/test_specificity.cpp +0 -25
  250. data/ext/libsass/test/test_subset_map.cpp +0 -472
  251. data/ext/libsass/test/test_superselector.cpp +0 -69
  252. data/ext/libsass/test/test_unification.cpp +0 -31
  253. data/ext/libsass/version.sh +0 -10
  254. data/ext/libsass/win/libsass.sln +0 -39
  255. data/ext/libsass/win/libsass.sln.DotSettings +0 -9
  256. data/ext/libsass/win/libsass.targets +0 -118
  257. data/ext/libsass/win/libsass.vcxproj +0 -188
  258. data/ext/libsass/win/libsass.vcxproj.filters +0 -357
  259. data/lib/sassc/native/lib_c.rb +0 -21
  260. data/lib/tasks/libsass.rb +0 -33
@@ -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"
@@ -10,196 +13,191 @@ namespace Sass {
10
13
 
11
14
  namespace Exception {
12
15
 
13
- Base::Base(ParserState pstate, std::string msg, Backtraces traces)
14
- : std::runtime_error(msg), msg(msg),
16
+ Base::Base(SourceSpan pstate, sass::string msg, Backtraces traces)
17
+ : std::runtime_error(msg.c_str()), msg(msg),
15
18
  prefix("Error"), pstate(pstate), traces(traces)
16
19
  { }
17
20
 
18
- InvalidSass::InvalidSass(ParserState pstate, Backtraces traces, std::string msg)
21
+ InvalidSass::InvalidSass(SourceSpan pstate, Backtraces traces, sass::string msg)
19
22
  : Base(pstate, msg, traces)
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(SourceSpan pstate, Backtraces traces, sass::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(SourceSpan pstate, Backtraces traces, sass::string fn, sass::string arg, sass::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
- MissingArgument::MissingArgument(ParserState pstate, Backtraces traces, std::string fn, std::string arg, std::string fntype)
49
+ MissingArgument::MissingArgument(SourceSpan pstate, Backtraces traces, sass::string fn, sass::string arg, sass::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
- InvalidSyntax::InvalidSyntax(ParserState pstate, Backtraces traces, std::string msg)
55
+ InvalidSyntax::InvalidSyntax(SourceSpan pstate, Backtraces traces, sass::string msg)
58
56
  : Base(pstate, msg, traces)
59
57
  { }
60
58
 
61
- NestingLimitError::NestingLimitError(ParserState pstate, Backtraces traces, std::string msg)
59
+ NestingLimitError::NestingLimitError(SourceSpan pstate, Backtraces traces, sass::string msg)
62
60
  : Base(pstate, msg, traces)
63
61
  { }
64
62
 
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
- TypeMismatch::TypeMismatch(Backtraces traces, const Expression& var, const std::string type)
69
+ TypeMismatch::TypeMismatch(Backtraces traces, const Expression& var, const sass::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 = sass::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
- SassValueError::SassValueError(Backtraces traces, ParserState pstate, OperationError& err)
128
+ SassValueError::SassValueError(Backtraces traces, SourceSpan pstate, OperationError& err)
152
129
  : Base(pstate, err.what(), traces)
153
130
  {
154
131
  msg = err.what();
155
132
  prefix = err.errtype();
156
133
  }
157
134
 
135
+ TopLevelParent::TopLevelParent(Backtraces traces, SourceSpan pstate)
136
+ : Base(pstate, "Top-level selectors may not contain the parent selector \"&\".", traces)
137
+ {
138
+
139
+ }
140
+
141
+ UnsatisfiedExtend::UnsatisfiedExtend(Backtraces traces, Extension extension)
142
+ : Base(extension.target->pstate(), "The target selector was not found.\n"
143
+ "Use \"@extend " + extension.target->to_string() + " !optional\" to avoid this error.", traces)
144
+ {
145
+
146
+ }
147
+
148
+ ExtendAcrossMedia::ExtendAcrossMedia(Backtraces traces, Extension extension)
149
+ : Base(extension.target->pstate(), "You may not @extend selectors across media queries.\n"
150
+ "Use \"@extend " + extension.target->to_string() + " !optional\" to avoid this error.", traces)
151
+ {
152
+
153
+ }
154
+
155
+
158
156
  }
159
157
 
160
158
 
161
- void warn(std::string msg, ParserState pstate)
159
+ void warn(sass::string msg, SourceSpan pstate)
162
160
  {
163
161
  std::cerr << "Warning: " << msg << std::endl;
164
162
  }
165
163
 
166
- void warning(std::string msg, ParserState pstate)
164
+ void warning(sass::string msg, SourceSpan pstate)
167
165
  {
168
- std::string cwd(Sass::File::get_cwd());
169
- std::string abs_path(Sass::File::rel2abs(pstate.path, cwd, cwd));
170
- std::string rel_path(Sass::File::abs2rel(pstate.path, cwd, cwd));
171
- std::string output_path(Sass::File::path_for_console(rel_path, abs_path, pstate.path));
166
+ sass::string cwd(Sass::File::get_cwd());
167
+ sass::string abs_path(Sass::File::rel2abs(pstate.getPath(), cwd, cwd));
168
+ sass::string rel_path(Sass::File::abs2rel(pstate.getPath(), cwd, cwd));
169
+ sass::string output_path(Sass::File::path_for_console(rel_path, abs_path, pstate.getPath()));
172
170
 
173
- std::cerr << "WARNING on line " << pstate.line+1 << ", column " << pstate.column+1 << " of " << output_path << ":" << std::endl;
171
+ std::cerr << "WARNING on line " << pstate.getLine() << ", column " << pstate.getColumn() << " of " << output_path << ":" << std::endl;
174
172
  std::cerr << msg << std::endl << std::endl;
175
173
  }
176
174
 
177
- void warn(std::string msg, ParserState pstate, Backtrace* bt)
175
+ void warn(sass::string msg, SourceSpan pstate, Backtrace* bt)
178
176
  {
179
177
  warn(msg, pstate);
180
178
  }
181
179
 
182
- void deprecated_function(std::string msg, ParserState pstate)
180
+ void deprecated_function(sass::string msg, SourceSpan pstate)
183
181
  {
184
- std::string cwd(Sass::File::get_cwd());
185
- std::string abs_path(Sass::File::rel2abs(pstate.path, cwd, cwd));
186
- std::string rel_path(Sass::File::abs2rel(pstate.path, cwd, cwd));
187
- std::string output_path(Sass::File::path_for_console(rel_path, abs_path, pstate.path));
182
+ sass::string cwd(Sass::File::get_cwd());
183
+ sass::string abs_path(Sass::File::rel2abs(pstate.getPath(), cwd, cwd));
184
+ sass::string rel_path(Sass::File::abs2rel(pstate.getPath(), cwd, cwd));
185
+ sass::string output_path(Sass::File::path_for_console(rel_path, abs_path, pstate.getPath()));
188
186
 
189
187
  std::cerr << "DEPRECATION WARNING: " << msg << std::endl;
190
188
  std::cerr << "will be an error in future versions of Sass." << std::endl;
191
- std::cerr << " on line " << pstate.line+1 << " of " << output_path << std::endl;
189
+ std::cerr << " on line " << pstate.getLine() << " of " << output_path << std::endl;
192
190
  }
193
191
 
194
- void deprecated(std::string msg, std::string msg2, bool with_column, ParserState pstate)
192
+ void deprecated(sass::string msg, sass::string msg2, bool with_column, SourceSpan pstate)
195
193
  {
196
- std::string cwd(Sass::File::get_cwd());
197
- std::string abs_path(Sass::File::rel2abs(pstate.path, cwd, cwd));
198
- std::string rel_path(Sass::File::abs2rel(pstate.path, cwd, cwd));
199
- std::string output_path(Sass::File::path_for_console(rel_path, pstate.path, pstate.path));
194
+ sass::string cwd(Sass::File::get_cwd());
195
+ sass::string abs_path(Sass::File::rel2abs(pstate.getPath(), cwd, cwd));
196
+ sass::string rel_path(Sass::File::abs2rel(pstate.getPath(), cwd, cwd));
197
+ sass::string output_path(Sass::File::path_for_console(rel_path, pstate.getPath(), pstate.getPath()));
200
198
 
201
- std::cerr << "DEPRECATION WARNING on line " << pstate.line + 1;
202
- if (with_column) std::cerr << ", column " << pstate.column + pstate.offset.column + 1;
199
+ std::cerr << "DEPRECATION WARNING on line " << pstate.getLine();
200
+ // if (with_column) std::cerr << ", column " << pstate.column + pstate.offset.column + 1;
203
201
  if (output_path.length()) std::cerr << " of " << output_path;
204
202
  std::cerr << ":" << std::endl;
205
203
  std::cerr << msg << std::endl;
@@ -207,26 +205,26 @@ namespace Sass {
207
205
  std::cerr << std::endl;
208
206
  }
209
207
 
210
- void deprecated_bind(std::string msg, ParserState pstate)
208
+ void deprecated_bind(sass::string msg, SourceSpan pstate)
211
209
  {
212
- std::string cwd(Sass::File::get_cwd());
213
- std::string abs_path(Sass::File::rel2abs(pstate.path, cwd, cwd));
214
- std::string rel_path(Sass::File::abs2rel(pstate.path, cwd, cwd));
215
- std::string output_path(Sass::File::path_for_console(rel_path, abs_path, pstate.path));
210
+ sass::string cwd(Sass::File::get_cwd());
211
+ sass::string abs_path(Sass::File::rel2abs(pstate.getPath(), cwd, cwd));
212
+ sass::string rel_path(Sass::File::abs2rel(pstate.getPath(), cwd, cwd));
213
+ sass::string output_path(Sass::File::path_for_console(rel_path, abs_path, pstate.getPath()));
216
214
 
217
215
  std::cerr << "WARNING: " << msg << std::endl;
218
- std::cerr << " on line " << pstate.line+1 << " of " << output_path << std::endl;
216
+ std::cerr << " on line " << pstate.getLine() << " of " << output_path << std::endl;
219
217
  std::cerr << "This will be an error in future versions of Sass." << std::endl;
220
218
  }
221
219
 
222
220
  // should be replaced with error with backtraces
223
- void coreError(std::string msg, ParserState pstate)
221
+ void coreError(sass::string msg, SourceSpan pstate)
224
222
  {
225
223
  Backtraces traces;
226
224
  throw Exception::InvalidSyntax(pstate, traces, msg);
227
225
  }
228
226
 
229
- void error(std::string msg, ParserState pstate, Backtraces& traces)
227
+ void error(sass::string msg, SourceSpan pstate, Backtraces& traces)
230
228
  {
231
229
  traces.push_back(Backtrace(pstate));
232
230
  throw Exception::InvalidSyntax(pstate, traces, msg);
@@ -1,9 +1,14 @@
1
1
  #ifndef SASS_ERROR_HANDLING_H
2
2
  #define SASS_ERROR_HANDLING_H
3
3
 
4
+ // sass.hpp must go before all system headers to get the
5
+ // __EXTENSIONS__ fix on Solaris.
6
+ #include "sass.hpp"
7
+
4
8
  #include <string>
5
9
  #include <sstream>
6
10
  #include <stdexcept>
11
+ #include "units.hpp"
7
12
  #include "position.hpp"
8
13
  #include "backtrace.hpp"
9
14
  #include "ast_fwd_decl.hpp"
@@ -15,20 +20,20 @@ namespace Sass {
15
20
 
16
21
  namespace Exception {
17
22
 
18
- const std::string def_msg = "Invalid sass detected";
19
- const std::string def_op_msg = "Undefined operation";
20
- const std::string def_op_null_msg = "Invalid null operation";
21
- const std::string def_nesting_limit = "Code too deeply neested";
23
+ const sass::string def_msg = "Invalid sass detected";
24
+ const sass::string def_op_msg = "Undefined operation";
25
+ const sass::string def_op_null_msg = "Invalid null operation";
26
+ const sass::string def_nesting_limit = "Code too deeply nested";
22
27
 
23
28
  class Base : public std::runtime_error {
24
29
  protected:
25
- std::string msg;
26
- std::string prefix;
30
+ sass::string msg;
31
+ sass::string prefix;
27
32
  public:
28
- ParserState pstate;
33
+ SourceSpan pstate;
29
34
  Backtraces traces;
30
35
  public:
31
- Base(ParserState pstate, std::string msg, Backtraces traces);
36
+ Base(SourceSpan pstate, sass::string msg, Backtraces traces);
32
37
  virtual const char* errtype() const { return prefix.c_str(); }
33
38
  virtual const char* what() const throw() { return msg.c_str(); }
34
39
  virtual ~Base() throw() {};
@@ -36,58 +41,58 @@ namespace Sass {
36
41
 
37
42
  class InvalidSass : public Base {
38
43
  public:
39
- InvalidSass(ParserState pstate, Backtraces traces, std::string msg);
44
+ InvalidSass(SourceSpan pstate, Backtraces traces, sass::string msg);
40
45
  virtual ~InvalidSass() throw() {};
41
46
  };
42
47
 
43
48
  class InvalidParent : public Base {
44
49
  protected:
45
- Selector_Ptr parent;
46
- Selector_Ptr selector;
50
+ Selector* parent;
51
+ Selector* selector;
47
52
  public:
48
- InvalidParent(Selector_Ptr parent, Backtraces traces, Selector_Ptr selector);
53
+ InvalidParent(Selector* parent, Backtraces traces, Selector* selector);
49
54
  virtual ~InvalidParent() throw() {};
50
55
  };
51
56
 
52
57
  class MissingArgument : public Base {
53
58
  protected:
54
- std::string fn;
55
- std::string arg;
56
- std::string fntype;
59
+ sass::string fn;
60
+ sass::string arg;
61
+ sass::string fntype;
57
62
  public:
58
- MissingArgument(ParserState pstate, Backtraces traces, std::string fn, std::string arg, std::string fntype);
63
+ MissingArgument(SourceSpan pstate, Backtraces traces, sass::string fn, sass::string arg, sass::string fntype);
59
64
  virtual ~MissingArgument() throw() {};
60
65
  };
61
66
 
62
67
  class InvalidArgumentType : public Base {
63
68
  protected:
64
- std::string fn;
65
- std::string arg;
66
- std::string type;
67
- const Value_Ptr value;
69
+ sass::string fn;
70
+ sass::string arg;
71
+ sass::string type;
72
+ const Value* value;
68
73
  public:
69
- InvalidArgumentType(ParserState pstate, Backtraces traces, std::string fn, std::string arg, std::string type, const Value_Ptr value = 0);
74
+ InvalidArgumentType(SourceSpan pstate, Backtraces traces, sass::string fn, sass::string arg, sass::string type, const Value* value = 0);
70
75
  virtual ~InvalidArgumentType() throw() {};
71
76
  };
72
77
 
73
78
  class InvalidVarKwdType : public Base {
74
79
  protected:
75
- std::string name;
76
- const Argument_Ptr arg;
80
+ sass::string name;
81
+ const Argument* arg;
77
82
  public:
78
- InvalidVarKwdType(ParserState pstate, Backtraces traces, std::string name, const Argument_Ptr arg = 0);
83
+ InvalidVarKwdType(SourceSpan pstate, Backtraces traces, sass::string name, const Argument* arg = 0);
79
84
  virtual ~InvalidVarKwdType() throw() {};
80
85
  };
81
86
 
82
87
  class InvalidSyntax : public Base {
83
88
  public:
84
- InvalidSyntax(ParserState pstate, Backtraces traces, std::string msg);
89
+ InvalidSyntax(SourceSpan pstate, Backtraces traces, sass::string msg);
85
90
  virtual ~InvalidSyntax() throw() {};
86
91
  };
87
92
 
88
93
  class NestingLimitError : public Base {
89
94
  public:
90
- NestingLimitError(ParserState pstate, Backtraces traces, std::string msg = def_nesting_limit);
95
+ NestingLimitError(SourceSpan pstate, Backtraces traces, sass::string msg = def_nesting_limit);
91
96
  virtual ~NestingLimitError() throw() {};
92
97
  };
93
98
 
@@ -104,9 +109,9 @@ namespace Sass {
104
109
  class TypeMismatch : public Base {
105
110
  protected:
106
111
  const Expression& var;
107
- const std::string type;
112
+ const sass::string type;
108
113
  public:
109
- TypeMismatch(Backtraces traces, const Expression& var, const std::string type);
114
+ TypeMismatch(Backtraces traces, const Expression& var, const sass::string type);
110
115
  virtual const char* errtype() const { return "Error"; }
111
116
  virtual ~TypeMismatch() throw() {};
112
117
  };
@@ -132,10 +137,10 @@ namespace Sass {
132
137
  /* common virtual base class (has no pstate or trace) */
133
138
  class OperationError : public std::runtime_error {
134
139
  protected:
135
- std::string msg;
140
+ sass::string msg;
136
141
  public:
137
- OperationError(std::string msg = def_op_msg)
138
- : std::runtime_error(msg), msg(msg)
142
+ OperationError(sass::string msg = def_op_msg)
143
+ : std::runtime_error(msg.c_str()), msg(msg)
139
144
  {};
140
145
  public:
141
146
  virtual const char* errtype() const { return "Error"; }
@@ -165,51 +170,69 @@ namespace Sass {
165
170
 
166
171
  class UndefinedOperation : public OperationError {
167
172
  protected:
168
- Expression_Ptr_Const lhs;
169
- Expression_Ptr_Const rhs;
173
+ const Expression* lhs;
174
+ const Expression* rhs;
170
175
  const Sass_OP op;
171
176
  public:
172
- UndefinedOperation(Expression_Ptr_Const lhs, Expression_Ptr_Const rhs, enum Sass_OP op);
177
+ UndefinedOperation(const Expression* lhs, const Expression* rhs, enum Sass_OP op);
173
178
  // virtual const char* errtype() const { return "Error"; }
174
179
  virtual ~UndefinedOperation() throw() {};
175
180
  };
176
181
 
177
182
  class InvalidNullOperation : public UndefinedOperation {
178
183
  public:
179
- InvalidNullOperation(Expression_Ptr_Const lhs, Expression_Ptr_Const rhs, enum Sass_OP op);
184
+ InvalidNullOperation(const Expression* lhs, const Expression* rhs, enum Sass_OP op);
180
185
  virtual ~InvalidNullOperation() throw() {};
181
186
  };
182
187
 
183
188
  class AlphaChannelsNotEqual : public OperationError {
184
189
  protected:
185
- Expression_Ptr_Const lhs;
186
- Expression_Ptr_Const rhs;
190
+ const Expression* lhs;
191
+ const Expression* rhs;
187
192
  const Sass_OP op;
188
193
  public:
189
- AlphaChannelsNotEqual(Expression_Ptr_Const lhs, Expression_Ptr_Const rhs, enum Sass_OP op);
194
+ AlphaChannelsNotEqual(const Expression* lhs, const Expression* rhs, enum Sass_OP op);
190
195
  // virtual const char* errtype() const { return "Error"; }
191
196
  virtual ~AlphaChannelsNotEqual() throw() {};
192
197
  };
193
198
 
194
199
  class SassValueError : public Base {
195
- public:
196
- SassValueError(Backtraces traces, ParserState pstate, OperationError& err);
197
- virtual ~SassValueError() throw() {};
200
+ public:
201
+ SassValueError(Backtraces traces, SourceSpan pstate, OperationError& err);
202
+ virtual ~SassValueError() throw() {};
203
+ };
204
+
205
+ class TopLevelParent : public Base {
206
+ public:
207
+ TopLevelParent(Backtraces traces, SourceSpan pstate);
208
+ virtual ~TopLevelParent() throw() {};
209
+ };
210
+
211
+ class UnsatisfiedExtend : public Base {
212
+ public:
213
+ UnsatisfiedExtend(Backtraces traces, Extension extension);
214
+ virtual ~UnsatisfiedExtend() throw() {};
215
+ };
216
+
217
+ class ExtendAcrossMedia : public Base {
218
+ public:
219
+ ExtendAcrossMedia(Backtraces traces, Extension extension);
220
+ virtual ~ExtendAcrossMedia() throw() {};
198
221
  };
199
222
 
200
223
  }
201
224
 
202
- void warn(std::string msg, ParserState pstate);
203
- void warn(std::string msg, ParserState pstate, Backtrace* bt);
204
- void warning(std::string msg, ParserState pstate);
225
+ void warn(sass::string msg, SourceSpan pstate);
226
+ void warn(sass::string msg, SourceSpan pstate, Backtrace* bt);
227
+ void warning(sass::string msg, SourceSpan pstate);
205
228
 
206
- void deprecated_function(std::string msg, ParserState pstate);
207
- void deprecated(std::string msg, std::string msg2, bool with_column, ParserState pstate);
208
- void deprecated_bind(std::string msg, ParserState pstate);
209
- // void deprecated(std::string msg, ParserState pstate, Backtrace* bt);
229
+ void deprecated_function(sass::string msg, SourceSpan pstate);
230
+ void deprecated(sass::string msg, sass::string msg2, bool with_column, SourceSpan pstate);
231
+ void deprecated_bind(sass::string msg, SourceSpan pstate);
232
+ // void deprecated(sass::string msg, SourceSpan pstate, Backtrace* bt);
210
233
 
211
- void coreError(std::string msg, ParserState pstate);
212
- void error(std::string msg, ParserState pstate, Backtraces& traces);
234
+ void coreError(sass::string msg, SourceSpan pstate);
235
+ void error(sass::string msg, SourceSpan pstate, Backtraces& traces);
213
236
 
214
237
  }
215
238