sassc 1.7.1 → 1.8.0.pre1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (164) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +3 -1
  3. data/ext/libsass/.gitignore +10 -6
  4. data/ext/libsass/.travis.yml +4 -1
  5. data/ext/libsass/GNUmakefile.am +88 -0
  6. data/ext/libsass/Makefile +157 -76
  7. data/ext/libsass/Makefile.conf +47 -0
  8. data/ext/libsass/Readme.md +13 -14
  9. data/ext/libsass/appveyor.yml +25 -41
  10. data/ext/libsass/configure.ac +20 -7
  11. data/ext/libsass/contrib/plugin.cpp +1 -1
  12. data/ext/libsass/include/sass.h +15 -0
  13. data/ext/libsass/{sass.h → include/sass/base.h} +17 -9
  14. data/ext/libsass/{sass_context.h → include/sass/context.h} +3 -1
  15. data/ext/libsass/{sass_functions.h → include/sass/functions.h} +4 -4
  16. data/ext/libsass/{sass_interface.h → include/sass/interface.h} +5 -2
  17. data/ext/libsass/{sass_values.h → include/sass/values.h} +15 -1
  18. data/ext/libsass/{sass_version.h → include/sass/version.h} +0 -0
  19. data/ext/libsass/{sass_version.h.in → include/sass/version.h.in} +0 -0
  20. data/ext/libsass/{sass2scss.h → include/sass2scss.h} +6 -7
  21. data/ext/libsass/m4/m4-ax_cxx_compile_stdcxx_11.m4 +167 -0
  22. data/ext/libsass/script/ci-build-libsass +67 -23
  23. data/ext/libsass/src/GNUmakefile.am +54 -0
  24. data/ext/libsass/src/ast.cpp +2029 -0
  25. data/ext/libsass/{ast.hpp → src/ast.hpp} +832 -660
  26. data/ext/libsass/src/ast_def_macros.hpp +47 -0
  27. data/ext/libsass/src/ast_factory.hpp +93 -0
  28. data/ext/libsass/{ast_fwd_decl.hpp → src/ast_fwd_decl.hpp} +9 -4
  29. data/ext/libsass/{b64 → src/b64}/cencode.h +1 -1
  30. data/ext/libsass/{b64 → src/b64}/encode.h +0 -0
  31. data/ext/libsass/{backtrace.hpp → src/backtrace.hpp} +9 -10
  32. data/ext/libsass/{base64vlq.cpp → src/base64vlq.cpp} +2 -2
  33. data/ext/libsass/{base64vlq.hpp → src/base64vlq.hpp} +1 -2
  34. data/ext/libsass/{bind.cpp → src/bind.cpp} +96 -59
  35. data/ext/libsass/{bind.hpp → src/bind.hpp} +1 -1
  36. data/ext/libsass/src/c99func.c +54 -0
  37. data/ext/libsass/{cencode.c → src/cencode.c} +5 -5
  38. data/ext/libsass/src/color_maps.cpp +643 -0
  39. data/ext/libsass/src/color_maps.hpp +333 -0
  40. data/ext/libsass/{constants.cpp → src/constants.cpp} +10 -1
  41. data/ext/libsass/{constants.hpp → src/constants.hpp} +7 -0
  42. data/ext/libsass/{context.cpp → src/context.cpp} +152 -122
  43. data/ext/libsass/src/context.hpp +150 -0
  44. data/ext/libsass/{cssize.cpp → src/cssize.cpp} +123 -109
  45. data/ext/libsass/{cssize.hpp → src/cssize.hpp} +9 -13
  46. data/ext/libsass/{debug.hpp → src/debug.hpp} +9 -9
  47. data/ext/libsass/src/debugger.hpp +683 -0
  48. data/ext/libsass/{emitter.cpp → src/emitter.cpp} +13 -13
  49. data/ext/libsass/{emitter.hpp → src/emitter.hpp} +10 -11
  50. data/ext/libsass/src/environment.cpp +184 -0
  51. data/ext/libsass/src/environment.hpp +92 -0
  52. data/ext/libsass/src/error_handling.cpp +46 -0
  53. data/ext/libsass/src/error_handling.hpp +34 -0
  54. data/ext/libsass/src/eval.cpp +1462 -0
  55. data/ext/libsass/src/eval.hpp +107 -0
  56. data/ext/libsass/src/expand.cpp +653 -0
  57. data/ext/libsass/{expand.hpp → src/expand.hpp} +17 -16
  58. data/ext/libsass/{extend.cpp → src/extend.cpp} +198 -139
  59. data/ext/libsass/{extend.hpp → src/extend.hpp} +7 -8
  60. data/ext/libsass/{file.cpp → src/file.cpp} +103 -57
  61. data/ext/libsass/{file.hpp → src/file.hpp} +23 -14
  62. data/ext/libsass/{functions.cpp → src/functions.cpp} +642 -333
  63. data/ext/libsass/{functions.hpp → src/functions.hpp} +17 -4
  64. data/ext/libsass/{inspect.cpp → src/inspect.cpp} +147 -260
  65. data/ext/libsass/{inspect.hpp → src/inspect.hpp} +7 -7
  66. data/ext/libsass/{json.cpp → src/json.cpp} +33 -43
  67. data/ext/libsass/{json.hpp → src/json.hpp} +1 -1
  68. data/ext/libsass/{kwd_arg_macros.hpp → src/kwd_arg_macros.hpp} +0 -0
  69. data/ext/libsass/{lexer.cpp → src/lexer.cpp} +28 -0
  70. data/ext/libsass/{lexer.hpp → src/lexer.hpp} +25 -10
  71. data/ext/libsass/{listize.cpp → src/listize.cpp} +17 -13
  72. data/ext/libsass/{listize.hpp → src/listize.hpp} +0 -2
  73. data/ext/libsass/{mapping.hpp → src/mapping.hpp} +0 -0
  74. data/ext/libsass/src/memory_manager.cpp +76 -0
  75. data/ext/libsass/src/memory_manager.hpp +48 -0
  76. data/ext/libsass/{node.cpp → src/node.cpp} +89 -18
  77. data/ext/libsass/{node.hpp → src/node.hpp} +5 -6
  78. data/ext/libsass/{operation.hpp → src/operation.hpp} +18 -12
  79. data/ext/libsass/{output.cpp → src/output.cpp} +47 -55
  80. data/ext/libsass/{output.hpp → src/output.hpp} +5 -4
  81. data/ext/libsass/src/parser.cpp +2529 -0
  82. data/ext/libsass/{parser.hpp → src/parser.hpp} +84 -60
  83. data/ext/libsass/{paths.hpp → src/paths.hpp} +10 -13
  84. data/ext/libsass/{plugins.cpp → src/plugins.cpp} +14 -17
  85. data/ext/libsass/{plugins.hpp → src/plugins.hpp} +10 -11
  86. data/ext/libsass/{position.cpp → src/position.cpp} +5 -6
  87. data/ext/libsass/{position.hpp → src/position.hpp} +19 -22
  88. data/ext/libsass/{prelexer.cpp → src/prelexer.cpp} +401 -53
  89. data/ext/libsass/{prelexer.hpp → src/prelexer.hpp} +50 -10
  90. data/ext/libsass/{remove_placeholders.cpp → src/remove_placeholders.cpp} +12 -16
  91. data/ext/libsass/{remove_placeholders.hpp → src/remove_placeholders.hpp} +1 -7
  92. data/ext/libsass/{sass.cpp → src/sass.cpp} +3 -5
  93. data/ext/libsass/{sass2scss.cpp → src/sass2scss.cpp} +51 -46
  94. data/ext/libsass/{sass_context.cpp → src/sass_context.cpp} +114 -112
  95. data/ext/libsass/{sass_functions.cpp → src/sass_functions.cpp} +11 -18
  96. data/ext/libsass/{sass_interface.cpp → src/sass_interface.cpp} +44 -81
  97. data/ext/libsass/{sass_util.cpp → src/sass_util.cpp} +26 -8
  98. data/ext/libsass/{sass_util.hpp → src/sass_util.hpp} +14 -18
  99. data/ext/libsass/{sass_values.cpp → src/sass_values.cpp} +91 -20
  100. data/ext/libsass/{source_map.cpp → src/source_map.cpp} +13 -13
  101. data/ext/libsass/{source_map.hpp → src/source_map.hpp} +9 -9
  102. data/ext/libsass/{subset_map.hpp → src/subset_map.hpp} +29 -31
  103. data/ext/libsass/{support → src/support}/libsass.pc.in +0 -0
  104. data/ext/libsass/src/to_c.cpp +73 -0
  105. data/ext/libsass/src/to_c.hpp +41 -0
  106. data/ext/libsass/src/to_string.cpp +47 -0
  107. data/ext/libsass/{to_string.hpp → src/to_string.hpp} +9 -7
  108. data/ext/libsass/src/to_value.cpp +109 -0
  109. data/ext/libsass/src/to_value.hpp +50 -0
  110. data/ext/libsass/{units.cpp → src/units.cpp} +56 -51
  111. data/ext/libsass/{units.hpp → src/units.hpp} +8 -9
  112. data/ext/libsass/{utf8.h → src/utf8.h} +0 -0
  113. data/ext/libsass/{utf8 → src/utf8}/checked.h +0 -0
  114. data/ext/libsass/{utf8 → src/utf8}/core.h +12 -12
  115. data/ext/libsass/{utf8 → src/utf8}/unchecked.h +0 -0
  116. data/ext/libsass/{utf8_string.cpp → src/utf8_string.cpp} +0 -0
  117. data/ext/libsass/{utf8_string.hpp → src/utf8_string.hpp} +6 -6
  118. data/ext/libsass/{util.cpp → src/util.cpp} +144 -86
  119. data/ext/libsass/src/util.hpp +59 -0
  120. data/ext/libsass/src/values.cpp +137 -0
  121. data/ext/libsass/src/values.hpp +12 -0
  122. data/ext/libsass/test/test_node.cpp +33 -33
  123. data/ext/libsass/test/test_paths.cpp +5 -6
  124. data/ext/libsass/test/test_selector_difference.cpp +4 -5
  125. data/ext/libsass/test/test_specificity.cpp +4 -5
  126. data/ext/libsass/test/test_subset_map.cpp +91 -91
  127. data/ext/libsass/test/test_superselector.cpp +11 -11
  128. data/ext/libsass/test/test_unification.cpp +4 -4
  129. data/ext/libsass/win/libsass.targets +101 -0
  130. data/ext/libsass/win/libsass.vcxproj +45 -127
  131. data/ext/libsass/win/libsass.vcxproj.filters +303 -0
  132. data/lib/sassc/import_handler.rb +1 -1
  133. data/lib/sassc/native/native_functions_api.rb +3 -3
  134. data/lib/sassc/version.rb +1 -1
  135. data/test/custom_importer_test.rb +1 -4
  136. data/test/functions_test.rb +3 -2
  137. data/test/native_test.rb +4 -3
  138. metadata +117 -110
  139. data/ext/libsass/Makefile.am +0 -146
  140. data/ext/libsass/ast.cpp +0 -945
  141. data/ext/libsass/ast_def_macros.hpp +0 -21
  142. data/ext/libsass/ast_factory.hpp +0 -92
  143. data/ext/libsass/color_names.hpp +0 -327
  144. data/ext/libsass/context.hpp +0 -157
  145. data/ext/libsass/contextualize.cpp +0 -148
  146. data/ext/libsass/contextualize.hpp +0 -46
  147. data/ext/libsass/contextualize_eval.cpp +0 -93
  148. data/ext/libsass/contextualize_eval.hpp +0 -44
  149. data/ext/libsass/debugger.hpp +0 -558
  150. data/ext/libsass/environment.hpp +0 -163
  151. data/ext/libsass/error_handling.cpp +0 -35
  152. data/ext/libsass/error_handling.hpp +0 -32
  153. data/ext/libsass/eval.cpp +0 -1392
  154. data/ext/libsass/eval.hpp +0 -88
  155. data/ext/libsass/expand.cpp +0 -575
  156. data/ext/libsass/memory_manager.hpp +0 -57
  157. data/ext/libsass/parser.cpp +0 -2403
  158. data/ext/libsass/posix/getopt.c +0 -562
  159. data/ext/libsass/posix/getopt.h +0 -95
  160. data/ext/libsass/to_c.cpp +0 -61
  161. data/ext/libsass/to_c.hpp +0 -44
  162. data/ext/libsass/to_string.cpp +0 -34
  163. data/ext/libsass/util.hpp +0 -54
  164. data/ext/libsass/win/libsass.filters +0 -312
