sassc 2.0.0 → 2.4.0

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -9,6 +9,9 @@
9
9
  #include "position.hpp"
10
10
  #include "mapping.hpp"
11
11
 
12
+ #include "backtrace.hpp"
13
+ #include "memory.hpp"
14
+
12
15
  #define VECTOR_PUSH(vec, ins) vec.insert(vec.end(), ins.begin(), ins.end())
13
16
  #define VECTOR_UNSHIFT(vec, ins) vec.insert(vec.begin(), ins.begin(), ins.end())
14
17
 
@@ -20,28 +23,28 @@ namespace Sass {
20
23
  class SourceMap {
21
24
 
22
25
  public:
23
- std::vector<size_t> source_index;
26
+ sass::vector<size_t> source_index;
24
27
  SourceMap();
25
- SourceMap(const std::string& file);
28
+ SourceMap(const sass::string& file);
26
29
 
27
30
  void append(const Offset& offset);
28
31
  void prepend(const Offset& offset);
29
32
  void append(const OutputBuffer& out);
30
33
  void prepend(const OutputBuffer& out);
31
- void add_open_mapping(const AST_Node_Ptr node);
32
- void add_close_mapping(const AST_Node_Ptr node);
34
+ void add_open_mapping(const AST_Node* node);
35
+ void add_close_mapping(const AST_Node* node);
33
36
 
34
- std::string render_srcmap(Context &ctx);
35
- ParserState remap(const ParserState& pstate);
37
+ sass::string render_srcmap(Context &ctx);
38
+ SourceSpan remap(const SourceSpan& pstate);
36
39
 
37
40
  private:
38
41
 
39
- std::string serialize_mappings();
42
+ sass::string serialize_mappings();
40
43
 
41
- std::vector<Mapping> mappings;
44
+ sass::vector<Mapping> mappings;
42
45
  Position current_position;
43
46
  public:
44
- std::string file;
47
+ sass::string file;
45
48
  private:
46
49
  Base64VLQ base64vlq;
47
50
  };
@@ -49,11 +52,11 @@ private:
49
52
  class OutputBuffer {
50
53
  public:
51
54
  OutputBuffer(void)
52
- : buffer(""),
55
+ : buffer(),
53
56
  smap()
54
57
  { }
55
58
  public:
56
- std::string buffer;
59
+ sass::string buffer;
57
60
  SourceMap smap;
58
61
  };
59
62
 
@@ -0,0 +1,22 @@
1
+ // sass.hpp must go before all system headers to get the
2
+ // __EXTENSIONS__ fix on Solaris.
3
+ #include "sass.hpp"
4
+
5
+ #include "stylesheet.hpp"
6
+
7
+ namespace Sass {
8
+
9
+ // Constructor
10
+ Sass::StyleSheet::StyleSheet(const Resource& res, Block_Obj root) :
11
+ Resource(res),
12
+ root(root)
13
+ {
14
+ }
15
+
16
+ StyleSheet::StyleSheet(const StyleSheet& sheet) :
17
+ Resource(sheet),
18
+ root(sheet.root)
19
+ {
20
+ }
21
+
22
+ }
@@ -0,0 +1,57 @@
1
+ #ifndef SASS_STYLESHEET_H
2
+ #define SASS_STYLESHEET_H
3
+
4
+ // sass.hpp must go before all system headers to get the
5
+ // __EXTENSIONS__ fix on Solaris.
6
+ #include "sass.hpp"
7
+
8
+ #include "ast_fwd_decl.hpp"
9
+ #include "extender.hpp"
10
+ #include "file.hpp"
11
+
12
+ namespace Sass {
13
+
14
+ // parsed stylesheet from loaded resource
15
+ // this should be a `Module` for sass 4.0
16
+ class StyleSheet : public Resource {
17
+ public:
18
+
19
+ // The canonical URL for this module's source file. This may be `null`
20
+ // if the module was loaded from a string without a URL provided.
21
+ // Uri get url;
22
+
23
+ // Modules that this module uses.
24
+ // List<Module> get upstream;
25
+
26
+ // The module's variables.
27
+ // Map<String, Value> get variables;
28
+
29
+ // The module's functions. Implementations must ensure
30
+ // that each [Callable] is stored under its own name.
31
+ // Map<String, Callable> get functions;
32
+
33
+ // The module's mixins. Implementations must ensure that
34
+ // each [Callable] is stored under its own name.
35
+ // Map<String, Callable> get mixins;
36
+
37
+ // The extensions defined in this module, which is also able to update
38
+ // [css]'s style rules in-place based on downstream extensions.
39
+ // Extender extender;
40
+
41
+ // The module's CSS tree.
42
+ Block_Obj root;
43
+
44
+ public:
45
+
46
+ // default argument constructor
47
+ StyleSheet(const Resource& res, Block_Obj root);
48
+
49
+ // Copy constructor
50
+ StyleSheet(const StyleSheet& res);
51
+
52
+ };
53
+
54
+
55
+ }
56
+
57
+ #endif
@@ -1,60 +1,62 @@
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 "to_value.hpp"
4
7
 
5
8
  namespace Sass {
6
9
 
7
- Value_Ptr To_Value::fallback_impl(AST_Node_Ptr n)
8
- {
9
- // throw a runtime error if this happens
10
- // we want a well defined set of possible nodes
11
- throw std::runtime_error("invalid node for to_value");
12
- }
13
-
14
10
  // Custom_Error is a valid value
15
- Value_Ptr To_Value::operator()(Custom_Error_Ptr e)
11
+ Value* To_Value::operator()(Custom_Error* e)
16
12
  {
17
13
  return e;
18
14
  }
19
15
 
20
16
  // Custom_Warning is a valid value
21
- Value_Ptr To_Value::operator()(Custom_Warning_Ptr w)
17
+ Value* To_Value::operator()(Custom_Warning* w)
22
18
  {
23
19
  return w;
24
20
  }
25
21
 
26
22
  // Boolean is a valid value
27
- Value_Ptr To_Value::operator()(Boolean_Ptr b)
23
+ Value* To_Value::operator()(Boolean* b)
28
24
  {
29
25
  return b;
30
26
  }
31
27
 
32
28
  // Number is a valid value
33
- Value_Ptr To_Value::operator()(Number_Ptr n)
29
+ Value* To_Value::operator()(Number* n)
34
30
  {
35
31
  return n;
36
32
  }
37
33
 
38
34
  // Color is a valid value
39
- Value_Ptr To_Value::operator()(Color_Ptr c)
35
+ Value* To_Value::operator()(Color_RGBA* c)
36
+ {
37
+ return c;
38
+ }
39
+
40
+ // Color is a valid value
41
+ Value* To_Value::operator()(Color_HSLA* c)
40
42
  {
41
43
  return c;
42
44
  }
43
45
 
44
46
  // String_Constant is a valid value
45
- Value_Ptr To_Value::operator()(String_Constant_Ptr s)
47
+ Value* To_Value::operator()(String_Constant* s)
46
48
  {
47
49
  return s;
48
50
  }
49
51
 
50
52
  // String_Quoted is a valid value
51
- Value_Ptr To_Value::operator()(String_Quoted_Ptr s)
53
+ Value* To_Value::operator()(String_Quoted* s)
52
54
  {
53
55
  return s;
54
56
  }
55
57
 
56
58
  // List is a valid value
57
- Value_Ptr To_Value::operator()(List_Ptr l)
59
+ Value* To_Value::operator()(List* l)
58
60
  {
59
61
  List_Obj ll = SASS_MEMORY_NEW(List,
60
62
  l->pstate(),
@@ -69,32 +71,32 @@ namespace Sass {
69
71
  }
70
72
 
71
73
  // Map is a valid value
72
- Value_Ptr To_Value::operator()(Map_Ptr m)
74
+ Value* To_Value::operator()(Map* m)
73
75
  {
74
76
  return m;
75
77
  }
76
78
 
77
79
  // Null is a valid value
78
- Value_Ptr To_Value::operator()(Null_Ptr n)
80
+ Value* To_Value::operator()(Null* n)
79
81
  {
80
82
  return n;
81
83
  }
82
84
 
83
85
  // Function is a valid value
84
- Value_Ptr To_Value::operator()(Function_Ptr n)
86
+ Value* To_Value::operator()(Function* n)
85
87
  {
86
88
  return n;
87
89
  }
88
90
 
89
91
  // Argument returns its value
90
- Value_Ptr To_Value::operator()(Argument_Ptr arg)
92
+ Value* To_Value::operator()(Argument* arg)
91
93
  {
92
94
  if (!arg->name().empty()) return 0;
93
95
  return arg->value()->perform(this);
94
96
  }
95
97
 
96
- // Selector_List is converted to a string
97
- Value_Ptr To_Value::operator()(Selector_List_Ptr s)
98
+ // SelectorList is converted to a string
99
+ Value* To_Value::operator()(SelectorList* s)
98
100
  {
99
101
  return SASS_MEMORY_NEW(String_Quoted,
100
102
  s->pstate(),
@@ -102,7 +104,7 @@ namespace Sass {
102
104
  }
103
105
 
104
106
  // Binary_Expression is converted to a string
105
- Value_Ptr To_Value::operator()(Binary_Expression_Ptr s)
107
+ Value* To_Value::operator()(Binary_Expression* s)
106
108
  {
107
109
  return SASS_MEMORY_NEW(String_Quoted,
108
110
  s->pstate(),
@@ -7,9 +7,7 @@
7
7
 
8
8
  namespace Sass {
9
9
 
10
- class To_Value : public Operation_CRTP<Value_Ptr, To_Value> {
11
-
12
- Value_Ptr fallback_impl(AST_Node_Ptr n);
10
+ class To_Value : public Operation_CRTP<Value*, To_Value> {
13
11
 
14
12
  private:
15
13
 
@@ -21,28 +19,26 @@ namespace Sass {
21
19
  : ctx(ctx)
22
20
  { }
23
21
  ~To_Value() { }
24
- using Operation<Value_Ptr>::operator();
25
-
26
- Value_Ptr operator()(Argument_Ptr);
27
- Value_Ptr operator()(Boolean_Ptr);
28
- Value_Ptr operator()(Number_Ptr);
29
- Value_Ptr operator()(Color_Ptr);
30
- Value_Ptr operator()(String_Constant_Ptr);
31
- Value_Ptr operator()(String_Quoted_Ptr);
32
- Value_Ptr operator()(Custom_Warning_Ptr);
33
- Value_Ptr operator()(Custom_Error_Ptr);
34
- Value_Ptr operator()(List_Ptr);
35
- Value_Ptr operator()(Map_Ptr);
36
- Value_Ptr operator()(Null_Ptr);
37
- Value_Ptr operator()(Function_Ptr);
22
+ using Operation<Value*>::operator();
23
+
24
+ Value* operator()(Argument*);
25
+ Value* operator()(Boolean*);
26
+ Value* operator()(Number*);
27
+ Value* operator()(Color_RGBA*);
28
+ Value* operator()(Color_HSLA*);
29
+ Value* operator()(String_Constant*);
30
+ Value* operator()(String_Quoted*);
31
+ Value* operator()(Custom_Warning*);
32
+ Value* operator()(Custom_Error*);
33
+ Value* operator()(List*);
34
+ Value* operator()(Map*);
35
+ Value* operator()(Null*);
36
+ Value* operator()(Function*);
38
37
 
39
38
  // convert to string via `To_String`
40
- Value_Ptr operator()(Selector_List_Ptr);
41
- Value_Ptr operator()(Binary_Expression_Ptr);
39
+ Value* operator()(SelectorList*);
40
+ Value* operator()(Binary_Expression*);
42
41
 
43
- // fallback throws error
44
- template <typename U>
45
- Value_Ptr fallback(U x) { return fallback_impl(x); }
46
42
  };
47
43
 
48
44
  }
@@ -1,5 +1,7 @@
1
1
  #include "sass.hpp"
2
+ #include <map>
2
3
  #include <stdexcept>
4
+ #include <algorithm>
3
5
  #include "units.hpp"
4
6
  #include "error_handling.hpp"
5
7
 
@@ -63,7 +65,7 @@ namespace Sass {
63
65
  }
64
66
  };
65
67
 
66
- std::string get_unit_class(UnitType unit)
68
+ sass::string get_unit_class(UnitType unit)
67
69
  {
68
70
  switch (unit & 0xFF00)
69
71
  {
@@ -89,7 +91,7 @@ namespace Sass {
89
91
  }
90
92
  };
91
93
 
92
- UnitType string_to_unit(const std::string& s)
94
+ UnitType string_to_unit(const sass::string& s)
93
95
  {
94
96
  // size units
95
97
  if (s == "px") return UnitType::PX;
@@ -147,7 +149,7 @@ namespace Sass {
147
149
  }
148
150
  }
149
151
 
150
- std::string unit_to_class(const std::string& s)
152
+ sass::string unit_to_class(const sass::string& s)
151
153
  {
152
154
  if (s == "px") return "LENGTH";
153
155
  else if (s == "pt") return "LENGTH";
@@ -175,7 +177,7 @@ namespace Sass {
175
177
  }
176
178
 
177
179
  // throws incompatibleUnits exceptions
178
- double conversion_factor(const std::string& s1, const std::string& s2)
180
+ double conversion_factor(const sass::string& s1, const sass::string& s2)
179
181
  {
180
182
  // assert for same units
181
183
  if (s1 == s2) return 1;
@@ -217,7 +219,7 @@ namespace Sass {
217
219
  return 0;
218
220
  }
219
221
 
220
- double convert_units(const std::string& lhs, const std::string& rhs, int& lhsexp, int& rhsexp)
222
+ double convert_units(const sass::string& lhs, const sass::string& rhs, int& lhsexp, int& rhsexp)
221
223
  {
222
224
  double f = 0;
223
225
  // do not convert same ones
@@ -266,6 +268,10 @@ namespace Sass {
266
268
  return (numerators == rhs.numerators) &&
267
269
  (denominators == rhs.denominators);
268
270
  }
271
+ bool Units::operator!= (const Units& rhs) const
272
+ {
273
+ return ! (*this == rhs);
274
+ }
269
275
 
270
276
  double Units::normalize()
271
277
  {
@@ -277,7 +283,7 @@ namespace Sass {
277
283
  double factor = 1;
278
284
 
279
285
  for (size_t i = 0; i < iL; i++) {
280
- std::string &lhs = numerators[i];
286
+ sass::string &lhs = numerators[i];
281
287
  UnitType ulhs = string_to_unit(lhs);
282
288
  if (ulhs == UNKNOWN) continue;
283
289
  UnitClass clhs = get_unit_type(ulhs);
@@ -290,7 +296,7 @@ namespace Sass {
290
296
  }
291
297
 
292
298
  for (size_t n = 0; n < nL; n++) {
293
- std::string &rhs = denominators[n];
299
+ sass::string &rhs = denominators[n];
294
300
  UnitType urhs = string_to_unit(rhs);
295
301
  if (urhs == UNKNOWN) continue;
296
302
  UnitClass crhs = get_unit_type(urhs);
@@ -322,9 +328,9 @@ namespace Sass {
322
328
  // it seems that a map table will fit nicely to do this
323
329
  // we basically construct exponents for each unit
324
330
  // has the advantage that they will be pre-sorted
325
- std::map<std::string, int> exponents;
331
+ std::map<sass::string, int> exponents;
326
332
 
327
- // initialize by summing up occurences in unit vectors
333
+ // initialize by summing up occurrences in unit vectors
328
334
  // this will already cancel out equivalent units (e.q. px/px)
329
335
  for (size_t i = 0; i < iL; i ++) exponents[numerators[i]] += 1;
330
336
  for (size_t n = 0; n < nL; n ++) exponents[denominators[n]] -= 1;
@@ -335,7 +341,7 @@ namespace Sass {
335
341
  // convert between compatible units
336
342
  for (size_t i = 0; i < iL; i++) {
337
343
  for (size_t n = 0; n < nL; n++) {
338
- std::string &lhs = numerators[i], &rhs = denominators[n];
344
+ sass::string &lhs = numerators[i], &rhs = denominators[n];
339
345
  int &lhsexp = exponents[lhs], &rhsexp = exponents[rhs];
340
346
  double f(convert_units(lhs, rhs, lhsexp, rhsexp));
341
347
  if (f == 0) continue;
@@ -361,9 +367,9 @@ namespace Sass {
361
367
 
362
368
  }
363
369
 
364
- std::string Units::unit() const
370
+ sass::string Units::unit() const
365
371
  {
366
- std::string u;
372
+ sass::string u;
367
373
  size_t iL = numerators.size();
368
374
  size_t nL = denominators.size();
369
375
  for (size_t i = 0; i < iL; i += 1) {
@@ -390,15 +396,15 @@ namespace Sass {
390
396
  denominators.size() == 0;
391
397
  }
392
398
 
393
- // this does not cover all cases (multiple prefered units)
399
+ // this does not cover all cases (multiple preferred units)
394
400
  double Units::convert_factor(const Units& r) const
395
401
  {
396
402
 
397
- std::vector<std::string> miss_nums(0);
398
- std::vector<std::string> miss_dens(0);
403
+ sass::vector<sass::string> miss_nums(0);
404
+ sass::vector<sass::string> miss_dens(0);
399
405
  // create copy since we need these for state keeping
400
- std::vector<std::string> r_nums(r.numerators);
401
- std::vector<std::string> r_dens(r.denominators);
406
+ sass::vector<sass::string> r_nums(r.numerators);
407
+ sass::vector<sass::string> r_dens(r.denominators);
402
408
 
403
409
  auto l_num_it = numerators.begin();
404
410
  auto l_num_end = numerators.end();
@@ -413,7 +419,7 @@ namespace Sass {
413
419
  while (l_num_it != l_num_end)
414
420
  {
415
421
  // get and increment afterwards
416
- const std::string l_num = *(l_num_it ++);
422
+ const sass::string l_num = *(l_num_it ++);
417
423
 
418
424
  auto r_num_it = r_nums.begin(), r_num_end = r_nums.end();
419
425
 
@@ -422,7 +428,7 @@ namespace Sass {
422
428
  while (r_num_it != r_num_end)
423
429
  {
424
430
  // get and increment afterwards
425
- const std::string r_num = *(r_num_it);
431
+ const sass::string r_num = *(r_num_it);
426
432
  // get possible conversion factor for units
427
433
  double conversion = conversion_factor(l_num, r_num);
428
434
  // skip incompatible numerator
@@ -450,7 +456,7 @@ namespace Sass {
450
456
  while (l_den_it != l_den_end)
451
457
  {
452
458
  // get and increment afterwards
453
- const std::string l_den = *(l_den_it ++);
459
+ const sass::string l_den = *(l_den_it ++);
454
460
 
455
461
  auto r_den_it = r_dens.begin();
456
462
  auto r_den_end = r_dens.end();
@@ -460,8 +466,8 @@ namespace Sass {
460
466
  while (r_den_it != r_den_end)
461
467
  {
462
468
  // get and increment afterwards
463
- const std::string r_den = *(r_den_it);
464
- // get possible converstion factor for units
469
+ const sass::string r_den = *(r_den_it);
470
+ // get possible conversion factor for units
465
471
  double conversion = conversion_factor(l_den, r_den);
466
472
  // skip incompatible denominator
467
473
  if (conversion == 0) {