sassc 1.11.1 → 1.11.2
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 +4 -4
- data/.travis.yml +2 -2
- data/README.md +3 -2
- data/ext/libsass/Makefile.conf +2 -1
- data/ext/libsass/appveyor.yml +10 -5
- data/ext/libsass/docs/dev-ast-memory.md +223 -0
- data/ext/libsass/include/sass/base.h +2 -0
- data/ext/libsass/script/bootstrap +7 -4
- data/ext/libsass/script/ci-build-libsass +3 -3
- data/ext/libsass/script/ci-install-compiler +2 -0
- data/ext/libsass/script/ci-report-coverage +2 -1
- data/ext/libsass/script/test-leaks.pl +103 -0
- data/ext/libsass/src/ast.cpp +621 -495
- data/ext/libsass/src/ast.hpp +801 -367
- data/ext/libsass/src/ast_def_macros.hpp +5 -5
- data/ext/libsass/src/ast_fwd_decl.hpp +312 -14
- data/ext/libsass/src/bind.cpp +54 -51
- data/ext/libsass/src/bind.hpp +3 -7
- data/ext/libsass/src/check_nesting.cpp +117 -120
- data/ext/libsass/src/check_nesting.hpp +38 -34
- data/ext/libsass/src/color_maps.cpp +3 -3
- data/ext/libsass/src/color_maps.hpp +3 -3
- data/ext/libsass/src/context.cpp +33 -34
- data/ext/libsass/src/context.hpp +12 -14
- data/ext/libsass/src/cssize.cpp +200 -228
- data/ext/libsass/src/cssize.hpp +49 -49
- data/ext/libsass/src/debugger.hpp +260 -241
- data/ext/libsass/src/emitter.cpp +6 -6
- data/ext/libsass/src/emitter.hpp +7 -7
- data/ext/libsass/src/environment.cpp +2 -2
- data/ext/libsass/src/environment.hpp +0 -2
- data/ext/libsass/src/error_handling.cpp +5 -5
- data/ext/libsass/src/error_handling.hpp +12 -12
- data/ext/libsass/src/eval.cpp +412 -401
- data/ext/libsass/src/eval.hpp +61 -62
- data/ext/libsass/src/expand.cpp +223 -204
- data/ext/libsass/src/expand.hpp +42 -42
- data/ext/libsass/src/extend.cpp +198 -201
- data/ext/libsass/src/extend.hpp +12 -14
- data/ext/libsass/src/file.hpp +4 -5
- data/ext/libsass/src/functions.cpp +413 -418
- data/ext/libsass/src/functions.hpp +7 -10
- data/ext/libsass/src/inspect.cpp +115 -109
- data/ext/libsass/src/inspect.hpp +69 -69
- data/ext/libsass/src/listize.cpp +31 -33
- data/ext/libsass/src/listize.hpp +8 -10
- data/ext/libsass/src/memory/SharedPtr.cpp +116 -0
- data/ext/libsass/src/memory/SharedPtr.hpp +202 -0
- data/ext/libsass/src/node.cpp +45 -43
- data/ext/libsass/src/node.hpp +15 -15
- data/ext/libsass/src/operation.hpp +136 -136
- data/ext/libsass/src/output.cpp +48 -49
- data/ext/libsass/src/output.hpp +14 -14
- data/ext/libsass/src/parser.cpp +530 -554
- data/ext/libsass/src/parser.hpp +91 -96
- data/ext/libsass/src/prelexer.cpp +13 -10
- data/ext/libsass/src/remove_placeholders.cpp +25 -21
- data/ext/libsass/src/remove_placeholders.hpp +7 -7
- data/ext/libsass/src/sass2scss.cpp +2 -1
- data/ext/libsass/src/sass_context.cpp +125 -107
- data/ext/libsass/src/sass_context.hpp +1 -1
- data/ext/libsass/src/sass_util.hpp +5 -5
- data/ext/libsass/src/sass_values.cpp +27 -27
- data/ext/libsass/src/source_map.cpp +2 -2
- data/ext/libsass/src/source_map.hpp +2 -2
- data/ext/libsass/src/subset_map.cpp +57 -0
- data/ext/libsass/src/subset_map.hpp +8 -76
- data/ext/libsass/src/to_c.cpp +13 -13
- data/ext/libsass/src/to_c.hpp +14 -14
- data/ext/libsass/src/to_value.cpp +20 -20
- data/ext/libsass/src/to_value.hpp +20 -21
- data/ext/libsass/src/util.cpp +55 -88
- data/ext/libsass/src/util.hpp +9 -13
- data/ext/libsass/src/values.cpp +27 -26
- data/ext/libsass/src/values.hpp +2 -2
- data/ext/libsass/test/test_subset_map.cpp +69 -69
- data/ext/libsass/win/libsass.targets +3 -2
- data/ext/libsass/win/libsass.vcxproj.filters +9 -6
- data/lib/sassc/version.rb +1 -1
- data/sassc.gemspec +0 -1
- data/test/native_test.rb +1 -1
- metadata +7 -5
- data/ext/libsass/src/ast_factory.hpp +0 -92
- data/ext/libsass/src/memory_manager.cpp +0 -77
- data/ext/libsass/src/memory_manager.hpp +0 -48
@@ -6,53 +6,57 @@
|
|
6
6
|
|
7
7
|
namespace Sass {
|
8
8
|
|
9
|
-
typedef Environment<
|
9
|
+
typedef Environment<AST_Node_Obj> Env;
|
10
10
|
|
11
|
-
class CheckNesting : public Operation_CRTP<
|
11
|
+
class CheckNesting : public Operation_CRTP<Statement_Ptr, CheckNesting> {
|
12
12
|
|
13
|
-
std::vector<
|
14
|
-
|
15
|
-
|
13
|
+
std::vector<Statement_Ptr> parents;
|
14
|
+
Statement_Ptr parent;
|
15
|
+
Definition_Ptr current_mixin_definition;
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
|
17
|
+
Statement_Ptr fallback_impl(Statement_Ptr);
|
18
|
+
Statement_Ptr before(Statement_Ptr);
|
19
|
+
Statement_Ptr visit_children(Statement_Ptr);
|
20
20
|
|
21
21
|
public:
|
22
22
|
CheckNesting();
|
23
23
|
~CheckNesting() { }
|
24
24
|
|
25
|
-
|
26
|
-
|
25
|
+
Statement_Ptr operator()(Block_Ptr);
|
26
|
+
Statement_Ptr operator()(Definition_Ptr);
|
27
27
|
|
28
28
|
template <typename U>
|
29
|
-
|
30
|
-
|
29
|
+
Statement_Ptr fallback(U x) {
|
30
|
+
Statement_Ptr n = SASS_MEMORY_CAST_PTR(Statement, x);
|
31
|
+
if (this->should_visit(n)) {
|
32
|
+
return fallback_impl(n);
|
33
|
+
}
|
34
|
+
return NULL;
|
31
35
|
}
|
32
36
|
|
33
37
|
private:
|
34
|
-
void invalid_content_parent(
|
35
|
-
void invalid_charset_parent(
|
36
|
-
void invalid_extend_parent(
|
37
|
-
// void invalid_import_parent(
|
38
|
-
void invalid_mixin_definition_parent(
|
39
|
-
void invalid_function_parent(
|
40
|
-
|
41
|
-
void invalid_function_child(
|
42
|
-
void invalid_prop_child(
|
43
|
-
void invalid_prop_parent(
|
44
|
-
void invalid_return_parent(
|
45
|
-
|
46
|
-
bool is_transparent_parent(
|
47
|
-
|
48
|
-
bool should_visit(
|
49
|
-
|
50
|
-
bool is_charset(
|
51
|
-
bool is_mixin(
|
52
|
-
bool is_function(
|
53
|
-
bool is_root_node(
|
54
|
-
bool is_at_root_node(
|
55
|
-
bool is_directive_node(
|
38
|
+
void invalid_content_parent(Statement_Ptr);
|
39
|
+
void invalid_charset_parent(Statement_Ptr);
|
40
|
+
void invalid_extend_parent(Statement_Ptr);
|
41
|
+
// void invalid_import_parent(Statement_Ptr);
|
42
|
+
void invalid_mixin_definition_parent(Statement_Ptr);
|
43
|
+
void invalid_function_parent(Statement_Ptr);
|
44
|
+
|
45
|
+
void invalid_function_child(Statement_Ptr);
|
46
|
+
void invalid_prop_child(Statement_Ptr);
|
47
|
+
void invalid_prop_parent(Statement_Ptr);
|
48
|
+
void invalid_return_parent(Statement_Ptr);
|
49
|
+
|
50
|
+
bool is_transparent_parent(Statement_Ptr, Statement_Ptr);
|
51
|
+
|
52
|
+
bool should_visit(Statement_Ptr);
|
53
|
+
|
54
|
+
bool is_charset(Statement_Ptr);
|
55
|
+
bool is_mixin(Statement_Ptr);
|
56
|
+
bool is_function(Statement_Ptr);
|
57
|
+
bool is_root_node(Statement_Ptr);
|
58
|
+
bool is_at_root_node(Statement_Ptr);
|
59
|
+
bool is_directive_node(Statement_Ptr);
|
56
60
|
};
|
57
61
|
|
58
62
|
}
|
@@ -452,7 +452,7 @@ namespace Sass {
|
|
452
452
|
{ 102 * 0x10000 + 51 * 0x100 + 153, ColorNames::rebeccapurple }
|
453
453
|
};
|
454
454
|
|
455
|
-
const std::map<const char*,
|
455
|
+
const std::map<const char*, Color_Ptr_Const, map_cmp_str> names_to_colors
|
456
456
|
{
|
457
457
|
{ ColorNames::aliceblue, &Colors::aliceblue },
|
458
458
|
{ ColorNames::antiquewhite, &Colors::antiquewhite },
|
@@ -605,7 +605,7 @@ namespace Sass {
|
|
605
605
|
{ ColorNames::transparent, &Colors::transparent }
|
606
606
|
};
|
607
607
|
|
608
|
-
|
608
|
+
Color_Ptr_Const name_to_color(const char* key)
|
609
609
|
{
|
610
610
|
auto p = names_to_colors.find(key);
|
611
611
|
if (p != names_to_colors.end()) {
|
@@ -614,7 +614,7 @@ namespace Sass {
|
|
614
614
|
return 0;
|
615
615
|
}
|
616
616
|
|
617
|
-
|
617
|
+
Color_Ptr_Const name_to_color(const std::string& key)
|
618
618
|
{
|
619
619
|
return name_to_color(key.c_str());
|
620
620
|
}
|
@@ -320,10 +320,10 @@ namespace Sass {
|
|
320
320
|
}
|
321
321
|
|
322
322
|
extern const std::map<const int, const char*> colors_to_names;
|
323
|
-
extern const std::map<const char*,
|
323
|
+
extern const std::map<const char*, Color_Ptr_Const, map_cmp_str> names_to_colors;
|
324
324
|
|
325
|
-
extern
|
326
|
-
extern
|
325
|
+
extern Color_Ptr_Const name_to_color(const char*);
|
326
|
+
extern Color_Ptr_Const name_to_color(const std::string&);
|
327
327
|
extern const char* color_to_name(const int);
|
328
328
|
extern const char* color_to_name(const Color&);
|
329
329
|
extern const char* color_to_name(const double);
|
data/ext/libsass/src/context.cpp
CHANGED
@@ -64,7 +64,6 @@ namespace Sass {
|
|
64
64
|
c_options(c_ctx),
|
65
65
|
entry_path(""),
|
66
66
|
head_imports(0),
|
67
|
-
mem(Memory_Manager()),
|
68
67
|
plugins(),
|
69
68
|
emitter(c_options),
|
70
69
|
|
@@ -146,6 +145,7 @@ namespace Sass {
|
|
146
145
|
}
|
147
146
|
// clear inner structures (vectors) and input source
|
148
147
|
resources.clear(); import_stack.clear();
|
148
|
+
subset_map.clear(), sheets.clear();
|
149
149
|
}
|
150
150
|
|
151
151
|
Data_Context::~Data_Context()
|
@@ -316,13 +316,13 @@ namespace Sass {
|
|
316
316
|
sass_import_take_source(import);
|
317
317
|
sass_import_take_srcmap(import);
|
318
318
|
// then parse the root block
|
319
|
-
|
319
|
+
Block_Obj root = p.parse();
|
320
320
|
// delete memory of current stack frame
|
321
321
|
sass_delete_import(import_stack.back());
|
322
322
|
// remove current stack frame
|
323
323
|
import_stack.pop_back();
|
324
324
|
// create key/value pair for ast node
|
325
|
-
std::pair<const std::string,
|
325
|
+
std::pair<const std::string, StyleSheet>
|
326
326
|
ast_pair(inc.abs_path, { res, root });
|
327
327
|
// register resulting resource
|
328
328
|
sheets.insert(ast_pair);
|
@@ -369,7 +369,7 @@ namespace Sass {
|
|
369
369
|
|
370
370
|
}
|
371
371
|
|
372
|
-
void Context::import_url (
|
372
|
+
void Context::import_url (Import_Ptr imp, std::string load_path, const std::string& ctx_path) {
|
373
373
|
|
374
374
|
ParserState pstate(imp->pstate());
|
375
375
|
std::string imp_path(unquote(load_path));
|
@@ -384,15 +384,15 @@ namespace Sass {
|
|
384
384
|
|
385
385
|
// add urls (protocol other than file) and urls without procotol to `urls` member
|
386
386
|
// ToDo: if ctx_path is already a file resource, we should not add it here?
|
387
|
-
if (imp->
|
388
|
-
imp->urls().push_back(SASS_MEMORY_NEW(
|
387
|
+
if (imp->import_queries() || protocol != "file" || imp_path.substr(0, 2) == "//") {
|
388
|
+
imp->urls().push_back(SASS_MEMORY_NEW(String_Quoted, imp->pstate(), load_path));
|
389
389
|
}
|
390
390
|
else if (imp_path.length() > 4 && imp_path.substr(imp_path.length() - 4, 4) == ".css") {
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
(
|
395
|
-
|
391
|
+
String_Constant_Ptr loc = SASS_MEMORY_NEW(String_Constant, pstate, unquote(load_path));
|
392
|
+
Argument_Obj loc_arg = SASS_MEMORY_NEW(Argument, pstate, loc);
|
393
|
+
Arguments_Obj loc_args = SASS_MEMORY_NEW(Arguments, pstate);
|
394
|
+
loc_args->append(&loc_arg);
|
395
|
+
Function_Call_Ptr new_url = SASS_MEMORY_NEW(Function_Call, pstate, "url", &loc_args);
|
396
396
|
imp->urls().push_back(new_url);
|
397
397
|
}
|
398
398
|
else {
|
@@ -408,7 +408,7 @@ namespace Sass {
|
|
408
408
|
|
409
409
|
|
410
410
|
// call custom importers on the given (unquoted) load_path and eventually parse the resulting style_sheet
|
411
|
-
bool Context::call_loader(const std::string& load_path, const char* ctx_path, ParserState& pstate,
|
411
|
+
bool Context::call_loader(const std::string& load_path, const char* ctx_path, ParserState& pstate, Import_Ptr imp, std::vector<Sass_Importer_Entry> importers, bool only_one)
|
412
412
|
{
|
413
413
|
// unique counter
|
414
414
|
size_t count = 0;
|
@@ -494,7 +494,7 @@ namespace Sass {
|
|
494
494
|
void register_c_functions(Context&, Env* env, Sass_Function_List);
|
495
495
|
void register_c_function(Context&, Env* env, Sass_Function_Entry);
|
496
496
|
|
497
|
-
char* Context::render(
|
497
|
+
char* Context::render(Block_Obj root)
|
498
498
|
{
|
499
499
|
// check for valid block
|
500
500
|
if (!root) return 0;
|
@@ -522,24 +522,24 @@ namespace Sass {
|
|
522
522
|
return sass_copy_c_string(emitted.buffer.c_str());
|
523
523
|
}
|
524
524
|
|
525
|
-
void Context::apply_custom_headers(
|
525
|
+
void Context::apply_custom_headers(Block_Obj root, const char* ctx_path, ParserState pstate)
|
526
526
|
{
|
527
527
|
// create a custom import to resolve headers
|
528
|
-
|
528
|
+
Import_Obj imp = SASS_MEMORY_NEW(Import, pstate);
|
529
529
|
// dispatch headers which will add custom functions
|
530
530
|
// custom headers are added to the import instance
|
531
|
-
call_headers(entry_path, ctx_path, pstate, imp);
|
531
|
+
call_headers(entry_path, ctx_path, pstate, &imp);
|
532
532
|
// increase head count to skip later
|
533
533
|
head_imports += resources.size() - 1;
|
534
534
|
// add the statement if we have urls
|
535
|
-
if (!imp->urls().empty()) (
|
535
|
+
if (!imp->urls().empty()) root->append(&imp);
|
536
536
|
// process all other resources (add Import_Stub nodes)
|
537
537
|
for (size_t i = 0, S = imp->incs().size(); i < S; ++i) {
|
538
|
-
(
|
538
|
+
root->append(SASS_MEMORY_NEW(Import_Stub, pstate, imp->incs()[i]));
|
539
539
|
}
|
540
540
|
}
|
541
541
|
|
542
|
-
|
542
|
+
Block_Obj File_Context::parse()
|
543
543
|
{
|
544
544
|
|
545
545
|
// check if entry file is given
|
@@ -562,7 +562,7 @@ namespace Sass {
|
|
562
562
|
}
|
563
563
|
|
564
564
|
// abort early if no content could be loaded (various reasons)
|
565
|
-
if (!contents) throw "File to read not found or unreadable: " + input_path;
|
565
|
+
if (!contents) throw std::runtime_error("File to read not found or unreadable: " + input_path);
|
566
566
|
|
567
567
|
// store entry path
|
568
568
|
entry_path = abs_path;
|
@@ -585,7 +585,7 @@ namespace Sass {
|
|
585
585
|
|
586
586
|
}
|
587
587
|
|
588
|
-
|
588
|
+
Block_Obj Data_Context::parse()
|
589
589
|
{
|
590
590
|
|
591
591
|
// check if source string is given
|
@@ -629,15 +629,14 @@ namespace Sass {
|
|
629
629
|
|
630
630
|
|
631
631
|
// parse root block from includes
|
632
|
-
|
632
|
+
Block_Obj Context::compile()
|
633
633
|
{
|
634
634
|
// abort if there is no data
|
635
635
|
if (resources.size() == 0) return 0;
|
636
636
|
// get root block from the first style sheet
|
637
|
-
|
637
|
+
Block_Obj root = sheets.at(entry_path).root;
|
638
638
|
// abort on invalid root
|
639
|
-
if (root
|
640
|
-
|
639
|
+
if (root.isNull()) return 0;
|
641
640
|
Env global; // create root environment
|
642
641
|
// register built-in functions on env
|
643
642
|
register_built_in_functions(*this, &global);
|
@@ -651,19 +650,19 @@ namespace Sass {
|
|
651
650
|
Cssize cssize(*this, &backtrace);
|
652
651
|
CheckNesting check_nesting;
|
653
652
|
// check nesting
|
654
|
-
|
653
|
+
check_nesting(&root);
|
655
654
|
// expand and eval the tree
|
656
|
-
root =
|
655
|
+
root = expand(&root);
|
657
656
|
// check nesting
|
658
|
-
|
657
|
+
check_nesting(&root);
|
659
658
|
// merge and bubble certain rules
|
660
|
-
root =
|
659
|
+
root = cssize(&root);
|
661
660
|
// should we extend something?
|
662
661
|
if (!subset_map.empty()) {
|
663
662
|
// create crtp visitor object
|
664
663
|
Extend extend(*this, subset_map);
|
665
664
|
// extend tree nodes
|
666
|
-
|
665
|
+
extend(&root);
|
667
666
|
}
|
668
667
|
|
669
668
|
// clean up by removing empty placeholders
|
@@ -719,14 +718,14 @@ namespace Sass {
|
|
719
718
|
|
720
719
|
void register_function(Context& ctx, Signature sig, Native_Function f, Env* env)
|
721
720
|
{
|
722
|
-
|
721
|
+
Definition_Ptr def = make_native_function(sig, f, ctx);
|
723
722
|
def->environment(env);
|
724
723
|
(*env)[def->name() + "[f]"] = def;
|
725
724
|
}
|
726
725
|
|
727
726
|
void register_function(Context& ctx, Signature sig, Native_Function f, size_t arity, Env* env)
|
728
727
|
{
|
729
|
-
|
728
|
+
Definition_Ptr def = make_native_function(sig, f, ctx);
|
730
729
|
std::stringstream ss;
|
731
730
|
ss << def->name() << "[f]" << arity;
|
732
731
|
def->environment(env);
|
@@ -735,7 +734,7 @@ namespace Sass {
|
|
735
734
|
|
736
735
|
void register_overload_stub(Context& ctx, std::string name, Env* env)
|
737
736
|
{
|
738
|
-
|
737
|
+
Definition_Ptr stub = SASS_MEMORY_NEW(Definition,
|
739
738
|
ParserState("[built-in function]"),
|
740
739
|
0,
|
741
740
|
name,
|
@@ -856,7 +855,7 @@ namespace Sass {
|
|
856
855
|
}
|
857
856
|
void register_c_function(Context& ctx, Env* env, Sass_Function_Entry descr)
|
858
857
|
{
|
859
|
-
|
858
|
+
Definition_Ptr def = make_c_function(descr, ctx);
|
860
859
|
def->environment(env);
|
861
860
|
(*env)[def->name() + "[f]"] = def;
|
862
861
|
}
|
data/ext/libsass/src/context.hpp
CHANGED
@@ -10,7 +10,6 @@
|
|
10
10
|
|
11
11
|
#include "ast_fwd_decl.hpp"
|
12
12
|
#include "kwd_arg_macros.hpp"
|
13
|
-
#include "memory_manager.hpp"
|
14
13
|
#include "ast_fwd_decl.hpp"
|
15
14
|
#include "sass_context.hpp"
|
16
15
|
#include "environment.hpp"
|
@@ -27,21 +26,20 @@ namespace Sass {
|
|
27
26
|
|
28
27
|
class Context {
|
29
28
|
public:
|
30
|
-
void import_url (
|
31
|
-
bool call_headers(const std::string& load_path, const char* ctx_path, ParserState& pstate,
|
29
|
+
void import_url (Import_Ptr imp, std::string load_path, const std::string& ctx_path);
|
30
|
+
bool call_headers(const std::string& load_path, const char* ctx_path, ParserState& pstate, Import_Ptr imp)
|
32
31
|
{ return call_loader(load_path, ctx_path, pstate, imp, c_headers, false); };
|
33
|
-
bool call_importers(const std::string& load_path, const char* ctx_path, ParserState& pstate,
|
32
|
+
bool call_importers(const std::string& load_path, const char* ctx_path, ParserState& pstate, Import_Ptr imp)
|
34
33
|
{ return call_loader(load_path, ctx_path, pstate, imp, c_importers, true); };
|
35
34
|
|
36
35
|
private:
|
37
|
-
bool call_loader(const std::string& load_path, const char* ctx_path, ParserState& pstate,
|
36
|
+
bool call_loader(const std::string& load_path, const char* ctx_path, ParserState& pstate, Import_Ptr imp, std::vector<Sass_Importer_Entry> importers, bool only_one = true);
|
38
37
|
|
39
38
|
public:
|
40
39
|
const std::string CWD;
|
41
40
|
struct Sass_Options& c_options;
|
42
41
|
std::string entry_path;
|
43
42
|
size_t head_imports;
|
44
|
-
Memory_Manager mem;
|
45
43
|
Plugins plugins;
|
46
44
|
Output emitter;
|
47
45
|
|
@@ -49,8 +47,8 @@ namespace Sass {
|
|
49
47
|
// these are guaranteed to be freed
|
50
48
|
std::vector<char*> strings;
|
51
49
|
std::vector<Resource> resources;
|
52
|
-
std::map<const std::string,
|
53
|
-
Subset_Map
|
50
|
+
std::map<const std::string, StyleSheet> sheets;
|
51
|
+
Subset_Map subset_map;
|
54
52
|
std::vector<Sass_Import_Entry> import_stack;
|
55
53
|
|
56
54
|
struct Sass_Compiler* c_compiler;
|
@@ -68,7 +66,7 @@ namespace Sass {
|
|
68
66
|
|
69
67
|
|
70
68
|
|
71
|
-
void apply_custom_headers(
|
69
|
+
void apply_custom_headers(Block_Obj root, const char* path, ParserState pstate);
|
72
70
|
|
73
71
|
std::vector<Sass_Importer_Entry> c_headers;
|
74
72
|
std::vector<Sass_Importer_Entry> c_importers;
|
@@ -87,9 +85,9 @@ namespace Sass {
|
|
87
85
|
|
88
86
|
virtual ~Context();
|
89
87
|
Context(struct Sass_Context&);
|
90
|
-
virtual
|
91
|
-
virtual
|
92
|
-
virtual char* render(
|
88
|
+
virtual Block_Obj parse() = 0;
|
89
|
+
virtual Block_Obj compile();
|
90
|
+
virtual char* render(Block_Obj root);
|
93
91
|
virtual char* render_srcmap();
|
94
92
|
|
95
93
|
void register_resource(const Include&, const Resource&, ParserState* = 0);
|
@@ -123,7 +121,7 @@ namespace Sass {
|
|
123
121
|
: Context(ctx)
|
124
122
|
{ }
|
125
123
|
virtual ~File_Context();
|
126
|
-
virtual
|
124
|
+
virtual Block_Obj parse();
|
127
125
|
};
|
128
126
|
|
129
127
|
class Data_Context : public Context {
|
@@ -139,7 +137,7 @@ namespace Sass {
|
|
139
137
|
ctx.srcmap_string = 0; // passed away
|
140
138
|
}
|
141
139
|
virtual ~Data_Context();
|
142
|
-
virtual
|
140
|
+
virtual Block_Obj parse();
|
143
141
|
};
|
144
142
|
|
145
143
|
}
|
data/ext/libsass/src/cssize.cpp
CHANGED
@@ -11,38 +11,38 @@ namespace Sass {
|
|
11
11
|
|
12
12
|
Cssize::Cssize(Context& ctx, Backtrace* bt)
|
13
13
|
: ctx(ctx),
|
14
|
-
block_stack(std::vector<
|
15
|
-
p_stack(std::vector<
|
14
|
+
block_stack(std::vector<Block_Ptr>()),
|
15
|
+
p_stack(std::vector<Statement_Ptr>()),
|
16
16
|
backtrace(bt)
|
17
17
|
{ }
|
18
18
|
|
19
|
-
|
19
|
+
Statement_Ptr Cssize::parent()
|
20
20
|
{
|
21
21
|
return p_stack.size() ? p_stack.back() : block_stack.front();
|
22
22
|
}
|
23
23
|
|
24
|
-
|
24
|
+
Block_Ptr Cssize::operator()(Block_Ptr b)
|
25
25
|
{
|
26
|
-
|
26
|
+
Block_Ptr bb = SASS_MEMORY_NEW(Block, b->pstate(), b->length(), b->is_root());
|
27
27
|
// bb->tabs(b->tabs());
|
28
28
|
block_stack.push_back(bb);
|
29
|
-
append_block(b);
|
29
|
+
append_block(b, bb);
|
30
30
|
block_stack.pop_back();
|
31
31
|
return bb;
|
32
32
|
}
|
33
33
|
|
34
|
-
|
34
|
+
Statement_Ptr Cssize::operator()(Trace_Ptr t)
|
35
35
|
{
|
36
36
|
return t->block()->perform(this);
|
37
37
|
}
|
38
38
|
|
39
|
-
|
39
|
+
Statement_Ptr Cssize::operator()(Declaration_Ptr d)
|
40
40
|
{
|
41
|
-
|
41
|
+
String_Obj property = SASS_MEMORY_CAST(String, d->property());
|
42
42
|
|
43
|
-
if (
|
44
|
-
|
45
|
-
property = SASS_MEMORY_NEW(
|
43
|
+
if (Declaration_Ptr dd = dynamic_cast<Declaration_Ptr>(parent())) {
|
44
|
+
String_Obj parent_property = SASS_MEMORY_CAST(String, dd->property());
|
45
|
+
property = SASS_MEMORY_NEW(String_Constant,
|
46
46
|
d->property()->pstate(),
|
47
47
|
parent_property->to_string() + "-" + property->to_string());
|
48
48
|
if (!dd->value()) {
|
@@ -50,7 +50,7 @@ namespace Sass {
|
|
50
50
|
}
|
51
51
|
}
|
52
52
|
|
53
|
-
|
53
|
+
Declaration_Obj dd = SASS_MEMORY_NEW(Declaration,
|
54
54
|
d->pstate(),
|
55
55
|
property,
|
56
56
|
d->value(),
|
@@ -58,99 +58,101 @@ namespace Sass {
|
|
58
58
|
dd->is_indented(d->is_indented());
|
59
59
|
dd->tabs(d->tabs());
|
60
60
|
|
61
|
-
p_stack.push_back(dd);
|
62
|
-
|
61
|
+
p_stack.push_back(&dd);
|
62
|
+
Block_Obj bb = d->block() ? operator()(&d->block()) : NULL;
|
63
63
|
p_stack.pop_back();
|
64
64
|
|
65
65
|
if (bb && bb->length()) {
|
66
66
|
if (dd->value() && !dd->value()->is_invisible()) {
|
67
|
-
bb->unshift(dd);
|
67
|
+
bb->unshift(&dd);
|
68
68
|
}
|
69
|
-
return bb;
|
69
|
+
return bb.detach();
|
70
70
|
}
|
71
71
|
else if (dd->value() && !dd->value()->is_invisible()) {
|
72
|
-
return dd;
|
72
|
+
return dd.detach();
|
73
73
|
}
|
74
74
|
|
75
75
|
return 0;
|
76
76
|
}
|
77
77
|
|
78
|
-
|
78
|
+
Statement_Ptr Cssize::operator()(Directive_Ptr r)
|
79
79
|
{
|
80
80
|
if (!r->block() || !r->block()->length()) return r;
|
81
81
|
|
82
82
|
if (parent()->statement_type() == Statement::RULESET)
|
83
83
|
{
|
84
|
-
return (r->is_keyframes()) ? SASS_MEMORY_NEW(
|
84
|
+
return (r->is_keyframes()) ? SASS_MEMORY_NEW(Bubble, r->pstate(), r) : bubble(r);
|
85
85
|
}
|
86
86
|
|
87
87
|
p_stack.push_back(r);
|
88
|
-
|
88
|
+
Directive_Obj rr = SASS_MEMORY_NEW(Directive,
|
89
89
|
r->pstate(),
|
90
90
|
r->keyword(),
|
91
91
|
r->selector(),
|
92
|
-
r->block() ?
|
92
|
+
r->block() ? operator()(&r->block()) : 0);
|
93
93
|
if (r->value()) rr->value(r->value());
|
94
94
|
p_stack.pop_back();
|
95
95
|
|
96
96
|
bool directive_exists = false;
|
97
97
|
size_t L = rr->block() ? rr->block()->length() : 0;
|
98
98
|
for (size_t i = 0; i < L && !directive_exists; ++i) {
|
99
|
-
|
99
|
+
Statement_Obj s = r->block()->at(i);
|
100
100
|
if (s->statement_type() != Statement::BUBBLE) directive_exists = true;
|
101
101
|
else {
|
102
|
-
|
102
|
+
Bubble_Obj s_obj = SASS_MEMORY_CAST(Bubble, s);
|
103
|
+
s = s_obj->node();
|
103
104
|
if (s->statement_type() != Statement::DIRECTIVE) directive_exists = false;
|
104
|
-
else directive_exists = (static_cast<
|
105
|
+
else directive_exists = (static_cast<Directive_Ptr>(&s)->keyword() == rr->keyword());
|
105
106
|
}
|
106
107
|
|
107
108
|
}
|
108
109
|
|
109
|
-
|
110
|
+
Block_Ptr result = SASS_MEMORY_NEW(Block, rr->pstate());
|
110
111
|
if (!(directive_exists || rr->is_keyframes()))
|
111
112
|
{
|
112
|
-
|
113
|
-
empty_node->block(SASS_MEMORY_NEW(
|
114
|
-
|
113
|
+
Directive_Ptr empty_node = SASS_MEMORY_CAST(Directive, rr);
|
114
|
+
empty_node->block(SASS_MEMORY_NEW(Block, rr->block() ? rr->block()->pstate() : rr->pstate()));
|
115
|
+
result->append(empty_node);
|
115
116
|
}
|
116
117
|
|
117
|
-
|
118
|
-
for (size_t i = 0, L = ss->
|
119
|
-
|
118
|
+
Block_Obj ss = debubble(rr->block() ? &rr->block() : SASS_MEMORY_NEW(Block, rr->pstate()), &rr);
|
119
|
+
for (size_t i = 0, L = ss->length(); i < L; ++i) {
|
120
|
+
result->append(ss->at(i));
|
120
121
|
}
|
121
122
|
|
122
123
|
return result;
|
123
124
|
}
|
124
125
|
|
125
|
-
|
126
|
+
Statement_Ptr Cssize::operator()(Keyframe_Rule_Ptr r)
|
126
127
|
{
|
127
128
|
if (!r->block() || !r->block()->length()) return r;
|
128
129
|
|
129
|
-
|
130
|
+
Keyframe_Rule_Obj rr = SASS_MEMORY_NEW(Keyframe_Rule,
|
130
131
|
r->pstate(),
|
131
|
-
|
132
|
-
if (r->
|
132
|
+
operator()(&r->block()));
|
133
|
+
if (&r->name()) rr->name(r->name());
|
133
134
|
|
134
|
-
return debubble(rr->block(), rr)
|
135
|
+
return debubble(&rr->block(), &rr);
|
135
136
|
}
|
136
137
|
|
137
|
-
|
138
|
+
Statement_Ptr Cssize::operator()(Ruleset_Ptr r)
|
138
139
|
{
|
139
140
|
p_stack.push_back(r);
|
140
141
|
// this can return a string schema
|
141
142
|
// string schema is not a statement!
|
142
143
|
// r->block() is already a string schema
|
143
144
|
// and that is comming from propset expand
|
144
|
-
|
145
|
+
Block_Ptr bb = operator()(&r->block());
|
145
146
|
// this should protect us (at least a bit) from our mess
|
146
147
|
// fixing this properly is harder that it should be ...
|
147
|
-
if (dynamic_cast<
|
148
|
+
if (dynamic_cast<Statement_Ptr>(bb) == NULL) {
|
148
149
|
error("Illegal nesting: Only properties may be nested beneath properties.", r->block()->pstate());
|
149
150
|
}
|
150
|
-
|
151
|
+
Ruleset_Obj rr = SASS_MEMORY_NEW(Ruleset,
|
151
152
|
r->pstate(),
|
152
153
|
r->selector(),
|
153
|
-
|
154
|
+
bb);
|
155
|
+
|
154
156
|
rr->is_root(r->is_root());
|
155
157
|
// rr->tabs(r->block()->tabs());
|
156
158
|
p_stack.pop_back();
|
@@ -159,68 +161,74 @@ namespace Sass {
|
|
159
161
|
error("Illegal nesting: Only properties may be nested beneath properties.", r->block()->pstate());
|
160
162
|
}
|
161
163
|
|
162
|
-
|
163
|
-
|
164
|
+
Block_Obj props = SASS_MEMORY_NEW(Block, rr->block()->pstate());
|
165
|
+
Block_Ptr rules = SASS_MEMORY_NEW(Block, rr->block()->pstate());
|
164
166
|
for (size_t i = 0, L = rr->block()->length(); i < L; i++)
|
165
167
|
{
|
166
|
-
|
167
|
-
if (bubblable(s))
|
168
|
-
if (!bubblable(s))
|
168
|
+
Statement_Ptr s = &rr->block()->at(i);
|
169
|
+
if (bubblable(s)) rules->append(s);
|
170
|
+
if (!bubblable(s)) props->append(s);
|
169
171
|
}
|
170
172
|
|
171
173
|
if (props->length())
|
172
174
|
{
|
173
|
-
|
174
|
-
|
175
|
+
Block_Obj bb = SASS_MEMORY_NEW(Block, rr->block()->pstate());
|
176
|
+
bb->concat(&props);
|
175
177
|
rr->block(bb);
|
176
178
|
|
177
179
|
for (size_t i = 0, L = rules->length(); i < L; i++)
|
178
180
|
{
|
179
|
-
|
181
|
+
Statement_Ptr stm = &rules->at(i);
|
182
|
+
stm->tabs(stm->tabs() + 1);
|
180
183
|
}
|
181
184
|
|
182
|
-
rules->unshift(rr);
|
185
|
+
rules->unshift(&rr);
|
183
186
|
}
|
184
187
|
|
185
|
-
|
188
|
+
Block_Ptr ptr = rules;
|
189
|
+
rules = debubble(rules);
|
190
|
+
void* lp = ptr;
|
191
|
+
void* rp = rules;
|
192
|
+
if (lp != rp) {
|
193
|
+
Block_Obj obj = ptr;
|
194
|
+
}
|
186
195
|
|
187
196
|
if (!(!rules->length() ||
|
188
|
-
!bubblable(rules->last()) ||
|
197
|
+
!bubblable(&rules->last()) ||
|
189
198
|
parent()->statement_type() == Statement::RULESET))
|
190
199
|
{
|
191
200
|
rules->last()->group_end(true);
|
192
201
|
}
|
193
|
-
|
194
202
|
return rules;
|
195
203
|
}
|
196
204
|
|
197
|
-
|
205
|
+
Statement_Ptr Cssize::operator()(Null_Ptr m)
|
198
206
|
{
|
199
207
|
return 0;
|
200
208
|
}
|
201
209
|
|
202
|
-
|
210
|
+
Statement_Ptr Cssize::operator()(Media_Block_Ptr m)
|
203
211
|
{
|
204
212
|
if (parent()->statement_type() == Statement::RULESET)
|
205
213
|
{ return bubble(m); }
|
206
214
|
|
207
215
|
if (parent()->statement_type() == Statement::MEDIA)
|
208
|
-
{ return SASS_MEMORY_NEW(
|
216
|
+
{ return SASS_MEMORY_NEW(Bubble, m->pstate(), m); }
|
209
217
|
|
210
218
|
p_stack.push_back(m);
|
211
219
|
|
212
|
-
|
220
|
+
Media_Block_Obj mm = SASS_MEMORY_NEW(Media_Block,
|
213
221
|
m->pstate(),
|
214
|
-
m->media_queries(),
|
215
|
-
|
222
|
+
&m->media_queries(),
|
223
|
+
operator()(&m->block()));
|
216
224
|
mm->tabs(m->tabs());
|
217
225
|
|
218
226
|
p_stack.pop_back();
|
219
227
|
|
220
|
-
return debubble(mm->block(), mm)
|
228
|
+
return debubble(&mm->block(), &mm);
|
221
229
|
}
|
222
230
|
|
223
|
-
|
231
|
+
Statement_Ptr Cssize::operator()(Supports_Block_Ptr m)
|
224
232
|
{
|
225
233
|
if (!m->block()->length())
|
226
234
|
{ return m; }
|
@@ -230,267 +238,231 @@ namespace Sass {
|
|
230
238
|
|
231
239
|
p_stack.push_back(m);
|
232
240
|
|
233
|
-
|
241
|
+
Supports_Block_Obj mm = SASS_MEMORY_NEW(Supports_Block,
|
234
242
|
m->pstate(),
|
235
|
-
m->condition(),
|
236
|
-
|
243
|
+
&m->condition(),
|
244
|
+
operator()(&m->block()));
|
237
245
|
mm->tabs(m->tabs());
|
238
246
|
|
239
247
|
p_stack.pop_back();
|
240
248
|
|
241
|
-
return debubble(mm->block(), mm)
|
249
|
+
return debubble(&mm->block(), &mm);
|
242
250
|
}
|
243
251
|
|
244
|
-
|
252
|
+
Statement_Ptr Cssize::operator()(At_Root_Block_Ptr m)
|
245
253
|
{
|
246
254
|
bool tmp = false;
|
247
255
|
for (size_t i = 0, L = p_stack.size(); i < L; ++i) {
|
248
|
-
|
256
|
+
Statement_Ptr s = p_stack[i];
|
249
257
|
tmp |= m->exclude_node(s);
|
250
258
|
}
|
251
259
|
|
252
260
|
if (!tmp)
|
253
261
|
{
|
254
|
-
|
262
|
+
Block_Ptr bb = operator()(&m->block());
|
255
263
|
for (size_t i = 0, L = bb->length(); i < L; ++i) {
|
256
264
|
// (bb->elements())[i]->tabs(m->tabs());
|
257
|
-
|
265
|
+
Statement_Obj stm = bb->at(i);
|
266
|
+
if (bubblable(&stm)) stm->tabs(stm->tabs() + m->tabs());
|
258
267
|
}
|
259
|
-
if (bb->length() && bubblable(bb->last())) bb->last()->group_end(m->group_end());
|
268
|
+
if (bb->length() && bubblable(&bb->last())) bb->last()->group_end(m->group_end());
|
260
269
|
return bb;
|
261
270
|
}
|
262
271
|
|
263
272
|
if (m->exclude_node(parent()))
|
264
273
|
{
|
265
|
-
return SASS_MEMORY_NEW(
|
274
|
+
return SASS_MEMORY_NEW(Bubble, m->pstate(), m);
|
266
275
|
}
|
267
276
|
|
268
277
|
return bubble(m);
|
269
278
|
}
|
270
279
|
|
271
|
-
|
280
|
+
Statement_Ptr Cssize::bubble(Directive_Ptr m)
|
272
281
|
{
|
273
|
-
|
274
|
-
|
282
|
+
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()));
|
275
284
|
new_rule->block(bb);
|
276
285
|
new_rule->tabs(this->parent()->tabs());
|
286
|
+
new_rule->block()->concat(&m->block());
|
277
287
|
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
}
|
282
|
-
|
283
|
-
Block* wrapper_block = SASS_MEMORY_NEW(ctx.mem, Block, m->block() ? m->block()->pstate() : m->pstate());
|
284
|
-
*wrapper_block << new_rule;
|
285
|
-
Directive* mm = SASS_MEMORY_NEW(ctx.mem, Directive,
|
288
|
+
Block_Obj wrapper_block = SASS_MEMORY_NEW(Block, m->block() ? m->block()->pstate() : m->pstate());
|
289
|
+
wrapper_block->append(&new_rule);
|
290
|
+
Directive_Obj mm = SASS_MEMORY_NEW(Directive,
|
286
291
|
m->pstate(),
|
287
292
|
m->keyword(),
|
288
293
|
m->selector(),
|
289
294
|
wrapper_block);
|
290
295
|
if (m->value()) mm->value(m->value());
|
291
296
|
|
292
|
-
|
297
|
+
Bubble_Ptr bubble = SASS_MEMORY_NEW(Bubble, mm->pstate(), &mm);
|
293
298
|
return bubble;
|
294
299
|
}
|
295
300
|
|
296
|
-
|
301
|
+
Statement_Ptr Cssize::bubble(At_Root_Block_Ptr m)
|
297
302
|
{
|
298
|
-
|
299
|
-
|
303
|
+
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()));
|
300
305
|
new_rule->block(bb);
|
301
306
|
new_rule->tabs(this->parent()->tabs());
|
307
|
+
new_rule->block()->concat(&m->block());
|
302
308
|
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
Block* wrapper_block = SASS_MEMORY_NEW(ctx.mem, Block, m->block()->pstate());
|
308
|
-
*wrapper_block << new_rule;
|
309
|
-
At_Root_Block* mm = SASS_MEMORY_NEW(ctx.mem, At_Root_Block,
|
309
|
+
Block_Ptr wrapper_block = SASS_MEMORY_NEW(Block, m->block()->pstate());
|
310
|
+
wrapper_block->append(&new_rule);
|
311
|
+
At_Root_Block_Ptr mm = SASS_MEMORY_NEW(At_Root_Block,
|
310
312
|
m->pstate(),
|
311
313
|
wrapper_block,
|
312
314
|
m->expression());
|
313
|
-
|
315
|
+
Bubble_Ptr bubble = SASS_MEMORY_NEW(Bubble, mm->pstate(), mm);
|
314
316
|
return bubble;
|
315
317
|
}
|
316
318
|
|
317
|
-
|
319
|
+
Statement_Ptr Cssize::bubble(Supports_Block_Ptr m)
|
318
320
|
{
|
319
|
-
|
321
|
+
Ruleset_Obj parent = static_cast<Ruleset_Ptr>(SASS_MEMORY_COPY(this->parent()));
|
320
322
|
|
321
|
-
|
322
|
-
|
323
|
+
Block_Ptr bb = SASS_MEMORY_NEW(Block, parent->block()->pstate());
|
324
|
+
Ruleset_Ptr new_rule = SASS_MEMORY_NEW(Ruleset,
|
323
325
|
parent->pstate(),
|
324
326
|
parent->selector(),
|
325
327
|
bb);
|
326
328
|
new_rule->tabs(parent->tabs());
|
329
|
+
new_rule->block()->concat(&m->block());
|
327
330
|
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
Block* wrapper_block = SASS_MEMORY_NEW(ctx.mem, Block, m->block()->pstate());
|
333
|
-
*wrapper_block << new_rule;
|
334
|
-
Supports_Block* mm = SASS_MEMORY_NEW(ctx.mem, Supports_Block,
|
331
|
+
Block_Ptr wrapper_block = SASS_MEMORY_NEW(Block, m->block()->pstate());
|
332
|
+
wrapper_block->append(new_rule);
|
333
|
+
Supports_Block_Ptr mm = SASS_MEMORY_NEW(Supports_Block,
|
335
334
|
m->pstate(),
|
336
|
-
m->condition(),
|
335
|
+
&m->condition(),
|
337
336
|
wrapper_block);
|
338
337
|
|
339
338
|
mm->tabs(m->tabs());
|
340
339
|
|
341
|
-
|
340
|
+
Bubble_Ptr bubble = SASS_MEMORY_NEW(Bubble, mm->pstate(), mm);
|
342
341
|
return bubble;
|
343
342
|
}
|
344
343
|
|
345
|
-
|
344
|
+
Statement_Ptr Cssize::bubble(Media_Block_Ptr m)
|
346
345
|
{
|
347
|
-
|
346
|
+
Ruleset_Obj parent = static_cast<Ruleset_Ptr>(SASS_MEMORY_COPY(this->parent()));
|
348
347
|
|
349
|
-
|
350
|
-
|
348
|
+
Block_Ptr bb = SASS_MEMORY_NEW(Block, parent->block()->pstate());
|
349
|
+
Ruleset_Ptr new_rule = SASS_MEMORY_NEW(Ruleset,
|
351
350
|
parent->pstate(),
|
352
351
|
parent->selector(),
|
353
352
|
bb);
|
354
353
|
new_rule->tabs(parent->tabs());
|
354
|
+
new_rule->block()->concat(&m->block());
|
355
355
|
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
Block* wrapper_block = SASS_MEMORY_NEW(ctx.mem, Block, m->block()->pstate());
|
361
|
-
*wrapper_block << new_rule;
|
362
|
-
Media_Block* mm = SASS_MEMORY_NEW(ctx.mem, Media_Block,
|
356
|
+
Block_Ptr wrapper_block = SASS_MEMORY_NEW(Block, m->block()->pstate());
|
357
|
+
wrapper_block->append(new_rule);
|
358
|
+
Media_Block_Obj mm = SASS_MEMORY_NEW(Media_Block,
|
363
359
|
m->pstate(),
|
364
|
-
m->media_queries(),
|
360
|
+
&m->media_queries(),
|
365
361
|
wrapper_block,
|
366
362
|
0);
|
367
363
|
|
368
364
|
mm->tabs(m->tabs());
|
369
365
|
|
370
|
-
|
371
|
-
|
372
|
-
return bubble;
|
366
|
+
return SASS_MEMORY_NEW(Bubble, mm->pstate(), &mm);
|
373
367
|
}
|
374
368
|
|
375
|
-
bool Cssize::bubblable(
|
369
|
+
bool Cssize::bubblable(Statement_Ptr s)
|
376
370
|
{
|
377
|
-
return s
|
371
|
+
return dynamic_cast<Ruleset_Ptr>(s) || s->bubbles();
|
378
372
|
}
|
379
373
|
|
380
|
-
|
374
|
+
Block_Ptr Cssize::flatten(Block_Ptr b)
|
381
375
|
{
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
*result << (*ss->block())[j];
|
376
|
+
Block_Ptr result = SASS_MEMORY_NEW(Block, b->pstate(), 0, b->is_root());
|
377
|
+
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)) {
|
380
|
+
Block_Obj bs = flatten(bb);
|
381
|
+
for (size_t j = 0, K = bs->length(); j < K; ++j) {
|
382
|
+
result->append(bs->at(j));
|
390
383
|
}
|
391
384
|
}
|
392
385
|
else {
|
393
|
-
|
386
|
+
result->append(ss);
|
394
387
|
}
|
395
388
|
}
|
396
389
|
return result;
|
397
390
|
}
|
398
391
|
|
399
|
-
std::vector<std::pair<bool,
|
392
|
+
std::vector<std::pair<bool, Block_Obj>> Cssize::slice_by_bubble(Block_Ptr b)
|
400
393
|
{
|
401
|
-
std::vector<std::pair<bool,
|
402
|
-
|
403
|
-
|
404
|
-
|
394
|
+
std::vector<std::pair<bool, Block_Obj>> results;
|
395
|
+
|
396
|
+
for (size_t i = 0, L = b->length(); i < L; ++i) {
|
397
|
+
Statement_Obj value = b->at(i);
|
398
|
+
bool key = dynamic_cast<Bubble_Ptr>(&value) != NULL;
|
405
399
|
|
406
400
|
if (!results.empty() && results.back().first == key)
|
407
401
|
{
|
408
|
-
|
409
|
-
|
402
|
+
Block_Obj wrapper_block = results.back().second;
|
403
|
+
wrapper_block->append(value);
|
410
404
|
}
|
411
405
|
else
|
412
406
|
{
|
413
|
-
|
414
|
-
|
407
|
+
Block_Ptr wrapper_block = SASS_MEMORY_NEW(Block, value->pstate());
|
408
|
+
wrapper_block->append(value);
|
415
409
|
results.push_back(std::make_pair(key, wrapper_block));
|
416
410
|
}
|
417
411
|
}
|
418
412
|
return results;
|
419
413
|
}
|
420
414
|
|
421
|
-
|
415
|
+
Block_Ptr Cssize::debubble(Block_Ptr children, Statement_Ptr parent)
|
422
416
|
{
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
return SASS_MEMORY_NEW(ctx.mem, Ruleset, *static_cast<Ruleset*>(s));
|
427
|
-
case Statement::MEDIA:
|
428
|
-
return SASS_MEMORY_NEW(ctx.mem, Media_Block, *static_cast<Media_Block*>(s));
|
429
|
-
case Statement::BUBBLE:
|
430
|
-
return SASS_MEMORY_NEW(ctx.mem, Bubble, *static_cast<Bubble*>(s));
|
431
|
-
case Statement::DIRECTIVE:
|
432
|
-
return SASS_MEMORY_NEW(ctx.mem, Directive, *static_cast<Directive*>(s));
|
433
|
-
case Statement::SUPPORTS:
|
434
|
-
return SASS_MEMORY_NEW(ctx.mem, Supports_Block, *static_cast<Supports_Block*>(s));
|
435
|
-
case Statement::ATROOT:
|
436
|
-
return SASS_MEMORY_NEW(ctx.mem, At_Root_Block, *static_cast<At_Root_Block*>(s));
|
437
|
-
case Statement::KEYFRAMERULE:
|
438
|
-
return SASS_MEMORY_NEW(ctx.mem, Keyframe_Rule, *static_cast<Keyframe_Rule*>(s));
|
439
|
-
case Statement::NONE:
|
440
|
-
default:
|
441
|
-
error("unknown internal error; please contact the LibSass maintainers", s->pstate(), backtrace);
|
442
|
-
String_Quoted* msg = SASS_MEMORY_NEW(ctx.mem, String_Quoted, ParserState("[WARN]"), std::string("`CSSize` can't clone ") + typeid(*s).name());
|
443
|
-
return SASS_MEMORY_NEW(ctx.mem, Warning, ParserState("[WARN]"), msg);
|
444
|
-
}
|
445
|
-
}
|
446
|
-
|
447
|
-
Statement* Cssize::debubble(Block* children, Statement* parent)
|
448
|
-
{
|
449
|
-
Has_Block* previous_parent = 0;
|
450
|
-
std::vector<std::pair<bool, Block*>> baz = slice_by_bubble(children);
|
451
|
-
Block* result = SASS_MEMORY_NEW(ctx.mem, Block, children->pstate());
|
417
|
+
Has_Block_Obj previous_parent = 0;
|
418
|
+
std::vector<std::pair<bool, Block_Obj>> baz = slice_by_bubble(children);
|
419
|
+
Block_Obj result = SASS_MEMORY_NEW(Block, children->pstate());
|
452
420
|
|
453
421
|
for (size_t i = 0, L = baz.size(); i < L; ++i) {
|
454
422
|
bool is_bubble = baz[i].first;
|
455
|
-
|
423
|
+
Block_Obj slice = baz[i].second;
|
456
424
|
|
457
425
|
if (!is_bubble) {
|
458
426
|
if (!parent) {
|
459
|
-
|
427
|
+
result->append(&slice);
|
460
428
|
}
|
461
429
|
else if (previous_parent) {
|
462
|
-
|
430
|
+
previous_parent->block()->concat(&slice);
|
463
431
|
}
|
464
432
|
else {
|
465
|
-
previous_parent = static_cast<
|
433
|
+
previous_parent = static_cast<Has_Block_Ptr>(SASS_MEMORY_COPY(parent));
|
466
434
|
previous_parent->block(slice);
|
467
435
|
previous_parent->tabs(parent->tabs());
|
468
436
|
|
469
|
-
|
470
|
-
|
471
|
-
*result << new_parent;
|
437
|
+
result->append(&previous_parent);
|
472
438
|
}
|
473
439
|
continue;
|
474
440
|
}
|
475
441
|
|
476
442
|
for (size_t j = 0, K = slice->length(); j < K; ++j)
|
477
443
|
{
|
478
|
-
|
479
|
-
|
480
|
-
|
444
|
+
Statement_Ptr ss = NULL;
|
445
|
+
Statement_Obj stm = slice->at(j);
|
446
|
+
// this has to go now here (too bad)
|
447
|
+
Bubble_Obj node = SASS_MEMORY_CAST(Bubble, stm);
|
448
|
+
Media_Block_Ptr m1 = NULL;
|
449
|
+
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());
|
481
452
|
if (!parent ||
|
482
453
|
parent->statement_type() != Statement::MEDIA ||
|
483
454
|
node->node()->statement_type() != Statement::MEDIA ||
|
484
|
-
|
455
|
+
(m1 && m2 && &m1->media_queries() == &m2->media_queries())
|
456
|
+
)
|
485
457
|
{
|
486
|
-
ss = node->node();
|
458
|
+
ss = &node->node();
|
487
459
|
}
|
488
460
|
else
|
489
461
|
{
|
490
|
-
|
462
|
+
List_Obj mq = merge_media_queries(static_cast<Media_Block_Ptr>(&node->node()), static_cast<Media_Block_Ptr>(parent));
|
491
463
|
if (!mq->length()) continue;
|
492
|
-
static_cast<
|
493
|
-
ss = node->node();
|
464
|
+
static_cast<Media_Block_Ptr>(&node->node())->media_queries(mq);
|
465
|
+
ss = &node->node();
|
494
466
|
}
|
495
467
|
|
496
468
|
if (!ss) continue;
|
@@ -500,69 +472,68 @@ namespace Sass {
|
|
500
472
|
|
501
473
|
if (!ss) continue;
|
502
474
|
|
503
|
-
|
504
|
-
children->
|
505
|
-
children->
|
506
|
-
children->
|
507
|
-
|
475
|
+
Block_Obj bb = SASS_MEMORY_NEW(Block,
|
476
|
+
children->pstate(),
|
477
|
+
children->length(),
|
478
|
+
children->is_root());
|
479
|
+
bb->append(ss->perform(this));
|
508
480
|
|
509
|
-
|
510
|
-
children->
|
511
|
-
children->
|
512
|
-
children->
|
481
|
+
Block_Obj wrapper_block = SASS_MEMORY_NEW(Block,
|
482
|
+
children->pstate(),
|
483
|
+
children->length(),
|
484
|
+
children->is_root());
|
513
485
|
|
514
|
-
|
515
|
-
|
486
|
+
Block_Ptr wrapper = flatten(&bb);
|
487
|
+
wrapper_block->append(wrapper);
|
516
488
|
|
517
|
-
if (wrapper->
|
518
|
-
previous_parent =
|
489
|
+
if (wrapper->length()) {
|
490
|
+
previous_parent = NULL;
|
519
491
|
}
|
520
492
|
|
521
493
|
if (wrapper_block) {
|
522
|
-
|
494
|
+
result->append(&wrapper_block);
|
523
495
|
}
|
524
496
|
}
|
525
497
|
}
|
526
498
|
|
527
|
-
return flatten(result);
|
499
|
+
return flatten(&result);
|
528
500
|
}
|
529
501
|
|
530
|
-
|
502
|
+
Statement_Ptr Cssize::fallback_impl(AST_Node_Ptr n)
|
531
503
|
{
|
532
|
-
return static_cast<
|
504
|
+
return static_cast<Statement_Ptr>(n);
|
533
505
|
}
|
534
506
|
|
535
|
-
void Cssize::append_block(
|
507
|
+
void Cssize::append_block(Block_Ptr b, Block_Ptr cur)
|
536
508
|
{
|
537
|
-
Block* current_block = block_stack.back();
|
538
|
-
|
539
509
|
for (size_t i = 0, L = b->length(); i < L; ++i) {
|
540
|
-
|
541
|
-
if (
|
542
|
-
for (size_t j = 0, K =
|
543
|
-
|
510
|
+
Statement_Obj ith = b->at(i)->perform(this);
|
511
|
+
if (Block_Ptr bb = SASS_MEMORY_CAST(Block, ith)) {
|
512
|
+
for (size_t j = 0, K = bb->length(); j < K; ++j) {
|
513
|
+
cur->append(bb->at(j));
|
544
514
|
}
|
545
515
|
}
|
546
516
|
else if (ith) {
|
547
|
-
|
517
|
+
cur->append(ith);
|
548
518
|
}
|
549
519
|
}
|
550
520
|
}
|
551
521
|
|
552
|
-
|
522
|
+
List_Ptr Cssize::merge_media_queries(Media_Block_Ptr m1, Media_Block_Ptr m2)
|
553
523
|
{
|
554
|
-
|
524
|
+
List_Ptr qq = SASS_MEMORY_NEW(List,
|
555
525
|
m1->media_queries()->pstate(),
|
556
526
|
m1->media_queries()->length(),
|
557
527
|
SASS_COMMA);
|
558
528
|
|
559
529
|
for (size_t i = 0, L = m1->media_queries()->length(); i < L; i++) {
|
560
530
|
for (size_t j = 0, K = m2->media_queries()->length(); j < K; j++) {
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
531
|
+
Expression_Obj l1 = m1->media_queries()->at(i);
|
532
|
+
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);
|
535
|
+
Media_Query_Ptr mq = merge_media_query(mq1, mq2);
|
536
|
+
if (mq) qq->append(mq);
|
566
537
|
}
|
567
538
|
}
|
568
539
|
|
@@ -570,16 +541,16 @@ namespace Sass {
|
|
570
541
|
}
|
571
542
|
|
572
543
|
|
573
|
-
|
544
|
+
Media_Query_Ptr Cssize::merge_media_query(Media_Query_Ptr mq1, Media_Query_Ptr mq2)
|
574
545
|
{
|
575
546
|
|
576
547
|
std::string type;
|
577
548
|
std::string mod;
|
578
549
|
|
579
550
|
std::string m1 = std::string(mq1->is_restricted() ? "only" : mq1->is_negated() ? "not" : "");
|
580
|
-
std::string t1 = mq1->media_type() ? mq1->media_type()->to_string(ctx.c_options) : "";
|
551
|
+
std::string t1 = &mq1->media_type() ? mq1->media_type()->to_string(ctx.c_options) : "";
|
581
552
|
std::string m2 = std::string(mq2->is_restricted() ? "only" : mq1->is_negated() ? "not" : "");
|
582
|
-
std::string t2 = mq2->media_type() ? mq2->media_type()->to_string(ctx.c_options) : "";
|
553
|
+
std::string t2 = &mq2->media_type() ? mq2->media_type()->to_string(ctx.c_options) : "";
|
583
554
|
|
584
555
|
|
585
556
|
if (t1.empty()) t1 = t2;
|
@@ -606,18 +577,19 @@ namespace Sass {
|
|
606
577
|
mod = m1.empty() ? m2 : m1;
|
607
578
|
}
|
608
579
|
|
609
|
-
|
580
|
+
Media_Query_Ptr mm = SASS_MEMORY_NEW(Media_Query,
|
610
581
|
|
611
582
|
mq1->pstate(), 0,
|
612
583
|
mq1->length() + mq2->length(), mod == "not", mod == "only"
|
613
584
|
);
|
614
585
|
|
615
586
|
if (!type.empty()) {
|
616
|
-
mm->media_type(SASS_MEMORY_NEW(
|
587
|
+
mm->media_type(SASS_MEMORY_NEW(String_Quoted, mq1->pstate(), type));
|
617
588
|
}
|
618
589
|
|
619
|
-
|
620
|
-
|
590
|
+
mm->concat(mq2);
|
591
|
+
mm->concat(mq1);
|
592
|
+
|
621
593
|
return mm;
|
622
594
|
}
|
623
595
|
}
|