@@ -0,0 +1,150 @@
1
+ #ifndef SASS_CONTEXT_H
2
+ #define SASS_CONTEXT_H
3
+
4
+ #include <string>
5
+ #include <vector>
6
+ #include <map>
7
+
8
+ #define BUFFERSIZE 255
9
+ #include "b64/encode.h"
10
+
11
+ #include "ast_fwd_decl.hpp"
12
+ #include "kwd_arg_macros.hpp"
13
+ #include "memory_manager.hpp"
14
+ #include "environment.hpp"
15
+ #include "source_map.hpp"
16
+ #include "subset_map.hpp"
17
+ #include "output.hpp"
18
+ #include "plugins.hpp"
19
+ #include "file.hpp"
20
+ #include "sass.h"
21
+
22
+ struct Sass_Function;
23
+
24
+ namespace Sass {
25
+
26
+ class Context {
27
+ public:
28
+ size_t head_imports;
29
+ Memory_Manager mem;
30
+
31
+ struct Sass_Options* c_options;
32
+ struct Sass_Compiler* c_compiler;
33
+ char* source_c_str;
34
+
35
+ // c-strs containing Sass file contents
36
+ // we will overtake ownership of memory
37
+ std::vector<char*> sources;
38
+ // strings get freed with context
39
+ std::vector<char*> strings;
40
+ // absolute paths to includes
41
+ std::vector<std::string> included_files;
42
+ // relative links to includes
43
+ std::vector<std::string> include_links;
44
+ // vectors above have same size
45
+
46
+ std::vector<std::string> plugin_paths; // relative paths to load plugins
47
+ std::vector<std::string> include_paths; // lookup paths for includes
48
+ std::vector<Sass_Queued> queue; // queue of files to be parsed
49
+ std::map<std::string, Block*> style_sheets; // map of paths to ASTs
50
+ // SourceMap source_map;
51
+ Output emitter;
52
+
53
+ std::vector<Sass_Importer_Entry> c_headers;
54
+ std::vector<Sass_Importer_Entry> c_importers;
55
+ std::vector<Sass_Function_Entry> c_functions;
56
+
57
+ void add_c_header(Sass_Importer_Entry header);
58
+ void add_c_importer(Sass_Importer_Entry importer);
59
+ void add_c_function(Sass_Function_Entry function);
60
+
61
+ std::string indent; // String to be used for indentation
62
+ std::string linefeed; // String to be used for line feeds
63
+ std::string input_path; // for relative paths in src-map
64
+ std::string output_path; // for relative paths to the output
65
+ bool source_comments; // for inline debug comments in css output
66
+ Output_Style output_style; // output style for the generated css code
67
+ std::string source_map_file; // path to source map file (enables feature)
68
+ std::string source_map_root; // path for sourceRoot property (pass-through)
69
+ bool source_map_embed; // embed in sourceMappingUrl (as data-url)
70
+ bool source_map_contents; // insert included contents into source map
71
+ bool omit_source_map_url; // disable source map comment in css output
72
+ bool is_indented_syntax_src; // treat source string as sass
73
+
74
+ // overload import calls
75
+ std::vector<Sass_Import_Entry> import_stack;
76
+
77
+ size_t precision; // precision for outputting fractional numbers
78
+
79
+ KWD_ARG_SET(Data) {
80
+ KWD_ARG(Data, struct Sass_Options*, c_options)
81
+ KWD_ARG(Data, struct Sass_Compiler*, c_compiler)
82
+ KWD_ARG(Data, char*, source_c_str)
83
+ KWD_ARG(Data, std::string, entry_point)
84
+ KWD_ARG(Data, std::string, input_path)
85
+ KWD_ARG(Data, std::string, output_path)
86
+ KWD_ARG(Data, std::string, indent)
87
+ KWD_ARG(Data, std::string, linefeed)
88
+ KWD_ARG(Data, const char*, include_paths_c_str)
89
+ KWD_ARG(Data, const char*, plugin_paths_c_str)
90
+ // KWD_ARG(Data, const char**, include_paths_array)
91
+ // KWD_ARG(Data, const char**, plugin_paths_array)
92
+ KWD_ARG(Data, std::vector<std::string>, include_paths)
93
+ KWD_ARG(Data, std::vector<std::string>, plugin_paths)
94
+ KWD_ARG(Data, bool, source_comments)
95
+ KWD_ARG(Data, Output_Style, output_style)
96
+ KWD_ARG(Data, std::string, source_map_file)
97
+ KWD_ARG(Data, std::string, source_map_root)
98
+ KWD_ARG(Data, bool, omit_source_map_url)
99
+ KWD_ARG(Data, bool, is_indented_syntax_src)
100
+ KWD_ARG(Data, size_t, precision)
101
+ KWD_ARG(Data, bool, source_map_embed)
102
+ KWD_ARG(Data, bool, source_map_contents)
103
+ };
104
+
105
+ Context(Data);
106
+ ~Context();
107
+ static std::string get_cwd();
108
+
109
+ Block* parse_file();
110
+ Block* parse_string();
111
+ void add_source(std::string, std::string, char*);
112
+
113
+ std::string add_file(const std::string& imp_path, bool delay = false);
114
+ std::string add_file(const std::string& imp_path, const std::string& abs_path, ParserState pstate);
115
+
116
+ void process_queue_entry(Sass_Queued& entry, size_t idx);
117
+
118
+ // allow to optionally overwrite the input path
119
+ // default argument for input_path is std::string("stdin")
120
+ // usefull to influence the source-map generating etc.
121
+ char* compile_file();
122
+ char* compile_string();
123
+ char* compile_block(Block* root);
124
+ char* generate_source_map();
125
+
126
+ std::vector<std::string> get_included_files(bool skip = false, size_t headers = 0);
127
+
128
+ private:
129
+ void collect_plugin_paths(const char* paths_str);
130
+ void collect_plugin_paths(const char** paths_array);
131
+ void collect_include_paths(const char* paths_str);
132
+ void collect_include_paths(const char** paths_array);
133
+ std::string format_embedded_source_map();
134
+ std::string format_source_mapping_url(const std::string& out_path);
135
+
136
+ std::string cwd;
137
+ Plugins plugins;
138
+
139
+ // void register_built_in_functions(Env* env);
140
+ // void register_function(Signature sig, Native_Function f, Env* env);
141
+ // void register_function(Signature sig, Native_Function f, size_t arity, Env* env);
142
+ // void register_overload_stub(std::string name, Env* env);
143
+
144
+ public:
145
+ Subset_Map<std::string, std::pair<Complex_Selector*, Compound_Selector*> > subset_map;
146
+ };
147
+
148
+ }
149
+
150
+ #endif
@@ -1,5 +1,6 @@
1
1
  #include <iostream>
