sassc 0.0.9 → 0.0.10

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 (111) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +1 -1
  3. data/ext/libsass/.gitignore +13 -6
  4. data/ext/libsass/Makefile +42 -26
  5. data/ext/libsass/Makefile.am +43 -30
  6. data/ext/libsass/Readme.md +4 -2
  7. data/ext/libsass/appveyor.yml +10 -14
  8. data/ext/libsass/ast.cpp +54 -44
  9. data/ext/libsass/ast.hpp +404 -236
  10. data/ext/libsass/ast_def_macros.hpp +5 -0
  11. data/ext/libsass/ast_factory.hpp +6 -3
  12. data/ext/libsass/ast_fwd_decl.hpp +12 -0
  13. data/ext/libsass/b64/encode.h +2 -2
  14. data/ext/libsass/backtrace.hpp +13 -17
  15. data/ext/libsass/base64vlq.hpp +4 -1
  16. data/ext/libsass/bind.cpp +12 -15
  17. data/ext/libsass/bind.hpp +6 -6
  18. data/ext/libsass/color_names.hpp +4 -1
  19. data/ext/libsass/configure.ac +7 -21
  20. data/ext/libsass/constants.cpp +6 -4
  21. data/ext/libsass/constants.hpp +10 -4
  22. data/ext/libsass/context.cpp +89 -58
  23. data/ext/libsass/context.hpp +28 -35
  24. data/ext/libsass/contextualize.cpp +20 -10
  25. data/ext/libsass/contextualize.hpp +8 -23
  26. data/ext/libsass/contrib/libsass.spec +66 -0
  27. data/ext/libsass/cssize.cpp +547 -0
  28. data/ext/libsass/cssize.hpp +82 -0
  29. data/ext/libsass/debug.hpp +3 -3
  30. data/ext/libsass/debugger.hpp +358 -0
  31. data/ext/libsass/emitter.cpp +255 -0
  32. data/ext/libsass/emitter.hpp +83 -0
  33. data/ext/libsass/environment.hpp +7 -3
  34. data/ext/libsass/error_handling.cpp +11 -14
  35. data/ext/libsass/error_handling.hpp +9 -7
  36. data/ext/libsass/eval.cpp +253 -161
  37. data/ext/libsass/eval.hpp +13 -13
  38. data/ext/libsass/expand.cpp +135 -64
  39. data/ext/libsass/expand.hpp +11 -13
  40. data/ext/libsass/extend.cpp +66 -20
  41. data/ext/libsass/extend.hpp +6 -11
  42. data/ext/libsass/file.cpp +31 -26
  43. data/ext/libsass/file.hpp +6 -1
  44. data/ext/libsass/functions.cpp +270 -287
  45. data/ext/libsass/functions.hpp +8 -11
  46. data/ext/libsass/inspect.cpp +385 -255
  47. data/ext/libsass/inspect.hpp +15 -26
  48. data/ext/libsass/kwd_arg_macros.hpp +5 -0
  49. data/ext/libsass/mapping.hpp +4 -3
  50. data/ext/libsass/memory_manager.hpp +5 -2
  51. data/ext/libsass/node.cpp +50 -50
  52. data/ext/libsass/node.hpp +26 -27
  53. data/ext/libsass/operation.hpp +15 -4
  54. data/ext/libsass/output.cpp +401 -0
  55. data/ext/libsass/output.hpp +56 -0
  56. data/ext/libsass/parser.cpp +573 -399
  57. data/ext/libsass/parser.hpp +122 -88
  58. data/ext/libsass/paths.hpp +7 -2
  59. data/ext/libsass/plugins.cpp +155 -0
  60. data/ext/libsass/plugins.hpp +56 -0
  61. data/ext/libsass/position.cpp +128 -0
  62. data/ext/libsass/position.hpp +108 -11
  63. data/ext/libsass/prelexer.cpp +184 -110
  64. data/ext/libsass/prelexer.hpp +131 -24
  65. data/ext/libsass/remove_placeholders.cpp +1 -1
  66. data/ext/libsass/remove_placeholders.hpp +6 -6
  67. data/ext/libsass/sass.cpp +3 -3
  68. data/ext/libsass/sass.h +12 -4
  69. data/ext/libsass/sass2scss.cpp +3 -2
  70. data/ext/libsass/sass2scss.h +5 -0
  71. data/ext/libsass/sass_context.cpp +136 -37
  72. data/ext/libsass/sass_context.h +19 -10
  73. data/ext/libsass/sass_functions.cpp +29 -2
  74. data/ext/libsass/sass_functions.h +8 -2
  75. data/ext/libsass/sass_interface.cpp +32 -23
  76. data/ext/libsass/sass_interface.h +9 -4
  77. data/ext/libsass/sass_util.cpp +19 -23
  78. data/ext/libsass/sass_util.hpp +28 -27
  79. data/ext/libsass/sass_values.cpp +6 -4
  80. data/ext/libsass/sass_values.h +3 -3
  81. data/ext/libsass/script/ci-build-libsass +13 -1
  82. data/ext/libsass/script/ci-report-coverage +2 -1
  83. data/ext/libsass/source_map.cpp +79 -28
  84. data/ext/libsass/source_map.hpp +35 -16
  85. data/ext/libsass/subset_map.hpp +6 -4
  86. data/ext/libsass/to_c.hpp +4 -4
  87. data/ext/libsass/to_string.cpp +13 -8
  88. data/ext/libsass/to_string.hpp +6 -4
  89. data/ext/libsass/units.cpp +2 -1
  90. data/ext/libsass/units.hpp +6 -1
  91. data/ext/libsass/utf8_string.cpp +0 -5
  92. data/ext/libsass/utf8_string.hpp +3 -2
  93. data/ext/libsass/util.cpp +461 -49
  94. data/ext/libsass/util.hpp +34 -13
  95. data/ext/libsass/version.sh +10 -0
  96. data/ext/libsass/win/libsass.filters +20 -11
  97. data/ext/libsass/win/libsass.vcxproj +11 -8
  98. data/lib/sassc/importer.rb +1 -8
  99. data/lib/sassc/native.rb +7 -0
  100. data/lib/sassc/native/native_context_api.rb +5 -5
  101. data/lib/sassc/version.rb +1 -1
  102. data/test/native_test.rb +1 -1
  103. metadata +14 -10
  104. data/ext/libsass/copy_c_str.cpp +0 -13
  105. data/ext/libsass/copy_c_str.hpp +0 -5
  106. data/ext/libsass/output_compressed.cpp +0 -401
  107. data/ext/libsass/output_compressed.hpp +0 -95
  108. data/ext/libsass/output_nested.cpp +0 -364
  109. data/ext/libsass/output_nested.hpp +0 -108
  110. data/ext/libsass/test-driver +0 -127
  111. data/ext/libsass/token.hpp +0 -32
