sassc 2.0.1 → 2.1.0.pre1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.gitmodules +1 -1
- data/.travis.yml +7 -3
- data/CHANGELOG.md +3 -0
- data/CODE_OF_CONDUCT.md +1 -1
- data/README.md +1 -1
- data/Rakefile +23 -8
- data/ext/extconf.rb +39 -0
- data/ext/libsass/.gitignore +1 -0
- data/ext/libsass/GNUmakefile.am +23 -39
- data/ext/libsass/Makefile +56 -91
- data/ext/libsass/Makefile.conf +16 -2
- data/ext/libsass/configure.ac +8 -12
- data/ext/libsass/include/sass/base.h +1 -0
- data/ext/libsass/include/sass/context.h +1 -1
- data/ext/libsass/src/GNUmakefile.am +1 -5
- data/ext/libsass/src/ast.cpp +747 -2010
- data/ext/libsass/src/ast.hpp +239 -2383
- data/ext/libsass/src/{to_c.cpp → ast2c.cpp} +22 -16
- data/ext/libsass/src/ast2c.hpp +39 -0
- data/ext/libsass/src/ast_def_macros.hpp +62 -10
- data/ext/libsass/src/ast_fwd_decl.cpp +1 -0
- data/ext/libsass/src/ast_fwd_decl.hpp +43 -165
- data/ext/libsass/src/ast_sel_cmp.cpp +909 -0
- data/ext/libsass/src/ast_sel_unify.cpp +280 -0
- data/ext/libsass/src/ast_selectors.cpp +1475 -0
- data/ext/libsass/src/ast_selectors.hpp +568 -0
- data/ext/libsass/src/ast_supports.cpp +130 -0
- data/ext/libsass/src/ast_supports.hpp +121 -0
- data/ext/libsass/src/ast_values.cpp +967 -0
- data/ext/libsass/src/ast_values.hpp +489 -0
- data/ext/libsass/src/backtrace.cpp +4 -0
- data/ext/libsass/src/base64vlq.cpp +3 -0
- data/ext/libsass/src/bind.cpp +18 -17
- data/ext/libsass/src/bind.hpp +3 -1
- data/ext/libsass/src/c2ast.cpp +64 -0
- data/ext/libsass/src/c2ast.hpp +14 -0
- data/ext/libsass/src/cencode.c +2 -2
- data/ext/libsass/src/check_nesting.cpp +52 -56
- data/ext/libsass/src/check_nesting.hpp +35 -34
- data/ext/libsass/src/color_maps.cpp +156 -153
- data/ext/libsass/src/color_maps.hpp +152 -152
- data/ext/libsass/src/constants.cpp +15 -0
- data/ext/libsass/src/constants.hpp +13 -0
- data/ext/libsass/src/context.cpp +24 -14
- data/ext/libsass/src/context.hpp +6 -6
- data/ext/libsass/src/cssize.cpp +69 -71
- data/ext/libsass/src/cssize.hpp +50 -50
- data/ext/libsass/src/debugger.hpp +117 -110
- data/ext/libsass/src/emitter.cpp +13 -12
- data/ext/libsass/src/emitter.hpp +13 -9
- data/ext/libsass/src/environment.cpp +15 -1
- data/ext/libsass/src/environment.hpp +6 -0
- data/ext/libsass/src/error_handling.cpp +36 -59
- data/ext/libsass/src/error_handling.hpp +29 -16
- data/ext/libsass/src/eval.cpp +302 -323
- data/ext/libsass/src/eval.hpp +64 -55
- data/ext/libsass/src/expand.cpp +94 -88
- data/ext/libsass/src/expand.hpp +33 -37
- data/ext/libsass/src/extend.cpp +38 -36
- data/ext/libsass/src/extend.hpp +15 -15
- data/ext/libsass/src/file.cpp +34 -2
- data/ext/libsass/src/fn_colors.cpp +594 -0
- data/ext/libsass/src/fn_colors.hpp +85 -0
- data/ext/libsass/src/fn_lists.cpp +284 -0
- data/ext/libsass/src/fn_lists.hpp +34 -0
- data/ext/libsass/src/fn_maps.cpp +94 -0
- data/ext/libsass/src/fn_maps.hpp +30 -0
- data/ext/libsass/src/fn_miscs.cpp +256 -0
- data/ext/libsass/src/fn_miscs.hpp +40 -0
- data/ext/libsass/src/fn_numbers.cpp +220 -0
- data/ext/libsass/src/fn_numbers.hpp +45 -0
- data/ext/libsass/src/fn_selectors.cpp +235 -0
- data/ext/libsass/src/fn_selectors.hpp +35 -0
- data/ext/libsass/src/fn_strings.cpp +254 -0
- data/ext/libsass/src/fn_strings.hpp +34 -0
- data/ext/libsass/src/fn_utils.cpp +156 -0
- data/ext/libsass/src/fn_utils.hpp +56 -0
- data/ext/libsass/src/inspect.cpp +101 -152
- data/ext/libsass/src/inspect.hpp +69 -73
- data/ext/libsass/src/json.cpp +2 -2
- data/ext/libsass/src/lexer.cpp +6 -3
- data/ext/libsass/src/listize.cpp +9 -11
- data/ext/libsass/src/listize.hpp +11 -7
- data/ext/libsass/src/memory/SharedPtr.cpp +2 -83
- data/ext/libsass/src/memory/SharedPtr.hpp +127 -143
- data/ext/libsass/src/node.cpp +13 -10
- data/ext/libsass/src/node.hpp +3 -3
- data/ext/libsass/src/operation.hpp +184 -144
- data/ext/libsass/src/operators.cpp +43 -17
- data/ext/libsass/src/operators.hpp +5 -5
- data/ext/libsass/src/output.cpp +21 -18
- data/ext/libsass/src/output.hpp +14 -21
- data/ext/libsass/src/parser.cpp +215 -183
- data/ext/libsass/src/parser.hpp +28 -24
- data/ext/libsass/src/plugins.cpp +5 -1
- data/ext/libsass/src/position.cpp +3 -0
- data/ext/libsass/src/prelexer.cpp +9 -3
- data/ext/libsass/src/prelexer.hpp +9 -9
- data/ext/libsass/src/remove_placeholders.cpp +14 -11
- data/ext/libsass/src/remove_placeholders.hpp +8 -9
- data/ext/libsass/src/sass.cpp +9 -3
- data/ext/libsass/src/sass.hpp +12 -9
- data/ext/libsass/src/sass2scss.cpp +45 -14
- data/ext/libsass/src/sass_context.cpp +18 -15
- data/ext/libsass/src/sass_functions.cpp +6 -3
- data/ext/libsass/src/sass_functions.hpp +1 -1
- data/ext/libsass/src/sass_util.cpp +3 -0
- data/ext/libsass/src/sass_values.cpp +21 -13
- data/ext/libsass/src/source_map.cpp +5 -2
- data/ext/libsass/src/source_map.hpp +2 -2
- data/ext/libsass/src/subset_map.cpp +4 -1
- data/ext/libsass/src/to_value.cpp +23 -21
- data/ext/libsass/src/to_value.hpp +18 -22
- data/ext/libsass/src/units.cpp +4 -0
- data/ext/libsass/src/units.hpp +1 -0
- data/ext/libsass/src/utf8/checked.h +12 -10
- data/ext/libsass/src/utf8/core.h +3 -0
- data/ext/libsass/src/utf8_string.cpp +3 -0
- data/ext/libsass/src/util.cpp +67 -75
- data/ext/libsass/src/util.hpp +64 -19
- data/ext/libsass/src/util_string.cpp +75 -0
- data/ext/libsass/src/util_string.hpp +19 -0
- data/ext/libsass/src/values.cpp +22 -13
- data/ext/libsass/src/values.hpp +2 -2
- data/ext/libsass/win/libsass.targets +30 -4
- data/ext/libsass/win/libsass.vcxproj.filters +82 -4
- data/lib/sassc.rb +24 -0
- data/lib/sassc/engine.rb +2 -2
- data/lib/sassc/native.rb +8 -1
- data/lib/sassc/version.rb +1 -1
- data/sassc.gemspec +19 -11
- data/test/engine_test.rb +26 -1
- data/test/native_test.rb +1 -1
- metadata +66 -72
- data/ext/Rakefile +0 -3
- data/ext/libsass/.github/CONTRIBUTING.md +0 -65
- data/ext/libsass/.github/ISSUE_TEMPLATE.md +0 -54
- data/ext/libsass/.travis.yml +0 -64
- data/ext/libsass/Readme.md +0 -104
- data/ext/libsass/SECURITY.md +0 -10
- data/ext/libsass/appveyor.yml +0 -91
- data/ext/libsass/docs/README.md +0 -20
- data/ext/libsass/docs/api-context-example.md +0 -45
- data/ext/libsass/docs/api-context-internal.md +0 -163
- data/ext/libsass/docs/api-context.md +0 -295
- data/ext/libsass/docs/api-doc.md +0 -215
- data/ext/libsass/docs/api-function-example.md +0 -67
- data/ext/libsass/docs/api-function-internal.md +0 -8
- data/ext/libsass/docs/api-function.md +0 -74
- data/ext/libsass/docs/api-importer-example.md +0 -112
- data/ext/libsass/docs/api-importer-internal.md +0 -20
- data/ext/libsass/docs/api-importer.md +0 -86
- data/ext/libsass/docs/api-value-example.md +0 -55
- data/ext/libsass/docs/api-value-internal.md +0 -76
- data/ext/libsass/docs/api-value.md +0 -154
- data/ext/libsass/docs/build-on-darwin.md +0 -27
- data/ext/libsass/docs/build-on-gentoo.md +0 -55
- data/ext/libsass/docs/build-on-windows.md +0 -139
- data/ext/libsass/docs/build-shared-library.md +0 -35
- data/ext/libsass/docs/build-with-autotools.md +0 -78
- data/ext/libsass/docs/build-with-makefiles.md +0 -68
- data/ext/libsass/docs/build-with-mingw.md +0 -107
- data/ext/libsass/docs/build-with-visual-studio.md +0 -90
- data/ext/libsass/docs/build.md +0 -97
- data/ext/libsass/docs/compatibility-plan.md +0 -48
- data/ext/libsass/docs/contributing.md +0 -17
- data/ext/libsass/docs/custom-functions-internal.md +0 -122
- data/ext/libsass/docs/dev-ast-memory.md +0 -223
- data/ext/libsass/docs/implementations.md +0 -56
- data/ext/libsass/docs/plugins.md +0 -47
- data/ext/libsass/docs/setup-environment.md +0 -68
- data/ext/libsass/docs/source-map-internals.md +0 -51
- data/ext/libsass/docs/trace.md +0 -26
- data/ext/libsass/docs/triage.md +0 -17
- data/ext/libsass/docs/unicode.md +0 -39
- data/ext/libsass/extconf.rb +0 -6
- data/ext/libsass/script/bootstrap +0 -13
- data/ext/libsass/script/branding +0 -10
- data/ext/libsass/script/ci-build-libsass +0 -134
- data/ext/libsass/script/ci-build-plugin +0 -62
- data/ext/libsass/script/ci-install-compiler +0 -6
- data/ext/libsass/script/ci-install-deps +0 -20
- data/ext/libsass/script/ci-report-coverage +0 -42
- data/ext/libsass/script/spec +0 -5
- data/ext/libsass/script/tap-driver +0 -652
- data/ext/libsass/script/tap-runner +0 -1
- data/ext/libsass/script/test-leaks.pl +0 -103
- data/ext/libsass/src/functions.cpp +0 -2234
- data/ext/libsass/src/functions.hpp +0 -198
- data/ext/libsass/src/to_c.hpp +0 -39
- data/ext/libsass/test/test_node.cpp +0 -94
- data/ext/libsass/test/test_paths.cpp +0 -28
- data/ext/libsass/test/test_selector_difference.cpp +0 -25
- data/ext/libsass/test/test_specificity.cpp +0 -25
- data/ext/libsass/test/test_subset_map.cpp +0 -472
- data/ext/libsass/test/test_superselector.cpp +0 -69
- data/ext/libsass/test/test_unification.cpp +0 -31
- data/lib/tasks/libsass.rb +0 -33
data/ext/libsass/src/node.cpp
CHANGED
@@ -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
|
-
|
21
|
-
pStripped->tail(
|
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,
|
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(
|
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
|
-
|
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
|
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,
|
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,
|
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
|
-
|
274
|
-
|
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);
|
data/ext/libsass/src/node.hpp
CHANGED
@@ -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,
|
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(
|
114
|
-
|
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()(
|
12
|
-
virtual ~Operation() { }
|
43
|
+
virtual T operator()(AST_Node* x) = 0;
|
13
44
|
// statements
|
14
|
-
virtual T operator()(
|
15
|
-
virtual T operator()(
|
16
|
-
virtual T operator()(
|
17
|
-
virtual T operator()(
|
18
|
-
virtual T operator()(
|
19
|
-
virtual T operator()(
|
20
|
-
virtual T operator()(
|
21
|
-
virtual T operator()(
|
22
|
-
virtual T operator()(
|
23
|
-
virtual T operator()(
|
24
|
-
virtual T operator()(
|
25
|
-
virtual T operator()(
|
26
|
-
virtual T operator()(
|
27
|
-
virtual T operator()(
|
28
|
-
virtual T operator()(
|
29
|
-
virtual T operator()(
|
30
|
-
virtual T operator()(
|
31
|
-
virtual T operator()(
|
32
|
-
virtual T operator()(
|
33
|
-
virtual T operator()(
|
34
|
-
virtual T operator()(
|
35
|
-
virtual T operator()(
|
36
|
-
virtual T operator()(
|
37
|
-
virtual T operator()(
|
38
|
-
virtual T operator()(
|
39
|
-
virtual T operator()(
|
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()(
|
42
|
-
virtual T operator()(
|
43
|
-
virtual T operator()(
|
44
|
-
virtual T operator()(
|
45
|
-
virtual T operator()(
|
46
|
-
virtual T operator()(
|
47
|
-
virtual T operator()(
|
48
|
-
virtual T operator()(
|
49
|
-
virtual T operator()(
|
50
|
-
virtual T operator()(
|
51
|
-
virtual T operator()(
|
52
|
-
virtual T operator()(
|
53
|
-
virtual T operator()(
|
54
|
-
virtual T operator()(
|
55
|
-
virtual T operator()(
|
56
|
-
virtual T operator()(
|
57
|
-
virtual T operator()(
|
58
|
-
virtual T operator()(
|
59
|
-
virtual T operator()(
|
60
|
-
virtual T operator()(
|
61
|
-
virtual T operator()(
|
62
|
-
virtual T operator()(
|
63
|
-
virtual T operator()(
|
64
|
-
virtual T operator()(
|
65
|
-
virtual T operator()(
|
66
|
-
virtual T operator()(
|
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()(
|
69
|
-
virtual T operator()(
|
70
|
-
virtual T operator()(
|
71
|
-
virtual T operator()(
|
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()(
|
74
|
-
virtual T operator()(
|
75
|
-
virtual T operator()(
|
76
|
-
virtual T operator()(
|
77
|
-
virtual T operator()(
|
78
|
-
virtual T operator()(
|
79
|
-
virtual T operator()(
|
80
|
-
virtual T operator()(
|
81
|
-
virtual T operator()(
|
82
|
-
virtual T operator()(
|
83
|
-
virtual T operator()(
|
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
|
-
|
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()(
|
97
|
-
T operator()(
|
98
|
-
T operator()(
|
99
|
-
T operator()(
|
100
|
-
T operator()(
|
101
|
-
T operator()(
|
102
|
-
T operator()(
|
103
|
-
T operator()(
|
104
|
-
T operator()(
|
105
|
-
T operator()(
|
106
|
-
T operator()(
|
107
|
-
T operator()(
|
108
|
-
T operator()(
|
109
|
-
T operator()(
|
110
|
-
T operator()(
|
111
|
-
T operator()(
|
112
|
-
T operator()(
|
113
|
-
T operator()(
|
114
|
-
T operator()(
|
115
|
-
T operator()(
|
116
|
-
T operator()(
|
117
|
-
T operator()(
|
118
|
-
T operator()(
|
119
|
-
T operator()(
|
120
|
-
T operator()(
|
121
|
-
T operator()(
|
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()(
|
124
|
-
T operator()(
|
125
|
-
T operator()(
|
126
|
-
T operator()(
|
127
|
-
T operator()(
|
128
|
-
T operator()(
|
129
|
-
T operator()(
|
130
|
-
T operator()(
|
131
|
-
T operator()(
|
132
|
-
T operator()(
|
133
|
-
T operator()(
|
134
|
-
T operator()(
|
135
|
-
T operator()(
|
136
|
-
T operator()(
|
137
|
-
T operator()(
|
138
|
-
T operator()(
|
139
|
-
T operator()(
|
140
|
-
T operator()(
|
141
|
-
T operator()(
|
142
|
-
T operator()(
|
143
|
-
T operator()(
|
144
|
-
T operator()(
|
145
|
-
T operator()(
|
146
|
-
T operator()(
|
147
|
-
T operator()(
|
148
|
-
T operator()(
|
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()(
|
151
|
-
T operator()(
|
152
|
-
T operator()(
|
153
|
-
T operator()(
|
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()(
|
156
|
-
T operator()(
|
157
|
-
T operator()(
|
158
|
-
T operator()(
|
159
|
-
T operator()(
|
160
|
-
T operator()(
|
161
|
-
T operator()(
|
162
|
-
T operator()(
|
163
|
-
T operator()(
|
164
|
-
T operator()(
|
165
|
-
T operator()(
|
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
|
}
|