2
2
  #include <typeinfo>
3
+ #include <vector>
3
4
 
4
5
  #include "cssize.hpp"
5
6
  #include "to_string.hpp"
@@ -8,11 +9,10 @@
8
9
 
9
10
  namespace Sass {
10
11
 
11
- Cssize::Cssize(Context& ctx, Env* env, Backtrace* bt)
12
+ Cssize::Cssize(Context& ctx, Backtrace* bt)
12
13
  : ctx(ctx),
13
- env(env),
14
- block_stack(vector<Block*>()),
15
- p_stack(vector<Statement*>()),
14
+ block_stack(std::vector<Block*>()),
15
+ p_stack(std::vector<Statement*>()),
16
16
  backtrace(bt)
17
17
  { }
18
18
 
@@ -23,15 +23,11 @@ namespace Sass {
23
23
 
24
24
  Statement* Cssize::operator()(Block* b)
25
25
  {
26
- Env new_env;
27
- new_env.link(*env);
28
- env = &new_env;
29
- Block* bb = new (ctx.mem) Block(b->pstate(), b->length(), b->is_root());
26
+ Block* bb = SASS_MEMORY_NEW(ctx.mem, Block, b->pstate(), b->length(), b->is_root());
30
27
  // bb->tabs(b->tabs());
31
28
  block_stack.push_back(bb);
32
29
  append_block(b);
33
30
  block_stack.pop_back();
34
- env = env->parent();
35
31
  return bb;
36
32
  }
37
33
 
@@ -41,14 +37,15 @@ namespace Sass {
41
37
 
42
38
  if (parent()->statement_type() == Statement::RULESET)
43
39
  {
44
- return (r->is_keyframes()) ? new (ctx.mem) Bubble(r->pstate(), r) : bubble(r);
40
+ return (r->is_keyframes()) ? SASS_MEMORY_NEW(ctx.mem, Bubble, r->pstate(), r) : bubble(r);
45
41
  }
46
42
 
47
43
  p_stack.push_back(r);
48
- At_Rule* rr = new (ctx.mem) At_Rule(r->pstate(),
49
- r->keyword(),
50
- r->selector(),
51
- r->block() ? r->block()->perform(this)->block() : 0);
44
+ At_Rule* rr = SASS_MEMORY_NEW(ctx.mem, At_Rule,
45
+ r->pstate(),
46
+ r->keyword(),
47
+ r->selector(),
48
+ r->block() ? r->block()->perform(this)->block() : 0);
52
49
  if (r->value()) rr->value(r->value());
53
50
  p_stack.pop_back();
54
51
 
@@ -65,15 +62,15 @@ namespace Sass {
65
62
 
66
63
  }
67
64
 
68
- Block* result = new (ctx.mem) Block(rr->pstate());
65
+ Block* result = SASS_MEMORY_NEW(ctx.mem, Block, rr->pstate());
69
66
  if (!(directive_exists || rr->is_keyframes()))
70
67
  {
71
68
  At_Rule* empty_node = static_cast<At_Rule*>(rr);
72
- empty_node->block(new (ctx.mem) Block(rr->block() ? rr->block()->pstate() : rr->pstate()));
69
+ empty_node->block(SASS_MEMORY_NEW(ctx.mem, Block, rr->block() ? rr->block()->pstate() : rr->pstate()));
73
70
  *result << empty_node;
74
71
  }
75
72
 
76
- Statement* ss = debubble(rr->block() ? rr->block() : new (ctx.mem) Block(rr->pstate()), rr);
73
+ Statement* ss = debubble(rr->block() ? rr->block() : SASS_MEMORY_NEW(ctx.mem, Block, rr->pstate()), rr);
77
74
  for (size_t i = 0, L = ss->block()->length(); i < L; ++i) {
78
75
  *result << (*ss->block())[i];
79
76
  }
@@ -85,8 +82,9 @@ namespace Sass {
85
82
  {
86
83
  if (!r->block() || !r->block()->length()) return r;
87
84
 
88
- Keyframe_Rule* rr = new (ctx.mem) Keyframe_Rule(r->pstate(),
89
- r->block()->perform(this)->block());
85
+ Keyframe_Rule* rr = SASS_MEMORY_NEW(ctx.mem, Keyframe_Rule,
86
+ r->pstate(),
87
+ r->block()->perform(this)->block());
90
88
  if (r->selector()) rr->selector(r->selector());
91
89
 
92
90
  return debubble(rr->block(), rr)->block();
@@ -95,14 +93,15 @@ namespace Sass {
95
93
  Statement* Cssize::operator()(Ruleset* r)
96
94
  {
97
95
  p_stack.push_back(r);
98
- Ruleset* rr = new (ctx.mem) Ruleset(r->pstate(),
99
- r->selector(),
100
- r->block()->perform(this)->block());
96
+ Ruleset* rr = SASS_MEMORY_NEW(ctx.mem, Ruleset,
97
+ r->pstate(),
98
+ r->selector(),
99
+ r->block()->perform(this)->block());
101
100
  // rr->tabs(r->block()->tabs());
102
101
  p_stack.pop_back();
103
102
 
104
- Block* props = new (ctx.mem) Block(rr->block()->pstate());
105
- Block* rules = new (ctx.mem) Block(rr->block()->pstate());
103
+ Block* props = SASS_MEMORY_NEW(ctx.mem, Block, rr->block()->pstate());
104
+ Block* rules = SASS_MEMORY_NEW(ctx.mem, Block, rr->block()->pstate());
106
105
  for (size_t i = 0, L = rr->block()->length(); i < L; i++)
107
106
  {
108
107
  Statement* s = (*rr->block())[i];
@@ -112,7 +111,7 @@ namespace Sass {
112
111
 
113
112
  if (props->length())
114
113
  {
115
- Block* bb = new (ctx.mem) Block(rr->block()->pstate());
114
+ Block* bb = SASS_MEMORY_NEW(ctx.mem, Block, rr->block()->pstate());
116
115
  *bb += props;
117
116
  rr->block(bb);
118
117
 
@@ -136,19 +135,25 @@ namespace Sass {
136
135
  return rules;
137
136
  }
138
137
 
138
+ Statement* Cssize::operator()(Null* m)
139
+ {
140
+ return 0;
141
+ }
142
+
139
143
  Statement* Cssize::operator()(Media_Block* m)
140
144
  {
141
145
  if (parent()->statement_type() == Statement::RULESET)
142
146
  { return bubble(m); }
143
147
 
144
148
  if (parent()->statement_type() == Statement::MEDIA)
145
- { return new (ctx.mem) Bubble(m->pstate(), m); }
149
+ { return SASS_MEMORY_NEW(ctx.mem, Bubble, m->pstate(), m); }
146
150
 
147
151
  p_stack.push_back(m);
148
152
 
149
- Media_Block* mm = new (ctx.mem) Media_Block(m->pstate(),
150
- m->media_queries(),
151
- m->block()->perform(this)->block());
153
+ Media_Block* mm = SASS_MEMORY_NEW(ctx.mem, Media_Block,
154
+ m->pstate(),
155
+ m->media_queries(),
156
+ m->block()->perform(this)->block());
152
157
  mm->tabs(m->tabs());
153
158
 
154
159
  p_stack.pop_back();
@@ -156,7 +161,7 @@ namespace Sass {
156
161
  return debubble(mm->block(), mm)->block();
157
162
  }
158
163
 
159
- Statement* Cssize::operator()(Feature_Block* m)
164
+ Statement* Cssize::operator()(Supports_Block* m)
160
165
  {
161
166
  if (!m->block()->length())
162
167
  { return m; }
@@ -166,9 +171,10 @@ namespace Sass {
166
171
 
167
172
  p_stack.push_back(m);
168
173
 
169
- Feature_Block* mm = new (ctx.mem) Feature_Block(m->pstate(),
170
- m->feature_queries(),
171
- m->block()->perform(this)->block());
174
+ Supports_Block* mm = SASS_MEMORY_NEW(ctx.mem, Supports_Block,
175
+ m->pstate(),
176
+ m->condition(),
177
+ m->block()->perform(this)->block());
172
178
  mm->tabs(m->tabs());
173
179
 
174
180
  p_stack.pop_back();
@@ -197,7 +203,7 @@ namespace Sass {
197
203
 
198
204
  if (m->exclude_node(parent()))
199
205
  {
200
- return new (ctx.mem) Bubble(m->pstate(), m);
206
+ return SASS_MEMORY_NEW(ctx.mem, Bubble, m->pstate(), m);
201
207
  }
202
208
 
203
209
  return bubble(m);
@@ -205,7 +211,7 @@ namespace Sass {
205
211
 
206
212
  Statement* Cssize::bubble(At_Rule* m)
207
213
  {
208
- Block* bb = new (ctx.mem) Block(this->parent()->pstate());
214
+ Block* bb = SASS_MEMORY_NEW(ctx.mem, Block, this->parent()->pstate());
209
215
  Has_Block* new_rule = static_cast<Has_Block*>(shallow_copy(this->parent()));
210
216
  new_rule->block(bb);
211
217
  new_rule->tabs(this->parent()->tabs());
@@ -215,21 +221,22 @@ namespace Sass {
215
221
  *new_rule->block() << (*m->block())[i];
216
222
  }
217
223
 
218
- Block* wrapper_block = new (ctx.mem) Block(m->block() ? m->block()->pstate() : m->pstate());
224
+ Block* wrapper_block = SASS_MEMORY_NEW(ctx.mem, Block, m->block() ? m->block()->pstate() : m->pstate());
219
225
  *wrapper_block << new_rule;
220
- At_Rule* mm = new (ctx.mem) At_Rule(m->pstate(),
221
- m->keyword(),
222
- m->selector(),
223
- wrapper_block);
226
+ At_Rule* mm = SASS_MEMORY_NEW(ctx.mem, At_Rule,
227
+ m->pstate(),
228
+ m->keyword(),
229
+ m->selector(),
230
+ wrapper_block);
224
231
  if (m->value()) mm->value(m->value());
225
232
 
226
- Bubble* bubble = new (ctx.mem) Bubble(mm->pstate(), mm);
233
+ Bubble* bubble = SASS_MEMORY_NEW(ctx.mem, Bubble, mm->pstate(), mm);
227
234
  return bubble;
228
235
  }
229
236
 
230
237
  Statement* Cssize::bubble(At_Root_Block* m)
231
238
  {
232
- Block* bb = new (ctx.mem) Block(this->parent()->pstate());
239
+ Block* bb = SASS_MEMORY_NEW(ctx.mem, Block, this->parent()->pstate());
233
240
  Has_Block* new_rule = static_cast<Has_Block*>(shallow_copy(this->parent()));
234
241
  new_rule->block(bb);
235
242
  new_rule->tabs(this->parent()->tabs());
@@ -238,39 +245,41 @@ namespace Sass {
238
245
  *new_rule->block() << (*m->block())[i];
239
246
  }
240
247
 
241
- Block* wrapper_block = new (ctx.mem) Block(m->block()->pstate());
248
+ Block* wrapper_block = SASS_MEMORY_NEW(ctx.mem, Block, m->block()->pstate());
242
249
  *wrapper_block << new_rule;
243
- At_Root_Block* mm = new (ctx.mem) At_Root_Block(m->pstate(),
244
- wrapper_block,
245
- m->expression());
246
-
247
- Bubble* bubble = new (ctx.mem) Bubble(mm->pstate(), mm);
250
+ At_Root_Block* mm = SASS_MEMORY_NEW(ctx.mem, At_Root_Block,
251
+ m->pstate(),
252
+ wrapper_block,
253
+ m->expression());
254
+ Bubble* bubble = SASS_MEMORY_NEW(ctx.mem, Bubble, mm->pstate(), mm);
248
255
  return bubble;
249
256
  }
250
257
 
251
- Statement* Cssize::bubble(Feature_Block* m)
258
+ Statement* Cssize::bubble(Supports_Block* m)
252
259
  {
253
260
  Ruleset* parent = static_cast<Ruleset*>(shallow_copy(this->parent()));
254
261
 
255
- Block* bb = new (ctx.mem) Block(parent->block()->pstate());
256
- Ruleset* new_rule = new (ctx.mem) Ruleset(parent->pstate(),
257
- parent->selector(),
258
- bb);
262
+ Block* bb = SASS_MEMORY_NEW(ctx.mem, Block, parent->block()->pstate());
263
+ Ruleset* new_rule = SASS_MEMORY_NEW(ctx.mem, Ruleset,
264
+ parent->pstate(),
265
+ parent->selector(),
266
+ bb);
259
267
  new_rule->tabs(parent->tabs());
260
268
 
261
269
  for (size_t i = 0, L = m->block()->length(); i < L; ++i) {
262
270
  *new_rule->block() << (*m->block())[i];
263
271
  }
264
272
 
265
- Block* wrapper_block = new (ctx.mem) Block(m->block()->pstate());
273
+ Block* wrapper_block = SASS_MEMORY_NEW(ctx.mem, Block, m->block()->pstate());
266
274
  *wrapper_block << new_rule;
267
- Feature_Block* mm = new (ctx.mem) Feature_Block(m->pstate(),
268
- m->feature_queries(),
269
- wrapper_block);
275
+ Supports_Block* mm = SASS_MEMORY_NEW(ctx.mem, Supports_Block,
276
+ m->pstate(),
277
+ m->condition(),
278
+ wrapper_block);
270
279
 
271
280
  mm->tabs(m->tabs());
272
281
 
273
- Bubble* bubble = new (ctx.mem) Bubble(mm->pstate(), mm);
282
+ Bubble* bubble = SASS_MEMORY_NEW(ctx.mem, Bubble, mm->pstate(), mm);
274
283
  return bubble;
275
284
  }
276
285
 
@@ -278,26 +287,28 @@ namespace Sass {
278
287
  {
279
288
  Ruleset* parent = static_cast<Ruleset*>(shallow_copy(this->parent()));
280
289
 
281
- Block* bb = new (ctx.mem) Block(parent->block()->pstate());
282
- Ruleset* new_rule = new (ctx.mem) Ruleset(parent->pstate(),
283
- parent->selector(),
284
- bb);
290
+ Block* bb = SASS_MEMORY_NEW(ctx.mem, Block, parent->block()->pstate());
291
+ Ruleset* new_rule = SASS_MEMORY_NEW(ctx.mem, Ruleset,
292
+ parent->pstate(),
293
+ parent->selector(),
294
+ bb);
285
295
  new_rule->tabs(parent->tabs());
286
296
 
287
297
  for (size_t i = 0, L = m->block()->length(); i < L; ++i) {
288
298
  *new_rule->block() << (*m->block())[i];
289
299
  }
290
300
 
291
- Block* wrapper_block = new (ctx.mem) Block(m->block()->pstate());
301
+ Block* wrapper_block = SASS_MEMORY_NEW(ctx.mem, Block, m->block()->pstate());
292
302
  *wrapper_block << new_rule;
293
- Media_Block* mm = new (ctx.mem) Media_Block(m->pstate(),
294
- m->media_queries(),
295
- wrapper_block,
296
- m->selector());
303
+ Media_Block* mm = SASS_MEMORY_NEW(ctx.mem, Media_Block,
304
+ m->pstate(),
305
+ m->media_queries(),
306
+ wrapper_block,
307
+ 0);
297
308
 
298
309
  mm->tabs(m->tabs());
299
310
 
300
- Bubble* bubble = new (ctx.mem) Bubble(mm->pstate(), mm);
311
+ Bubble* bubble = SASS_MEMORY_NEW(ctx.mem, Bubble, mm->pstate(), mm);
301
312
 
302
313
  return bubble;
303
314
  }
@@ -310,7 +321,7 @@ namespace Sass {
310
321
  Statement* Cssize::flatten(Statement* s)
311
322
  {
312
323
  Block* bb = s->block();
313
- Block* result = new (ctx.mem) Block(bb->pstate(), 0, bb->is_root());
324
+ Block* result = SASS_MEMORY_NEW(ctx.mem, Block, bb->pstate(), 0, bb->is_root());
314
325
  for (size_t i = 0, L = bb->length(); i < L; ++i) {
315
326
  Statement* ss = (*bb)[i];
316
327
  if (ss->block()) {
@@ -326,9 +337,9 @@ namespace Sass {
326
337
  return result;
327
338
  }
328
339
 
329
- vector<pair<bool, Block*>> Cssize::slice_by_bubble(Statement* b)
340
+ std::vector<std::pair<bool, Block*>> Cssize::slice_by_bubble(Statement* b)
330
341
  {
331
- vector<pair<bool, Block*>> results;
342
+ std::vector<std::pair<bool, Block*>> results;
332
343
  for (size_t i = 0, L = b->block()->length(); i < L; ++i) {
333
344
  Statement* value = (*b->block())[i];
334
345
  bool key = value->statement_type() == Statement::BUBBLE;
@@ -340,9 +351,9 @@ namespace Sass {
340
351
  }
341
352
  else
342
353
  {
343
- Block* wrapper_block = new (ctx.mem) Block(value->pstate());
354
+ Block* wrapper_block = SASS_MEMORY_NEW(ctx.mem, Block, value->pstate());
344
355
  *wrapper_block << value;
345
- results.push_back(make_pair(key, wrapper_block));
356
+ results.push_back(std::make_pair(key, wrapper_block));
346
357
  }
347
358
  }
348
359
  return results;
@@ -353,32 +364,32 @@ namespace Sass {
353
364
  switch (s->statement_type())
354
365
  {
355
366
  case Statement::RULESET:
356
- return new (ctx.mem) Ruleset(*static_cast<Ruleset*>(s));
367
+ return SASS_MEMORY_NEW(ctx.mem, Ruleset, *static_cast<Ruleset*>(s));
357
368
  case Statement::MEDIA:
358
- return new (ctx.mem) Media_Block(*static_cast<Media_Block*>(s));
369
+ return SASS_MEMORY_NEW(ctx.mem, Media_Block, *static_cast<Media_Block*>(s));
359
370
  case Statement::BUBBLE:
360
- return new (ctx.mem) Bubble(*static_cast<Bubble*>(s));
371
+ return SASS_MEMORY_NEW(ctx.mem, Bubble, *static_cast<Bubble*>(s));
361
372
  case Statement::DIRECTIVE:
362
- return new (ctx.mem) At_Rule(*static_cast<At_Rule*>(s));
363
- case Statement::FEATURE:
364
- return new (ctx.mem) Feature_Block(*static_cast<Feature_Block*>(s));
373
+ return SASS_MEMORY_NEW(ctx.mem, At_Rule, *static_cast<At_Rule*>(s));
374
+ case Statement::SUPPORTS:
375
+ return SASS_MEMORY_NEW(ctx.mem, Supports_Block, *static_cast<Supports_Block*>(s));
365
376
  case Statement::ATROOT:
366
- return new (ctx.mem) At_Root_Block(*static_cast<At_Root_Block*>(s));
377
+ return SASS_MEMORY_NEW(ctx.mem, At_Root_Block, *static_cast<At_Root_Block*>(s));
367
378
  case Statement::KEYFRAMERULE:
368
- return new (ctx.mem) Keyframe_Rule(*static_cast<Keyframe_Rule*>(s));
379
+ return SASS_MEMORY_NEW(ctx.mem, Keyframe_Rule, *static_cast<Keyframe_Rule*>(s));
369
380
  case Statement::NONE:
370
381
  default:
371
382
  error("unknown internal error; please contact the LibSass maintainers", s->pstate(), backtrace);
372
- String_Constant* msg = new (ctx.mem) String_Constant(ParserState("[WARN]"), string("`CSSize` can't clone ") + typeid(*s).name());
373
- return new (ctx.mem) Warning(ParserState("[WARN]"), msg);
383
+ String_Quoted* msg = SASS_MEMORY_NEW(ctx.mem, String_Quoted, ParserState("[WARN]"), std::string("`CSSize` can't clone ") + typeid(*s).name());
384
+ return SASS_MEMORY_NEW(ctx.mem, Warning, ParserState("[WARN]"), msg);
374
385
  }
375
386
  }
376
387
 
377
388
  Statement* Cssize::debubble(Block* children, Statement* parent)
378
389
  {
379
390
  Has_Block* previous_parent = 0;
380
- vector<pair<bool, Block*>> baz = slice_by_bubble(children);
381
- Block* result = new (ctx.mem) Block(children->pstate());
391
+ std::vector<std::pair<bool, Block*>> baz = slice_by_bubble(children);
392
+ Block* result = SASS_MEMORY_NEW(ctx.mem, Block, children->pstate());
382
393
 
383
394
  for (size_t i = 0, L = baz.size(); i < L; ++i) {
384
395
  bool is_bubble = baz[i].first;
@@ -404,9 +415,10 @@ namespace Sass {
404
415
  continue;
405
416
  }
406
417
 
407
- Block* wrapper_block = new (ctx.mem) Block(children->block()->pstate(),
408
- children->block()->length(),
409
- children->block()->is_root());
418
+ Block* wrapper_block = SASS_MEMORY_NEW(ctx.mem, Block,
419
+ children->block()->pstate(),
420
+ children->block()->length(),
421
+ children->block()->is_root());
410
422
 
411
423
  for (size_t j = 0, K = slice->length(); j < K; ++j)
412
424
  {
@@ -423,10 +435,9 @@ namespace Sass {
423
435
  else
424
436
  {
425
437
  List* mq = merge_media_queries(static_cast<Media_Block*>(b->node()), static_cast<Media_Block*>(parent));
426
- if (mq->length()) {
427
- static_cast<Media_Block*>(b->node())->media_queries(mq);
428
- ss = b->node();
429
- }
438
+ if (!mq->length()) continue;
439
+ static_cast<Media_Block*>(b->node())->media_queries(mq);
440
+ ss = b->node();
430
441
  }
431
442
 
432
443
  if (!ss) continue;
@@ -436,9 +447,10 @@ namespace Sass {
436
447
 
437
448
  if (!ss) continue;
438
449
 
439
- Block* bb = new (ctx.mem) Block(children->block()->pstate(),
440
- children->block()->length(),
441
- children->block()->is_root());
450
+ Block* bb = SASS_MEMORY_NEW(ctx.mem, Block,
451
+ children->block()->pstate(),
452
+ children->block()->length(),
453
+ children->block()->is_root());
442
454
  *bb << ss->perform(this);
443
455
  Statement* wrapper = flatten(bb);
444
456
  *wrapper_block << wrapper;
@@ -480,9 +492,10 @@ namespace Sass {
480
492
 
481
493
  List* Cssize::merge_media_queries(Media_Block* m1, Media_Block* m2)
482
494
  {
483
- List* qq = new (ctx.mem) List(m1->media_queries()->pstate(),
484
- m1->media_queries()->length(),
485
- List::COMMA);
495
+ List* qq = SASS_MEMORY_NEW(ctx.mem, List,
496
+ m1->media_queries()->pstate(),
497
+ m1->media_queries()->length(),
498
+ SASS_COMMA);
486
499
 
487
500
  for (size_t i = 0, L = m1->media_queries()->length(); i < L; i++) {
488
501
  for (size_t j = 0, K = m2->media_queries()->length(); j < K; j++) {
@@ -502,13 +515,13 @@ namespace Sass {
502
515
  {
503
516
  To_String to_string(&ctx);
504
517
 
505
- string type;
506
- string mod;
518
+ std::string type;
519
+ std::string mod;
507
520
 
508
- string m1 = string(mq1->is_restricted() ? "only" : mq1->is_negated() ? "not" : "");
509
- string t1 = mq1->media_type() ? mq1->media_type()->perform(&to_string) : "";
510
- string m2 = string(mq2->is_restricted() ? "only" : mq1->is_negated() ? "not" : "");
511
- string t2 = mq2->media_type() ? mq2->media_type()->perform(&to_string) : "";
521
+ std::string m1 = std::string(mq1->is_restricted() ? "only" : mq1->is_negated() ? "not" : "");
522
+ std::string t1 = mq1->media_type() ? mq1->media_type()->perform(&to_string) : "";
523
+ std::string m2 = std::string(mq2->is_restricted() ? "only" : mq1->is_negated() ? "not" : "");
524
+ std::string t2 = mq2->media_type() ? mq2->media_type()->perform(&to_string) : "";
512
525
 
513
526
 
514
527
  if (t1.empty()) t1 = t2;
@@ -535,13 +548,14 @@ namespace Sass {
535
548
  mod = m1.empty() ? m2 : m1;
536
549
  }
537
550
 
538
- Media_Query* mm = new (ctx.mem) Media_Query(
539
- mq1->pstate(), 0,
540
- mq1->length() + mq2->length(), mod == "not", mod == "only"
541
- );
551
+ Media_Query* mm = SASS_MEMORY_NEW(ctx.mem, Media_Query,
552
+
553
+ mq1->pstate(), 0,
554
+ mq1->length() + mq2->length(), mod == "not", mod == "only"
555
+ );
542
556
 
543
557
  if (!type.empty()) {
544
- mm->media_type(new (ctx.mem) String_Constant(mq1->pstate(), type));
558
+ mm->media_type(SASS_MEMORY_NEW(ctx.mem, String_Quoted, mq1->pstate(), type));
545
559
  }
546
560
 
547
561
  *mm += mq2;