sassc 2.0.1 → 2.1.0.pre1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (200) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.gitmodules +1 -1
  4. data/.travis.yml +7 -3
  5. data/CHANGELOG.md +3 -0
  6. data/CODE_OF_CONDUCT.md +1 -1
  7. data/README.md +1 -1
  8. data/Rakefile +23 -8
  9. data/ext/extconf.rb +39 -0
  10. data/ext/libsass/.gitignore +1 -0
  11. data/ext/libsass/GNUmakefile.am +23 -39
  12. data/ext/libsass/Makefile +56 -91
  13. data/ext/libsass/Makefile.conf +16 -2
  14. data/ext/libsass/configure.ac +8 -12
  15. data/ext/libsass/include/sass/base.h +1 -0
  16. data/ext/libsass/include/sass/context.h +1 -1
  17. data/ext/libsass/src/GNUmakefile.am +1 -5
  18. data/ext/libsass/src/ast.cpp +747 -2010
  19. data/ext/libsass/src/ast.hpp +239 -2383
  20. data/ext/libsass/src/{to_c.cpp → ast2c.cpp} +22 -16
  21. data/ext/libsass/src/ast2c.hpp +39 -0
  22. data/ext/libsass/src/ast_def_macros.hpp +62 -10
  23. data/ext/libsass/src/ast_fwd_decl.cpp +1 -0
  24. data/ext/libsass/src/ast_fwd_decl.hpp +43 -165
  25. data/ext/libsass/src/ast_sel_cmp.cpp +909 -0
  26. data/ext/libsass/src/ast_sel_unify.cpp +280 -0
  27. data/ext/libsass/src/ast_selectors.cpp +1475 -0
  28. data/ext/libsass/src/ast_selectors.hpp +568 -0
  29. data/ext/libsass/src/ast_supports.cpp +130 -0
  30. data/ext/libsass/src/ast_supports.hpp +121 -0
  31. data/ext/libsass/src/ast_values.cpp +967 -0
  32. data/ext/libsass/src/ast_values.hpp +489 -0
  33. data/ext/libsass/src/backtrace.cpp +4 -0
  34. data/ext/libsass/src/base64vlq.cpp +3 -0
  35. data/ext/libsass/src/bind.cpp +18 -17
  36. data/ext/libsass/src/bind.hpp +3 -1
  37. data/ext/libsass/src/c2ast.cpp +64 -0
  38. data/ext/libsass/src/c2ast.hpp +14 -0
  39. data/ext/libsass/src/cencode.c +2 -2
  40. data/ext/libsass/src/check_nesting.cpp +52 -56
  41. data/ext/libsass/src/check_nesting.hpp +35 -34
  42. data/ext/libsass/src/color_maps.cpp +156 -153
  43. data/ext/libsass/src/color_maps.hpp +152 -152
  44. data/ext/libsass/src/constants.cpp +15 -0
  45. data/ext/libsass/src/constants.hpp +13 -0
  46. data/ext/libsass/src/context.cpp +24 -14
  47. data/ext/libsass/src/context.hpp +6 -6
  48. data/ext/libsass/src/cssize.cpp +69 -71
  49. data/ext/libsass/src/cssize.hpp +50 -50
  50. data/ext/libsass/src/debugger.hpp +117 -110
  51. data/ext/libsass/src/emitter.cpp +13 -12
  52. data/ext/libsass/src/emitter.hpp +13 -9
  53. data/ext/libsass/src/environment.cpp +15 -1
  54. data/ext/libsass/src/environment.hpp +6 -0
  55. data/ext/libsass/src/error_handling.cpp +36 -59
  56. data/ext/libsass/src/error_handling.hpp +29 -16
  57. data/ext/libsass/src/eval.cpp +302 -323
  58. data/ext/libsass/src/eval.hpp +64 -55
  59. data/ext/libsass/src/expand.cpp +94 -88
  60. data/ext/libsass/src/expand.hpp +33 -37
  61. data/ext/libsass/src/extend.cpp +38 -36
  62. data/ext/libsass/src/extend.hpp +15 -15
  63. data/ext/libsass/src/file.cpp +34 -2
  64. data/ext/libsass/src/fn_colors.cpp +594 -0
  65. data/ext/libsass/src/fn_colors.hpp +85 -0
  66. data/ext/libsass/src/fn_lists.cpp +284 -0
  67. data/ext/libsass/src/fn_lists.hpp +34 -0
  68. data/ext/libsass/src/fn_maps.cpp +94 -0
  69. data/ext/libsass/src/fn_maps.hpp +30 -0
  70. data/ext/libsass/src/fn_miscs.cpp +256 -0
  71. data/ext/libsass/src/fn_miscs.hpp +40 -0
  72. data/ext/libsass/src/fn_numbers.cpp +220 -0
  73. data/ext/libsass/src/fn_numbers.hpp +45 -0
  74. data/ext/libsass/src/fn_selectors.cpp +235 -0
  75. data/ext/libsass/src/fn_selectors.hpp +35 -0
  76. data/ext/libsass/src/fn_strings.cpp +254 -0
  77. data/ext/libsass/src/fn_strings.hpp +34 -0
  78. data/ext/libsass/src/fn_utils.cpp +156 -0
  79. data/ext/libsass/src/fn_utils.hpp +56 -0
  80. data/ext/libsass/src/inspect.cpp +101 -152
  81. data/ext/libsass/src/inspect.hpp +69 -73
  82. data/ext/libsass/src/json.cpp +2 -2
  83. data/ext/libsass/src/lexer.cpp +6 -3
  84. data/ext/libsass/src/listize.cpp +9 -11
  85. data/ext/libsass/src/listize.hpp +11 -7
  86. data/ext/libsass/src/memory/SharedPtr.cpp +2 -83
  87. data/ext/libsass/src/memory/SharedPtr.hpp +127 -143
  88. data/ext/libsass/src/node.cpp +13 -10
  89. data/ext/libsass/src/node.hpp +3 -3
  90. data/ext/libsass/src/operation.hpp +184 -144
  91. data/ext/libsass/src/operators.cpp +43 -17
  92. data/ext/libsass/src/operators.hpp +5 -5
  93. data/ext/libsass/src/output.cpp +21 -18
  94. data/ext/libsass/src/output.hpp +14 -21
  95. data/ext/libsass/src/parser.cpp +215 -183
  96. data/ext/libsass/src/parser.hpp +28 -24
  97. data/ext/libsass/src/plugins.cpp +5 -1
  98. data/ext/libsass/src/position.cpp +3 -0
  99. data/ext/libsass/src/prelexer.cpp +9 -3
  100. data/ext/libsass/src/prelexer.hpp +9 -9
  101. data/ext/libsass/src/remove_placeholders.cpp +14 -11
  102. data/ext/libsass/src/remove_placeholders.hpp +8 -9
  103. data/ext/libsass/src/sass.cpp +9 -3
  104. data/ext/libsass/src/sass.hpp +12 -9
  105. data/ext/libsass/src/sass2scss.cpp +45 -14
  106. data/ext/libsass/src/sass_context.cpp +18 -15
  107. data/ext/libsass/src/sass_functions.cpp +6 -3
  108. data/ext/libsass/src/sass_functions.hpp +1 -1
  109. data/ext/libsass/src/sass_util.cpp +3 -0
  110. data/ext/libsass/src/sass_values.cpp +21 -13
  111. data/ext/libsass/src/source_map.cpp +5 -2
  112. data/ext/libsass/src/source_map.hpp +2 -2
  113. data/ext/libsass/src/subset_map.cpp +4 -1
  114. data/ext/libsass/src/to_value.cpp +23 -21
  115. data/ext/libsass/src/to_value.hpp +18 -22
  116. data/ext/libsass/src/units.cpp +4 -0
  117. data/ext/libsass/src/units.hpp +1 -0
  118. data/ext/libsass/src/utf8/checked.h +12 -10
  119. data/ext/libsass/src/utf8/core.h +3 -0
  120. data/ext/libsass/src/utf8_string.cpp +3 -0
  121. data/ext/libsass/src/util.cpp +67 -75
  122. data/ext/libsass/src/util.hpp +64 -19
  123. data/ext/libsass/src/util_string.cpp +75 -0
  124. data/ext/libsass/src/util_string.hpp +19 -0
  125. data/ext/libsass/src/values.cpp +22 -13
  126. data/ext/libsass/src/values.hpp +2 -2
  127. data/ext/libsass/win/libsass.targets +30 -4
  128. data/ext/libsass/win/libsass.vcxproj.filters +82 -4
  129. data/lib/sassc.rb +24 -0
  130. data/lib/sassc/engine.rb +2 -2
  131. data/lib/sassc/native.rb +8 -1
  132. data/lib/sassc/version.rb +1 -1
  133. data/sassc.gemspec +19 -11
  134. data/test/engine_test.rb +26 -1
  135. data/test/native_test.rb +1 -1
  136. metadata +66 -72
  137. data/ext/Rakefile +0 -3
  138. data/ext/libsass/.github/CONTRIBUTING.md +0 -65
  139. data/ext/libsass/.github/ISSUE_TEMPLATE.md +0 -54
  140. data/ext/libsass/.travis.yml +0 -64
  141. data/ext/libsass/Readme.md +0 -104
  142. data/ext/libsass/SECURITY.md +0 -10
  143. data/ext/libsass/appveyor.yml +0 -91
  144. data/ext/libsass/docs/README.md +0 -20
  145. data/ext/libsass/docs/api-context-example.md +0 -45
  146. data/ext/libsass/docs/api-context-internal.md +0 -163
  147. data/ext/libsass/docs/api-context.md +0 -295
  148. data/ext/libsass/docs/api-doc.md +0 -215
  149. data/ext/libsass/docs/api-function-example.md +0 -67
  150. data/ext/libsass/docs/api-function-internal.md +0 -8
  151. data/ext/libsass/docs/api-function.md +0 -74
  152. data/ext/libsass/docs/api-importer-example.md +0 -112
  153. data/ext/libsass/docs/api-importer-internal.md +0 -20
  154. data/ext/libsass/docs/api-importer.md +0 -86
  155. data/ext/libsass/docs/api-value-example.md +0 -55
  156. data/ext/libsass/docs/api-value-internal.md +0 -76
  157. data/ext/libsass/docs/api-value.md +0 -154
  158. data/ext/libsass/docs/build-on-darwin.md +0 -27
  159. data/ext/libsass/docs/build-on-gentoo.md +0 -55
  160. data/ext/libsass/docs/build-on-windows.md +0 -139
  161. data/ext/libsass/docs/build-shared-library.md +0 -35
  162. data/ext/libsass/docs/build-with-autotools.md +0 -78
  163. data/ext/libsass/docs/build-with-makefiles.md +0 -68
  164. data/ext/libsass/docs/build-with-mingw.md +0 -107
  165. data/ext/libsass/docs/build-with-visual-studio.md +0 -90
  166. data/ext/libsass/docs/build.md +0 -97
  167. data/ext/libsass/docs/compatibility-plan.md +0 -48
  168. data/ext/libsass/docs/contributing.md +0 -17
  169. data/ext/libsass/docs/custom-functions-internal.md +0 -122
  170. data/ext/libsass/docs/dev-ast-memory.md +0 -223
  171. data/ext/libsass/docs/implementations.md +0 -56
  172. data/ext/libsass/docs/plugins.md +0 -47
  173. data/ext/libsass/docs/setup-environment.md +0 -68
  174. data/ext/libsass/docs/source-map-internals.md +0 -51
  175. data/ext/libsass/docs/trace.md +0 -26
  176. data/ext/libsass/docs/triage.md +0 -17
  177. data/ext/libsass/docs/unicode.md +0 -39
  178. data/ext/libsass/extconf.rb +0 -6
  179. data/ext/libsass/script/bootstrap +0 -13
  180. data/ext/libsass/script/branding +0 -10
  181. data/ext/libsass/script/ci-build-libsass +0 -134
  182. data/ext/libsass/script/ci-build-plugin +0 -62
  183. data/ext/libsass/script/ci-install-compiler +0 -6
  184. data/ext/libsass/script/ci-install-deps +0 -20
  185. data/ext/libsass/script/ci-report-coverage +0 -42
  186. data/ext/libsass/script/spec +0 -5
  187. data/ext/libsass/script/tap-driver +0 -652
  188. data/ext/libsass/script/tap-runner +0 -1
  189. data/ext/libsass/script/test-leaks.pl +0 -103
  190. data/ext/libsass/src/functions.cpp +0 -2234
  191. data/ext/libsass/src/functions.hpp +0 -198
  192. data/ext/libsass/src/to_c.hpp +0 -39
  193. data/ext/libsass/test/test_node.cpp +0 -94
  194. data/ext/libsass/test/test_paths.cpp +0 -28
  195. data/ext/libsass/test/test_selector_difference.cpp +0 -25
  196. data/ext/libsass/test/test_specificity.cpp +0 -25
  197. data/ext/libsass/test/test_subset_map.cpp +0 -472
  198. data/ext/libsass/test/test_superselector.cpp +0 -69
  199. data/ext/libsass/test/test_unification.cpp +0 -31
  200. data/lib/tasks/libsass.rb +0 -33
