sassc4 2.4.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.
- checksums.yaml +7 -0
- data/.gitignore +18 -0
- data/.gitmodules +3 -0
- data/.travis.yml +16 -0
- data/CHANGELOG.md +97 -0
- data/CODE_OF_CONDUCT.md +10 -0
- data/Gemfile +2 -0
- data/LICENSE.txt +22 -0
- data/README.md +80 -0
- data/Rakefile +51 -0
- data/ext/depend +4 -0
- data/ext/extconf.rb +92 -0
- data/ext/libsass/VERSION +1 -0
- data/ext/libsass/contrib/plugin.cpp +60 -0
- data/ext/libsass/include/sass/base.h +97 -0
- data/ext/libsass/include/sass/context.h +174 -0
- data/ext/libsass/include/sass/functions.h +139 -0
- data/ext/libsass/include/sass/values.h +145 -0
- data/ext/libsass/include/sass/version.h +12 -0
- data/ext/libsass/include/sass.h +15 -0
- data/ext/libsass/include/sass2scss.h +120 -0
- data/ext/libsass/src/MurmurHash2.hpp +91 -0
- data/ext/libsass/src/ast.cpp +953 -0
- data/ext/libsass/src/ast.hpp +1064 -0
- data/ext/libsass/src/ast2c.cpp +80 -0
- data/ext/libsass/src/ast2c.hpp +39 -0
- data/ext/libsass/src/ast_def_macros.hpp +140 -0
- data/ext/libsass/src/ast_fwd_decl.cpp +31 -0
- data/ext/libsass/src/ast_fwd_decl.hpp +274 -0
- data/ext/libsass/src/ast_helpers.hpp +316 -0
- data/ext/libsass/src/ast_sel_cmp.cpp +396 -0
- data/ext/libsass/src/ast_sel_super.cpp +539 -0
- data/ext/libsass/src/ast_sel_unify.cpp +275 -0
- data/ext/libsass/src/ast_sel_weave.cpp +616 -0
- data/ext/libsass/src/ast_selectors.cpp +1070 -0
- data/ext/libsass/src/ast_selectors.hpp +523 -0
- data/ext/libsass/src/ast_supports.cpp +114 -0
- data/ext/libsass/src/ast_supports.hpp +121 -0
- data/ext/libsass/src/ast_values.cpp +1154 -0
- data/ext/libsass/src/ast_values.hpp +498 -0
- data/ext/libsass/src/b64/cencode.h +32 -0
- data/ext/libsass/src/b64/encode.h +79 -0
- data/ext/libsass/src/backtrace.cpp +50 -0
- data/ext/libsass/src/backtrace.hpp +29 -0
- data/ext/libsass/src/base64vlq.cpp +47 -0
- data/ext/libsass/src/base64vlq.hpp +30 -0
- data/ext/libsass/src/bind.cpp +312 -0
- data/ext/libsass/src/bind.hpp +15 -0
- data/ext/libsass/src/c2ast.cpp +64 -0
- data/ext/libsass/src/c2ast.hpp +14 -0
- data/ext/libsass/src/c99func.c +54 -0
- data/ext/libsass/src/cencode.c +106 -0
- data/ext/libsass/src/check_nesting.cpp +393 -0
- data/ext/libsass/src/check_nesting.hpp +70 -0
- data/ext/libsass/src/color_maps.cpp +652 -0
- data/ext/libsass/src/color_maps.hpp +323 -0
- data/ext/libsass/src/color_spaces.cpp +241 -0
- data/ext/libsass/src/color_spaces.hpp +227 -0
- data/ext/libsass/src/constants.cpp +199 -0
- data/ext/libsass/src/constants.hpp +200 -0
- data/ext/libsass/src/context.cpp +870 -0
- data/ext/libsass/src/context.hpp +140 -0
- data/ext/libsass/src/cssize.cpp +521 -0
- data/ext/libsass/src/cssize.hpp +71 -0
- data/ext/libsass/src/dart_helpers.hpp +199 -0
- data/ext/libsass/src/debug.hpp +43 -0
- data/ext/libsass/src/debugger.hpp +964 -0
- data/ext/libsass/src/emitter.cpp +297 -0
- data/ext/libsass/src/emitter.hpp +101 -0
- data/ext/libsass/src/environment.cpp +260 -0
- data/ext/libsass/src/environment.hpp +124 -0
- data/ext/libsass/src/error_handling.cpp +239 -0
- data/ext/libsass/src/error_handling.hpp +248 -0
- data/ext/libsass/src/eval.cpp +1543 -0
- data/ext/libsass/src/eval.hpp +110 -0
- data/ext/libsass/src/eval_selectors.cpp +75 -0
- data/ext/libsass/src/expand.cpp +875 -0
- data/ext/libsass/src/expand.hpp +98 -0
- data/ext/libsass/src/extender.cpp +1226 -0
- data/ext/libsass/src/extender.hpp +399 -0
- data/ext/libsass/src/extension.cpp +43 -0
- data/ext/libsass/src/extension.hpp +89 -0
- data/ext/libsass/src/file.cpp +531 -0
- data/ext/libsass/src/file.hpp +124 -0
- data/ext/libsass/src/fn_colors.cpp +836 -0
- data/ext/libsass/src/fn_colors.hpp +99 -0
- data/ext/libsass/src/fn_lists.cpp +285 -0
- data/ext/libsass/src/fn_lists.hpp +34 -0
- data/ext/libsass/src/fn_maps.cpp +94 -0
- data/ext/libsass/src/fn_maps.hpp +30 -0
- data/ext/libsass/src/fn_miscs.cpp +248 -0
- data/ext/libsass/src/fn_miscs.hpp +40 -0
- data/ext/libsass/src/fn_numbers.cpp +246 -0
- data/ext/libsass/src/fn_numbers.hpp +45 -0
- data/ext/libsass/src/fn_selectors.cpp +205 -0
- data/ext/libsass/src/fn_selectors.hpp +35 -0
- data/ext/libsass/src/fn_strings.cpp +268 -0
- data/ext/libsass/src/fn_strings.hpp +34 -0
- data/ext/libsass/src/fn_utils.cpp +159 -0
- data/ext/libsass/src/fn_utils.hpp +62 -0
- data/ext/libsass/src/inspect.cpp +1126 -0
- data/ext/libsass/src/inspect.hpp +101 -0
- data/ext/libsass/src/json.cpp +1436 -0
- data/ext/libsass/src/json.hpp +117 -0
- data/ext/libsass/src/kwd_arg_macros.hpp +28 -0
- data/ext/libsass/src/lexer.cpp +122 -0
- data/ext/libsass/src/lexer.hpp +304 -0
- data/ext/libsass/src/listize.cpp +70 -0
- data/ext/libsass/src/listize.hpp +37 -0
- data/ext/libsass/src/mapping.hpp +19 -0
- data/ext/libsass/src/memory/allocator.cpp +48 -0
- data/ext/libsass/src/memory/allocator.hpp +138 -0
- data/ext/libsass/src/memory/config.hpp +20 -0
- data/ext/libsass/src/memory/memory_pool.hpp +186 -0
- data/ext/libsass/src/memory/shared_ptr.cpp +33 -0
- data/ext/libsass/src/memory/shared_ptr.hpp +332 -0
- data/ext/libsass/src/memory.hpp +12 -0
- data/ext/libsass/src/operation.hpp +223 -0
- data/ext/libsass/src/operators.cpp +267 -0
- data/ext/libsass/src/operators.hpp +30 -0
- data/ext/libsass/src/ordered_map.hpp +112 -0
- data/ext/libsass/src/output.cpp +320 -0
- data/ext/libsass/src/output.hpp +47 -0
- data/ext/libsass/src/parser.cpp +3059 -0
- data/ext/libsass/src/parser.hpp +395 -0
- data/ext/libsass/src/parser_selectors.cpp +189 -0
- data/ext/libsass/src/permutate.hpp +164 -0
- data/ext/libsass/src/plugins.cpp +188 -0
- data/ext/libsass/src/plugins.hpp +57 -0
- data/ext/libsass/src/position.cpp +163 -0
- data/ext/libsass/src/position.hpp +147 -0
- data/ext/libsass/src/prelexer.cpp +1780 -0
- data/ext/libsass/src/prelexer.hpp +484 -0
- data/ext/libsass/src/remove_placeholders.cpp +86 -0
- data/ext/libsass/src/remove_placeholders.hpp +37 -0
- data/ext/libsass/src/sass.cpp +156 -0
- data/ext/libsass/src/sass.hpp +147 -0
- data/ext/libsass/src/sass2scss.cpp +895 -0
- data/ext/libsass/src/sass_context.cpp +742 -0
- data/ext/libsass/src/sass_context.hpp +129 -0
- data/ext/libsass/src/sass_functions.cpp +210 -0
- data/ext/libsass/src/sass_functions.hpp +50 -0
- data/ext/libsass/src/sass_values.cpp +362 -0
- data/ext/libsass/src/sass_values.hpp +82 -0
- data/ext/libsass/src/settings.hpp +19 -0
- data/ext/libsass/src/source.cpp +69 -0
- data/ext/libsass/src/source.hpp +95 -0
- data/ext/libsass/src/source_data.hpp +32 -0
- data/ext/libsass/src/source_map.cpp +202 -0
- data/ext/libsass/src/source_map.hpp +65 -0
- data/ext/libsass/src/stylesheet.cpp +22 -0
- data/ext/libsass/src/stylesheet.hpp +57 -0
- data/ext/libsass/src/to_value.cpp +114 -0
- data/ext/libsass/src/to_value.hpp +46 -0
- data/ext/libsass/src/units.cpp +507 -0
- data/ext/libsass/src/units.hpp +110 -0
- data/ext/libsass/src/utf8/checked.h +336 -0
- data/ext/libsass/src/utf8/core.h +332 -0
- data/ext/libsass/src/utf8/unchecked.h +235 -0
- data/ext/libsass/src/utf8.h +34 -0
- data/ext/libsass/src/utf8_string.cpp +104 -0
- data/ext/libsass/src/utf8_string.hpp +38 -0
- data/ext/libsass/src/util.cpp +723 -0
- data/ext/libsass/src/util.hpp +105 -0
- data/ext/libsass/src/util_string.cpp +125 -0
- data/ext/libsass/src/util_string.hpp +73 -0
- data/ext/libsass/src/values.cpp +140 -0
- data/ext/libsass/src/values.hpp +12 -0
- data/lib/sassc/dependency.rb +17 -0
- data/lib/sassc/engine.rb +141 -0
- data/lib/sassc/error.rb +37 -0
- data/lib/sassc/functions_handler.rb +73 -0
- data/lib/sassc/import_handler.rb +50 -0
- data/lib/sassc/importer.rb +31 -0
- data/lib/sassc/native/native_context_api.rb +147 -0
- data/lib/sassc/native/native_functions_api.rb +159 -0
- data/lib/sassc/native/sass2scss_api.rb +10 -0
- data/lib/sassc/native/sass_input_style.rb +13 -0
- data/lib/sassc/native/sass_output_style.rb +12 -0
- data/lib/sassc/native/sass_value.rb +97 -0
- data/lib/sassc/native/string_list.rb +10 -0
- data/lib/sassc/native.rb +64 -0
- data/lib/sassc/sass_2_scss.rb +9 -0
- data/lib/sassc/script/functions.rb +8 -0
- data/lib/sassc/script/value/bool.rb +32 -0
- data/lib/sassc/script/value/color.rb +95 -0
- data/lib/sassc/script/value/list.rb +136 -0
- data/lib/sassc/script/value/map.rb +69 -0
- data/lib/sassc/script/value/number.rb +389 -0
- data/lib/sassc/script/value/string.rb +96 -0
- data/lib/sassc/script/value.rb +137 -0
- data/lib/sassc/script/value_conversion/base.rb +13 -0
- data/lib/sassc/script/value_conversion/bool.rb +13 -0
- data/lib/sassc/script/value_conversion/color.rb +18 -0
- data/lib/sassc/script/value_conversion/list.rb +25 -0
- data/lib/sassc/script/value_conversion/map.rb +21 -0
- data/lib/sassc/script/value_conversion/number.rb +13 -0
- data/lib/sassc/script/value_conversion/string.rb +17 -0
- data/lib/sassc/script/value_conversion.rb +69 -0
- data/lib/sassc/script.rb +17 -0
- data/lib/sassc/util/normalized_map.rb +117 -0
- data/lib/sassc/util.rb +231 -0
- data/lib/sassc/version.rb +5 -0
- data/lib/sassc.rb +57 -0
- data/sassc.gemspec +69 -0
- data/test/css_color_level4_test.rb +168 -0
- data/test/custom_importer_test.rb +127 -0
- data/test/engine_test.rb +314 -0
- data/test/error_test.rb +29 -0
- data/test/fixtures/paths.scss +10 -0
- data/test/functions_test.rb +340 -0
- data/test/native_test.rb +213 -0
- data/test/output_style_test.rb +107 -0
- data/test/sass_2_scss_test.rb +14 -0
- data/test/test_helper.rb +45 -0
- metadata +396 -0
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
#ifndef SASS_CONTEXT_H
|
|
2
|
+
#define SASS_CONTEXT_H
|
|
3
|
+
|
|
4
|
+
// sass.hpp must go before all system headers to get the
|
|
5
|
+
// __EXTENSIONS__ fix on Solaris.
|
|
6
|
+
#include "sass.hpp"
|
|
7
|
+
#include "ast.hpp"
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
#define BUFFERSIZE 255
|
|
11
|
+
#include "b64/encode.h"
|
|
12
|
+
|
|
13
|
+
#include "sass_context.hpp"
|
|
14
|
+
#include "stylesheet.hpp"
|
|
15
|
+
#include "plugins.hpp"
|
|
16
|
+
#include "output.hpp"
|
|
17
|
+
|
|
18
|
+
namespace Sass {
|
|
19
|
+
|
|
20
|
+
class Context {
|
|
21
|
+
public:
|
|
22
|
+
void import_url (Import* imp, sass::string load_path, const sass::string& ctx_path);
|
|
23
|
+
bool call_headers(const sass::string& load_path, const char* ctx_path, SourceSpan& pstate, Import* imp)
|
|
24
|
+
{ return call_loader(load_path, ctx_path, pstate, imp, c_headers, false); };
|
|
25
|
+
bool call_importers(const sass::string& load_path, const char* ctx_path, SourceSpan& pstate, Import* imp)
|
|
26
|
+
{ return call_loader(load_path, ctx_path, pstate, imp, c_importers, true); };
|
|
27
|
+
|
|
28
|
+
private:
|
|
29
|
+
bool call_loader(const sass::string& load_path, const char* ctx_path, SourceSpan& pstate, Import* imp, sass::vector<Sass_Importer_Entry> importers, bool only_one = true);
|
|
30
|
+
|
|
31
|
+
public:
|
|
32
|
+
const sass::string CWD;
|
|
33
|
+
struct Sass_Options& c_options;
|
|
34
|
+
sass::string entry_path;
|
|
35
|
+
size_t head_imports;
|
|
36
|
+
Plugins plugins;
|
|
37
|
+
Output emitter;
|
|
38
|
+
|
|
39
|
+
// generic ast node garbage container
|
|
40
|
+
// used to avoid possible circular refs
|
|
41
|
+
CallStack ast_gc;
|
|
42
|
+
// resources add under our control
|
|
43
|
+
// these are guaranteed to be freed
|
|
44
|
+
sass::vector<char*> strings;
|
|
45
|
+
sass::vector<Resource> resources;
|
|
46
|
+
std::map<const sass::string, StyleSheet> sheets;
|
|
47
|
+
ImporterStack import_stack;
|
|
48
|
+
sass::vector<Sass_Callee> callee_stack;
|
|
49
|
+
sass::vector<Backtrace> traces;
|
|
50
|
+
Extender extender;
|
|
51
|
+
|
|
52
|
+
struct Sass_Compiler* c_compiler;
|
|
53
|
+
|
|
54
|
+
// absolute paths to includes
|
|
55
|
+
sass::vector<sass::string> included_files;
|
|
56
|
+
// relative includes for sourcemap
|
|
57
|
+
sass::vector<sass::string> srcmap_links;
|
|
58
|
+
// vectors above have same size
|
|
59
|
+
|
|
60
|
+
sass::vector<sass::string> plugin_paths; // relative paths to load plugins
|
|
61
|
+
sass::vector<sass::string> include_paths; // lookup paths for includes
|
|
62
|
+
|
|
63
|
+
void apply_custom_headers(Block_Obj root, const char* path, SourceSpan pstate);
|
|
64
|
+
|
|
65
|
+
sass::vector<Sass_Importer_Entry> c_headers;
|
|
66
|
+
sass::vector<Sass_Importer_Entry> c_importers;
|
|
67
|
+
sass::vector<Sass_Function_Entry> c_functions;
|
|
68
|
+
|
|
69
|
+
void add_c_header(Sass_Importer_Entry header);
|
|
70
|
+
void add_c_importer(Sass_Importer_Entry importer);
|
|
71
|
+
void add_c_function(Sass_Function_Entry function);
|
|
72
|
+
|
|
73
|
+
const sass::string indent; // String to be used for indentation
|
|
74
|
+
const sass::string linefeed; // String to be used for line feeds
|
|
75
|
+
const sass::string input_path; // for relative paths in src-map
|
|
76
|
+
const sass::string output_path; // for relative paths to the output
|
|
77
|
+
const sass::string source_map_file; // path to source map file (enables feature)
|
|
78
|
+
const sass::string source_map_root; // path for sourceRoot property (pass-through)
|
|
79
|
+
|
|
80
|
+
virtual ~Context();
|
|
81
|
+
Context(struct Sass_Context&);
|
|
82
|
+
virtual Block_Obj parse() = 0;
|
|
83
|
+
virtual Block_Obj compile();
|
|
84
|
+
virtual char* render(Block_Obj root);
|
|
85
|
+
virtual char* render_srcmap();
|
|
86
|
+
|
|
87
|
+
void register_resource(const Include&, const Resource&);
|
|
88
|
+
void register_resource(const Include&, const Resource&, SourceSpan&);
|
|
89
|
+
sass::vector<Include> find_includes(const Importer& import);
|
|
90
|
+
Include load_import(const Importer&, SourceSpan pstate);
|
|
91
|
+
|
|
92
|
+
Sass_Output_Style output_style() { return c_options.output_style; };
|
|
93
|
+
sass::vector<sass::string> get_included_files(bool skip = false, size_t headers = 0);
|
|
94
|
+
|
|
95
|
+
private:
|
|
96
|
+
void collect_plugin_paths(const char* paths_str);
|
|
97
|
+
void collect_plugin_paths(string_list* paths_array);
|
|
98
|
+
void collect_include_paths(const char* paths_str);
|
|
99
|
+
void collect_include_paths(string_list* paths_array);
|
|
100
|
+
sass::string format_embedded_source_map();
|
|
101
|
+
sass::string format_source_mapping_url(const sass::string& out_path);
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
// void register_built_in_functions(Env* env);
|
|
105
|
+
// void register_function(Signature sig, Native_Function f, Env* env);
|
|
106
|
+
// void register_function(Signature sig, Native_Function f, size_t arity, Env* env);
|
|
107
|
+
// void register_overload_stub(sass::string name, Env* env);
|
|
108
|
+
|
|
109
|
+
public:
|
|
110
|
+
const sass::string& cwd() { return CWD; };
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
class File_Context : public Context {
|
|
114
|
+
public:
|
|
115
|
+
File_Context(struct Sass_File_Context& ctx)
|
|
116
|
+
: Context(ctx)
|
|
117
|
+
{ }
|
|
118
|
+
virtual ~File_Context();
|
|
119
|
+
virtual Block_Obj parse();
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
class Data_Context : public Context {
|
|
123
|
+
public:
|
|
124
|
+
char* source_c_str;
|
|
125
|
+
char* srcmap_c_str;
|
|
126
|
+
Data_Context(struct Sass_Data_Context& ctx)
|
|
127
|
+
: Context(ctx)
|
|
128
|
+
{
|
|
129
|
+
source_c_str = ctx.source_string;
|
|
130
|
+
srcmap_c_str = ctx.srcmap_string;
|
|
131
|
+
ctx.source_string = 0; // passed away
|
|
132
|
+
ctx.srcmap_string = 0; // passed away
|
|
133
|
+
}
|
|
134
|
+
virtual ~Data_Context();
|
|
135
|
+
virtual Block_Obj parse();
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
#endif
|
|
@@ -0,0 +1,521 @@
|
|
|
1
|
+
// sass.hpp must go before all system headers to get the
|
|
2
|
+
// __EXTENSIONS__ fix on Solaris.
|
|
3
|
+
#include "sass.hpp"
|
|
4
|
+
|
|
5
|
+
#include <iostream>
|
|
6
|
+
#include <typeinfo>
|
|
7
|
+
#include <vector>
|
|
8
|
+
|
|
9
|
+
#include "cssize.hpp"
|
|
10
|
+
#include "context.hpp"
|
|
11
|
+
|
|
12
|
+
namespace Sass {
|
|
13
|
+
|
|
14
|
+
Cssize::Cssize(Context& ctx)
|
|
15
|
+
: traces(ctx.traces),
|
|
16
|
+
block_stack(BlockStack()),
|
|
17
|
+
p_stack(sass::vector<Statement*>())
|
|
18
|
+
{ }
|
|
19
|
+
|
|
20
|
+
Statement* Cssize::parent()
|
|
21
|
+
{
|
|
22
|
+
return p_stack.size() ? p_stack.back() : block_stack.front();
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
Block* Cssize::operator()(Block* b)
|
|
26
|
+
{
|
|
27
|
+
Block_Obj bb = SASS_MEMORY_NEW(Block, b->pstate(), b->length(), b->is_root());
|
|
28
|
+
// bb->tabs(b->tabs());
|
|
29
|
+
block_stack.push_back(bb);
|
|
30
|
+
append_block(b, bb);
|
|
31
|
+
block_stack.pop_back();
|
|
32
|
+
return bb.detach();
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
Statement* Cssize::operator()(Trace* t)
|
|
36
|
+
{
|
|
37
|
+
traces.push_back(Backtrace(t->pstate()));
|
|
38
|
+
auto result = t->block()->perform(this);
|
|
39
|
+
traces.pop_back();
|
|
40
|
+
return result;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
Statement* Cssize::operator()(Declaration* d)
|
|
44
|
+
{
|
|
45
|
+
String_Obj property = Cast<String>(d->property());
|
|
46
|
+
|
|
47
|
+
if (Declaration* dd = Cast<Declaration>(parent())) {
|
|
48
|
+
String_Obj parent_property = Cast<String>(dd->property());
|
|
49
|
+
property = SASS_MEMORY_NEW(String_Constant,
|
|
50
|
+
d->property()->pstate(),
|
|
51
|
+
parent_property->to_string() + "-" + property->to_string());
|
|
52
|
+
if (!dd->value()) {
|
|
53
|
+
d->tabs(dd->tabs() + 1);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
Declaration_Obj dd = SASS_MEMORY_NEW(Declaration,
|
|
58
|
+
d->pstate(),
|
|
59
|
+
property,
|
|
60
|
+
d->value(),
|
|
61
|
+
d->is_important(),
|
|
62
|
+
d->is_custom_property());
|
|
63
|
+
dd->is_indented(d->is_indented());
|
|
64
|
+
dd->tabs(d->tabs());
|
|
65
|
+
|
|
66
|
+
p_stack.push_back(dd);
|
|
67
|
+
Block_Obj bb = d->block() ? operator()(d->block()) : NULL;
|
|
68
|
+
p_stack.pop_back();
|
|
69
|
+
|
|
70
|
+
if (bb && bb->length()) {
|
|
71
|
+
if (dd->value() && !dd->value()->is_invisible()) {
|
|
72
|
+
bb->unshift(dd);
|
|
73
|
+
}
|
|
74
|
+
return bb.detach();
|
|
75
|
+
}
|
|
76
|
+
else if (dd->value() && !dd->value()->is_invisible()) {
|
|
77
|
+
return dd.detach();
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return 0;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
Statement* Cssize::operator()(AtRule* r)
|
|
84
|
+
{
|
|
85
|
+
if (!r->block() || !r->block()->length()) return r;
|
|
86
|
+
|
|
87
|
+
if (parent()->statement_type() == Statement::RULESET)
|
|
88
|
+
{
|
|
89
|
+
return r->is_keyframes() ? SASS_MEMORY_NEW(Bubble, r->pstate(), r) : bubble(r);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
p_stack.push_back(r);
|
|
93
|
+
AtRuleObj rr = SASS_MEMORY_NEW(AtRule,
|
|
94
|
+
r->pstate(),
|
|
95
|
+
r->keyword(),
|
|
96
|
+
r->selector(),
|
|
97
|
+
r->block() ? operator()(r->block()) : 0);
|
|
98
|
+
if (r->value()) rr->value(r->value());
|
|
99
|
+
p_stack.pop_back();
|
|
100
|
+
|
|
101
|
+
bool directive_exists = false;
|
|
102
|
+
size_t L = rr->block() ? rr->block()->length() : 0;
|
|
103
|
+
for (size_t i = 0; i < L && !directive_exists; ++i) {
|
|
104
|
+
Statement_Obj s = r->block()->at(i);
|
|
105
|
+
if (s->statement_type() != Statement::BUBBLE) directive_exists = true;
|
|
106
|
+
else {
|
|
107
|
+
Bubble_Obj s_obj = Cast<Bubble>(s);
|
|
108
|
+
s = s_obj->node();
|
|
109
|
+
if (s->statement_type() != Statement::DIRECTIVE) directive_exists = false;
|
|
110
|
+
else directive_exists = (Cast<AtRule>(s)->keyword() == rr->keyword());
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
Block* result = SASS_MEMORY_NEW(Block, rr->pstate());
|
|
116
|
+
if (!(directive_exists || rr->is_keyframes()))
|
|
117
|
+
{
|
|
118
|
+
AtRule* empty_node = Cast<AtRule>(rr);
|
|
119
|
+
empty_node->block(SASS_MEMORY_NEW(Block, rr->block() ? rr->block()->pstate() : rr->pstate()));
|
|
120
|
+
result->append(empty_node);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
Block_Obj db = rr->block();
|
|
124
|
+
if (db.isNull()) db = SASS_MEMORY_NEW(Block, rr->pstate());
|
|
125
|
+
Block_Obj ss = debubble(db, rr);
|
|
126
|
+
for (size_t i = 0, L = ss->length(); i < L; ++i) {
|
|
127
|
+
result->append(ss->at(i));
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
return result;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
Statement* Cssize::operator()(Keyframe_Rule* r)
|
|
134
|
+
{
|
|
135
|
+
if (!r->block() || !r->block()->length()) return r;
|
|
136
|
+
|
|
137
|
+
Keyframe_Rule_Obj rr = SASS_MEMORY_NEW(Keyframe_Rule,
|
|
138
|
+
r->pstate(),
|
|
139
|
+
operator()(r->block()));
|
|
140
|
+
if (!r->name().isNull()) rr->name(r->name());
|
|
141
|
+
|
|
142
|
+
return debubble(rr->block(), rr);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
Statement* Cssize::operator()(StyleRule* r)
|
|
146
|
+
{
|
|
147
|
+
p_stack.push_back(r);
|
|
148
|
+
// this can return a string schema
|
|
149
|
+
// string schema is not a statement!
|
|
150
|
+
// r->block() is already a string schema
|
|
151
|
+
// and that is coming from propset expand
|
|
152
|
+
Block* bb = operator()(r->block());
|
|
153
|
+
// this should protect us (at least a bit) from our mess
|
|
154
|
+
// fixing this properly is harder that it should be ...
|
|
155
|
+
if (Cast<Statement>(bb) == NULL) {
|
|
156
|
+
error("Illegal nesting: Only properties may be nested beneath properties.", r->block()->pstate(), traces);
|
|
157
|
+
}
|
|
158
|
+
StyleRuleObj rr = SASS_MEMORY_NEW(StyleRule,
|
|
159
|
+
r->pstate(),
|
|
160
|
+
r->selector(),
|
|
161
|
+
bb);
|
|
162
|
+
|
|
163
|
+
rr->is_root(r->is_root());
|
|
164
|
+
// rr->tabs(r->block()->tabs());
|
|
165
|
+
p_stack.pop_back();
|
|
166
|
+
|
|
167
|
+
if (!rr->block()) {
|
|
168
|
+
error("Illegal nesting: Only properties may be nested beneath properties.", r->block()->pstate(), traces);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
Block_Obj props = SASS_MEMORY_NEW(Block, rr->block()->pstate());
|
|
172
|
+
Block* rules = SASS_MEMORY_NEW(Block, rr->block()->pstate());
|
|
173
|
+
for (size_t i = 0, L = rr->block()->length(); i < L; i++)
|
|
174
|
+
{
|
|
175
|
+
Statement* s = rr->block()->at(i);
|
|
176
|
+
if (bubblable(s)) rules->append(s);
|
|
177
|
+
if (!bubblable(s)) props->append(s);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
if (props->length())
|
|
181
|
+
{
|
|
182
|
+
Block_Obj pb = SASS_MEMORY_NEW(Block, rr->block()->pstate());
|
|
183
|
+
pb->concat(props);
|
|
184
|
+
rr->block(pb);
|
|
185
|
+
|
|
186
|
+
for (size_t i = 0, L = rules->length(); i < L; i++)
|
|
187
|
+
{
|
|
188
|
+
Statement* stm = rules->at(i);
|
|
189
|
+
stm->tabs(stm->tabs() + 1);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
rules->unshift(rr);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
Block* ptr = rules;
|
|
196
|
+
rules = debubble(rules);
|
|
197
|
+
void* lp = ptr;
|
|
198
|
+
void* rp = rules;
|
|
199
|
+
if (lp != rp) {
|
|
200
|
+
Block_Obj obj = ptr;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
if (!(!rules->length() ||
|
|
204
|
+
!bubblable(rules->last()) ||
|
|
205
|
+
parent()->statement_type() == Statement::RULESET))
|
|
206
|
+
{
|
|
207
|
+
rules->last()->group_end(true);
|
|
208
|
+
}
|
|
209
|
+
return rules;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
Statement* Cssize::operator()(Null* m)
|
|
213
|
+
{
|
|
214
|
+
return 0;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
Statement* Cssize::operator()(CssMediaRule* m)
|
|
218
|
+
{
|
|
219
|
+
if (parent()->statement_type() == Statement::RULESET)
|
|
220
|
+
{
|
|
221
|
+
return bubble(m);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
if (parent()->statement_type() == Statement::MEDIA)
|
|
225
|
+
{
|
|
226
|
+
return SASS_MEMORY_NEW(Bubble, m->pstate(), m);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
p_stack.push_back(m);
|
|
230
|
+
|
|
231
|
+
CssMediaRuleObj mm = SASS_MEMORY_NEW(CssMediaRule, m->pstate(), m->block());
|
|
232
|
+
mm->concat(m->elements());
|
|
233
|
+
mm->block(operator()(m->block()));
|
|
234
|
+
mm->tabs(m->tabs());
|
|
235
|
+
|
|
236
|
+
p_stack.pop_back();
|
|
237
|
+
|
|
238
|
+
return debubble(mm->block(), mm);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
Statement* Cssize::operator()(SupportsRule* m)
|
|
242
|
+
{
|
|
243
|
+
if (!m->block()->length())
|
|
244
|
+
{ return m; }
|
|
245
|
+
|
|
246
|
+
if (parent()->statement_type() == Statement::RULESET)
|
|
247
|
+
{ return bubble(m); }
|
|
248
|
+
|
|
249
|
+
p_stack.push_back(m);
|
|
250
|
+
|
|
251
|
+
SupportsRuleObj mm = SASS_MEMORY_NEW(SupportsRule,
|
|
252
|
+
m->pstate(),
|
|
253
|
+
m->condition(),
|
|
254
|
+
operator()(m->block()));
|
|
255
|
+
mm->tabs(m->tabs());
|
|
256
|
+
|
|
257
|
+
p_stack.pop_back();
|
|
258
|
+
|
|
259
|
+
return debubble(mm->block(), mm);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
Statement* Cssize::operator()(AtRootRule* m)
|
|
263
|
+
{
|
|
264
|
+
bool tmp = false;
|
|
265
|
+
for (size_t i = 0, L = p_stack.size(); i < L; ++i) {
|
|
266
|
+
Statement* s = p_stack[i];
|
|
267
|
+
tmp |= m->exclude_node(s);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
if (!tmp && m->block())
|
|
271
|
+
{
|
|
272
|
+
Block* bb = operator()(m->block());
|
|
273
|
+
for (size_t i = 0, L = bb->length(); i < L; ++i) {
|
|
274
|
+
// (bb->elements())[i]->tabs(m->tabs());
|
|
275
|
+
Statement_Obj stm = bb->at(i);
|
|
276
|
+
if (bubblable(stm)) stm->tabs(stm->tabs() + m->tabs());
|
|
277
|
+
}
|
|
278
|
+
if (bb->length() && bubblable(bb->last())) bb->last()->group_end(m->group_end());
|
|
279
|
+
return bb;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
if (m->exclude_node(parent()))
|
|
283
|
+
{
|
|
284
|
+
return SASS_MEMORY_NEW(Bubble, m->pstate(), m);
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
return bubble(m);
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
Statement* Cssize::bubble(AtRule* m)
|
|
291
|
+
{
|
|
292
|
+
Block* bb = SASS_MEMORY_NEW(Block, this->parent()->pstate());
|
|
293
|
+
ParentStatementObj new_rule = Cast<ParentStatement>(SASS_MEMORY_COPY(this->parent()));
|
|
294
|
+
new_rule->block(bb);
|
|
295
|
+
new_rule->tabs(this->parent()->tabs());
|
|
296
|
+
new_rule->block()->concat(m->block());
|
|
297
|
+
|
|
298
|
+
Block_Obj wrapper_block = SASS_MEMORY_NEW(Block, m->block() ? m->block()->pstate() : m->pstate());
|
|
299
|
+
wrapper_block->append(new_rule);
|
|
300
|
+
AtRuleObj mm = SASS_MEMORY_NEW(AtRule,
|
|
301
|
+
m->pstate(),
|
|
302
|
+
m->keyword(),
|
|
303
|
+
m->selector(),
|
|
304
|
+
wrapper_block);
|
|
305
|
+
if (m->value()) mm->value(m->value());
|
|
306
|
+
|
|
307
|
+
Bubble* bubble = SASS_MEMORY_NEW(Bubble, mm->pstate(), mm);
|
|
308
|
+
return bubble;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
Statement* Cssize::bubble(AtRootRule* m)
|
|
312
|
+
{
|
|
313
|
+
if (!m || !m->block()) return NULL;
|
|
314
|
+
Block* bb = SASS_MEMORY_NEW(Block, this->parent()->pstate());
|
|
315
|
+
ParentStatementObj new_rule = Cast<ParentStatement>(SASS_MEMORY_COPY(this->parent()));
|
|
316
|
+
Block* wrapper_block = SASS_MEMORY_NEW(Block, m->block()->pstate());
|
|
317
|
+
if (new_rule) {
|
|
318
|
+
new_rule->block(bb);
|
|
319
|
+
new_rule->tabs(this->parent()->tabs());
|
|
320
|
+
new_rule->block()->concat(m->block());
|
|
321
|
+
wrapper_block->append(new_rule);
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
AtRootRule* mm = SASS_MEMORY_NEW(AtRootRule,
|
|
325
|
+
m->pstate(),
|
|
326
|
+
wrapper_block,
|
|
327
|
+
m->expression());
|
|
328
|
+
Bubble* bubble = SASS_MEMORY_NEW(Bubble, mm->pstate(), mm);
|
|
329
|
+
return bubble;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
Statement* Cssize::bubble(SupportsRule* m)
|
|
333
|
+
{
|
|
334
|
+
StyleRuleObj parent = Cast<StyleRule>(SASS_MEMORY_COPY(this->parent()));
|
|
335
|
+
|
|
336
|
+
Block* bb = SASS_MEMORY_NEW(Block, parent->block()->pstate());
|
|
337
|
+
StyleRule* new_rule = SASS_MEMORY_NEW(StyleRule,
|
|
338
|
+
parent->pstate(),
|
|
339
|
+
parent->selector(),
|
|
340
|
+
bb);
|
|
341
|
+
new_rule->tabs(parent->tabs());
|
|
342
|
+
new_rule->block()->concat(m->block());
|
|
343
|
+
|
|
344
|
+
Block* wrapper_block = SASS_MEMORY_NEW(Block, m->block()->pstate());
|
|
345
|
+
wrapper_block->append(new_rule);
|
|
346
|
+
SupportsRule* mm = SASS_MEMORY_NEW(SupportsRule,
|
|
347
|
+
m->pstate(),
|
|
348
|
+
m->condition(),
|
|
349
|
+
wrapper_block);
|
|
350
|
+
|
|
351
|
+
mm->tabs(m->tabs());
|
|
352
|
+
|
|
353
|
+
Bubble* bubble = SASS_MEMORY_NEW(Bubble, mm->pstate(), mm);
|
|
354
|
+
return bubble;
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
Statement* Cssize::bubble(CssMediaRule* m)
|
|
358
|
+
{
|
|
359
|
+
StyleRuleObj parent = Cast<StyleRule>(SASS_MEMORY_COPY(this->parent()));
|
|
360
|
+
|
|
361
|
+
Block* bb = SASS_MEMORY_NEW(Block, parent->block()->pstate());
|
|
362
|
+
StyleRule* new_rule = SASS_MEMORY_NEW(StyleRule,
|
|
363
|
+
parent->pstate(),
|
|
364
|
+
parent->selector(),
|
|
365
|
+
bb);
|
|
366
|
+
new_rule->tabs(parent->tabs());
|
|
367
|
+
new_rule->block()->concat(m->block());
|
|
368
|
+
|
|
369
|
+
Block* wrapper_block = SASS_MEMORY_NEW(Block, m->block()->pstate());
|
|
370
|
+
wrapper_block->append(new_rule);
|
|
371
|
+
CssMediaRuleObj mm = SASS_MEMORY_NEW(CssMediaRule,
|
|
372
|
+
m->pstate(),
|
|
373
|
+
wrapper_block);
|
|
374
|
+
mm->concat(m->elements());
|
|
375
|
+
|
|
376
|
+
mm->tabs(m->tabs());
|
|
377
|
+
|
|
378
|
+
return SASS_MEMORY_NEW(Bubble, mm->pstate(), mm);
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
bool Cssize::bubblable(Statement* s)
|
|
382
|
+
{
|
|
383
|
+
return Cast<StyleRule>(s) || (s && s->bubbles());
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
Block* Cssize::flatten(const Block* b)
|
|
387
|
+
{
|
|
388
|
+
Block* result = SASS_MEMORY_NEW(Block, b->pstate(), 0, b->is_root());
|
|
389
|
+
for (size_t i = 0, L = b->length(); i < L; ++i) {
|
|
390
|
+
Statement* ss = b->at(i);
|
|
391
|
+
if (const Block* bb = Cast<Block>(ss)) {
|
|
392
|
+
Block_Obj bs = flatten(bb);
|
|
393
|
+
for (size_t j = 0, K = bs->length(); j < K; ++j) {
|
|
394
|
+
result->append(bs->at(j));
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
else {
|
|
398
|
+
result->append(ss);
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
return result;
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
sass::vector<std::pair<bool, Block_Obj>> Cssize::slice_by_bubble(Block* b)
|
|
405
|
+
{
|
|
406
|
+
sass::vector<std::pair<bool, Block_Obj>> results;
|
|
407
|
+
|
|
408
|
+
for (size_t i = 0, L = b->length(); i < L; ++i) {
|
|
409
|
+
Statement_Obj value = b->at(i);
|
|
410
|
+
bool key = Cast<Bubble>(value) != NULL;
|
|
411
|
+
|
|
412
|
+
if (!results.empty() && results.back().first == key)
|
|
413
|
+
{
|
|
414
|
+
Block_Obj wrapper_block = results.back().second;
|
|
415
|
+
wrapper_block->append(value);
|
|
416
|
+
}
|
|
417
|
+
else
|
|
418
|
+
{
|
|
419
|
+
Block* wrapper_block = SASS_MEMORY_NEW(Block, value->pstate());
|
|
420
|
+
wrapper_block->append(value);
|
|
421
|
+
results.push_back(std::make_pair(key, wrapper_block));
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
return results;
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
Block* Cssize::debubble(Block* children, Statement* parent)
|
|
428
|
+
{
|
|
429
|
+
ParentStatementObj previous_parent;
|
|
430
|
+
sass::vector<std::pair<bool, Block_Obj>> baz = slice_by_bubble(children);
|
|
431
|
+
Block_Obj result = SASS_MEMORY_NEW(Block, children->pstate());
|
|
432
|
+
|
|
433
|
+
for (size_t i = 0, L = baz.size(); i < L; ++i) {
|
|
434
|
+
bool is_bubble = baz[i].first;
|
|
435
|
+
Block_Obj slice = baz[i].second;
|
|
436
|
+
|
|
437
|
+
if (!is_bubble) {
|
|
438
|
+
if (!parent) {
|
|
439
|
+
result->append(slice);
|
|
440
|
+
}
|
|
441
|
+
else if (previous_parent) {
|
|
442
|
+
previous_parent->block()->concat(slice);
|
|
443
|
+
}
|
|
444
|
+
else {
|
|
445
|
+
previous_parent = SASS_MEMORY_COPY(parent);
|
|
446
|
+
previous_parent->block(slice);
|
|
447
|
+
previous_parent->tabs(parent->tabs());
|
|
448
|
+
|
|
449
|
+
result->append(previous_parent);
|
|
450
|
+
}
|
|
451
|
+
continue;
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
for (size_t j = 0, K = slice->length(); j < K; ++j)
|
|
455
|
+
{
|
|
456
|
+
Statement_Obj ss;
|
|
457
|
+
Statement_Obj stm = slice->at(j);
|
|
458
|
+
// this has to go now here (too bad)
|
|
459
|
+
Bubble_Obj node = Cast<Bubble>(stm);
|
|
460
|
+
|
|
461
|
+
CssMediaRule* rule1 = NULL;
|
|
462
|
+
CssMediaRule* rule2 = NULL;
|
|
463
|
+
if (parent) rule1 = Cast<CssMediaRule>(parent);
|
|
464
|
+
if (node) rule2 = Cast<CssMediaRule>(node->node());
|
|
465
|
+
if (rule1 || rule2) {
|
|
466
|
+
ss = node->node();
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
ss = node->node();
|
|
470
|
+
|
|
471
|
+
if (!ss) {
|
|
472
|
+
continue;
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
ss->tabs(ss->tabs() + node->tabs());
|
|
476
|
+
ss->group_end(node->group_end());
|
|
477
|
+
|
|
478
|
+
Block_Obj bb = SASS_MEMORY_NEW(Block,
|
|
479
|
+
children->pstate(),
|
|
480
|
+
children->length(),
|
|
481
|
+
children->is_root());
|
|
482
|
+
auto evaled = ss->perform(this);
|
|
483
|
+
if (evaled) bb->append(evaled);
|
|
484
|
+
|
|
485
|
+
Block_Obj wrapper_block = SASS_MEMORY_NEW(Block,
|
|
486
|
+
children->pstate(),
|
|
487
|
+
children->length(),
|
|
488
|
+
children->is_root());
|
|
489
|
+
|
|
490
|
+
Block* wrapper = flatten(bb);
|
|
491
|
+
wrapper_block->append(wrapper);
|
|
492
|
+
|
|
493
|
+
if (wrapper->length()) {
|
|
494
|
+
previous_parent = {};
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
if (wrapper_block) {
|
|
498
|
+
result->append(wrapper_block);
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
return flatten(result);
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
void Cssize::append_block(Block* b, Block* cur)
|
|
507
|
+
{
|
|
508
|
+
for (size_t i = 0, L = b->length(); i < L; ++i) {
|
|
509
|
+
Statement_Obj ith = b->at(i)->perform(this);
|
|
510
|
+
if (Block_Obj bb = Cast<Block>(ith)) {
|
|
511
|
+
for (size_t j = 0, K = bb->length(); j < K; ++j) {
|
|
512
|
+
cur->append(bb->at(j));
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
else if (ith) {
|
|
516
|
+
cur->append(ith);
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
}
|