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
@@ -25,6 +25,7 @@ namespace Sass {
25
25
  const char* kwd_gte(const char* src);
26
26
  const char* kwd_lt(const char* src);
27
27
  const char* kwd_lte(const char* src);
28
+ const char* kwd_using(const char* src);
28
29
 
29
30
  // Match standard control chars
30
31
  const char* kwd_at(const char* src);
@@ -64,16 +65,15 @@ namespace Sass {
64
65
  size_t level = 0;
65
66
  bool in_squote = false;
66
67
  bool in_dquote = false;
67
- // bool in_braces = false;
68
-
69
- while (*src) {
70
-
71
- // check for abort condition
72
- if (end && src >= end) break;
68
+ bool in_backslash_escape = false;
73
69
 
70
+ while ((end == nullptr || src < end) && *src != '\0') {
74
71
  // has escaped sequence?
75
- if (*src == '\\') {
76
- ++ src; // skip this (and next)
72
+ if (in_backslash_escape) {
73
+ in_backslash_escape = false;
74
+ }
75
+ else if (*src == '\\') {
76
+ in_backslash_escape = true;
77
77
  }
78
78
  else if (*src == '"') {
79
79
  in_dquote = ! in_dquote;
@@ -119,7 +119,7 @@ namespace Sass {
119
119
  // first start/opener must be consumed already!
120
120
  template<prelexer start, prelexer stop>
121
121
  const char* skip_over_scopes(const char* src) {
122
- return skip_over_scopes<start, stop>(src, 0);
122
+ return skip_over_scopes<start, stop>(src, nullptr);
123
123
  }
124
124
 
125
125
  // Match a sequence of characters delimited by the supplied chars.
@@ -1,84 +1,86 @@
1
+ // sass.hpp must go before all system headers to get the
2
+ // __EXTENSIONS__ fix on Solaris.
1
3
  #include "sass.hpp"
4
+ #include "ast.hpp"
5
+
2
6
  #include "remove_placeholders.hpp"
3
- #include "context.hpp"
4
- #include "inspect.hpp"
5
- #include <iostream>
6
7
 
7
8
  namespace Sass {
8
9
 
9
10
  Remove_Placeholders::Remove_Placeholders()
10
11
  { }
11
12
 
12
- void Remove_Placeholders::operator()(Block_Ptr b) {
13
- for (size_t i = 0, L = b->length(); i < L; ++i) {
14
- Statement_Ptr st = b->at(i);
15
- st->perform(this);
16
- }
13
+ void Remove_Placeholders::operator()(Block* b) {
14
+ for (size_t i = 0, L = b->length(); i < L; ++i) {
15
+ if (b->get(i)) b->get(i)->perform(this);
16
+ }
17
17
  }
18
18
 
19
- Selector_List_Ptr Remove_Placeholders::remove_placeholders(Selector_List_Ptr sl)
19
+ void Remove_Placeholders::remove_placeholders(SimpleSelector* simple)
20
20
  {
21
- Selector_List_Ptr new_sl = SASS_MEMORY_NEW(Selector_List, sl->pstate());
22
-
23
- for (size_t i = 0, L = sl->length(); i < L; ++i) {
24
- if (!sl->at(i)->contains_placeholder()) {
25
- new_sl->append(sl->at(i));
26
- }
21
+ if (PseudoSelector * pseudo = simple->getPseudoSelector()) {
22
+ if (pseudo->selector()) remove_placeholders(pseudo->selector());
27
23
  }
28
-
29
- return new_sl;
30
-
31
24
  }
32
25
 
26
+ void Remove_Placeholders::remove_placeholders(CompoundSelector* compound)
27
+ {
28
+ for (size_t i = 0, L = compound->length(); i < L; ++i) {
29
+ if (compound->get(i)) remove_placeholders(compound->get(i));
30
+ }
31
+ listEraseItemIf(compound->elements(), listIsEmpty<SimpleSelector>);
32
+ }
33
33
 
34
- void Remove_Placeholders::operator()(Ruleset_Ptr r) {
35
- // Create a new selector group without placeholders
36
- Selector_List_Obj sl = Cast<Selector_List>(r->selector());
37
-
38
- if (sl) {
39
- // Set the new placeholder selector list
40
- r->selector(remove_placeholders(sl));
41
- // Remove placeholders in wrapped selectors
42
- for (Complex_Selector_Obj cs : sl->elements()) {
43
- while (cs) {
44
- if (cs->head()) {
45
- for (Simple_Selector_Obj& ss : cs->head()->elements()) {
46
- if (Wrapped_Selector_Ptr ws = Cast<Wrapped_Selector>(ss)) {
47
- if (Selector_List_Ptr wsl = Cast<Selector_List>(ws->selector())) {
48
- Selector_List_Ptr clean = remove_placeholders(wsl);
49
- // also clean superflous parent selectors
50
- // probably not really the correct place
51
- clean->remove_parent_selectors();
52
- ws->selector(clean);
53
- }
54
- }
55
- }
56
- }
57
- cs = cs->tail();
58
- }
34
+ void Remove_Placeholders::remove_placeholders(ComplexSelector* complex)
35
+ {
36
+ if (complex->has_placeholder()) {
37
+ complex->clear(); // remove all
38
+ }
39
+ else {
40
+ for (size_t i = 0, L = complex->length(); i < L; ++i) {
41
+ if (CompoundSelector * compound = complex->get(i)->getCompound()) {
42
+ if (compound) remove_placeholders(compound);
59
43
  }
60
44
  }
45
+ listEraseItemIf(complex->elements(), listIsEmpty<SelectorComponent>);
46
+ }
47
+ }
61
48
 
62
- // Iterate into child blocks
63
- Block_Obj b = r->block();
49
+ SelectorList* Remove_Placeholders::remove_placeholders(SelectorList* sl)
50
+ {
51
+ for (size_t i = 0, L = sl->length(); i < L; ++i) {
52
+ if (sl->get(i)) remove_placeholders(sl->get(i));
53
+ }
54
+ listEraseItemIf(sl->elements(), listIsEmpty<ComplexSelector>);
55
+ return sl;
56
+ }
64
57
 
65
- for (size_t i = 0, L = b->length(); i < L; ++i) {
66
- if (b->at(i)) {
67
- Statement_Obj st = b->at(i);
68
- st->perform(this);
69
- }
70
- }
58
+ void Remove_Placeholders::operator()(CssMediaRule* rule)
59
+ {
60
+ if (rule->block()) operator()(rule->block());
71
61
  }
72
62
 
73
- void Remove_Placeholders::operator()(Media_Block_Ptr m) {
74
- operator()(m->block());
63
+ void Remove_Placeholders::operator()(StyleRule* r)
64
+ {
65
+ if (SelectorListObj sl = r->selector()) {
66
+ // Set the new placeholder selector list
67
+ r->selector((remove_placeholders(sl)));
68
+ }
69
+ // Iterate into child blocks
70
+ Block_Obj b = r->block();
71
+ for (size_t i = 0, L = b->length(); i < L; ++i) {
72
+ if (b->get(i)) { b->get(i)->perform(this); }
73
+ }
75
74
  }
76
- void Remove_Placeholders::operator()(Supports_Block_Ptr m) {
77
- operator()(m->block());
75
+
76
+ void Remove_Placeholders::operator()(SupportsRule* m)
77
+ {
78
+ if (m->block()) operator()(m->block());
78
79
  }
79
80
 
80
- void Remove_Placeholders::operator()(Directive_Ptr a) {
81
- if (a->block()) a->block()->perform(this);
81
+ void Remove_Placeholders::operator()(AtRule* a)
82
+ {
83
+ if (a->block()) a->block()->perform(this);
82
84
  }
83
85
 
84
86
  }
@@ -1,34 +1,36 @@
1
1
  #ifndef SASS_REMOVE_PLACEHOLDERS_H
2
2
  #define SASS_REMOVE_PLACEHOLDERS_H
3
3
 
4
- #pragma once
5
-
6
- #include "ast.hpp"
4
+ #include "ast_fwd_decl.hpp"
7
5
  #include "operation.hpp"
8
6
 
9
7
  namespace Sass {
10
8
 
9
+ class Remove_Placeholders : public Operation_CRTP<void, Remove_Placeholders> {
10
+
11
+ public:
11
12
 
12
- class Remove_Placeholders : public Operation_CRTP<void, Remove_Placeholders> {
13
+ SelectorList* remove_placeholders(SelectorList*);
14
+ void remove_placeholders(SimpleSelector* simple);
15
+ void remove_placeholders(CompoundSelector* complex);
16
+ void remove_placeholders(ComplexSelector* complex);
13
17
 
14
- void fallback_impl(AST_Node_Ptr n) {}
15
18
 
16
- public:
17
- Selector_List_Ptr remove_placeholders(Selector_List_Ptr);
19
+ public:
20
+ Remove_Placeholders();
21
+ ~Remove_Placeholders() { }
18
22
 
19
- public:
20
- Remove_Placeholders();
21
- ~Remove_Placeholders() { }
23
+ void operator()(Block*);
24
+ void operator()(StyleRule*);
25
+ void operator()(CssMediaRule*);
26
+ void operator()(SupportsRule*);
27
+ void operator()(AtRule*);
22
28
 
23
- void operator()(Block_Ptr);
24
- void operator()(Ruleset_Ptr);
25
- void operator()(Media_Block_Ptr);
26
- void operator()(Supports_Block_Ptr);
27
- void operator()(Directive_Ptr);
29
+ // ignore missed types
30
+ template <typename U>
31
+ void fallback(U x) {}
28
32
 
29
- template <typename U>
30
- void fallback(U x) { return fallback_impl(x); }
31
- };
33
+ };
32
34
 
33
35
  }
34
36
 
@@ -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 <cstdlib>
3
6
  #include <cstring>
4
7
  #include <vector>
@@ -7,15 +10,16 @@
7
10
  #include "sass.h"
8
11
  #include "file.hpp"
9
12
  #include "util.hpp"
13
+ #include "context.hpp"
10
14
  #include "sass_context.hpp"
11
15
  #include "sass_functions.hpp"
12
16
 
13
17
  namespace Sass {
14
18
 
15
19
  // helper to convert string list to vector
16
- std::vector<std::string> list2vec(struct string_list* cur)
20
+ sass::vector<sass::string> list2vec(struct string_list* cur)
17
21
  {
18
- std::vector<std::string> list;
22
+ sass::vector<sass::string> list;
19
23
  while (cur) {
20
24
  list.push_back(cur->string);
21
25
  cur = cur->next;
@@ -33,13 +37,16 @@ extern "C" {
33
37
  void* ADDCALL sass_alloc_memory(size_t size)
34
38
  {
35
39
  void* ptr = malloc(size);
36
- if (ptr == NULL)
37
- out_of_memory();
40
+ if (ptr == NULL) {
41
+ std::cerr << "Out of memory.\n";
42
+ exit(EXIT_FAILURE);
43
+ }
38
44
  return ptr;
39
45
  }
40
46
 
41
47
  char* ADDCALL sass_copy_c_string(const char* str)
42
48
  {
49
+ if (str == nullptr) return nullptr;
43
50
  size_t len = strlen(str) + 1;
44
51
  char* cpy = (char*) sass_alloc_memory(len);
45
52
  std::memcpy(cpy, str, len);
@@ -55,14 +62,14 @@ extern "C" {
55
62
  // caller must free the returned memory
56
63
  char* ADDCALL sass_string_quote (const char *str, const char quote_mark)
57
64
  {
58
- std::string quoted = quote(str, quote_mark);
65
+ sass::string quoted = quote(str, quote_mark);
59
66
  return sass_copy_c_string(quoted.c_str());
60
67
  }
61
68
 
62
69
  // caller must free the returned memory
63
70
  char* ADDCALL sass_string_unquote (const char *str)
64
71
  {
65
- std::string unquoted = unquote(str);
72
+ sass::string unquoted = unquote(str);
66
73
  return sass_copy_c_string(unquoted.c_str());
67
74
  }
68
75
 
@@ -70,13 +77,13 @@ extern "C" {
70
77
  {
71
78
  // get the last import entry to get current base directory
72
79
  Sass_Import_Entry import = sass_compiler_get_last_import(compiler);
73
- const std::vector<std::string>& incs = compiler->cpp_ctx->include_paths;
80
+ const sass::vector<sass::string>& incs = compiler->cpp_ctx->include_paths;
74
81
  // create the vector with paths to lookup
75
- std::vector<std::string> paths(1 + incs.size());
82
+ sass::vector<sass::string> paths(1 + incs.size());
76
83
  paths.push_back(File::dir_name(import->abs_path));
77
84
  paths.insert( paths.end(), incs.begin(), incs.end() );
78
85
  // now resolve the file path relative to lookup paths
79
- std::string resolved(File::find_include(file, paths));
86
+ sass::string resolved(File::find_include(file, paths));
80
87
  return sass_copy_c_string(resolved.c_str());
81
88
  }
82
89
 
@@ -84,13 +91,13 @@ extern "C" {
84
91
  {
85
92
  // get the last import entry to get current base directory
86
93
  Sass_Import_Entry import = sass_compiler_get_last_import(compiler);
87
- const std::vector<std::string>& incs = compiler->cpp_ctx->include_paths;
94
+ const sass::vector<sass::string>& incs = compiler->cpp_ctx->include_paths;
88
95
  // create the vector with paths to lookup
89
- std::vector<std::string> paths(1 + incs.size());
96
+ sass::vector<sass::string> paths(1 + incs.size());
90
97
  paths.push_back(File::dir_name(import->abs_path));
91
98
  paths.insert( paths.end(), incs.begin(), incs.end() );
92
99
  // now resolve the file path relative to lookup paths
93
- std::string resolved(File::find_file(file, paths));
100
+ sass::string resolved(File::find_file(file, paths));
94
101
  return sass_copy_c_string(resolved.c_str());
95
102
  }
96
103
 
@@ -99,8 +106,8 @@ extern "C" {
99
106
  // this has the original resolve logic for sass include
100
107
  char* ADDCALL sass_find_include (const char* file, struct Sass_Options* opt)
101
108
  {
102
- std::vector<std::string> vec(list2vec(opt->include_paths));
103
- std::string resolved(File::find_include(file, vec));
109
+ sass::vector<sass::string> vec(list2vec(opt->include_paths));
110
+ sass::string resolved(File::find_include(file, vec));
104
111
  return sass_copy_c_string(resolved.c_str());
105
112
  }
106
113
 
@@ -108,8 +115,8 @@ extern "C" {
108
115
  // Incs array has to be null terminated!
109
116
  char* ADDCALL sass_find_file (const char* file, struct Sass_Options* opt)
110
117
  {
111
- std::vector<std::string> vec(list2vec(opt->include_paths));
112
- std::string resolved(File::find_file(file, vec));
118
+ sass::vector<sass::string> vec(list2vec(opt->include_paths));
119
+ sass::string resolved(File::find_file(file, vec));
113
120
  return sass_copy_c_string(resolved.c_str());
114
121
  }
115
122
 
@@ -130,7 +137,7 @@ extern "C" {
130
137
  namespace Sass {
131
138
 
132
139
  // helper to aid dreaded MSVC debug mode
133
- char* sass_copy_string(std::string str)
140
+ char* sass_copy_string(sass::string str)
134
141
  {
135
142
  // In MSVC the following can lead to segfault:
136
143
  // sass_copy_c_string(stream.str().c_str());
@@ -146,4 +153,4 @@ namespace Sass {
146
153
  return sass_copy_c_string(str.c_str());
147
154
  }
148
155
 
149
- }
156
+ }
@@ -11,14 +11,20 @@
11
11
  #pragma warning(disable : 4005)
12
12
  #endif
13
13
 
14
- // aplies to MSVC and MinGW
14
+ // applies to MSVC and MinGW
15
15
  #ifdef _WIN32
16
16
  // we do not want the ERROR macro
17
- # define NOGDI
17
+ # ifndef NOGDI
18
+ # define NOGDI
19
+ # endif
18
20
  // we do not want the min/max macro
19
- # define NOMINMAX
21
+ # ifndef NOMINMAX
22
+ # define NOMINMAX
23
+ # endif
20
24
  // we do not want the IN/OUT macro
21
- # define _NO_W32_PSEUDO_MODIFIERS
25
+ # ifndef _NO_W32_PSEUDO_MODIFIERS
26
+ # define _NO_W32_PSEUDO_MODIFIERS
27
+ # endif
22
28
  #endif
23
29
 
24
30
 
@@ -42,13 +48,17 @@
42
48
  #endif
43
49
 
44
50
 
45
- // include C-API header
51
+ // Include C-API header
46
52
  #include "sass/base.h"
47
53
 
54
+ // Include allocator
55
+ #include "memory.hpp"
56
+
48
57
  // For C++ helper
49
58
  #include <string>
59
+ #include <vector>
50
60
 
51
- // output behaviours
61
+ // output behavior
52
62
  namespace Sass {
53
63
 
54
64
  // create some C++ aliases for the most used options
@@ -59,14 +69,15 @@ namespace Sass {
59
69
  // only used internal to trigger ruby inspect behavior
60
70
  const static Sass_Output_Style INSPECT = SASS_STYLE_INSPECT;
61
71
  const static Sass_Output_Style TO_SASS = SASS_STYLE_TO_SASS;
72
+ const static Sass_Output_Style TO_CSS = SASS_STYLE_TO_CSS;
62
73
 
63
74
  // helper to aid dreaded MSVC debug mode
64
75
  // see implementation for more details
65
- char* sass_copy_string(std::string str);
76
+ char* sass_copy_string(sass::string str);
66
77
 
67
78
  }
68
79
 
69
- // input behaviours
80
+ // input behaviors
70
81
  enum Sass_Input_Style {
71
82
  SASS_CONTEXT_NULL,
72
83
  SASS_CONTEXT_FILE,
@@ -90,13 +101,10 @@ struct Sass_Inspect_Options {
90
101
  // Precision for fractional numbers
91
102
  int precision;
92
103
 
93
- // Do not compress colors in selectors
94
- bool in_selector;
95
-
96
104
  // initialization list (constructor with defaults)
97
105
  Sass_Inspect_Options(Sass_Output_Style style = Sass::NESTED,
98
- int precision = 5, bool in_selector = false)
99
- : output_style(style), precision(precision), in_selector(in_selector)
106
+ int precision = 10)
107
+ : output_style(style), precision(precision)
100
108
  { }
101
109
 
102
110
  };
@@ -125,7 +133,7 @@ struct Sass_Output_Options : Sass_Inspect_Options {
125
133
 
126
134
  // initialization list (constructor with defaults)
127
135
  Sass_Output_Options(Sass_Output_Style style = Sass::NESTED,
128
- int precision = 5,
136
+ int precision = 10,
129
137
  const char* indent = " ",
130
138
  const char* linefeed = "\n",
131
139
  bool source_comments = false)