@@ -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 <vector>
3
6
 
4
7
  #include "node.hpp"
@@ -17,8 +20,8 @@ namespace Sass {
17
20
  Node Node::createSelector(const Complex_Selector& pSelector) {
18
21
  NodeDequePtr null;
19
22
 
20
- Complex_Selector_Ptr pStripped = SASS_MEMORY_COPY(&pSelector);
21
- pStripped->tail(NULL);
23
+ Complex_Selector* pStripped = SASS_MEMORY_COPY(&pSelector);
24
+ pStripped->tail({});
22
25
  pStripped->combinator(Complex_Selector::ANCESTOR_OF);
23
26
 
24
27
  Node n(SELECTOR, Complex_Selector::ANCESTOR_OF, pStripped, null /*pCollection*/);
@@ -45,7 +48,7 @@ namespace Sass {
45
48
  }
46
49
 
47
50
 
48
- Node::Node(const TYPE& type, Complex_Selector::Combinator combinator, Complex_Selector_Ptr pSelector, NodeDequePtr& pCollection)
51
+ Node::Node(const TYPE& type, Complex_Selector::Combinator combinator, Complex_Selector* pSelector, NodeDequePtr& pCollection)
49
52
  : got_line_feed(false), mType(type), mCombinator(combinator), mpSelector(pSelector), mpCollection(pCollection)
50
53
  { if (pSelector) got_line_feed = pSelector->has_line_feed(); }
51
54
 
@@ -172,7 +175,7 @@ namespace Sass {
172
175
  #endif
173
176
 
174
177
 
175
- Node complexSelectorToNode(Complex_Selector_Ptr pToConvert) {
178
+ Node complexSelectorToNode(Complex_Selector* pToConvert) {
176
179
  if (pToConvert == NULL) {
177
180
  return Node::createNil();
178
181
  }
@@ -220,21 +223,21 @@ namespace Sass {
220
223
  }
221
224
 
222
225
 
223
- Complex_Selector_Ptr nodeToComplexSelector(const Node& toConvert) {
226
+ Complex_Selector* nodeToComplexSelector(const Node& toConvert) {
224
227
  if (toConvert.isNil()) {
225
228
  return NULL;
226
229
  }
227
230
 
228
231
 
229
232
  if (!toConvert.isCollection()) {
230
- throw "The node to convert to a Complex_Selector_Ptr must be a collection type or nil.";
233
+ throw "The node to convert to a Complex_Selector* must be a collection type or nil.";
231
234
  }
232
235
 
233
236
 
234
237
  NodeDeque& childNodes = *toConvert.collection();
235
238
 
236
239
  std::string noPath("");
237
- Complex_Selector_Obj pFirst = SASS_MEMORY_NEW(Complex_Selector, ParserState("[NODE]"), Complex_Selector::ANCESTOR_OF, NULL, NULL);
240
+ Complex_Selector_Obj pFirst = SASS_MEMORY_NEW(Complex_Selector, ParserState("[NODE]"), Complex_Selector::ANCESTOR_OF, {}, {});
238
241
 
239
242
  Complex_Selector_Obj pCurrent = pFirst;
240
243
 
@@ -259,7 +262,7 @@ namespace Sass {
259
262
  if (childIter+1 != childIterEnd) {
260
263
  Node& nextNode = *(childIter+1);
261
264
  if (nextNode.isCombinator()) {
262
- pCurrent->tail(SASS_MEMORY_NEW(Complex_Selector, ParserState("[NODE]"), Complex_Selector::ANCESTOR_OF, NULL, NULL));
265
+ pCurrent->tail(SASS_MEMORY_NEW(Complex_Selector, ParserState("[NODE]"), Complex_Selector::ANCESTOR_OF, {}, {}));
263
266
  if (nextNode.got_line_feed) pCurrent->tail()->has_line_feed(nextNode.got_line_feed);
264
267
  pCurrent = pCurrent->tail();
265
268
  }
@@ -270,8 +273,8 @@ namespace Sass {
270
273
  }
271
274
 
272
275
  // Put the dummy Compound_Selector in the first position, for consistency with the rest of libsass
273
- Compound_Selector_Ptr fakeHead = SASS_MEMORY_NEW(Compound_Selector, ParserState("[NODE]"), 1);
274
- Parent_Selector_Ptr selectorRef = SASS_MEMORY_NEW(Parent_Selector, ParserState("[NODE]"));
276
+ Compound_Selector* fakeHead = SASS_MEMORY_NEW(Compound_Selector, ParserState("[NODE]"), 1);
277
+ Parent_Selector* selectorRef = SASS_MEMORY_NEW(Parent_Selector, ParserState("[NODE]"));
275
278
  fakeHead->elements().push_back(selectorRef);
276
279
  if (toConvert.got_line_feed) pFirst->has_line_feed(toConvert.got_line_feed);
277
280
  // pFirst->has_line_feed(pFirst->has_line_feed() || pFirst->tail()->has_line_feed() || toConvert.got_line_feed);
@@ -97,7 +97,7 @@ namespace Sass {
97
97
  // Private constructor; Use the static methods (like createCombinator and createSelector)
98
98
  // to instantiate this object. This is more expressive, and it allows us to break apart each
99
99
  // case into separate functions.
100
- Node(const TYPE& type, Complex_Selector::Combinator combinator, Complex_Selector_Ptr pSelector, NodeDequePtr& pCollection);
100
+ Node(const TYPE& type, Complex_Selector::Combinator combinator, Complex_Selector* pSelector, NodeDequePtr& pCollection);
101
101
 
102
102
  TYPE mType;
103
103
 
@@ -110,8 +110,8 @@ namespace Sass {
110
110
  #ifdef DEBUG
111
111
  std::ostream& operator<<(std::ostream& os, const Node& node);
112
112
  #endif
113
- Node complexSelectorToNode(Complex_Selector_Ptr pToConvert);
114
- Complex_Selector_Ptr nodeToComplexSelector(const Node& toConvert);
113
+ Node complexSelectorToNode(Complex_Selector* pToConvert);
114
+ Complex_Selector* nodeToComplexSelector(const Node& toConvert);
115
115
 
116
116
  }
117
117
 
@@ -1,171 +1,211 @@
1
1
  #ifndef SASS_OPERATION_H
2
2
  #define SASS_OPERATION_H
3
3
 
4
+ // base classes to implement curiously recurring template pattern (CRTP)
5
+ // https://en.wikipedia.org/wiki/Curiously_recurring_template_pattern
6
+
7
+ #include <stdexcept>
8
+
4
9
  #include "ast_fwd_decl.hpp"
10
+ #include "ast_def_macros.hpp"
5
11
 
6
12
  namespace Sass {
7
13
 
14
+ #define ATTACH_ABSTRACT_CRTP_PERFORM_METHODS()\
15
+ virtual void perform(Operation<void>* op) = 0; \
16
+ virtual Value* perform(Operation<Value*>* op) = 0; \
17
+ virtual std::string perform(Operation<std::string>* op) = 0; \
18
+ virtual AST_Node* perform(Operation<AST_Node*>* op) = 0; \
19
+ virtual Selector* perform(Operation<Selector*>* op) = 0; \
20
+ virtual Statement* perform(Operation<Statement*>* op) = 0; \
21
+ virtual Expression* perform(Operation<Expression*>* op) = 0; \
22
+ virtual union Sass_Value* perform(Operation<union Sass_Value*>* op) = 0; \
23
+ virtual Supports_Condition* perform(Operation<Supports_Condition*>* op) = 0; \
24
+
25
+ // you must add operators to every class
26
+ // ensures `this` of actual instance type
27
+ // we therefore call the specific operator
28
+ // they are virtual so most specific is used
29
+ #define ATTACH_CRTP_PERFORM_METHODS()\
30
+ virtual void perform(Operation<void>* op) override { return (*op)(this); } \
31
+ virtual Value* perform(Operation<Value*>* op) override { return (*op)(this); } \
32
+ virtual std::string perform(Operation<std::string>* op) override { return (*op)(this); } \
33
+ virtual AST_Node* perform(Operation<AST_Node*>* op) override { return (*op)(this); } \
34
+ virtual Selector* perform(Operation<Selector*>* op) override { return (*op)(this); } \
35
+ virtual Statement* perform(Operation<Statement*>* op) override { return (*op)(this); } \
36
+ virtual Expression* perform(Operation<Expression*>* op) override { return (*op)(this); } \
37
+ virtual union Sass_Value* perform(Operation<union Sass_Value*>* op) override { return (*op)(this); } \
38
+ virtual Supports_Condition* perform(Operation<Supports_Condition*>* op) override { return (*op)(this); } \
39
+
8
40
  template<typename T>
9
41
  class Operation {
10
42
  public:
11
- virtual T operator()(AST_Node_Ptr x) = 0;
12
- virtual ~Operation() { }
43
+ virtual T operator()(AST_Node* x) = 0;
13
44
  // statements
14
- virtual T operator()(Block_Ptr x) = 0;
15
- virtual T operator()(Ruleset_Ptr x) = 0;
16
- virtual T operator()(Bubble_Ptr x) = 0;
17
- virtual T operator()(Trace_Ptr x) = 0;
18
- virtual T operator()(Supports_Block_Ptr x) = 0;
19
- virtual T operator()(Media_Block_Ptr x) = 0;
20
- virtual T operator()(At_Root_Block_Ptr x) = 0;
21
- virtual T operator()(Directive_Ptr x) = 0;
22
- virtual T operator()(Keyframe_Rule_Ptr x) = 0;
23
- virtual T operator()(Declaration_Ptr x) = 0;
24
- virtual T operator()(Assignment_Ptr x) = 0;
25
- virtual T operator()(Import_Ptr x) = 0;
26
- virtual T operator()(Import_Stub_Ptr x) = 0;
27
- virtual T operator()(Warning_Ptr x) = 0;
28
- virtual T operator()(Error_Ptr x) = 0;
29
- virtual T operator()(Debug_Ptr x) = 0;
30
- virtual T operator()(Comment_Ptr x) = 0;
31
- virtual T operator()(If_Ptr x) = 0;
32
- virtual T operator()(For_Ptr x) = 0;
33
- virtual T operator()(Each_Ptr x) = 0;
34
- virtual T operator()(While_Ptr x) = 0;
35
- virtual T operator()(Return_Ptr x) = 0;
36
- virtual T operator()(Content_Ptr x) = 0;
37
- virtual T operator()(Extension_Ptr x) = 0;
38
- virtual T operator()(Definition_Ptr x) = 0;
39
- virtual T operator()(Mixin_Call_Ptr x) = 0;
45
+ virtual T operator()(Block* x) = 0;
46
+ virtual T operator()(Ruleset* x) = 0;
47
+ virtual T operator()(Bubble* x) = 0;
48
+ virtual T operator()(Trace* x) = 0;
49
+ virtual T operator()(Supports_Block* x) = 0;
50
+ virtual T operator()(Media_Block* x) = 0;
51
+ virtual T operator()(At_Root_Block* x) = 0;
52
+ virtual T operator()(Directive* x) = 0;
53
+ virtual T operator()(Keyframe_Rule* x) = 0;
54
+ virtual T operator()(Declaration* x) = 0;
55
+ virtual T operator()(Assignment* x) = 0;
56
+ virtual T operator()(Import* x) = 0;
57
+ virtual T operator()(Import_Stub* x) = 0;
58
+ virtual T operator()(Warning* x) = 0;
59
+ virtual T operator()(Error* x) = 0;
60
+ virtual T operator()(Debug* x) = 0;
61
+ virtual T operator()(Comment* x) = 0;
62
+ virtual T operator()(If* x) = 0;
63
+ virtual T operator()(For* x) = 0;
64
+ virtual T operator()(Each* x) = 0;
65
+ virtual T operator()(While* x) = 0;
66
+ virtual T operator()(Return* x) = 0;
67
+ virtual T operator()(Content* x) = 0;
68
+ virtual T operator()(Extension* x) = 0;
69
+ virtual T operator()(Definition* x) = 0;
70
+ virtual T operator()(Mixin_Call* x) = 0;
40
71
  // expressions
41
- virtual T operator()(List_Ptr x) = 0;
42
- virtual T operator()(Map_Ptr x) = 0;
43
- virtual T operator()(Function_Ptr x) = 0;
44
- virtual T operator()(Binary_Expression_Ptr x) = 0;
45
- virtual T operator()(Unary_Expression_Ptr x) = 0;
46
- virtual T operator()(Function_Call_Ptr x) = 0;
47
- virtual T operator()(Function_Call_Schema_Ptr x) = 0;
48
- virtual T operator()(Custom_Warning_Ptr x) = 0;
49
- virtual T operator()(Custom_Error_Ptr x) = 0;
50
- virtual T operator()(Variable_Ptr x) = 0;
51
- virtual T operator()(Number_Ptr x) = 0;
52
- virtual T operator()(Color_Ptr x) = 0;
53
- virtual T operator()(Boolean_Ptr x) = 0;
54
- virtual T operator()(String_Schema_Ptr x) = 0;
55
- virtual T operator()(String_Quoted_Ptr x) = 0;
56
- virtual T operator()(String_Constant_Ptr x) = 0;
57
- virtual T operator()(Supports_Condition_Ptr x) = 0;
58
- virtual T operator()(Supports_Operator_Ptr x) = 0;
59
- virtual T operator()(Supports_Negation_Ptr x) = 0;
60
- virtual T operator()(Supports_Declaration_Ptr x) = 0;
61
- virtual T operator()(Supports_Interpolation_Ptr x) = 0;
62
- virtual T operator()(Media_Query_Ptr x) = 0;
63
- virtual T operator()(Media_Query_Expression_Ptr x) = 0;
64
- virtual T operator()(At_Root_Query_Ptr x) = 0;
65
- virtual T operator()(Null_Ptr x) = 0;
66
- virtual T operator()(Parent_Selector_Ptr x) = 0;
72
+ virtual T operator()(Null* x) = 0;
73
+ virtual T operator()(List* x) = 0;
74
+ virtual T operator()(Map* x) = 0;
75
+ virtual T operator()(Function* x) = 0;
76
+ virtual T operator()(Binary_Expression* x) = 0;
77
+ virtual T operator()(Unary_Expression* x) = 0;
78
+ virtual T operator()(Function_Call* x) = 0;
79
+ virtual T operator()(Custom_Warning* x) = 0;
80
+ virtual T operator()(Custom_Error* x) = 0;
81
+ virtual T operator()(Variable* x) = 0;
82
+ virtual T operator()(Number* x) = 0;
83
+ virtual T operator()(Color* x) = 0;
84
+ virtual T operator()(Color_RGBA* x) = 0;
85
+ virtual T operator()(Color_HSLA* x) = 0;
86
+ virtual T operator()(Boolean* x) = 0;
87
+ virtual T operator()(String_Schema* x) = 0;
88
+ virtual T operator()(String_Quoted* x) = 0;
89
+ virtual T operator()(String_Constant* x) = 0;
90
+ virtual T operator()(Supports_Condition* x) = 0;
91
+ virtual T operator()(Supports_Operator* x) = 0;
92
+ virtual T operator()(Supports_Negation* x) = 0;
93
+ virtual T operator()(Supports_Declaration* x) = 0;
94
+ virtual T operator()(Supports_Interpolation* x) = 0;
95
+ virtual T operator()(Media_Query* x) = 0;
96
+ virtual T operator()(Media_Query_Expression* x) = 0;
97
+ virtual T operator()(At_Root_Query* x) = 0;
98
+ virtual T operator()(Parent_Selector* x) = 0;
99
+ virtual T operator()(Parent_Reference* x) = 0;
67
100
  // parameters and arguments
68
- virtual T operator()(Parameter_Ptr x) = 0;
69
- virtual T operator()(Parameters_Ptr x) = 0;
70
- virtual T operator()(Argument_Ptr x) = 0;
71
- virtual T operator()(Arguments_Ptr x) = 0;
101
+ virtual T operator()(Parameter* x) = 0;
102
+ virtual T operator()(Parameters* x) = 0;
103
+ virtual T operator()(Argument* x) = 0;
104
+ virtual T operator()(Arguments* x) = 0;
72
105
  // selectors
73
- virtual T operator()(Selector_Schema_Ptr x) = 0;
74
- virtual T operator()(Placeholder_Selector_Ptr x) = 0;
75
- virtual T operator()(Element_Selector_Ptr x) = 0;
76
- virtual T operator()(Class_Selector_Ptr x) = 0;
77
- virtual T operator()(Id_Selector_Ptr x) = 0;
78
- virtual T operator()(Attribute_Selector_Ptr x) = 0;
79
- virtual T operator()(Pseudo_Selector_Ptr x) = 0;
80
- virtual T operator()(Wrapped_Selector_Ptr x) = 0;
81
- virtual T operator()(Compound_Selector_Ptr x)= 0;
82
- virtual T operator()(Complex_Selector_Ptr x) = 0;
83
- virtual T operator()(Selector_List_Ptr x) = 0;
84
-
85
- template <typename U>
86
- T fallback(U x) { return T(); }
106
+ virtual T operator()(Selector_Schema* x) = 0;
107
+ virtual T operator()(Placeholder_Selector* x) = 0;
108
+ virtual T operator()(Type_Selector* x) = 0;
109
+ virtual T operator()(Class_Selector* x) = 0;
110
+ virtual T operator()(Id_Selector* x) = 0;
111
+ virtual T operator()(Attribute_Selector* x) = 0;
112
+ virtual T operator()(Pseudo_Selector* x) = 0;
113
+ virtual T operator()(Wrapped_Selector* x) = 0;
114
+ virtual T operator()(Compound_Selector* x)= 0;
115
+ virtual T operator()(Complex_Selector* x) = 0;
116
+ virtual T operator()(Selector_List* x) = 0;
87
117
  };
88
118
 
119
+ // example: Operation_CRTP<Expression*, Eval>
120
+ // T is the base return type of all visitors
121
+ // D is the class derived visitor class
122
+ // normaly you want to implement all operators
89
123
  template <typename T, typename D>
90
124
  class Operation_CRTP : public Operation<T> {
91
125
  public:
92
- D& impl() { return static_cast<D&>(*this); }
93
- public:
94
- T operator()(AST_Node_Ptr x) { return static_cast<D*>(this)->fallback(x); }
126
+ T operator()(AST_Node* x) { return static_cast<D*>(this)->fallback(x); }
95
127
  // statements
96
- T operator()(Block_Ptr x) { return static_cast<D*>(this)->fallback(x); }
97
- T operator()(Ruleset_Ptr x) { return static_cast<D*>(this)->fallback(x); }
98
- T operator()(Bubble_Ptr x) { return static_cast<D*>(this)->fallback(x); }
99
- T operator()(Trace_Ptr x) { return static_cast<D*>(this)->fallback(x); }
100
- T operator()(Supports_Block_Ptr x) { return static_cast<D*>(this)->fallback(x); }
101
- T operator()(Media_Block_Ptr x) { return static_cast<D*>(this)->fallback(x); }
102
- T operator()(At_Root_Block_Ptr x) { return static_cast<D*>(this)->fallback(x); }
103
- T operator()(Directive_Ptr x) { return static_cast<D*>(this)->fallback(x); }
104
- T operator()(Keyframe_Rule_Ptr x) { return static_cast<D*>(this)->fallback(x); }
105
- T operator()(Declaration_Ptr x) { return static_cast<D*>(this)->fallback(x); }
106
- T operator()(Assignment_Ptr x) { return static_cast<D*>(this)->fallback(x); }
107
- T operator()(Import_Ptr x) { return static_cast<D*>(this)->fallback(x); }
108
- T operator()(Import_Stub_Ptr x) { return static_cast<D*>(this)->fallback(x); }
109
- T operator()(Warning_Ptr x) { return static_cast<D*>(this)->fallback(x); }
110
- T operator()(Error_Ptr x) { return static_cast<D*>(this)->fallback(x); }
111
- T operator()(Debug_Ptr x) { return static_cast<D*>(this)->fallback(x); }
112
- T operator()(Comment_Ptr x) { return static_cast<D*>(this)->fallback(x); }
113
- T operator()(If_Ptr x) { return static_cast<D*>(this)->fallback(x); }
114
- T operator()(For_Ptr x) { return static_cast<D*>(this)->fallback(x); }
115
- T operator()(Each_Ptr x) { return static_cast<D*>(this)->fallback(x); }
116
- T operator()(While_Ptr x) { return static_cast<D*>(this)->fallback(x); }
117
- T operator()(Return_Ptr x) { return static_cast<D*>(this)->fallback(x); }
118
- T operator()(Content_Ptr x) { return static_cast<D*>(this)->fallback(x); }
119
- T operator()(Extension_Ptr x) { return static_cast<D*>(this)->fallback(x); }
120
- T operator()(Definition_Ptr x) { return static_cast<D*>(this)->fallback(x); }
121
- T operator()(Mixin_Call_Ptr x) { return static_cast<D*>(this)->fallback(x); }
128
+ T operator()(Block* x) { return static_cast<D*>(this)->fallback(x); }
129
+ T operator()(Ruleset* x) { return static_cast<D*>(this)->fallback(x); }
130
+ T operator()(Bubble* x) { return static_cast<D*>(this)->fallback(x); }
131
+ T operator()(Trace* x) { return static_cast<D*>(this)->fallback(x); }
132
+ T operator()(Supports_Block* x) { return static_cast<D*>(this)->fallback(x); }
133
+ T operator()(Media_Block* x) { return static_cast<D*>(this)->fallback(x); }
134
+ T operator()(At_Root_Block* x) { return static_cast<D*>(this)->fallback(x); }
135
+ T operator()(Directive* x) { return static_cast<D*>(this)->fallback(x); }
136
+ T operator()(Keyframe_Rule* x) { return static_cast<D*>(this)->fallback(x); }
137
+ T operator()(Declaration* x) { return static_cast<D*>(this)->fallback(x); }
138
+ T operator()(Assignment* x) { return static_cast<D*>(this)->fallback(x); }
139
+ T operator()(Import* x) { return static_cast<D*>(this)->fallback(x); }
140
+ T operator()(Import_Stub* x) { return static_cast<D*>(this)->fallback(x); }
141
+ T operator()(Warning* x) { return static_cast<D*>(this)->fallback(x); }
142
+ T operator()(Error* x) { return static_cast<D*>(this)->fallback(x); }
143
+ T operator()(Debug* x) { return static_cast<D*>(this)->fallback(x); }
144
+ T operator()(Comment* x) { return static_cast<D*>(this)->fallback(x); }
145
+ T operator()(If* x) { return static_cast<D*>(this)->fallback(x); }
146
+ T operator()(For* x) { return static_cast<D*>(this)->fallback(x); }
147
+ T operator()(Each* x) { return static_cast<D*>(this)->fallback(x); }
148
+ T operator()(While* x) { return static_cast<D*>(this)->fallback(x); }
149
+ T operator()(Return* x) { return static_cast<D*>(this)->fallback(x); }
150
+ T operator()(Content* x) { return static_cast<D*>(this)->fallback(x); }
151
+ T operator()(Extension* x) { return static_cast<D*>(this)->fallback(x); }
152
+ T operator()(Definition* x) { return static_cast<D*>(this)->fallback(x); }
153
+ T operator()(Mixin_Call* x) { return static_cast<D*>(this)->fallback(x); }
122
154
  // expressions
123
- T operator()(List_Ptr x) { return static_cast<D*>(this)->fallback(x); }
124
- T operator()(Map_Ptr x) { return static_cast<D*>(this)->fallback(x); }
125
- T operator()(Function_Ptr x) { return static_cast<D*>(this)->fallback(x); }
126
- T operator()(Binary_Expression_Ptr x) { return static_cast<D*>(this)->fallback(x); }
127
- T operator()(Unary_Expression_Ptr x) { return static_cast<D*>(this)->fallback(x); }
128
- T operator()(Function_Call_Ptr x) { return static_cast<D*>(this)->fallback(x); }
129
- T operator()(Function_Call_Schema_Ptr x) { return static_cast<D*>(this)->fallback(x); }
130
- T operator()(Custom_Warning_Ptr x) { return static_cast<D*>(this)->fallback(x); }
131
- T operator()(Custom_Error_Ptr x) { return static_cast<D*>(this)->fallback(x); }
132
- T operator()(Variable_Ptr x) { return static_cast<D*>(this)->fallback(x); }
133
- T operator()(Number_Ptr x) { return static_cast<D*>(this)->fallback(x); }
134
- T operator()(Color_Ptr x) { return static_cast<D*>(this)->fallback(x); }
135
- T operator()(Boolean_Ptr x) { return static_cast<D*>(this)->fallback(x); }
136
- T operator()(String_Schema_Ptr x) { return static_cast<D*>(this)->fallback(x); }
137
- T operator()(String_Constant_Ptr x) { return static_cast<D*>(this)->fallback(x); }
138
- T operator()(String_Quoted_Ptr x) { return static_cast<D*>(this)->fallback(x); }
139
- T operator()(Supports_Condition_Ptr x) { return static_cast<D*>(this)->fallback(x); }
140
- T operator()(Supports_Operator_Ptr x) { return static_cast<D*>(this)->fallback(x); }
141
- T operator()(Supports_Negation_Ptr x) { return static_cast<D*>(this)->fallback(x); }
142
- T operator()(Supports_Declaration_Ptr x) { return static_cast<D*>(this)->fallback(x); }
143
- T operator()(Supports_Interpolation_Ptr x) { return static_cast<D*>(this)->fallback(x); }
144
- T operator()(Media_Query_Ptr x) { return static_cast<D*>(this)->fallback(x); }
145
- T operator()(Media_Query_Expression_Ptr x) { return static_cast<D*>(this)->fallback(x); }
146
- T operator()(At_Root_Query_Ptr x) { return static_cast<D*>(this)->fallback(x); }
147
- T operator()(Null_Ptr x) { return static_cast<D*>(this)->fallback(x); }
148
- T operator()(Parent_Selector_Ptr x) { return static_cast<D*>(this)->fallback(x); }
155
+ T operator()(Null* x) { return static_cast<D*>(this)->fallback(x); }
156
+ T operator()(List* x) { return static_cast<D*>(this)->fallback(x); }
157
+ T operator()(Map* x) { return static_cast<D*>(this)->fallback(x); }
158
+ T operator()(Function* x) { return static_cast<D*>(this)->fallback(x); }
159
+ T operator()(Binary_Expression* x) { return static_cast<D*>(this)->fallback(x); }
160
+ T operator()(Unary_Expression* x) { return static_cast<D*>(this)->fallback(x); }
161
+ T operator()(Function_Call* x) { return static_cast<D*>(this)->fallback(x); }
162
+ T operator()(Custom_Warning* x) { return static_cast<D*>(this)->fallback(x); }
163
+ T operator()(Custom_Error* x) { return static_cast<D*>(this)->fallback(x); }
164
+ T operator()(Variable* x) { return static_cast<D*>(this)->fallback(x); }
165
+ T operator()(Number* x) { return static_cast<D*>(this)->fallback(x); }
166
+ T operator()(Color* x) { return static_cast<D*>(this)->fallback(x); }
167
+ T operator()(Color_RGBA* x) { return static_cast<D*>(this)->fallback(x); }
168
+ T operator()(Color_HSLA* x) { return static_cast<D*>(this)->fallback(x); }
169
+ T operator()(Boolean* x) { return static_cast<D*>(this)->fallback(x); }
170
+ T operator()(String_Schema* x) { return static_cast<D*>(this)->fallback(x); }
171
+ T operator()(String_Constant* x) { return static_cast<D*>(this)->fallback(x); }
172
+ T operator()(String_Quoted* x) { return static_cast<D*>(this)->fallback(x); }
173
+ T operator()(Supports_Condition* x) { return static_cast<D*>(this)->fallback(x); }
174
+ T operator()(Supports_Operator* x) { return static_cast<D*>(this)->fallback(x); }
175
+ T operator()(Supports_Negation* x) { return static_cast<D*>(this)->fallback(x); }
176
+ T operator()(Supports_Declaration* x) { return static_cast<D*>(this)->fallback(x); }
177
+ T operator()(Supports_Interpolation* x) { return static_cast<D*>(this)->fallback(x); }
178
+ T operator()(Media_Query* x) { return static_cast<D*>(this)->fallback(x); }
179
+ T operator()(Media_Query_Expression* x) { return static_cast<D*>(this)->fallback(x); }
180
+ T operator()(At_Root_Query* x) { return static_cast<D*>(this)->fallback(x); }
181
+ T operator()(Parent_Selector* x) { return static_cast<D*>(this)->fallback(x); }
182
+ T operator()(Parent_Reference* x) { return static_cast<D*>(this)->fallback(x); }
149
183
  // parameters and arguments
150
- T operator()(Parameter_Ptr x) { return static_cast<D*>(this)->fallback(x); }
151
- T operator()(Parameters_Ptr x) { return static_cast<D*>(this)->fallback(x); }
152
- T operator()(Argument_Ptr x) { return static_cast<D*>(this)->fallback(x); }
153
- T operator()(Arguments_Ptr x) { return static_cast<D*>(this)->fallback(x); }
184
+ T operator()(Parameter* x) { return static_cast<D*>(this)->fallback(x); }
185
+ T operator()(Parameters* x) { return static_cast<D*>(this)->fallback(x); }
186
+ T operator()(Argument* x) { return static_cast<D*>(this)->fallback(x); }
187
+ T operator()(Arguments* x) { return static_cast<D*>(this)->fallback(x); }
154
188
  // selectors
155
- T operator()(Selector_Schema_Ptr x) { return static_cast<D*>(this)->fallback(x); }
156
- T operator()(Placeholder_Selector_Ptr x) { return static_cast<D*>(this)->fallback(x); }
157
- T operator()(Element_Selector_Ptr x) { return static_cast<D*>(this)->fallback(x); }
158
- T operator()(Class_Selector_Ptr x) { return static_cast<D*>(this)->fallback(x); }
159
- T operator()(Id_Selector_Ptr x) { return static_cast<D*>(this)->fallback(x); }
160
- T operator()(Attribute_Selector_Ptr x) { return static_cast<D*>(this)->fallback(x); }
161
- T operator()(Pseudo_Selector_Ptr x) { return static_cast<D*>(this)->fallback(x); }
162
- T operator()(Wrapped_Selector_Ptr x) { return static_cast<D*>(this)->fallback(x); }
163
- T operator()(Compound_Selector_Ptr x){ return static_cast<D*>(this)->fallback(x); }
164
- T operator()(Complex_Selector_Ptr x) { return static_cast<D*>(this)->fallback(x); }
165
- T operator()(Selector_List_Ptr x) { return static_cast<D*>(this)->fallback(x); }
189
+ T operator()(Selector_Schema* x) { return static_cast<D*>(this)->fallback(x); }
190
+ T operator()(Placeholder_Selector* x) { return static_cast<D*>(this)->fallback(x); }
191
+ T operator()(Type_Selector* x) { return static_cast<D*>(this)->fallback(x); }
192
+ T operator()(Class_Selector* x) { return static_cast<D*>(this)->fallback(x); }
193
+ T operator()(Id_Selector* x) { return static_cast<D*>(this)->fallback(x); }
194
+ T operator()(Attribute_Selector* x) { return static_cast<D*>(this)->fallback(x); }
195
+ T operator()(Pseudo_Selector* x) { return static_cast<D*>(this)->fallback(x); }
196
+ T operator()(Wrapped_Selector* x) { return static_cast<D*>(this)->fallback(x); }
197
+ T operator()(Compound_Selector* x){ return static_cast<D*>(this)->fallback(x); }
198
+ T operator()(Complex_Selector* x) { return static_cast<D*>(this)->fallback(x); }
199
+ T operator()(Selector_List* x) { return static_cast<D*>(this)->fallback(x); }
200
+
201
+ // fallback with specific type U
202
+ // will be called if not overloaded
203
+ template <typename U> T fallback(U x)
204
+ {
205
+ throw std::runtime_error(
206
+ std::string(typeid(*this).name()) + ": CRTP not implemented for " + typeid(x).name());
207
+ }
166
208
 
167
- template <typename U>
168
- T fallback(U x) { return T(); }
169
209
  };
170
210
 
171
211
  }