sassc 1.11.4 → 1.12.0

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 (137) hide show
  1. checksums.yaml +5 -5
  2. data/.travis.yml +2 -2
  3. data/CODE_OF_CONDUCT.md +10 -0
  4. data/README.md +4 -1
  5. data/ext/libsass/.editorconfig +1 -1
  6. data/ext/libsass/.github/CONTRIBUTING.md +7 -7
  7. data/ext/libsass/.github/ISSUE_TEMPLATE.md +31 -6
  8. data/ext/libsass/.gitignore +3 -0
  9. data/ext/libsass/.travis.yml +37 -18
  10. data/ext/libsass/GNUmakefile.am +23 -37
  11. data/ext/libsass/Makefile +10 -6
  12. data/ext/libsass/Makefile.conf +3 -0
  13. data/ext/libsass/Readme.md +68 -63
  14. data/ext/libsass/appveyor.yml +7 -3
  15. data/ext/libsass/configure.ac +10 -14
  16. data/ext/libsass/docs/api-context-internal.md +29 -21
  17. data/ext/libsass/docs/api-context.md +26 -6
  18. data/ext/libsass/docs/api-doc.md +49 -16
  19. data/ext/libsass/docs/api-function-example.md +1 -1
  20. data/ext/libsass/docs/api-function.md +31 -7
  21. data/ext/libsass/docs/api-importer.md +19 -19
  22. data/ext/libsass/docs/api-value.md +4 -2
  23. data/ext/libsass/docs/build-on-windows.md +4 -4
  24. data/ext/libsass/docs/build-with-mingw.md +3 -3
  25. data/ext/libsass/docs/build.md +9 -9
  26. data/ext/libsass/docs/custom-functions-internal.md +10 -8
  27. data/ext/libsass/docs/implementations.md +20 -8
  28. data/ext/libsass/docs/unicode.md +16 -10
  29. data/ext/libsass/include/sass/base.h +0 -3
  30. data/ext/libsass/include/sass/context.h +20 -2
  31. data/ext/libsass/include/sass/functions.h +31 -0
  32. data/ext/libsass/include/sass/values.h +3 -1
  33. data/ext/libsass/include/sass/version.h +1 -1
  34. data/ext/libsass/include/sass/version.h.in +1 -1
  35. data/ext/libsass/include/sass2scss.h +1 -1
  36. data/ext/libsass/res/resource.rc +6 -6
  37. data/ext/libsass/script/ci-build-libsass +10 -5
  38. data/ext/libsass/script/ci-build-plugin +62 -0
  39. data/ext/libsass/script/ci-install-compiler +1 -1
  40. data/ext/libsass/script/ci-install-deps +4 -7
  41. data/ext/libsass/script/ci-report-coverage +13 -3
  42. data/ext/libsass/script/tap-driver +1 -1
  43. data/ext/libsass/script/tap-runner +1 -1
  44. data/ext/libsass/src/GNUmakefile.am +1 -1
  45. data/ext/libsass/src/ast.cpp +537 -762
  46. data/ext/libsass/src/ast.hpp +377 -419
  47. data/ext/libsass/src/ast_def_macros.hpp +26 -1
  48. data/ext/libsass/src/ast_fwd_decl.cpp +29 -0
  49. data/ext/libsass/src/ast_fwd_decl.hpp +94 -21
  50. data/ext/libsass/src/b64/encode.h +3 -1
  51. data/ext/libsass/src/backtrace.cpp +46 -0
  52. data/ext/libsass/src/backtrace.hpp +7 -54
  53. data/ext/libsass/src/bind.cpp +72 -50
  54. data/ext/libsass/src/bind.hpp +0 -1
  55. data/ext/libsass/src/cencode.c +6 -0
  56. data/ext/libsass/src/check_nesting.cpp +157 -135
  57. data/ext/libsass/src/check_nesting.hpp +11 -10
  58. data/ext/libsass/src/color_maps.cpp +10 -6
  59. data/ext/libsass/src/color_maps.hpp +6 -8
  60. data/ext/libsass/src/constants.cpp +4 -3
  61. data/ext/libsass/src/constants.hpp +4 -3
  62. data/ext/libsass/src/context.cpp +110 -47
  63. data/ext/libsass/src/context.hpp +11 -1
  64. data/ext/libsass/src/cssize.cpp +105 -94
  65. data/ext/libsass/src/cssize.hpp +4 -5
  66. data/ext/libsass/src/debugger.hpp +247 -244
  67. data/ext/libsass/src/emitter.cpp +30 -6
  68. data/ext/libsass/src/emitter.hpp +7 -0
  69. data/ext/libsass/src/environment.cpp +67 -16
  70. data/ext/libsass/src/environment.hpp +28 -7
  71. data/ext/libsass/src/error_handling.cpp +92 -64
  72. data/ext/libsass/src/error_handling.hpp +64 -43
  73. data/ext/libsass/src/eval.cpp +494 -544
  74. data/ext/libsass/src/eval.hpp +17 -23
  75. data/ext/libsass/src/expand.cpp +182 -154
  76. data/ext/libsass/src/expand.hpp +4 -5
  77. data/ext/libsass/src/extend.cpp +299 -291
  78. data/ext/libsass/src/extend.hpp +46 -11
  79. data/ext/libsass/src/file.cpp +103 -36
  80. data/ext/libsass/src/file.hpp +21 -4
  81. data/ext/libsass/src/functions.cpp +561 -312
  82. data/ext/libsass/src/functions.hpp +8 -5
  83. data/ext/libsass/src/inspect.cpp +108 -53
  84. data/ext/libsass/src/inspect.hpp +5 -2
  85. data/ext/libsass/src/lexer.cpp +15 -7
  86. data/ext/libsass/src/lexer.hpp +13 -4
  87. data/ext/libsass/src/listize.cpp +3 -2
  88. data/ext/libsass/src/listize.hpp +0 -1
  89. data/ext/libsass/src/memory/SharedPtr.cpp +16 -18
  90. data/ext/libsass/src/memory/SharedPtr.hpp +47 -43
  91. data/ext/libsass/src/node.cpp +34 -38
  92. data/ext/libsass/src/node.hpp +6 -8
  93. data/ext/libsass/src/operation.hpp +2 -2
  94. data/ext/libsass/src/operators.cpp +240 -0
  95. data/ext/libsass/src/operators.hpp +30 -0
  96. data/ext/libsass/src/output.cpp +22 -20
  97. data/ext/libsass/src/parser.cpp +719 -358
  98. data/ext/libsass/src/parser.hpp +57 -22
  99. data/ext/libsass/src/plugins.cpp +28 -10
  100. data/ext/libsass/src/position.cpp +21 -3
  101. data/ext/libsass/src/position.hpp +2 -1
  102. data/ext/libsass/src/prelexer.cpp +104 -19
  103. data/ext/libsass/src/prelexer.hpp +10 -3
  104. data/ext/libsass/src/remove_placeholders.cpp +9 -10
  105. data/ext/libsass/src/remove_placeholders.hpp +1 -5
  106. data/ext/libsass/src/sass.cpp +62 -4
  107. data/ext/libsass/src/sass.hpp +5 -2
  108. data/ext/libsass/src/sass_context.cpp +96 -58
  109. data/ext/libsass/src/sass_context.hpp +7 -5
  110. data/ext/libsass/src/sass_functions.cpp +63 -1
  111. data/ext/libsass/src/sass_functions.hpp +19 -1
  112. data/ext/libsass/src/sass_util.cpp +3 -3
  113. data/ext/libsass/src/sass_util.hpp +4 -4
  114. data/ext/libsass/src/sass_values.cpp +42 -39
  115. data/ext/libsass/src/sass_values.hpp +2 -1
  116. data/ext/libsass/src/source_map.cpp +16 -18
  117. data/ext/libsass/src/subset_map.cpp +6 -8
  118. data/ext/libsass/src/subset_map.hpp +6 -6
  119. data/ext/libsass/src/to_c.cpp +2 -2
  120. data/ext/libsass/src/to_value.cpp +8 -3
  121. data/ext/libsass/src/to_value.hpp +1 -0
  122. data/ext/libsass/src/units.cpp +349 -45
  123. data/ext/libsass/src/units.hpp +39 -22
  124. data/ext/libsass/src/utf8/checked.h +7 -0
  125. data/ext/libsass/src/utf8/unchecked.h +7 -0
  126. data/ext/libsass/src/utf8_string.cpp +1 -1
  127. data/ext/libsass/src/util.cpp +139 -45
  128. data/ext/libsass/src/util.hpp +4 -7
  129. data/ext/libsass/src/values.cpp +15 -23
  130. data/ext/libsass/win/libsass.sln +13 -2
  131. data/ext/libsass/win/libsass.sln.DotSettings +9 -0
  132. data/ext/libsass/win/libsass.targets +3 -0
  133. data/ext/libsass/win/libsass.vcxproj.filters +9 -0
  134. data/lib/sassc/version.rb +1 -1
  135. data/sassc.gemspec +1 -1
  136. data/test/native_test.rb +1 -1
  137. metadata +11 -4
