sassc 1.8.3 → 1.8.4

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 (96) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +3 -1
  3. data/ext/libsass/.editorconfig +1 -1
  4. data/ext/libsass/.gitignore +1 -0
  5. data/ext/libsass/LICENSE +1 -1
  6. data/ext/libsass/Makefile +20 -14
  7. data/ext/libsass/Makefile.conf +0 -1
  8. data/ext/libsass/Readme.md +3 -1
  9. data/ext/libsass/appveyor.yml +19 -11
  10. data/ext/libsass/docs/api-importer-example.md +2 -1235
  11. data/ext/libsass/docs/build-with-autotools.md +10 -0
  12. data/ext/libsass/docs/build-with-makefiles.md +18 -0
  13. data/ext/libsass/include/sass/base.h +4 -1
  14. data/ext/libsass/include/sass/values.h +2 -1
  15. data/ext/libsass/src/ast.cpp +279 -346
  16. data/ext/libsass/src/ast.hpp +234 -60
  17. data/ext/libsass/src/base64vlq.cpp +1 -0
  18. data/ext/libsass/src/bind.cpp +35 -45
  19. data/ext/libsass/src/bind.hpp +1 -0
  20. data/ext/libsass/src/color_maps.cpp +1 -0
  21. data/ext/libsass/src/constants.cpp +4 -1
  22. data/ext/libsass/src/constants.hpp +2 -1
  23. data/ext/libsass/src/context.cpp +41 -31
  24. data/ext/libsass/src/context.hpp +10 -10
  25. data/ext/libsass/src/cssize.cpp +7 -4
  26. data/ext/libsass/src/cssize.hpp +1 -3
  27. data/ext/libsass/src/debugger.hpp +73 -14
  28. data/ext/libsass/src/emitter.cpp +37 -25
  29. data/ext/libsass/src/emitter.hpp +10 -9
  30. data/ext/libsass/src/environment.cpp +16 -5
  31. data/ext/libsass/src/environment.hpp +5 -3
  32. data/ext/libsass/src/error_handling.cpp +91 -14
  33. data/ext/libsass/src/error_handling.hpp +105 -4
  34. data/ext/libsass/src/eval.cpp +519 -330
  35. data/ext/libsass/src/eval.hpp +12 -13
  36. data/ext/libsass/src/expand.cpp +92 -56
  37. data/ext/libsass/src/expand.hpp +5 -3
  38. data/ext/libsass/src/extend.cpp +60 -51
  39. data/ext/libsass/src/extend.hpp +1 -3
  40. data/ext/libsass/src/file.cpp +37 -27
  41. data/ext/libsass/src/functions.cpp +78 -62
  42. data/ext/libsass/src/functions.hpp +1 -0
  43. data/ext/libsass/src/inspect.cpp +293 -64
  44. data/ext/libsass/src/inspect.hpp +2 -0
  45. data/ext/libsass/src/lexer.cpp +1 -0
  46. data/ext/libsass/src/listize.cpp +14 -15
  47. data/ext/libsass/src/listize.hpp +3 -5
  48. data/ext/libsass/src/memory_manager.cpp +1 -0
  49. data/ext/libsass/src/node.cpp +2 -3
  50. data/ext/libsass/src/operation.hpp +70 -71
  51. data/ext/libsass/src/output.cpp +28 -32
  52. data/ext/libsass/src/output.hpp +1 -2
  53. data/ext/libsass/src/parser.cpp +402 -183
  54. data/ext/libsass/src/parser.hpp +19 -9
  55. data/ext/libsass/src/plugins.cpp +1 -0
  56. data/ext/libsass/src/position.cpp +1 -0
  57. data/ext/libsass/src/prelexer.cpp +134 -56
  58. data/ext/libsass/src/prelexer.hpp +51 -3
  59. data/ext/libsass/src/remove_placeholders.cpp +35 -9
  60. data/ext/libsass/src/remove_placeholders.hpp +4 -3
  61. data/ext/libsass/src/sass.cpp +1 -0
  62. data/ext/libsass/src/sass.hpp +129 -0
  63. data/ext/libsass/src/sass_context.cpp +31 -14
  64. data/ext/libsass/src/sass_context.hpp +2 -31
  65. data/ext/libsass/src/sass_functions.cpp +1 -0
  66. data/ext/libsass/src/sass_interface.cpp +5 -6
  67. data/ext/libsass/src/sass_util.cpp +1 -2
  68. data/ext/libsass/src/sass_util.hpp +5 -5
  69. data/ext/libsass/src/sass_values.cpp +13 -10
  70. data/ext/libsass/src/source_map.cpp +4 -3
  71. data/ext/libsass/src/source_map.hpp +2 -2
  72. data/ext/libsass/src/subset_map.hpp +0 -1
  73. data/ext/libsass/src/to_c.cpp +1 -0
  74. data/ext/libsass/src/to_c.hpp +1 -3
  75. data/ext/libsass/src/to_value.cpp +3 -5
  76. data/ext/libsass/src/to_value.hpp +1 -1
  77. data/ext/libsass/src/units.cpp +96 -59
  78. data/ext/libsass/src/units.hpp +10 -8
  79. data/ext/libsass/src/utf8_string.cpp +5 -0
  80. data/ext/libsass/src/util.cpp +23 -156
  81. data/ext/libsass/src/util.hpp +10 -14
  82. data/ext/libsass/src/values.cpp +1 -0
  83. data/ext/libsass/test/test_node.cpp +2 -6
  84. data/ext/libsass/test/test_selector_difference.cpp +1 -3
  85. data/ext/libsass/test/test_specificity.cpp +0 -2
  86. data/ext/libsass/test/test_superselector.cpp +0 -2
  87. data/ext/libsass/test/test_unification.cpp +1 -3
  88. data/ext/libsass/win/libsass.targets +18 -5
  89. data/ext/libsass/win/libsass.vcxproj +9 -7
  90. data/ext/libsass/win/libsass.vcxproj.filters +148 -106
  91. data/lib/sassc/version.rb +1 -1
  92. data/test/engine_test.rb +12 -0
  93. data/test/native_test.rb +1 -1
  94. metadata +3 -4
  95. data/ext/libsass/src/to_string.cpp +0 -48
  96. data/ext/libsass/src/to_string.hpp +0 -38