@@ -1,12 +1,13 @@
1
- #define SASS_OPERATION
2
-
3
- #include "ast_fwd_decl.hpp"
1
+ #ifndef SASS_OPERATION_H
2
+ #define SASS_OPERATION_H
4
3
 
5
4
  #include <iostream>
6
- using namespace std;
7
5
  #include <typeinfo>
8
6
 
7
+ #include "ast_fwd_decl.hpp"
8
+
9
9
  namespace Sass {
10
+ using namespace std;
10
11
 
11
12
  template<typename T>
12
13
  class Operation {
@@ -17,9 +18,12 @@ namespace Sass {
17
18
  virtual T operator()(Block* x) = 0;
18
19
  virtual T operator()(Ruleset* x) = 0;
19
20
  virtual T operator()(Propset* x) = 0;
21
+ virtual T operator()(Bubble* x) = 0;
20
22
  virtual T operator()(Feature_Block* x) = 0;
21
23
  virtual T operator()(Media_Block* x) = 0;
24
+ virtual T operator()(At_Root_Block* x) = 0;
22
25
  virtual T operator()(At_Rule* x) = 0;
26
+ virtual T operator()(Keyframe_Rule* x) = 0;
23
27
  virtual T operator()(Declaration* x) = 0;
24
28
  virtual T operator()(Assignment* x) = 0;
25
29
  virtual T operator()(Import* x) = 0;
@@ -55,6 +59,7 @@ namespace Sass {
55
59
  virtual T operator()(Feature_Query_Condition* x)= 0;
56
60
  virtual T operator()(Media_Query* x) = 0;
57
61
  virtual T operator()(Media_Query_Expression* x) = 0;
62
+ virtual T operator()(At_Root_Expression* x) = 0;
58
63
  virtual T operator()(Null* x) = 0;
59
64
  // parameters and arguments
60
65
  virtual T operator()(Parameter* x) = 0;
@@ -87,9 +92,12 @@ namespace Sass {
87
92
  virtual T operator()(Block* x) { return static_cast<D*>(this)->fallback(x); }
88
93
  virtual T operator()(Ruleset* x) { return static_cast<D*>(this)->fallback(x); }
89
94
  virtual T operator()(Propset* x) { return static_cast<D*>(this)->fallback(x); }
95
+ virtual T operator()(Bubble* x) { return static_cast<D*>(this)->fallback(x); }
90
96
  virtual T operator()(Feature_Block* x) { return static_cast<D*>(this)->fallback(x); }
91
97
  virtual T operator()(Media_Block* x) { return static_cast<D*>(this)->fallback(x); }
98
+ virtual T operator()(At_Root_Block* x) { return static_cast<D*>(this)->fallback(x); }
92
99
  virtual T operator()(At_Rule* x) { return static_cast<D*>(this)->fallback(x); }
100
+ virtual T operator()(Keyframe_Rule* x) { return static_cast<D*>(this)->fallback(x); }
93
101
  virtual T operator()(Declaration* x) { return static_cast<D*>(this)->fallback(x); }
94
102
  virtual T operator()(Assignment* x) { return static_cast<D*>(this)->fallback(x); }
95
103
  virtual T operator()(Import* x) { return static_cast<D*>(this)->fallback(x); }
@@ -125,6 +133,7 @@ namespace Sass {
125
133
  virtual T operator()(Feature_Query_Condition* x){ return static_cast<D*>(this)->fallback(x); }
126
134
  virtual T operator()(Media_Query* x) { return static_cast<D*>(this)->fallback(x); }
127
135
  virtual T operator()(Media_Query_Expression* x) { return static_cast<D*>(this)->fallback(x); }
136
+ virtual T operator()(At_Root_Expression* x) { return static_cast<D*>(this)->fallback(x); }
128
137
  virtual T operator()(Null* x) { return static_cast<D*>(this)->fallback(x); }
129
138
  // parameters and arguments
130
139
  virtual T operator()(Parameter* x) { return static_cast<D*>(this)->fallback(x); }
@@ -151,3 +160,5 @@ namespace Sass {
151
160
  inline Operation_CRTP<T, D>::~Operation_CRTP() { }
152
161
 
153
162
  }
163
+
164
+ #endif
@@ -0,0 +1,401 @@
1
+ #include "ast.hpp"
2
+ #include "output.hpp"
3
+ #include "to_string.hpp"
4
+
5
+ namespace Sass {
6
+ using namespace std;
7
+
8
+ Output::Output(Context* ctx)
9
+ : Inspect(Emitter(ctx)),
10
+ charset(""),
11
+ top_imports(0),
12
+ top_comments(0)
13
+ {}
14
+
15
+ Output::~Output() { }
16
+
17
+ void Output::fallback_impl(AST_Node* n)
18
+ {
19
+ return n->perform(this);
20
+ }
21
+
22
+ void Output::operator()(Import* imp)
23
+ {
24
+ top_imports.push_back(imp);
25
+ }
26
+
27
+ OutputBuffer Output::get_buffer(void)
28
+ {
29
+
30
+ Emitter emitter(ctx);
31
+ Inspect inspect(emitter);
32
+
33
+ size_t size_com = top_comments.size();
34
+ for (size_t i = 0; i < size_com; i++) {
35
+ top_comments[i]->perform(&inspect);
36
+ inspect.append_mandatory_linefeed();
37
+ }
38
+
39
+ size_t size_imp = top_imports.size();
40
+ for (size_t i = 0; i < size_imp; i++) {
41
+ top_imports[i]->perform(&inspect);
42
+ inspect.append_mandatory_linefeed();
43
+ }
44
+
45
+ // flush scheduled outputs
46
+ inspect.finalize();
47
+ // prepend buffer on top
48
+ prepend_output(inspect.output());
49
+ // make sure we end with a linefeed
50
+ if (!ends_with(wbuf.buffer, ctx->linefeed)) {
51
+ // if the output is not completely empty
52
+ if (!wbuf.buffer.empty()) append_string(ctx->linefeed);
53
+ }
54
+
55
+ // search for unicode char
56
+ for(const char& chr : wbuf.buffer) {
57
+ // skip all ascii chars
58
+ if (chr >= 0) continue;
59
+ // declare the charset
60
+ if (output_style() != COMPRESSED)
61
+ charset = "@charset \"UTF-8\";"
62
+ + ctx->linefeed;
63
+ else charset = "\xEF\xBB\xBF";
64
+ // abort search
65
+ break;
66
+ }
67
+
68
+ // add charset as first line, before comments and imports
69
+ if (!charset.empty()) prepend_string(charset);
70
+
71
+ return wbuf;
72
+
73
+ }
74
+
75
+ void Output::operator()(Comment* c)
76
+ {
77
+ To_String to_string(ctx);
78
+ string txt = c->text()->perform(&to_string);
79
+ // if (indentation && txt == "/**/") return;
80
+ bool important = c->is_important();
81
+ if (output_style() != COMPRESSED || important) {
82
+ if (buffer().size() + top_imports.size() == 0) {
83
+ top_comments.push_back(c);
84
+ } else {
85
+ in_comment = true;
86
+ append_indentation();
87
+ c->text()->perform(this);
88
+ in_comment = false;
89
+ if (indentation == 0) {
90
+ append_mandatory_linefeed();
91
+ } else {
92
+ append_optional_linefeed();
93
+ }
94
+ }
95
+ }
96
+ }
97
+
98
+ void Output::operator()(Ruleset* r)
99
+ {
100
+ Selector* s = r->selector();
101
+ Block* b = r->block();
102
+ bool decls = false;
103
+
104
+ // Filter out rulesets that aren't printable (process its children though)
105
+ if (!Util::isPrintable(r, output_style())) {
106
+ for (size_t i = 0, L = b->length(); i < L; ++i) {
107
+ Statement* stm = (*b)[i];
108
+ if (dynamic_cast<Has_Block*>(stm)) {
109
+ stm->perform(this);
110
+ }
111
+ }
112
+ return;
113
+ }
114
+
115
+ if (b->has_non_hoistable()) {
116
+ decls = true;
117
+ if (output_style() == NESTED) indentation += r->tabs();
118
+ if (ctx && ctx->source_comments) {
119
+ stringstream ss;
120
+ append_indentation();
121
+ ss << "/* line " << r->pstate().line+1 << ", " << r->pstate().path << " */";
122
+ append_string(ss.str());
123
+ append_optional_linefeed();
124
+ }
125
+ s->perform(this);
126
+ append_scope_opener(b);
127
+ for (size_t i = 0, L = b->length(); i < L; ++i) {
128
+ Statement* stm = (*b)[i];
129
+ bool bPrintExpression = true;
130
+ // Check print conditions
131
+ if (typeid(*stm) == typeid(Declaration)) {
132
+ Declaration* dec = static_cast<Declaration*>(stm);
133
+ if (dec->value()->concrete_type() == Expression::STRING) {
134
+ String_Constant* valConst = static_cast<String_Constant*>(dec->value());
135
+ string val(valConst->value());
136
+ if (dynamic_cast<String_Quoted*>(valConst)) {
137
+ if (val.empty()) {
138
+ bPrintExpression = false;
139
+ }
140
+ }
141
+ }
142
+ else if (dec->value()->concrete_type() == Expression::LIST) {
143
+ List* list = static_cast<List*>(dec->value());
144
+ bool all_invisible = true;
145
+ for (size_t list_i = 0, list_L = list->length(); list_i < list_L; ++list_i) {
146
+ Expression* item = (*list)[list_i];
147
+ if (!item->is_invisible()) all_invisible = false;
148
+ }
149
+ if (all_invisible) bPrintExpression = false;
150
+ }
151
+ }
152
+ // Print if OK
153
+ if (!stm->is_hoistable() && bPrintExpression) {
154
+ stm->perform(this);
155
+ }
156
+ }
157
+ if (output_style() == NESTED) indentation -= r->tabs();
158
+ append_scope_closer(b);
159
+ }
160
+
161
+ if (b->has_hoistable()) {
162
+ if (decls) ++indentation;
163
+ for (size_t i = 0, L = b->length(); i < L; ++i) {
164
+ Statement* stm = (*b)[i];
165
+ if (stm->is_hoistable()) {
166
+ stm->perform(this);
167
+ }
168
+ }
169
+ if (decls) --indentation;
170
+ }
171
+ }
172
+
173
+ void Output::operator()(Keyframe_Rule* r)
174
+ {
175
+ String* v = r->rules();
176
+ Block* b = r->block();
177
+
178
+ if (v) {
179
+ append_indentation();
180
+ v->perform(this);
181
+ }
182
+
183
+ if (!b) {
184
+ append_colon_separator();
185
+ return;
186
+ }
187
+
188
+ append_scope_opener();
189
+ for (size_t i = 0, L = b->length(); i < L; ++i) {
190
+ Statement* stm = (*b)[i];
191
+ if (!stm->is_hoistable()) {
192
+ stm->perform(this);
193
+ if (i < L - 1) append_special_linefeed();
194
+ }
195
+ }
196
+
197
+ for (size_t i = 0, L = b->length(); i < L; ++i) {
198
+ Statement* stm = (*b)[i];
199
+ if (stm->is_hoistable()) {
200
+ stm->perform(this);
201
+ }
202
+ }
203
+
204
+ append_scope_closer();
205
+ }
206
+
207
+ void Output::operator()(Feature_Block* f)
208
+ {
209
+ if (f->is_invisible()) return;
210
+
211
+ Feature_Query* q = f->feature_queries();
212
+ Block* b = f->block();
213
+
214
+ // Filter out feature blocks that aren't printable (process its children though)
215
+ if (!Util::isPrintable(f, output_style())) {
216
+ for (size_t i = 0, L = b->length(); i < L; ++i) {
217
+ Statement* stm = (*b)[i];
218
+ if (dynamic_cast<Has_Block*>(stm)) {
219
+ stm->perform(this);
220
+ }
221
+ }
222
+ return;
223
+ }
224
+
225
+ if (output_style() == NESTED) indentation += f->tabs();
226
+ append_indentation();
227
+ append_token("@supports", f);
228
+ append_mandatory_space();
229
+ q->perform(this);
230
+ append_scope_opener();
231
+
232
+ Selector* e = f->selector();
233
+ if (e && b->has_non_hoistable()) {
234
+ // JMA - hoisted, output the non-hoistable in a nested block, followed by the hoistable
235
+ e->perform(this);
236
+ append_scope_opener();
237
+
238
+ for (size_t i = 0, L = b->length(); i < L; ++i) {
239
+ Statement* stm = (*b)[i];
240
+ if (!stm->is_hoistable()) {
241
+ stm->perform(this);
242
+ }
243
+ }
244
+
245
+ append_scope_closer();
246
+
247
+ for (size_t i = 0, L = b->length(); i < L; ++i) {
248
+ Statement* stm = (*b)[i];
249
+ if (stm->is_hoistable()) {
250
+ stm->perform(this);
251
+ }
252
+ }
253
+ }
254
+ else {
255
+ // JMA - not hoisted, just output in order
256
+ for (size_t i = 0, L = b->length(); i < L; ++i) {
257
+ Statement* stm = (*b)[i];
258
+ stm->perform(this);
259
+ if (i < L - 1) append_special_linefeed();
260
+ }
261
+ }
262
+
263
+ if (output_style() == NESTED) indentation -= f->tabs();
264
+
265
+ append_scope_closer();
266
+
267
+ }
268
+
269
+ void Output::operator()(Media_Block* m)
270
+ {
271
+ if (m->is_invisible()) return;
272
+
273
+ List* q = m->media_queries();
274
+ Block* b = m->block();
275
+
276
+ // Filter out media blocks that aren't printable (process its children though)
277
+ if (!Util::isPrintable(m, output_style())) {
278
+ for (size_t i = 0, L = b->length(); i < L; ++i) {
279
+ Statement* stm = (*b)[i];
280
+ if (dynamic_cast<Has_Block*>(stm)) {
281
+ stm->perform(this);
282
+ }
283
+ }
284
+ return;
285
+ }
286
+ if (output_style() == NESTED) indentation += m->tabs();
287
+ append_indentation();
288
+ append_token("@media", m);
289
+ append_mandatory_space();
290
+ in_media_block = true;
291
+ q->perform(this);
292
+ in_media_block = false;
293
+ append_scope_opener();
294
+
295
+ Selector* e = m->selector();
296
+ if (e && b->has_non_hoistable()) {
297
+ // JMA - hoisted, output the non-hoistable in a nested block, followed by the hoistable
298
+ e->perform(this);
299
+ append_scope_opener();
300
+
301
+ for (size_t i = 0, L = b->length(); i < L; ++i) {
302
+ Statement* stm = (*b)[i];
303
+ if (!stm->is_hoistable()) {
304
+ stm->perform(this);
305
+ }
306
+ }
307
+
308
+ append_scope_closer();
309
+
310
+ for (size_t i = 0, L = b->length(); i < L; ++i) {
311
+ Statement* stm = (*b)[i];
312
+ if (stm->is_hoistable()) {
313
+ stm->perform(this);
314
+ }
315
+ }
316
+ }
317
+ else {
318
+ // JMA - not hoisted, just output in order
319
+ for (size_t i = 0, L = b->length(); i < L; ++i) {
320
+ Statement* stm = (*b)[i];
321
+ stm->perform(this);
322
+ if (i < L - 1) append_special_linefeed();
323
+ }
324
+ }
325
+
326
+ if (output_style() == NESTED) indentation -= m->tabs();
327
+ append_scope_closer();
328
+ }
329
+
330
+ void Output::operator()(At_Rule* a)
331
+ {
332
+ string kwd = a->keyword();
333
+ Selector* s = a->selector();
334
+ Expression* v = a->value();
335
+ Block* b = a->block();
336
+
337
+ append_indentation();
338
+ append_token(kwd, a);
339
+ if (s) {
340
+ append_mandatory_space();
341
+ in_at_rule = true;
342
+ s->perform(this);
343
+ in_at_rule = false;
344
+ }
345
+ else if (v) {
346
+ append_mandatory_space();
347
+ v->perform(this);
348
+ }
349
+ if (!b) {
350
+ append_delimiter();
351
+ return;
352
+ }
353
+
354
+ if (b->is_invisible() || b->length() == 0) {
355
+ return append_string(" {}");
356
+ }
357
+
358
+ append_scope_opener();
359
+
360
+ for (size_t i = 0, L = b->length(); i < L; ++i) {
361
+ Statement* stm = (*b)[i];
362
+ if (!stm->is_hoistable()) {
363
+ stm->perform(this);
364
+ if (i < L - 1) append_special_linefeed();
365
+ }
366
+ }
367
+
368
+ for (size_t i = 0, L = b->length(); i < L; ++i) {
369
+ Statement* stm = (*b)[i];
370
+ if (stm->is_hoistable()) {
371
+ stm->perform(this);
372
+ if (i < L - 1) append_special_linefeed();
373
+ }
374
+ }
375
+
376
+ append_scope_closer();
377
+ }
378
+
379
+ void Output::operator()(String_Quoted* s)
380
+ {
381
+ if (s->quote_mark()) {
382
+ append_token(quote((s->value()), s->quote_mark()), s);
383
+ } else if (!in_comment) {
384
+ append_token(string_to_output(s->value()), s);
385
+ } else {
386
+ append_token(s->value(), s);
387
+ }
388
+ }
389
+
390
+ void Output::operator()(String_Constant* s)
391
+ {
392
+ if (String_Quoted* quoted = dynamic_cast<String_Quoted*>(s)) {
393
+ return Output::operator()(quoted);
394
+ } else if (!in_comment) {
395
+ append_token(string_to_output(s->value()), s);
396
+ } else {
397
+ append_token(s->value(), s);
398
+ }
399
+ }
400
+
401
+ }