@@ -15,6 +15,7 @@
15
15
  #include "environment.hpp"
16
16
  #include "source_map.hpp"
17
17
  #include "subset_map.hpp"
18
+ #include "backtrace.hpp"
18
19
  #include "output.hpp"
19
20
  #include "plugins.hpp"
20
21
  #include "file.hpp"
@@ -43,6 +44,9 @@ namespace Sass {
43
44
  Plugins plugins;
44
45
  Output emitter;
45
46
 
47
+ // generic ast node garbage container
48
+ // used to avoid possible circular refs
49
+ std::vector<AST_Node_Obj> ast_gc;
46
50
  // resources add under our control
47
51
  // these are guaranteed to be freed
48
52
  std::vector<char*> strings;
@@ -50,6 +54,8 @@ namespace Sass {
50
54
  std::map<const std::string, StyleSheet> sheets;
51
55
  Subset_Map subset_map;
52
56
  std::vector<Sass_Import_Entry> import_stack;
57
+ std::vector<Sass_Callee> callee_stack;
58
+ std::vector<Backtrace> traces;
53
59
 
54
60
  struct Sass_Compiler* c_compiler;
55
61
 
@@ -61,6 +67,7 @@ namespace Sass {
61
67
 
62
68
  std::vector<std::string> plugin_paths; // relative paths to load plugins
63
69
  std::vector<std::string> include_paths; // lookup paths for includes
70
+ std::vector<std::string> extensions; // lookup extensions for imports`
64
71
 
65
72
 
66
73
 
@@ -90,7 +97,8 @@ namespace Sass {
90
97
  virtual char* render(Block_Obj root);
91
98
  virtual char* render_srcmap();
92
99
 
93
- void register_resource(const Include&, const Resource&, ParserState* = 0);
100
+ void register_resource(const Include&, const Resource&);
101
+ void register_resource(const Include&, const Resource&, ParserState&);
94
102
  std::vector<Include> find_includes(const Importer& import);
95
103
  Include load_import(const Importer&, ParserState pstate);
96
104
 
@@ -102,6 +110,8 @@ namespace Sass {
102
110
  void collect_plugin_paths(string_list* paths_array);
103
111
  void collect_include_paths(const char* paths_str);
104
112
  void collect_include_paths(string_list* paths_array);
113
+ void collect_extensions(const char* extensions_str);
114
+ void collect_extensions(string_list* extensions_array);
105
115
  std::string format_embedded_source_map();
106
116
  std::string format_source_mapping_url(const std::string& out_path);
107
117
 
@@ -5,15 +5,14 @@
5
5
 
6
6
  #include "cssize.hpp"
7
7
  #include "context.hpp"
8
- #include "backtrace.hpp"
9
8
 
10
9
  namespace Sass {
11
10
 
12
- Cssize::Cssize(Context& ctx, Backtrace* bt)
11
+ Cssize::Cssize(Context& ctx)
13
12
  : ctx(ctx),
13
+ traces(ctx.traces),
14
14
  block_stack(std::vector<Block_Ptr>()),
15
- p_stack(std::vector<Statement_Ptr>()),
16
- backtrace(bt)
15
+ p_stack(std::vector<Statement_Ptr>())
17
16
  { }
18
17
 
19
18
  Statement_Ptr Cssize::parent()
@@ -23,25 +22,28 @@ namespace Sass {
23
22
 
24
23
  Block_Ptr Cssize::operator()(Block_Ptr b)
25
24
  {
26
- Block_Ptr bb = SASS_MEMORY_NEW(Block, b->pstate(), b->length(), b->is_root());
25
+ Block_Obj bb = SASS_MEMORY_NEW(Block, b->pstate(), b->length(), b->is_root());
27
26
  // bb->tabs(b->tabs());
28
27
  block_stack.push_back(bb);
29
28
  append_block(b, bb);
30
29
  block_stack.pop_back();
31
- return bb;
30
+ return bb.detach();
32
31
  }
33
32
 
34
33
  Statement_Ptr Cssize::operator()(Trace_Ptr t)
35
34
  {
36
- return t->block()->perform(this);
35
+ traces.push_back(Backtrace(t->pstate()));
36
+ auto result = t->block()->perform(this);
37
+ traces.pop_back();
38
+ return result;
37
39
  }
38
40
 
39
41
  Statement_Ptr Cssize::operator()(Declaration_Ptr d)
40
42
  {
41
- String_Obj property = SASS_MEMORY_CAST(String, d->property());
43
+ String_Obj property = Cast<String>(d->property());
42
44
 
43
- if (Declaration_Ptr dd = dynamic_cast<Declaration_Ptr>(parent())) {
44
- String_Obj parent_property = SASS_MEMORY_CAST(String, dd->property());
45
+ if (Declaration_Ptr dd = Cast<Declaration>(parent())) {
46
+ String_Obj parent_property = Cast<String>(dd->property());
45
47
  property = SASS_MEMORY_NEW(String_Constant,
46
48
  d->property()->pstate(),
47
49
  parent_property->to_string() + "-" + property->to_string());
@@ -54,17 +56,18 @@ namespace Sass {
54
56
  d->pstate(),
55
57
  property,
56
58
  d->value(),
57
- d->is_important());
59
+ d->is_important(),
60
+ d->is_custom_property());
58
61
  dd->is_indented(d->is_indented());
59
62
  dd->tabs(d->tabs());
60
63
 
61
- p_stack.push_back(&dd);
62
- Block_Obj bb = d->block() ? operator()(&d->block()) : NULL;
64
+ p_stack.push_back(dd);
65
+ Block_Obj bb = d->block() ? operator()(d->block()) : NULL;
63
66
  p_stack.pop_back();
64
67
 
65
68
  if (bb && bb->length()) {
66
69
  if (dd->value() && !dd->value()->is_invisible()) {
67
- bb->unshift(&dd);
70
+ bb->unshift(dd);
68
71
  }
69
72
  return bb.detach();
70
73
  }
@@ -89,7 +92,7 @@ namespace Sass {
89
92
  r->pstate(),
90
93
  r->keyword(),
91
94
  r->selector(),
92
- r->block() ? operator()(&r->block()) : 0);
95
+ r->block() ? operator()(r->block()) : 0);
93
96
  if (r->value()) rr->value(r->value());
94
97
  p_stack.pop_back();
95
98
 
@@ -99,10 +102,10 @@ namespace Sass {
99
102
  Statement_Obj s = r->block()->at(i);
100
103
  if (s->statement_type() != Statement::BUBBLE) directive_exists = true;
101
104
  else {
102
- Bubble_Obj s_obj = SASS_MEMORY_CAST(Bubble, s);
105
+ Bubble_Obj s_obj = Cast<Bubble>(s);
103
106
  s = s_obj->node();
104
107
  if (s->statement_type() != Statement::DIRECTIVE) directive_exists = false;
105
- else directive_exists = (static_cast<Directive_Ptr>(&s)->keyword() == rr->keyword());
108
+ else directive_exists = (Cast<Directive>(s)->keyword() == rr->keyword());
106
109
  }
107
110
 
108
111
  }
@@ -110,12 +113,14 @@ namespace Sass {
110
113
  Block_Ptr result = SASS_MEMORY_NEW(Block, rr->pstate());
111
114
  if (!(directive_exists || rr->is_keyframes()))
112
115
  {
113
- Directive_Ptr empty_node = SASS_MEMORY_CAST(Directive, rr);
116
+ Directive_Ptr empty_node = Cast<Directive>(rr);
114
117
  empty_node->block(SASS_MEMORY_NEW(Block, rr->block() ? rr->block()->pstate() : rr->pstate()));
115
118
  result->append(empty_node);
116
119
  }
117
120
 
118
- Block_Obj ss = debubble(rr->block() ? &rr->block() : SASS_MEMORY_NEW(Block, rr->pstate()), &rr);
121
+ Block_Obj db = rr->block();
122
+ if (db.isNull()) db = SASS_MEMORY_NEW(Block, rr->pstate());
123
+ Block_Obj ss = debubble(db, rr);
119
124
  for (size_t i = 0, L = ss->length(); i < L; ++i) {
120
125
  result->append(ss->at(i));
121
126
  }
@@ -129,10 +134,10 @@ namespace Sass {
129
134
 
130
135
  Keyframe_Rule_Obj rr = SASS_MEMORY_NEW(Keyframe_Rule,
131
136
  r->pstate(),
132
- operator()(&r->block()));
133
- if (&r->name()) rr->name(r->name());
137
+ operator()(r->block()));
138
+ if (!r->name().isNull()) rr->name(r->name());
134
139
 
135
- return debubble(&rr->block(), &rr);
140
+ return debubble(rr->block(), rr);
136
141
  }
137
142
 
138
143
  Statement_Ptr Cssize::operator()(Ruleset_Ptr r)
@@ -142,11 +147,11 @@ namespace Sass {
142
147
  // string schema is not a statement!
143
148
  // r->block() is already a string schema
144
149
  // and that is comming from propset expand
145
- Block_Ptr bb = operator()(&r->block());
150
+ Block_Ptr bb = operator()(r->block());
146
151
  // this should protect us (at least a bit) from our mess
147
152
  // fixing this properly is harder that it should be ...
148
- if (dynamic_cast<Statement_Ptr>(bb) == NULL) {
149
- error("Illegal nesting: Only properties may be nested beneath properties.", r->block()->pstate());
153
+ if (Cast<Statement>(bb) == NULL) {
154
+ error("Illegal nesting: Only properties may be nested beneath properties.", r->block()->pstate(), traces);
150
155
  }
151
156
  Ruleset_Obj rr = SASS_MEMORY_NEW(Ruleset,
152
157
  r->pstate(),
@@ -158,31 +163,31 @@ namespace Sass {
158
163
  p_stack.pop_back();
159
164
 
160
165
  if (!rr->block()) {
161
- error("Illegal nesting: Only properties may be nested beneath properties.", r->block()->pstate());
166
+ error("Illegal nesting: Only properties may be nested beneath properties.", r->block()->pstate(), traces);
162
167
  }
163
168
 
164
169
  Block_Obj props = SASS_MEMORY_NEW(Block, rr->block()->pstate());
165
170
  Block_Ptr rules = SASS_MEMORY_NEW(Block, rr->block()->pstate());
166
171
  for (size_t i = 0, L = rr->block()->length(); i < L; i++)
167
172
  {
168
- Statement_Ptr s = &rr->block()->at(i);
173
+ Statement_Ptr s = rr->block()->at(i);
169
174
  if (bubblable(s)) rules->append(s);
170
175
  if (!bubblable(s)) props->append(s);
171
176
  }
172
177
 
173
178
  if (props->length())
174
179
  {
175
- Block_Obj bb = SASS_MEMORY_NEW(Block, rr->block()->pstate());
176
- bb->concat(&props);
177
- rr->block(bb);
180
+ Block_Obj pb = SASS_MEMORY_NEW(Block, rr->block()->pstate());
181
+ pb->concat(props);
182
+ rr->block(pb);
178
183
 
179
184
  for (size_t i = 0, L = rules->length(); i < L; i++)
180
185
  {
181
- Statement_Ptr stm = &rules->at(i);
186
+ Statement_Ptr stm = rules->at(i);
182
187
  stm->tabs(stm->tabs() + 1);
183
188
  }
184
189
 
185
- rules->unshift(&rr);
190
+ rules->unshift(rr);
186
191
  }
187
192
 
188
193
  Block_Ptr ptr = rules;
@@ -194,7 +199,7 @@ namespace Sass {
194
199
  }
195
200
 
196
201
  if (!(!rules->length() ||
197
- !bubblable(&rules->last()) ||
202
+ !bubblable(rules->last()) ||
198
203
  parent()->statement_type() == Statement::RULESET))
199
204
  {
200
205
  rules->last()->group_end(true);
@@ -219,13 +224,13 @@ namespace Sass {
219
224
 
220
225
  Media_Block_Obj mm = SASS_MEMORY_NEW(Media_Block,
221
226
  m->pstate(),
222
- &m->media_queries(),
223
- operator()(&m->block()));
227
+ m->media_queries(),
228
+ operator()(m->block()));
224
229
  mm->tabs(m->tabs());
225
230
 
226
231
  p_stack.pop_back();
227
232
 
228
- return debubble(&mm->block(), &mm);
233
+ return debubble(mm->block(), mm);
229
234
  }
230
235
 
231
236
  Statement_Ptr Cssize::operator()(Supports_Block_Ptr m)
@@ -240,13 +245,13 @@ namespace Sass {
240
245
 
241
246
  Supports_Block_Obj mm = SASS_MEMORY_NEW(Supports_Block,
242
247
  m->pstate(),
243
- &m->condition(),
244
- operator()(&m->block()));
248
+ m->condition(),
249
+ operator()(m->block()));
245
250
  mm->tabs(m->tabs());
246
251
 
247
252
  p_stack.pop_back();
248
253
 
249
- return debubble(&mm->block(), &mm);
254
+ return debubble(mm->block(), mm);
250
255
  }
251
256
 
252
257
  Statement_Ptr Cssize::operator()(At_Root_Block_Ptr m)
@@ -257,15 +262,15 @@ namespace Sass {
257
262
  tmp |= m->exclude_node(s);
258
263
  }
259
264
 
260
- if (!tmp)
265
+ if (!tmp && m->block())
261
266
  {
262
- Block_Ptr bb = operator()(&m->block());
267
+ Block_Ptr bb = operator()(m->block());
263
268
  for (size_t i = 0, L = bb->length(); i < L; ++i) {
264
269
  // (bb->elements())[i]->tabs(m->tabs());
265
270
  Statement_Obj stm = bb->at(i);
266
- if (bubblable(&stm)) stm->tabs(stm->tabs() + m->tabs());
271
+ if (bubblable(stm)) stm->tabs(stm->tabs() + m->tabs());
267
272
  }
268
- if (bb->length() && bubblable(&bb->last())) bb->last()->group_end(m->group_end());
273
+ if (bb->length() && bubblable(bb->last())) bb->last()->group_end(m->group_end());
269
274
  return bb;
270
275
  }
271
276
 
@@ -280,13 +285,13 @@ namespace Sass {
280
285
  Statement_Ptr Cssize::bubble(Directive_Ptr m)
281
286
  {
282
287
  Block_Ptr bb = SASS_MEMORY_NEW(Block, this->parent()->pstate());
283
- Has_Block_Obj new_rule = static_cast<Has_Block_Ptr>(SASS_MEMORY_COPY(this->parent()));
288
+ Has_Block_Obj new_rule = Cast<Has_Block>(SASS_MEMORY_COPY(this->parent()));
284
289
  new_rule->block(bb);
285
290
  new_rule->tabs(this->parent()->tabs());
286
- new_rule->block()->concat(&m->block());
291
+ new_rule->block()->concat(m->block());
287
292
 
288
293
  Block_Obj wrapper_block = SASS_MEMORY_NEW(Block, m->block() ? m->block()->pstate() : m->pstate());
289
- wrapper_block->append(&new_rule);
294
+ wrapper_block->append(new_rule);
290
295
  Directive_Obj mm = SASS_MEMORY_NEW(Directive,
291
296
  m->pstate(),
292
297
  m->keyword(),
@@ -294,20 +299,23 @@ namespace Sass {
294
299
  wrapper_block);
295
300
  if (m->value()) mm->value(m->value());
296
301
 
297
- Bubble_Ptr bubble = SASS_MEMORY_NEW(Bubble, mm->pstate(), &mm);
302
+ Bubble_Ptr bubble = SASS_MEMORY_NEW(Bubble, mm->pstate(), mm);
298
303
  return bubble;
299
304
  }
300
305
 
301
306
  Statement_Ptr Cssize::bubble(At_Root_Block_Ptr m)
302
307
  {
308
+ if (!m || !m->block()) return NULL;
303
309
  Block_Ptr bb = SASS_MEMORY_NEW(Block, this->parent()->pstate());
304
- Has_Block_Obj new_rule = static_cast<Has_Block_Ptr>(SASS_MEMORY_COPY(this->parent()));
305
- new_rule->block(bb);
306
- new_rule->tabs(this->parent()->tabs());
307
- new_rule->block()->concat(&m->block());
308
-
310
+ Has_Block_Obj new_rule = Cast<Has_Block>(SASS_MEMORY_COPY(this->parent()));
309
311
  Block_Ptr wrapper_block = SASS_MEMORY_NEW(Block, m->block()->pstate());
310
- wrapper_block->append(&new_rule);
312
+ if (new_rule) {
313
+ new_rule->block(bb);
314
+ new_rule->tabs(this->parent()->tabs());
315
+ new_rule->block()->concat(m->block());
316
+ wrapper_block->append(new_rule);
317
+ }
318
+
311
319
  At_Root_Block_Ptr mm = SASS_MEMORY_NEW(At_Root_Block,
312
320
  m->pstate(),
313
321
  wrapper_block,
@@ -318,7 +326,7 @@ namespace Sass {
318
326
 
319
327
  Statement_Ptr Cssize::bubble(Supports_Block_Ptr m)
320
328
  {
321
- Ruleset_Obj parent = static_cast<Ruleset_Ptr>(SASS_MEMORY_COPY(this->parent()));
329
+ Ruleset_Obj parent = Cast<Ruleset>(SASS_MEMORY_COPY(this->parent()));
322
330
 
323
331
  Block_Ptr bb = SASS_MEMORY_NEW(Block, parent->block()->pstate());
324
332
  Ruleset_Ptr new_rule = SASS_MEMORY_NEW(Ruleset,
@@ -326,13 +334,13 @@ namespace Sass {
326
334
  parent->selector(),
327
335
  bb);
328
336
  new_rule->tabs(parent->tabs());
329
- new_rule->block()->concat(&m->block());
337
+ new_rule->block()->concat(m->block());
330
338
 
331
339
  Block_Ptr wrapper_block = SASS_MEMORY_NEW(Block, m->block()->pstate());
332
340
  wrapper_block->append(new_rule);
333
341
  Supports_Block_Ptr mm = SASS_MEMORY_NEW(Supports_Block,
334
342
  m->pstate(),
335
- &m->condition(),
343
+ m->condition(),
336
344
  wrapper_block);
337
345
 
338
346
  mm->tabs(m->tabs());
@@ -343,7 +351,7 @@ namespace Sass {
343
351
 
344
352
  Statement_Ptr Cssize::bubble(Media_Block_Ptr m)
345
353
  {
346
- Ruleset_Obj parent = static_cast<Ruleset_Ptr>(SASS_MEMORY_COPY(this->parent()));
354
+ Ruleset_Obj parent = Cast<Ruleset>(SASS_MEMORY_COPY(this->parent()));
347
355
 
348
356
  Block_Ptr bb = SASS_MEMORY_NEW(Block, parent->block()->pstate());
349
357
  Ruleset_Ptr new_rule = SASS_MEMORY_NEW(Ruleset,
@@ -351,32 +359,31 @@ namespace Sass {
351
359
  parent->selector(),
352
360
  bb);
353
361
  new_rule->tabs(parent->tabs());
354
- new_rule->block()->concat(&m->block());
362
+ new_rule->block()->concat(m->block());
355
363
 
356
364
  Block_Ptr wrapper_block = SASS_MEMORY_NEW(Block, m->block()->pstate());
357
365
  wrapper_block->append(new_rule);
358
366
  Media_Block_Obj mm = SASS_MEMORY_NEW(Media_Block,
359
367
  m->pstate(),
360
- &m->media_queries(),
361
- wrapper_block,
362
- 0);
368
+ m->media_queries(),
369
+ wrapper_block);
363
370
 
364
371
  mm->tabs(m->tabs());
365
372
 
366
- return SASS_MEMORY_NEW(Bubble, mm->pstate(), &mm);
373
+ return SASS_MEMORY_NEW(Bubble, mm->pstate(), mm);
367
374
  }
368
375
 
369
376
  bool Cssize::bubblable(Statement_Ptr s)
370
377
  {
371
- return dynamic_cast<Ruleset_Ptr>(s) || s->bubbles();
378
+ return Cast<Ruleset>(s) || s->bubbles();
372
379
  }
373
380
 
374
381
  Block_Ptr Cssize::flatten(Block_Ptr b)
375
382
  {
376
383
  Block_Ptr result = SASS_MEMORY_NEW(Block, b->pstate(), 0, b->is_root());
377
384
  for (size_t i = 0, L = b->length(); i < L; ++i) {
378
- Statement_Ptr ss = &b->at(i);
379
- if (Block_Ptr bb = SASS_MEMORY_CAST_PTR(Block, ss)) {
385
+ Statement_Ptr ss = b->at(i);
386
+ if (Block_Ptr bb = Cast<Block>(ss)) {
380
387
  Block_Obj bs = flatten(bb);
381
388
  for (size_t j = 0, K = bs->length(); j < K; ++j) {
382
389
  result->append(bs->at(j));
@@ -395,7 +402,7 @@ namespace Sass {
395
402
 
396
403
  for (size_t i = 0, L = b->length(); i < L; ++i) {
397
404
  Statement_Obj value = b->at(i);
398
- bool key = dynamic_cast<Bubble_Ptr>(&value) != NULL;
405
+ bool key = Cast<Bubble>(value) != NULL;
399
406
 
400
407
  if (!results.empty() && results.back().first == key)
401
408
  {
@@ -424,45 +431,50 @@ namespace Sass {
424
431
 
425
432
  if (!is_bubble) {
426
433
  if (!parent) {
427
- result->append(&slice);
434
+ result->append(slice);
428
435
  }
429
436
  else if (previous_parent) {
430
- previous_parent->block()->concat(&slice);
437
+ previous_parent->block()->concat(slice);
431
438
  }
432
439
  else {
433
- previous_parent = static_cast<Has_Block_Ptr>(SASS_MEMORY_COPY(parent));
440
+ previous_parent = Cast<Has_Block>(SASS_MEMORY_COPY(parent));
434
441
  previous_parent->block(slice);
435
442
  previous_parent->tabs(parent->tabs());
436
443
 
437
- result->append(&previous_parent);
444
+ result->append(previous_parent);
438
445
  }
439
446
  continue;
440
447
  }
441
448
 
442
449
  for (size_t j = 0, K = slice->length(); j < K; ++j)
443
450
  {
444
- Statement_Ptr ss = NULL;
451
+ Statement_Ptr ss;
445
452
  Statement_Obj stm = slice->at(j);
446
453
  // this has to go now here (too bad)
447
- Bubble_Obj node = SASS_MEMORY_CAST(Bubble, stm);
454
+ Bubble_Obj node = Cast<Bubble>(stm);
448
455
  Media_Block_Ptr m1 = NULL;
449
456
  Media_Block_Ptr m2 = NULL;
450
- if (parent) m1 = SASS_MEMORY_CAST(Media_Block, *parent);
451
- if (node) m2 = SASS_MEMORY_CAST(Media_Block, node->node());
457
+ if (parent) m1 = Cast<Media_Block>(parent);
458
+ if (node) m2 = Cast<Media_Block>(node->node());
452
459
  if (!parent ||
453
460
  parent->statement_type() != Statement::MEDIA ||
454
461
  node->node()->statement_type() != Statement::MEDIA ||
455
- (m1 && m2 && &m1->media_queries() == &m2->media_queries())
462
+ (m1 && m2 && *m1->media_queries() == *m2->media_queries())
456
463
  )
457
464
  {
458
- ss = &node->node();
465
+ ss = node->node();
459
466
  }
460
467
  else
461
468
  {
462
- List_Obj mq = merge_media_queries(static_cast<Media_Block_Ptr>(&node->node()), static_cast<Media_Block_Ptr>(parent));
469
+ List_Obj mq = merge_media_queries(
470
+ Cast<Media_Block>(node->node()),
471
+ Cast<Media_Block>(parent)
472
+ );
463
473
  if (!mq->length()) continue;
464
- static_cast<Media_Block_Ptr>(&node->node())->media_queries(mq);
465
- ss = &node->node();
474
+ if (Media_Block* b = Cast<Media_Block>(node->node())) {
475
+ b->media_queries(mq);
476
+ }
477
+ ss = node->node();
466
478
  }
467
479
 
468
480
  if (!ss) continue;
@@ -470,8 +482,6 @@ namespace Sass {
470
482
  ss->tabs(ss->tabs() + node->tabs());
471
483
  ss->group_end(node->group_end());
472
484
 
473
- if (!ss) continue;
474
-
475
485
  Block_Obj bb = SASS_MEMORY_NEW(Block,
476
486
  children->pstate(),
477
487
  children->length(),
@@ -483,7 +493,7 @@ namespace Sass {
483
493
  children->length(),
484
494
  children->is_root());
485
495
 
486
- Block_Ptr wrapper = flatten(&bb);
496
+ Block_Ptr wrapper = flatten(bb);
487
497
  wrapper_block->append(wrapper);
488
498
 
489
499
  if (wrapper->length()) {
@@ -491,12 +501,12 @@ namespace Sass {
491
501
  }
492
502
 
493
503
  if (wrapper_block) {
494
- result->append(&wrapper_block);
504
+ result->append(wrapper_block);
495
505
  }
496
506
  }
497
507
  }
498
508
 
499
- return flatten(&result);
509
+ return flatten(result);
500
510
  }
501
511
 
502
512
  Statement_Ptr Cssize::fallback_impl(AST_Node_Ptr n)
@@ -508,7 +518,7 @@ namespace Sass {
508
518
  {
509
519
  for (size_t i = 0, L = b->length(); i < L; ++i) {
510
520
  Statement_Obj ith = b->at(i)->perform(this);
511
- if (Block_Ptr bb = SASS_MEMORY_CAST(Block, ith)) {
521
+ if (Block_Ptr bb = Cast<Block>(ith)) {
512
522
  for (size_t j = 0, K = bb->length(); j < K; ++j) {
513
523
  cur->append(bb->at(j));
514
524
  }
@@ -530,8 +540,8 @@ namespace Sass {
530
540
  for (size_t j = 0, K = m2->media_queries()->length(); j < K; j++) {
531
541
  Expression_Obj l1 = m1->media_queries()->at(i);
532
542
  Expression_Obj l2 = m2->media_queries()->at(j);
533
- Media_Query_Ptr mq1 = SASS_MEMORY_CAST(Media_Query, l1);
534
- Media_Query_Ptr mq2 = SASS_MEMORY_CAST(Media_Query, l2);
543
+ Media_Query_Ptr mq1 = Cast<Media_Query>(l1);
544
+ Media_Query_Ptr mq2 = Cast<Media_Query>(l2);
535
545
  Media_Query_Ptr mq = merge_media_query(mq1, mq2);
536
546
  if (mq) qq->append(mq);
537
547
  }
@@ -548,9 +558,9 @@ namespace Sass {
548
558
  std::string mod;
549
559
 
550
560
  std::string m1 = std::string(mq1->is_restricted() ? "only" : mq1->is_negated() ? "not" : "");
551
- std::string t1 = &mq1->media_type() ? mq1->media_type()->to_string(ctx.c_options) : "";
552
- std::string m2 = std::string(mq2->is_restricted() ? "only" : mq1->is_negated() ? "not" : "");
553
- std::string t2 = &mq2->media_type() ? mq2->media_type()->to_string(ctx.c_options) : "";
561
+ std::string t1 = mq1->media_type() ? mq1->media_type()->to_string(ctx.c_options) : "";
562
+ std::string m2 = std::string(mq2->is_restricted() ? "only" : mq2->is_negated() ? "not" : "");
563
+ std::string t2 = mq2->media_type() ? mq2->media_type()->to_string(ctx.c_options) : "";
554
564
 
555
565
 
556
566
  if (t1.empty()) t1 = t2;
@@ -578,10 +588,11 @@ namespace Sass {
578
588
  }
579
589
 
580
590
  Media_Query_Ptr mm = SASS_MEMORY_NEW(Media_Query,
581
-
582
- mq1->pstate(), 0,
583
- mq1->length() + mq2->length(), mod == "not", mod == "only"
584
- );
591
+ mq1->pstate(),
592
+ 0,
593
+ mq1->length() + mq2->length(),
594
+ mod == "not",
595
+ mod == "only");
585
596
 
586
597
  if (!type.empty()) {
587
598
  mm->media_type(SASS_MEMORY_NEW(String_Quoted, mq1->pstate(), type));