@@ -64,6 +64,8 @@ namespace Sass {
64
64
  virtual void operator()(String_Schema*);
65
65
  virtual void operator()(String_Constant*);
66
66
  virtual void operator()(String_Quoted*);
67
+ virtual void operator()(Custom_Error*);
68
+ virtual void operator()(Custom_Warning*);
67
69
  virtual void operator()(Supports_Operator*);
68
70
  virtual void operator()(Supports_Negation*);
69
71
  virtual void operator()(Supports_Declaration*);
@@ -1,3 +1,4 @@
1
+ #include "sass.hpp"
1
2
  #include <cctype>
2
3
  #include <cstddef>
3
4
  #include <iostream>
@@ -1,43 +1,43 @@
1
+ #include "sass.hpp"
1
2
  #include <iostream>
2
3
  #include <typeinfo>
3
4
  #include <string>
4
5
 
5
6
  #include "listize.hpp"
6
- #include "to_string.hpp"
7
7
  #include "context.hpp"
8
8
  #include "backtrace.hpp"
9
9
  #include "error_handling.hpp"
10
10
 
11
11
  namespace Sass {
12
12
 
13
- Listize::Listize(Context& ctx)
14
- : ctx(ctx)
13
+ Listize::Listize(Memory_Manager& mem)
14
+ : mem(mem)
15
15
  { }
16
16
 
17
17
  Expression* Listize::operator()(Selector_List* sel)
18
18
  {
19
- List* l = SASS_MEMORY_NEW(ctx.mem, List, sel->pstate(), sel->length(), SASS_COMMA);
19
+ List* l = SASS_MEMORY_NEW(mem, List, sel->pstate(), sel->length(), SASS_COMMA);
20
20
  for (size_t i = 0, L = sel->length(); i < L; ++i) {
21
21
  if (!(*sel)[i]) continue;
22
22
  *l << (*sel)[i]->perform(this);
23
23
  }
24
- return l;
24
+ if (l->length()) return l;
25
+ return SASS_MEMORY_NEW(mem, Null, l->pstate());
25
26
  }
26
27
 
27
28
  Expression* Listize::operator()(Compound_Selector* sel)
28
29
  {
29
- To_String to_string;
30
30
  std::string str;
31
31
  for (size_t i = 0, L = sel->length(); i < L; ++i) {
32
32
  Expression* e = (*sel)[i]->perform(this);
33
- if (e) str += e->perform(&to_string);
33
+ if (e) str += e->to_string();
34
34
  }
35
- return SASS_MEMORY_NEW(ctx.mem, String_Quoted, sel->pstate(), str);
35
+ return SASS_MEMORY_NEW(mem, String_Quoted, sel->pstate(), str);
36
36
  }
37
37
 
38
38
  Expression* Listize::operator()(Complex_Selector* sel)
39
39
  {
40
- List* l = SASS_MEMORY_NEW(ctx.mem, List, sel->pstate(), 2);
40
+ List* l = SASS_MEMORY_NEW(mem, List, sel->pstate(), 2);
41
41
 
42
42
  Compound_Selector* head = sel->head();
43
43
  if (head && !head->is_empty_reference())
@@ -46,22 +46,21 @@ namespace Sass {
46
46
  if (hh) *l << hh;
47
47
  }
48
48
 
49
- To_String to_string;
50
49
  std::string reference = ! sel->reference() ? ""
51
- : sel->reference()->perform(&to_string);
50
+ : sel->reference()->to_string();
52
51
  switch(sel->combinator())
53
52
  {
54
53
  case Complex_Selector::PARENT_OF:
55
- *l << SASS_MEMORY_NEW(ctx.mem, String_Quoted, sel->pstate(), ">");
54
+ *l << SASS_MEMORY_NEW(mem, String_Quoted, sel->pstate(), ">");
56
55
  break;
57
56
  case Complex_Selector::ADJACENT_TO:
58
- *l << SASS_MEMORY_NEW(ctx.mem, String_Quoted, sel->pstate(), "+");
57
+ *l << SASS_MEMORY_NEW(mem, String_Quoted, sel->pstate(), "+");
59
58
  break;
60
59
  case Complex_Selector::REFERENCE:
61
- *l << SASS_MEMORY_NEW(ctx.mem, String_Quoted, sel->pstate(), "/" + reference + "/");
60
+ *l << SASS_MEMORY_NEW(mem, String_Quoted, sel->pstate(), "/" + reference + "/");
62
61
  break;
63
62
  case Complex_Selector::PRECEDES:
64
- *l << SASS_MEMORY_NEW(ctx.mem, String_Quoted, sel->pstate(), "~");
63
+ *l << SASS_MEMORY_NEW(mem, String_Quoted, sel->pstate(), "~");
65
64
  break;
66
65
  case Complex_Selector::ANCESTOR_OF:
67
66
  break;
@@ -16,15 +16,13 @@ namespace Sass {
16
16
 
17
17
  class Listize : public Operation_CRTP<Expression*, Listize> {
18
18
 
19
- Context& ctx;
19
+ Memory_Manager& mem;
20
20
 
21
21
  Expression* fallback_impl(AST_Node* n);
22
22
 
23
23
  public:
24
- Listize(Context&);
25
- virtual ~Listize() { }
26
-
27
- using Operation<Expression*>::operator();
24
+ Listize(Memory_Manager&);
25
+ ~Listize() { }
28
26
 
29
27
  Expression* operator()(Selector_List*);
30
28
  Expression* operator()(Complex_Selector*);
@@ -1,3 +1,4 @@
1
+ #include "sass.hpp"
1
2
  #include "ast.hpp"
2
3
  #include "memory_manager.hpp"
3
4
 
@@ -1,7 +1,7 @@
1
+ #include "sass.hpp"
1
2
  #include <vector>
2
3
 
3
4
  #include "node.hpp"
4
- #include "to_string.hpp"
5
5
  #include "context.hpp"
6
6
  #include "parser.hpp"
7
7
 
@@ -153,8 +153,7 @@ namespace Sass {
153
153
 
154
154
  } else if (node.isSelector()){
155
155
 
156
- To_String to_string;
157
- os << node.selector()->head()->perform(&to_string);
156
+ os << node.selector()->head()->to_string();
158
157
 
159
158
  } else if (node.isCollection()) {
160
159
 
@@ -15,7 +15,7 @@ namespace Sass {
15
15
  virtual T operator()(Ruleset* x) = 0;
16
16
  virtual T operator()(Propset* x) = 0;
17
17
  virtual T operator()(Bubble* x) = 0;
18
- virtual T operator()(Supports_Block* x) = 0;
18
+ virtual T operator()(Supports_Block* x) = 0;
19
19
  virtual T operator()(Media_Block* x) = 0;
20
20
  virtual T operator()(At_Root_Block* x) = 0;
21
21
  virtual T operator()(At_Rule* x) = 0;
@@ -88,84 +88,83 @@ namespace Sass {
88
88
  template <typename T, typename D>
89
89
  class Operation_CRTP : public Operation<T> {
90
90
  public:
91
- virtual T operator()(AST_Node* x) { return static_cast<D*>(this)->fallback(x); }
92
- virtual ~Operation_CRTP() = 0;
91
+ D& impl() { return static_cast<D&>(*this); }
92
+ public:
93
+ T operator()(AST_Node* x) { return static_cast<D*>(this)->fallback(x); }
93
94
  // statements
94
- virtual T operator()(Block* x) { return static_cast<D*>(this)->fallback(x); }
95
- virtual T operator()(Ruleset* x) { return static_cast<D*>(this)->fallback(x); }
96
- virtual T operator()(Propset* x) { return static_cast<D*>(this)->fallback(x); }
97
- virtual T operator()(Bubble* x) { return static_cast<D*>(this)->fallback(x); }
98
- virtual T operator()(Supports_Block* x) { return static_cast<D*>(this)->fallback(x); }
99
- virtual T operator()(Media_Block* x) { return static_cast<D*>(this)->fallback(x); }
100
- virtual T operator()(At_Root_Block* x) { return static_cast<D*>(this)->fallback(x); }
101
- virtual T operator()(At_Rule* x) { return static_cast<D*>(this)->fallback(x); }
102
- virtual T operator()(Keyframe_Rule* x) { return static_cast<D*>(this)->fallback(x); }
103
- virtual T operator()(Declaration* x) { return static_cast<D*>(this)->fallback(x); }
104
- virtual T operator()(Assignment* x) { return static_cast<D*>(this)->fallback(x); }
105
- virtual T operator()(Import* x) { return static_cast<D*>(this)->fallback(x); }
106
- virtual T operator()(Import_Stub* x) { return static_cast<D*>(this)->fallback(x); }
107
- virtual T operator()(Warning* x) { return static_cast<D*>(this)->fallback(x); }
108
- virtual T operator()(Error* x) { return static_cast<D*>(this)->fallback(x); }
109
- virtual T operator()(Debug* x) { return static_cast<D*>(this)->fallback(x); }
110
- virtual T operator()(Comment* x) { return static_cast<D*>(this)->fallback(x); }
111
- virtual T operator()(If* x) { return static_cast<D*>(this)->fallback(x); }
112
- virtual T operator()(For* x) { return static_cast<D*>(this)->fallback(x); }
113
- virtual T operator()(Each* x) { return static_cast<D*>(this)->fallback(x); }
114
- virtual T operator()(While* x) { return static_cast<D*>(this)->fallback(x); }
115
- virtual T operator()(Return* x) { return static_cast<D*>(this)->fallback(x); }
116
- virtual T operator()(Content* x) { return static_cast<D*>(this)->fallback(x); }
117
- virtual T operator()(Extension* x) { return static_cast<D*>(this)->fallback(x); }
118
- virtual T operator()(Definition* x) { return static_cast<D*>(this)->fallback(x); }
119
- virtual T operator()(Mixin_Call* x) { return static_cast<D*>(this)->fallback(x); }
95
+ T operator()(Block* x) { return static_cast<D*>(this)->fallback(x); }
96
+ T operator()(Ruleset* x) { return static_cast<D*>(this)->fallback(x); }
97
+ T operator()(Propset* x) { return static_cast<D*>(this)->fallback(x); }
98
+ T operator()(Bubble* x) { return static_cast<D*>(this)->fallback(x); }
99
+ T operator()(Supports_Block* x) { return static_cast<D*>(this)->fallback(x); }
100
+ T operator()(Media_Block* x) { return static_cast<D*>(this)->fallback(x); }
101
+ T operator()(At_Root_Block* x) { return static_cast<D*>(this)->fallback(x); }
102
+ T operator()(At_Rule* x) { return static_cast<D*>(this)->fallback(x); }
103
+ T operator()(Keyframe_Rule* x) { return static_cast<D*>(this)->fallback(x); }
104
+ T operator()(Declaration* x) { return static_cast<D*>(this)->fallback(x); }
105
+ T operator()(Assignment* x) { return static_cast<D*>(this)->fallback(x); }
106
+ T operator()(Import* x) { return static_cast<D*>(this)->fallback(x); }
107
+ T operator()(Import_Stub* x) { return static_cast<D*>(this)->fallback(x); }
108
+ T operator()(Warning* x) { return static_cast<D*>(this)->fallback(x); }
109
+ T operator()(Error* x) { return static_cast<D*>(this)->fallback(x); }
110
+ T operator()(Debug* x) { return static_cast<D*>(this)->fallback(x); }
111
+ T operator()(Comment* x) { return static_cast<D*>(this)->fallback(x); }
112
+ T operator()(If* x) { return static_cast<D*>(this)->fallback(x); }
113
+ T operator()(For* x) { return static_cast<D*>(this)->fallback(x); }
114
+ T operator()(Each* x) { return static_cast<D*>(this)->fallback(x); }
115
+ T operator()(While* x) { return static_cast<D*>(this)->fallback(x); }
116
+ T operator()(Return* x) { return static_cast<D*>(this)->fallback(x); }
117
+ T operator()(Content* x) { return static_cast<D*>(this)->fallback(x); }
118
+ T operator()(Extension* x) { return static_cast<D*>(this)->fallback(x); }
119
+ T operator()(Definition* x) { return static_cast<D*>(this)->fallback(x); }
120
+ T operator()(Mixin_Call* x) { return static_cast<D*>(this)->fallback(x); }
120
121
  // expressions
121
- virtual T operator()(List* x) { return static_cast<D*>(this)->fallback(x); }
122
- virtual T operator()(Map* x) { return static_cast<D*>(this)->fallback(x); }
123
- virtual T operator()(Binary_Expression* x) { return static_cast<D*>(this)->fallback(x); }
124
- virtual T operator()(Unary_Expression* x) { return static_cast<D*>(this)->fallback(x); }
125
- virtual T operator()(Function_Call* x) { return static_cast<D*>(this)->fallback(x); }
126
- virtual T operator()(Function_Call_Schema* x) { return static_cast<D*>(this)->fallback(x); }
127
- virtual T operator()(Custom_Warning* x) { return static_cast<D*>(this)->fallback(x); }
128
- virtual T operator()(Custom_Error* x) { return static_cast<D*>(this)->fallback(x); }
129
- virtual T operator()(Variable* x) { return static_cast<D*>(this)->fallback(x); }
130
- virtual T operator()(Textual* x) { return static_cast<D*>(this)->fallback(x); }
131
- virtual T operator()(Number* x) { return static_cast<D*>(this)->fallback(x); }
132
- virtual T operator()(Color* x) { return static_cast<D*>(this)->fallback(x); }
133
- virtual T operator()(Boolean* x) { return static_cast<D*>(this)->fallback(x); }
134
- virtual T operator()(String_Schema* x) { return static_cast<D*>(this)->fallback(x); }
135
- virtual T operator()(String_Constant* x) { return static_cast<D*>(this)->fallback(x); }
136
- virtual T operator()(String_Quoted* x) { return static_cast<D*>(this)->fallback(x); }
137
- virtual T operator()(Supports_Condition* x) { return static_cast<D*>(this)->fallback(x); }
138
- virtual T operator()(Supports_Operator* x) { return static_cast<D*>(this)->fallback(x); }
139
- virtual T operator()(Supports_Negation* x) { return static_cast<D*>(this)->fallback(x); }
140
- virtual T operator()(Supports_Declaration* x) { return static_cast<D*>(this)->fallback(x); }
141
- virtual T operator()(Supports_Interpolation* x) { return static_cast<D*>(this)->fallback(x); }
142
- virtual T operator()(Media_Query* x) { return static_cast<D*>(this)->fallback(x); }
143
- virtual T operator()(Media_Query_Expression* x) { return static_cast<D*>(this)->fallback(x); }
144
- virtual T operator()(At_Root_Expression* x) { return static_cast<D*>(this)->fallback(x); }
145
- virtual T operator()(Null* x) { return static_cast<D*>(this)->fallback(x); }
146
- virtual T operator()(Parent_Selector* x) { return static_cast<D*>(this)->fallback(x); }
122
+ T operator()(List* x) { return static_cast<D*>(this)->fallback(x); }
123
+ T operator()(Map* x) { return static_cast<D*>(this)->fallback(x); }
124
+ T operator()(Binary_Expression* x) { return static_cast<D*>(this)->fallback(x); }
125
+ T operator()(Unary_Expression* x) { return static_cast<D*>(this)->fallback(x); }
126
+ T operator()(Function_Call* x) { return static_cast<D*>(this)->fallback(x); }
127
+ T operator()(Function_Call_Schema* x) { return static_cast<D*>(this)->fallback(x); }
128
+ T operator()(Custom_Warning* x) { return static_cast<D*>(this)->fallback(x); }
129
+ T operator()(Custom_Error* x) { return static_cast<D*>(this)->fallback(x); }
130
+ T operator()(Variable* x) { return static_cast<D*>(this)->fallback(x); }
131
+ T operator()(Textual* x) { return static_cast<D*>(this)->fallback(x); }
132
+ T operator()(Number* x) { return static_cast<D*>(this)->fallback(x); }
133
+ T operator()(Color* x) { return static_cast<D*>(this)->fallback(x); }
134
+ T operator()(Boolean* x) { return static_cast<D*>(this)->fallback(x); }
135
+ T operator()(String_Schema* x) { return static_cast<D*>(this)->fallback(x); }
136
+ T operator()(String_Constant* x) { return static_cast<D*>(this)->fallback(x); }
137
+ T operator()(String_Quoted* x) { return static_cast<D*>(this)->fallback(x); }
138
+ T operator()(Supports_Condition* x) { return static_cast<D*>(this)->fallback(x); }
139
+ T operator()(Supports_Operator* x) { return static_cast<D*>(this)->fallback(x); }
140
+ T operator()(Supports_Negation* x) { return static_cast<D*>(this)->fallback(x); }
141
+ T operator()(Supports_Declaration* x) { return static_cast<D*>(this)->fallback(x); }
142
+ T operator()(Supports_Interpolation* x) { return static_cast<D*>(this)->fallback(x); }
143
+ T operator()(Media_Query* x) { return static_cast<D*>(this)->fallback(x); }
144
+ T operator()(Media_Query_Expression* x) { return static_cast<D*>(this)->fallback(x); }
145
+ T operator()(At_Root_Expression* x) { return static_cast<D*>(this)->fallback(x); }
146
+ T operator()(Null* x) { return static_cast<D*>(this)->fallback(x); }
147
+ T operator()(Parent_Selector* x) { return static_cast<D*>(this)->fallback(x); }
147
148
  // parameters and arguments
148
- virtual T operator()(Parameter* x) { return static_cast<D*>(this)->fallback(x); }
149
- virtual T operator()(Parameters* x) { return static_cast<D*>(this)->fallback(x); }
150
- virtual T operator()(Argument* x) { return static_cast<D*>(this)->fallback(x); }
151
- virtual T operator()(Arguments* x) { return static_cast<D*>(this)->fallback(x); }
149
+ T operator()(Parameter* x) { return static_cast<D*>(this)->fallback(x); }
150
+ T operator()(Parameters* x) { return static_cast<D*>(this)->fallback(x); }
151
+ T operator()(Argument* x) { return static_cast<D*>(this)->fallback(x); }
152
+ T operator()(Arguments* x) { return static_cast<D*>(this)->fallback(x); }
152
153
  // selectors
153
- virtual T operator()(Selector_Schema* x) { return static_cast<D*>(this)->fallback(x); }
154
- virtual T operator()(Selector_Placeholder* x) { return static_cast<D*>(this)->fallback(x); }
155
- virtual T operator()(Type_Selector* x) { return static_cast<D*>(this)->fallback(x); }
156
- virtual T operator()(Selector_Qualifier* x) { return static_cast<D*>(this)->fallback(x); }
157
- virtual T operator()(Attribute_Selector* x) { return static_cast<D*>(this)->fallback(x); }
158
- virtual T operator()(Pseudo_Selector* x) { return static_cast<D*>(this)->fallback(x); }
159
- virtual T operator()(Wrapped_Selector* x) { return static_cast<D*>(this)->fallback(x); }
160
- virtual T operator()(Compound_Selector* x) { return static_cast<D*>(this)->fallback(x); }
161
- virtual T operator()(Complex_Selector* x) { return static_cast<D*>(this)->fallback(x); }
162
- virtual T operator()(Selector_List* x) { return static_cast<D*>(this)->fallback(x); }
154
+ T operator()(Selector_Schema* x) { return static_cast<D*>(this)->fallback(x); }
155
+ T operator()(Selector_Placeholder* x) { return static_cast<D*>(this)->fallback(x); }
156
+ T operator()(Type_Selector* x) { return static_cast<D*>(this)->fallback(x); }
157
+ T operator()(Selector_Qualifier* x) { return static_cast<D*>(this)->fallback(x); }
158
+ T operator()(Attribute_Selector* x) { return static_cast<D*>(this)->fallback(x); }
159
+ T operator()(Pseudo_Selector* x) { return static_cast<D*>(this)->fallback(x); }
160
+ T operator()(Wrapped_Selector* x) { return static_cast<D*>(this)->fallback(x); }
161
+ T operator()(Compound_Selector* x) { return static_cast<D*>(this)->fallback(x); }
162
+ T operator()(Complex_Selector* x) { return static_cast<D*>(this)->fallback(x); }
163
+ T operator()(Selector_List* x) { return static_cast<D*>(this)->fallback(x); }
163
164
 
164
165
  template <typename U>
165
166
  T fallback(U x) { return T(); }
166
167
  };
167
- template<typename T, typename D>
168
- inline Operation_CRTP<T, D>::~Operation_CRTP() { }
169
168
 
170
169
  }
171
170
 
@@ -1,11 +1,11 @@
1
+ #include "sass.hpp"
1
2
  #include "ast.hpp"
2
3
  #include "output.hpp"
3
- #include "to_string.hpp"
4
4
 
5
5
  namespace Sass {
6
6
 
7
- Output::Output(Context* ctx)
8
- : Inspect(Emitter(ctx)),
7
+ Output::Output(Sass_Output_Options& opt)
8
+ : Inspect(Emitter(opt)),
9
9
  charset(""),
10
10
  top_nodes(0)
11
11
  {}
@@ -20,16 +20,11 @@ namespace Sass {
20
20
  void Output::operator()(Number* n)
21
21
  {
22
22
  // use values to_string facility
23
- To_String to_string(ctx);
24
- std::string res = n->perform(&to_string);
23
+ std::string res = n->to_string(opt);
25
24
  // check for a valid unit here
26
25
  // includes result for reporting
27
- if (n->numerator_units().size() > 1 ||
28
- n->denominator_units().size() > 0 ||
29
- (n->numerator_units().size() && n->numerator_units()[0].find_first_of('/') != std::string::npos) ||
30
- (n->numerator_units().size() && n->numerator_units()[0].find_first_of('*') != std::string::npos)
31
- ) {
32
- error(res + " isn't a valid CSS value.", n->pstate());
26
+ if (!n->is_valid_css_unit()) {
27
+ throw Exception::InvalidValue(*n);
33
28
  }
34
29
  // output the final token
35
30
  append_token(res, n);
@@ -42,15 +37,14 @@ namespace Sass {
42
37
 
43
38
  void Output::operator()(Map* m)
44
39
  {
45
- To_String to_string(ctx);
46
- std::string dbg(m->perform(&to_string));
40
+ std::string dbg(m->to_string(opt));
47
41
  error(dbg + " isn't a valid CSS value.", m->pstate());
48
42
  }
49
43
 
50
44
  OutputBuffer Output::get_buffer(void)
51
45
  {
52
46
 
53
- Emitter emitter(ctx);
47
+ Emitter emitter(opt);
54
48
  Inspect inspect(emitter);
55
49
 
56
50
  size_t size_nodes = top_nodes.size();
@@ -60,13 +54,14 @@ namespace Sass {
60
54
  }
61
55
 
62
56
  // flush scheduled outputs
63
- inspect.finalize();
57
+ // maybe omit semicolon if possible
58
+ inspect.finalize(wbuf.buffer.size() == 0);
64
59
  // prepend buffer on top
65
60
  prepend_output(inspect.output());
66
61
  // make sure we end with a linefeed
67
- if (!ends_with(wbuf.buffer, ctx->linefeed)) {
62
+ if (!ends_with(wbuf.buffer, opt.linefeed)) {
68
63
  // if the output is not completely empty
69
- if (!wbuf.buffer.empty()) append_string(ctx->linefeed);
64
+ if (!wbuf.buffer.empty()) append_string(opt.linefeed);
70
65
  }
71
66
 
72
67
  // search for unicode char
@@ -74,9 +69,9 @@ namespace Sass {
74
69
  // skip all ascii chars
75
70
  if (chr >= 0) continue;
76
71
  // declare the charset
77
- if (output_style() != SASS_STYLE_COMPRESSED)
72
+ if (output_style() != COMPRESSED)
78
73
  charset = "@charset \"UTF-8\";"
79
- + ctx->linefeed;
74
+ + std::string(opt.linefeed);
80
75
  else charset = "\xEF\xBB\xBF";
81
76
  // abort search
82
77
  break;
@@ -91,11 +86,10 @@ namespace Sass {
91
86
 
92
87
  void Output::operator()(Comment* c)
93
88
  {
94
- To_String to_string(ctx);
95
- std::string txt = c->text()->perform(&to_string);
89
+ std::string txt = c->text()->to_string(opt);
96
90
  // if (indentation && txt == "/**/") return;
97
91
  bool important = c->is_important();
98
- if (output_style() != SASS_STYLE_COMPRESSED || important) {
92
+ if (output_style() != COMPRESSED || important) {
99
93
  if (buffer().size() == 0) {
100
94
  top_nodes.push_back(c);
101
95
  } else {
@@ -131,8 +125,8 @@ namespace Sass {
131
125
 
132
126
  if (b->has_non_hoistable()) {
133
127
  decls = true;
134
- if (output_style() == SASS_STYLE_NESTED) indentation += r->tabs();
135
- if (ctx && ctx->c_options->source_comments) {
128
+ if (output_style() == NESTED) indentation += r->tabs();
129
+ if (opt.source_comments) {
136
130
  std::stringstream ss;
137
131
  append_indentation();
138
132
  ss << "/* line " << r->pstate().line + 1 << ", " << r->pstate().path << " */";
@@ -171,7 +165,7 @@ namespace Sass {
171
165
  stm->perform(this);
172
166
  }
173
167
  }
174
- if (output_style() == SASS_STYLE_NESTED) indentation -= r->tabs();
168
+ if (output_style() == NESTED) indentation -= r->tabs();
175
169
  append_scope_closer(b);
176
170
  }
177
171
 
@@ -238,7 +232,7 @@ namespace Sass {
238
232
  return;
239
233
  }
240
234
 
241
- if (output_style() == SASS_STYLE_NESTED) indentation += f->tabs();
235
+ if (output_style() == NESTED) indentation += f->tabs();
242
236
  append_indentation();
243
237
  append_token("@supports", f);
244
238
  append_mandatory_space();
@@ -274,7 +268,7 @@ namespace Sass {
274
268
  }
275
269
  }
276
270
 
277
- if (output_style() == SASS_STYLE_NESTED) indentation -= f->tabs();
271
+ if (output_style() == NESTED) indentation -= f->tabs();
278
272
 
279
273
  append_scope_closer();
280
274
 
@@ -297,7 +291,7 @@ namespace Sass {
297
291
  }
298
292
  return;
299
293
  }
300
- if (output_style() == SASS_STYLE_NESTED) indentation += m->tabs();
294
+ if (output_style() == NESTED) indentation += m->tabs();
301
295
  append_indentation();
302
296
  append_token("@media", m);
303
297
  append_mandatory_space();
@@ -311,7 +305,7 @@ namespace Sass {
311
305
  if (i < L - 1) append_special_linefeed();
312
306
  }
313
307
 
314
- if (output_style() == SASS_STYLE_NESTED) indentation -= m->tabs();
308
+ if (output_style() == NESTED) indentation -= m->tabs();
315
309
  append_scope_closer();
316
310
  }
317
311
 
@@ -332,7 +326,8 @@ namespace Sass {
332
326
  }
333
327
  if (v) {
334
328
  append_mandatory_space();
335
- v->perform(this);
329
+ // ruby sass bug? should use options?
330
+ append_token(v->to_string(/* opt */), v);
336
331
  }
337
332
  if (!b) {
338
333
  append_delimiter();
@@ -340,7 +335,8 @@ namespace Sass {
340
335
  }
341
336
 
342
337
  if (b->is_invisible() || b->length() == 0) {
343
- return append_string(" {}");
338
+ append_optional_space();
339
+ return append_string("{}");
344
340
  }
345
341
 
346
342
  append_scope_opener();
@@ -380,7 +376,7 @@ namespace Sass {
380
376
  void Output::operator()(String_Constant* s)
381
377
  {
382
378
  std::string value(s->value());
383
- if (s->can_compress_whitespace() && output_style() == SASS_STYLE_COMPRESSED) {
379
+ if (s->can_compress_whitespace() && output_style() == COMPRESSED) {
384
380
  value.erase(std::remove_if(value.begin(), value.end(), ::isspace), value.end());
385
381
  }
386
382
  if (!in_comment) {