sassc 2.0.1 → 2.1.0.pre1
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/.gitignore +1 -0
- data/.gitmodules +1 -1
- data/.travis.yml +7 -3
- data/CHANGELOG.md +3 -0
- data/CODE_OF_CONDUCT.md +1 -1
- data/README.md +1 -1
- data/Rakefile +23 -8
- data/ext/extconf.rb +39 -0
- data/ext/libsass/.gitignore +1 -0
- data/ext/libsass/GNUmakefile.am +23 -39
- data/ext/libsass/Makefile +56 -91
- data/ext/libsass/Makefile.conf +16 -2
- data/ext/libsass/configure.ac +8 -12
- data/ext/libsass/include/sass/base.h +1 -0
- data/ext/libsass/include/sass/context.h +1 -1
- data/ext/libsass/src/GNUmakefile.am +1 -5
- data/ext/libsass/src/ast.cpp +747 -2010
- data/ext/libsass/src/ast.hpp +239 -2383
- data/ext/libsass/src/{to_c.cpp → ast2c.cpp} +22 -16
- data/ext/libsass/src/ast2c.hpp +39 -0
- data/ext/libsass/src/ast_def_macros.hpp +62 -10
- data/ext/libsass/src/ast_fwd_decl.cpp +1 -0
- data/ext/libsass/src/ast_fwd_decl.hpp +43 -165
- data/ext/libsass/src/ast_sel_cmp.cpp +909 -0
- data/ext/libsass/src/ast_sel_unify.cpp +280 -0
- data/ext/libsass/src/ast_selectors.cpp +1475 -0
- data/ext/libsass/src/ast_selectors.hpp +568 -0
- data/ext/libsass/src/ast_supports.cpp +130 -0
- data/ext/libsass/src/ast_supports.hpp +121 -0
- data/ext/libsass/src/ast_values.cpp +967 -0
- data/ext/libsass/src/ast_values.hpp +489 -0
- data/ext/libsass/src/backtrace.cpp +4 -0
- data/ext/libsass/src/base64vlq.cpp +3 -0
- data/ext/libsass/src/bind.cpp +18 -17
- data/ext/libsass/src/bind.hpp +3 -1
- data/ext/libsass/src/c2ast.cpp +64 -0
- data/ext/libsass/src/c2ast.hpp +14 -0
- data/ext/libsass/src/cencode.c +2 -2
- data/ext/libsass/src/check_nesting.cpp +52 -56
- data/ext/libsass/src/check_nesting.hpp +35 -34
- data/ext/libsass/src/color_maps.cpp +156 -153
- data/ext/libsass/src/color_maps.hpp +152 -152
- data/ext/libsass/src/constants.cpp +15 -0
- data/ext/libsass/src/constants.hpp +13 -0
- data/ext/libsass/src/context.cpp +24 -14
- data/ext/libsass/src/context.hpp +6 -6
- data/ext/libsass/src/cssize.cpp +69 -71
- data/ext/libsass/src/cssize.hpp +50 -50
- data/ext/libsass/src/debugger.hpp +117 -110
- data/ext/libsass/src/emitter.cpp +13 -12
- data/ext/libsass/src/emitter.hpp +13 -9
- data/ext/libsass/src/environment.cpp +15 -1
- data/ext/libsass/src/environment.hpp +6 -0
- data/ext/libsass/src/error_handling.cpp +36 -59
- data/ext/libsass/src/error_handling.hpp +29 -16
- data/ext/libsass/src/eval.cpp +302 -323
- data/ext/libsass/src/eval.hpp +64 -55
- data/ext/libsass/src/expand.cpp +94 -88
- data/ext/libsass/src/expand.hpp +33 -37
- data/ext/libsass/src/extend.cpp +38 -36
- data/ext/libsass/src/extend.hpp +15 -15
- data/ext/libsass/src/file.cpp +34 -2
- data/ext/libsass/src/fn_colors.cpp +594 -0
- data/ext/libsass/src/fn_colors.hpp +85 -0
- data/ext/libsass/src/fn_lists.cpp +284 -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 +256 -0
- data/ext/libsass/src/fn_miscs.hpp +40 -0
- data/ext/libsass/src/fn_numbers.cpp +220 -0
- data/ext/libsass/src/fn_numbers.hpp +45 -0
- data/ext/libsass/src/fn_selectors.cpp +235 -0
- data/ext/libsass/src/fn_selectors.hpp +35 -0
- data/ext/libsass/src/fn_strings.cpp +254 -0
- data/ext/libsass/src/fn_strings.hpp +34 -0
- data/ext/libsass/src/fn_utils.cpp +156 -0
- data/ext/libsass/src/fn_utils.hpp +56 -0
- data/ext/libsass/src/inspect.cpp +101 -152
- data/ext/libsass/src/inspect.hpp +69 -73
- data/ext/libsass/src/json.cpp +2 -2
- data/ext/libsass/src/lexer.cpp +6 -3
- data/ext/libsass/src/listize.cpp +9 -11
- data/ext/libsass/src/listize.hpp +11 -7
- data/ext/libsass/src/memory/SharedPtr.cpp +2 -83
- data/ext/libsass/src/memory/SharedPtr.hpp +127 -143
- data/ext/libsass/src/node.cpp +13 -10
- data/ext/libsass/src/node.hpp +3 -3
- data/ext/libsass/src/operation.hpp +184 -144
- data/ext/libsass/src/operators.cpp +43 -17
- data/ext/libsass/src/operators.hpp +5 -5
- data/ext/libsass/src/output.cpp +21 -18
- data/ext/libsass/src/output.hpp +14 -21
- data/ext/libsass/src/parser.cpp +215 -183
- data/ext/libsass/src/parser.hpp +28 -24
- data/ext/libsass/src/plugins.cpp +5 -1
- data/ext/libsass/src/position.cpp +3 -0
- data/ext/libsass/src/prelexer.cpp +9 -3
- data/ext/libsass/src/prelexer.hpp +9 -9
- data/ext/libsass/src/remove_placeholders.cpp +14 -11
- data/ext/libsass/src/remove_placeholders.hpp +8 -9
- data/ext/libsass/src/sass.cpp +9 -3
- data/ext/libsass/src/sass.hpp +12 -9
- data/ext/libsass/src/sass2scss.cpp +45 -14
- data/ext/libsass/src/sass_context.cpp +18 -15
- data/ext/libsass/src/sass_functions.cpp +6 -3
- data/ext/libsass/src/sass_functions.hpp +1 -1
- data/ext/libsass/src/sass_util.cpp +3 -0
- data/ext/libsass/src/sass_values.cpp +21 -13
- data/ext/libsass/src/source_map.cpp +5 -2
- data/ext/libsass/src/source_map.hpp +2 -2
- data/ext/libsass/src/subset_map.cpp +4 -1
- data/ext/libsass/src/to_value.cpp +23 -21
- data/ext/libsass/src/to_value.hpp +18 -22
- data/ext/libsass/src/units.cpp +4 -0
- data/ext/libsass/src/units.hpp +1 -0
- data/ext/libsass/src/utf8/checked.h +12 -10
- data/ext/libsass/src/utf8/core.h +3 -0
- data/ext/libsass/src/utf8_string.cpp +3 -0
- data/ext/libsass/src/util.cpp +67 -75
- data/ext/libsass/src/util.hpp +64 -19
- data/ext/libsass/src/util_string.cpp +75 -0
- data/ext/libsass/src/util_string.hpp +19 -0
- data/ext/libsass/src/values.cpp +22 -13
- data/ext/libsass/src/values.hpp +2 -2
- data/ext/libsass/win/libsass.targets +30 -4
- data/ext/libsass/win/libsass.vcxproj.filters +82 -4
- data/lib/sassc.rb +24 -0
- data/lib/sassc/engine.rb +2 -2
- data/lib/sassc/native.rb +8 -1
- data/lib/sassc/version.rb +1 -1
- data/sassc.gemspec +19 -11
- data/test/engine_test.rb +26 -1
- data/test/native_test.rb +1 -1
- metadata +66 -72
- data/ext/Rakefile +0 -3
- data/ext/libsass/.github/CONTRIBUTING.md +0 -65
- data/ext/libsass/.github/ISSUE_TEMPLATE.md +0 -54
- data/ext/libsass/.travis.yml +0 -64
- data/ext/libsass/Readme.md +0 -104
- data/ext/libsass/SECURITY.md +0 -10
- data/ext/libsass/appveyor.yml +0 -91
- data/ext/libsass/docs/README.md +0 -20
- data/ext/libsass/docs/api-context-example.md +0 -45
- data/ext/libsass/docs/api-context-internal.md +0 -163
- data/ext/libsass/docs/api-context.md +0 -295
- data/ext/libsass/docs/api-doc.md +0 -215
- data/ext/libsass/docs/api-function-example.md +0 -67
- data/ext/libsass/docs/api-function-internal.md +0 -8
- data/ext/libsass/docs/api-function.md +0 -74
- data/ext/libsass/docs/api-importer-example.md +0 -112
- data/ext/libsass/docs/api-importer-internal.md +0 -20
- data/ext/libsass/docs/api-importer.md +0 -86
- data/ext/libsass/docs/api-value-example.md +0 -55
- data/ext/libsass/docs/api-value-internal.md +0 -76
- data/ext/libsass/docs/api-value.md +0 -154
- data/ext/libsass/docs/build-on-darwin.md +0 -27
- data/ext/libsass/docs/build-on-gentoo.md +0 -55
- data/ext/libsass/docs/build-on-windows.md +0 -139
- data/ext/libsass/docs/build-shared-library.md +0 -35
- data/ext/libsass/docs/build-with-autotools.md +0 -78
- data/ext/libsass/docs/build-with-makefiles.md +0 -68
- data/ext/libsass/docs/build-with-mingw.md +0 -107
- data/ext/libsass/docs/build-with-visual-studio.md +0 -90
- data/ext/libsass/docs/build.md +0 -97
- data/ext/libsass/docs/compatibility-plan.md +0 -48
- data/ext/libsass/docs/contributing.md +0 -17
- data/ext/libsass/docs/custom-functions-internal.md +0 -122
- data/ext/libsass/docs/dev-ast-memory.md +0 -223
- data/ext/libsass/docs/implementations.md +0 -56
- data/ext/libsass/docs/plugins.md +0 -47
- data/ext/libsass/docs/setup-environment.md +0 -68
- data/ext/libsass/docs/source-map-internals.md +0 -51
- data/ext/libsass/docs/trace.md +0 -26
- data/ext/libsass/docs/triage.md +0 -17
- data/ext/libsass/docs/unicode.md +0 -39
- data/ext/libsass/extconf.rb +0 -6
- data/ext/libsass/script/bootstrap +0 -13
- data/ext/libsass/script/branding +0 -10
- data/ext/libsass/script/ci-build-libsass +0 -134
- data/ext/libsass/script/ci-build-plugin +0 -62
- data/ext/libsass/script/ci-install-compiler +0 -6
- data/ext/libsass/script/ci-install-deps +0 -20
- data/ext/libsass/script/ci-report-coverage +0 -42
- data/ext/libsass/script/spec +0 -5
- data/ext/libsass/script/tap-driver +0 -652
- data/ext/libsass/script/tap-runner +0 -1
- data/ext/libsass/script/test-leaks.pl +0 -103
- data/ext/libsass/src/functions.cpp +0 -2234
- data/ext/libsass/src/functions.hpp +0 -198
- data/ext/libsass/src/to_c.hpp +0 -39
- data/ext/libsass/test/test_node.cpp +0 -94
- data/ext/libsass/test/test_paths.cpp +0 -28
- data/ext/libsass/test/test_selector_difference.cpp +0 -25
- data/ext/libsass/test/test_specificity.cpp +0 -25
- data/ext/libsass/test/test_subset_map.cpp +0 -472
- data/ext/libsass/test/test_superselector.cpp +0 -69
- data/ext/libsass/test/test_unification.cpp +0 -31
- data/lib/tasks/libsass.rb +0 -33
@@ -1,4 +1,7 @@
|
|
1
|
+
// sass.hpp must go before all system headers to get the
|
2
|
+
// __EXTENSIONS__ fix on Solaris.
|
1
3
|
#include "sass.hpp"
|
4
|
+
|
2
5
|
#include "constants.hpp"
|
3
6
|
|
4
7
|
namespace Sass {
|
@@ -18,6 +21,15 @@ namespace Sass {
|
|
18
21
|
extern const unsigned long Specificity_Pseudo = 1000;
|
19
22
|
extern const unsigned long Specificity_ID = 1000000;
|
20
23
|
|
24
|
+
extern const int UnificationOrder_Element = 1;
|
25
|
+
extern const int UnificationOrder_Id = 2;
|
26
|
+
extern const int UnificationOrder_Class = 2;
|
27
|
+
extern const int UnificationOrder_Attribute = 3;
|
28
|
+
extern const int UnificationOrder_PseudoClass = 4;
|
29
|
+
extern const int UnificationOrder_Wrapped = 5;
|
30
|
+
extern const int UnificationOrder_PseudoElement = 6;
|
31
|
+
extern const int UnificationOrder_Placeholder = 7;
|
32
|
+
|
21
33
|
// sass keywords
|
22
34
|
extern const char at_root_kwd[] = "@at-root";
|
23
35
|
extern const char import_kwd[] = "@import";
|
@@ -116,6 +128,9 @@ namespace Sass {
|
|
116
128
|
extern const char true_kwd[] = "true";
|
117
129
|
extern const char false_kwd[] = "false";
|
118
130
|
|
131
|
+
// definition keywords
|
132
|
+
extern const char using_kwd[] = "using";
|
133
|
+
|
119
134
|
// miscellaneous punctuation and delimiters
|
120
135
|
extern const char percent_str[] = "%";
|
121
136
|
extern const char empty_str[] = "";
|
@@ -18,6 +18,16 @@ namespace Sass {
|
|
18
18
|
extern const unsigned long Specificity_Pseudo;
|
19
19
|
extern const unsigned long Specificity_ID;
|
20
20
|
|
21
|
+
// Selector unification order;
|
22
|
+
extern const int UnificationOrder_Element;
|
23
|
+
extern const int UnificationOrder_Id;
|
24
|
+
extern const int UnificationOrder_Class;
|
25
|
+
extern const int UnificationOrder_Attribute;
|
26
|
+
extern const int UnificationOrder_PseudoClass;
|
27
|
+
extern const int UnificationOrder_Wrapped;
|
28
|
+
extern const int UnificationOrder_PseudoElement;
|
29
|
+
extern const int UnificationOrder_Placeholder;
|
30
|
+
|
21
31
|
// sass keywords
|
22
32
|
extern const char at_root_kwd[];
|
23
33
|
extern const char import_kwd[];
|
@@ -117,6 +127,9 @@ namespace Sass {
|
|
117
127
|
extern const char true_kwd[];
|
118
128
|
extern const char false_kwd[];
|
119
129
|
|
130
|
+
// definition keywords
|
131
|
+
extern const char using_kwd[];
|
132
|
+
|
120
133
|
// miscellaneous punctuation and delimiters
|
121
134
|
extern const char percent_str[];
|
122
135
|
extern const char empty_str[];
|
data/ext/libsass/src/context.cpp
CHANGED
@@ -1,4 +1,7 @@
|
|
1
|
+
// sass.hpp must go before all system headers to get the
|
2
|
+
// __EXTENSIONS__ fix on Solaris.
|
1
3
|
#include "sass.hpp"
|
4
|
+
|
2
5
|
#include <string>
|
3
6
|
#include <cstdlib>
|
4
7
|
#include <cstring>
|
@@ -23,12 +26,19 @@
|
|
23
26
|
#include "listize.hpp"
|
24
27
|
#include "extend.hpp"
|
25
28
|
#include "remove_placeholders.hpp"
|
26
|
-
#include "functions.hpp"
|
27
29
|
#include "sass_functions.hpp"
|
28
30
|
#include "backtrace.hpp"
|
29
31
|
#include "sass2scss.h"
|
30
32
|
#include "prelexer.hpp"
|
31
33
|
#include "emitter.hpp"
|
34
|
+
#include "fn_utils.hpp"
|
35
|
+
#include "fn_miscs.hpp"
|
36
|
+
#include "fn_maps.hpp"
|
37
|
+
#include "fn_lists.hpp"
|
38
|
+
#include "fn_colors.hpp"
|
39
|
+
#include "fn_numbers.hpp"
|
40
|
+
#include "fn_strings.hpp"
|
41
|
+
#include "fn_selectors.hpp"
|
32
42
|
|
33
43
|
namespace Sass {
|
34
44
|
using namespace Constants;
|
@@ -382,7 +392,7 @@ namespace Sass {
|
|
382
392
|
|
383
393
|
}
|
384
394
|
|
385
|
-
void Context::import_url (
|
395
|
+
void Context::import_url (Import* imp, std::string load_path, const std::string& ctx_path) {
|
386
396
|
|
387
397
|
ParserState pstate(imp->pstate());
|
388
398
|
std::string imp_path(unquote(load_path));
|
@@ -401,11 +411,11 @@ namespace Sass {
|
|
401
411
|
imp->urls().push_back(SASS_MEMORY_NEW(String_Quoted, imp->pstate(), load_path));
|
402
412
|
}
|
403
413
|
else if (imp_path.length() > 4 && imp_path.substr(imp_path.length() - 4, 4) == ".css") {
|
404
|
-
|
414
|
+
String_Constant* loc = SASS_MEMORY_NEW(String_Constant, pstate, unquote(load_path));
|
405
415
|
Argument_Obj loc_arg = SASS_MEMORY_NEW(Argument, pstate, loc);
|
406
416
|
Arguments_Obj loc_args = SASS_MEMORY_NEW(Arguments, pstate);
|
407
417
|
loc_args->append(loc_arg);
|
408
|
-
|
418
|
+
Function_Call* new_url = SASS_MEMORY_NEW(Function_Call, pstate, std::string("url"), loc_args);
|
409
419
|
imp->urls().push_back(new_url);
|
410
420
|
}
|
411
421
|
else {
|
@@ -421,7 +431,7 @@ namespace Sass {
|
|
421
431
|
|
422
432
|
|
423
433
|
// call custom importers on the given (unquoted) load_path and eventually parse the resulting style_sheet
|
424
|
-
bool Context::call_loader(const std::string& load_path, const char* ctx_path, ParserState& pstate,
|
434
|
+
bool Context::call_loader(const std::string& load_path, const char* ctx_path, ParserState& pstate, Import* imp, std::vector<Sass_Importer_Entry> importers, bool only_one)
|
425
435
|
{
|
426
436
|
// unique counter
|
427
437
|
size_t count = 0;
|
@@ -556,7 +566,7 @@ namespace Sass {
|
|
556
566
|
{
|
557
567
|
|
558
568
|
// check if entry file is given
|
559
|
-
if (input_path.empty()) return
|
569
|
+
if (input_path.empty()) return {};
|
560
570
|
|
561
571
|
// create absolute path from input filename
|
562
572
|
// ToDo: this should be resolved via custom importers
|
@@ -602,7 +612,7 @@ namespace Sass {
|
|
602
612
|
{
|
603
613
|
|
604
614
|
// check if source string is given
|
605
|
-
if (!source_c_str) return
|
615
|
+
if (!source_c_str) return {};
|
606
616
|
|
607
617
|
// convert indented sass syntax
|
608
618
|
if(c_options.is_indented_syntax_src) {
|
@@ -645,11 +655,11 @@ namespace Sass {
|
|
645
655
|
Block_Obj Context::compile()
|
646
656
|
{
|
647
657
|
// abort if there is no data
|
648
|
-
if (resources.size() == 0) return
|
658
|
+
if (resources.size() == 0) return {};
|
649
659
|
// get root block from the first style sheet
|
650
660
|
Block_Obj root = sheets.at(entry_path).root;
|
651
661
|
// abort on invalid root
|
652
|
-
if (root.isNull()) return
|
662
|
+
if (root.isNull()) return {};
|
653
663
|
Env global; // create root environment
|
654
664
|
// register built-in functions on env
|
655
665
|
register_built_in_functions(*this, &global);
|
@@ -732,14 +742,14 @@ namespace Sass {
|
|
732
742
|
|
733
743
|
void register_function(Context& ctx, Signature sig, Native_Function f, Env* env)
|
734
744
|
{
|
735
|
-
|
745
|
+
Definition* def = make_native_function(sig, f, ctx);
|
736
746
|
def->environment(env);
|
737
747
|
(*env)[def->name() + "[f]"] = def;
|
738
748
|
}
|
739
749
|
|
740
750
|
void register_function(Context& ctx, Signature sig, Native_Function f, size_t arity, Env* env)
|
741
751
|
{
|
742
|
-
|
752
|
+
Definition* def = make_native_function(sig, f, ctx);
|
743
753
|
std::stringstream ss;
|
744
754
|
ss << def->name() << "[f]" << arity;
|
745
755
|
def->environment(env);
|
@@ -748,11 +758,11 @@ namespace Sass {
|
|
748
758
|
|
749
759
|
void register_overload_stub(Context& ctx, std::string name, Env* env)
|
750
760
|
{
|
751
|
-
|
761
|
+
Definition* stub = SASS_MEMORY_NEW(Definition,
|
752
762
|
ParserState("[built-in function]"),
|
753
763
|
0,
|
754
764
|
name,
|
755
|
-
|
765
|
+
{},
|
756
766
|
0,
|
757
767
|
true);
|
758
768
|
(*env)[name + "[f]"] = stub;
|
@@ -872,7 +882,7 @@ namespace Sass {
|
|
872
882
|
}
|
873
883
|
void register_c_function(Context& ctx, Env* env, Sass_Function_Entry descr)
|
874
884
|
{
|
875
|
-
|
885
|
+
Definition* def = make_c_function(descr, ctx);
|
876
886
|
def->environment(env);
|
877
887
|
(*env)[def->name() + "[f]"] = def;
|
878
888
|
}
|
data/ext/libsass/src/context.hpp
CHANGED
@@ -27,14 +27,14 @@ namespace Sass {
|
|
27
27
|
|
28
28
|
class Context {
|
29
29
|
public:
|
30
|
-
void import_url (
|
31
|
-
bool call_headers(const std::string& load_path, const char* ctx_path, ParserState& pstate,
|
30
|
+
void import_url (Import* imp, std::string load_path, const std::string& ctx_path);
|
31
|
+
bool call_headers(const std::string& load_path, const char* ctx_path, ParserState& pstate, Import* imp)
|
32
32
|
{ 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,
|
33
|
+
bool call_importers(const std::string& load_path, const char* ctx_path, ParserState& pstate, Import* imp)
|
34
34
|
{ return call_loader(load_path, ctx_path, pstate, imp, c_importers, true); };
|
35
35
|
|
36
36
|
private:
|
37
|
-
bool call_loader(const std::string& load_path, const char* ctx_path, ParserState& pstate,
|
37
|
+
bool call_loader(const std::string& load_path, const char* ctx_path, ParserState& pstate, Import* imp, std::vector<Sass_Importer_Entry> importers, bool only_one = true);
|
38
38
|
|
39
39
|
public:
|
40
40
|
const std::string CWD;
|
@@ -46,14 +46,14 @@ namespace Sass {
|
|
46
46
|
|
47
47
|
// generic ast node garbage container
|
48
48
|
// used to avoid possible circular refs
|
49
|
-
|
49
|
+
CallStack ast_gc;
|
50
50
|
// resources add under our control
|
51
51
|
// these are guaranteed to be freed
|
52
52
|
std::vector<char*> strings;
|
53
53
|
std::vector<Resource> resources;
|
54
54
|
std::map<const std::string, StyleSheet> sheets;
|
55
55
|
Subset_Map subset_map;
|
56
|
-
|
56
|
+
ImporterStack import_stack;
|
57
57
|
std::vector<Sass_Callee> callee_stack;
|
58
58
|
std::vector<Backtrace> traces;
|
59
59
|
|
data/ext/libsass/src/cssize.cpp
CHANGED
@@ -1,4 +1,7 @@
|
|
1
|
+
// sass.hpp must go before all system headers to get the
|
2
|
+
// __EXTENSIONS__ fix on Solaris.
|
1
3
|
#include "sass.hpp"
|
4
|
+
|
2
5
|
#include <iostream>
|
3
6
|
#include <typeinfo>
|
4
7
|
#include <vector>
|
@@ -11,16 +14,16 @@ namespace Sass {
|
|
11
14
|
Cssize::Cssize(Context& ctx)
|
12
15
|
: ctx(ctx),
|
13
16
|
traces(ctx.traces),
|
14
|
-
block_stack(
|
15
|
-
p_stack(std::vector<
|
17
|
+
block_stack(BlockStack()),
|
18
|
+
p_stack(std::vector<Statement*>())
|
16
19
|
{ }
|
17
20
|
|
18
|
-
|
21
|
+
Statement* Cssize::parent()
|
19
22
|
{
|
20
23
|
return p_stack.size() ? p_stack.back() : block_stack.front();
|
21
24
|
}
|
22
25
|
|
23
|
-
|
26
|
+
Block* Cssize::operator()(Block* b)
|
24
27
|
{
|
25
28
|
Block_Obj bb = SASS_MEMORY_NEW(Block, b->pstate(), b->length(), b->is_root());
|
26
29
|
// bb->tabs(b->tabs());
|
@@ -30,7 +33,7 @@ namespace Sass {
|
|
30
33
|
return bb.detach();
|
31
34
|
}
|
32
35
|
|
33
|
-
|
36
|
+
Statement* Cssize::operator()(Trace* t)
|
34
37
|
{
|
35
38
|
traces.push_back(Backtrace(t->pstate()));
|
36
39
|
auto result = t->block()->perform(this);
|
@@ -38,11 +41,11 @@ namespace Sass {
|
|
38
41
|
return result;
|
39
42
|
}
|
40
43
|
|
41
|
-
|
44
|
+
Statement* Cssize::operator()(Declaration* d)
|
42
45
|
{
|
43
46
|
String_Obj property = Cast<String>(d->property());
|
44
47
|
|
45
|
-
if (
|
48
|
+
if (Declaration* dd = Cast<Declaration>(parent())) {
|
46
49
|
String_Obj parent_property = Cast<String>(dd->property());
|
47
50
|
property = SASS_MEMORY_NEW(String_Constant,
|
48
51
|
d->property()->pstate(),
|
@@ -78,7 +81,7 @@ namespace Sass {
|
|
78
81
|
return 0;
|
79
82
|
}
|
80
83
|
|
81
|
-
|
84
|
+
Statement* Cssize::operator()(Directive* r)
|
82
85
|
{
|
83
86
|
if (!r->block() || !r->block()->length()) return r;
|
84
87
|
|
@@ -110,10 +113,10 @@ namespace Sass {
|
|
110
113
|
|
111
114
|
}
|
112
115
|
|
113
|
-
|
116
|
+
Block* result = SASS_MEMORY_NEW(Block, rr->pstate());
|
114
117
|
if (!(directive_exists || rr->is_keyframes()))
|
115
118
|
{
|
116
|
-
|
119
|
+
Directive* empty_node = Cast<Directive>(rr);
|
117
120
|
empty_node->block(SASS_MEMORY_NEW(Block, rr->block() ? rr->block()->pstate() : rr->pstate()));
|
118
121
|
result->append(empty_node);
|
119
122
|
}
|
@@ -128,7 +131,7 @@ namespace Sass {
|
|
128
131
|
return result;
|
129
132
|
}
|
130
133
|
|
131
|
-
|
134
|
+
Statement* Cssize::operator()(Keyframe_Rule* r)
|
132
135
|
{
|
133
136
|
if (!r->block() || !r->block()->length()) return r;
|
134
137
|
|
@@ -140,14 +143,14 @@ namespace Sass {
|
|
140
143
|
return debubble(rr->block(), rr);
|
141
144
|
}
|
142
145
|
|
143
|
-
|
146
|
+
Statement* Cssize::operator()(Ruleset* r)
|
144
147
|
{
|
145
148
|
p_stack.push_back(r);
|
146
149
|
// this can return a string schema
|
147
150
|
// string schema is not a statement!
|
148
151
|
// r->block() is already a string schema
|
149
152
|
// and that is comming from propset expand
|
150
|
-
|
153
|
+
Block* bb = operator()(r->block());
|
151
154
|
// this should protect us (at least a bit) from our mess
|
152
155
|
// fixing this properly is harder that it should be ...
|
153
156
|
if (Cast<Statement>(bb) == NULL) {
|
@@ -167,10 +170,10 @@ namespace Sass {
|
|
167
170
|
}
|
168
171
|
|
169
172
|
Block_Obj props = SASS_MEMORY_NEW(Block, rr->block()->pstate());
|
170
|
-
|
173
|
+
Block* rules = SASS_MEMORY_NEW(Block, rr->block()->pstate());
|
171
174
|
for (size_t i = 0, L = rr->block()->length(); i < L; i++)
|
172
175
|
{
|
173
|
-
|
176
|
+
Statement* s = rr->block()->at(i);
|
174
177
|
if (bubblable(s)) rules->append(s);
|
175
178
|
if (!bubblable(s)) props->append(s);
|
176
179
|
}
|
@@ -183,14 +186,14 @@ namespace Sass {
|
|
183
186
|
|
184
187
|
for (size_t i = 0, L = rules->length(); i < L; i++)
|
185
188
|
{
|
186
|
-
|
189
|
+
Statement* stm = rules->at(i);
|
187
190
|
stm->tabs(stm->tabs() + 1);
|
188
191
|
}
|
189
192
|
|
190
193
|
rules->unshift(rr);
|
191
194
|
}
|
192
195
|
|
193
|
-
|
196
|
+
Block* ptr = rules;
|
194
197
|
rules = debubble(rules);
|
195
198
|
void* lp = ptr;
|
196
199
|
void* rp = rules;
|
@@ -207,12 +210,12 @@ namespace Sass {
|
|
207
210
|
return rules;
|
208
211
|
}
|
209
212
|
|
210
|
-
|
213
|
+
Statement* Cssize::operator()(Null* m)
|
211
214
|
{
|
212
215
|
return 0;
|
213
216
|
}
|
214
217
|
|
215
|
-
|
218
|
+
Statement* Cssize::operator()(Media_Block* m)
|
216
219
|
{
|
217
220
|
if (parent()->statement_type() == Statement::RULESET)
|
218
221
|
{ return bubble(m); }
|
@@ -233,7 +236,7 @@ namespace Sass {
|
|
233
236
|
return debubble(mm->block(), mm);
|
234
237
|
}
|
235
238
|
|
236
|
-
|
239
|
+
Statement* Cssize::operator()(Supports_Block* m)
|
237
240
|
{
|
238
241
|
if (!m->block()->length())
|
239
242
|
{ return m; }
|
@@ -254,17 +257,17 @@ namespace Sass {
|
|
254
257
|
return debubble(mm->block(), mm);
|
255
258
|
}
|
256
259
|
|
257
|
-
|
260
|
+
Statement* Cssize::operator()(At_Root_Block* m)
|
258
261
|
{
|
259
262
|
bool tmp = false;
|
260
263
|
for (size_t i = 0, L = p_stack.size(); i < L; ++i) {
|
261
|
-
|
264
|
+
Statement* s = p_stack[i];
|
262
265
|
tmp |= m->exclude_node(s);
|
263
266
|
}
|
264
267
|
|
265
268
|
if (!tmp && m->block())
|
266
269
|
{
|
267
|
-
|
270
|
+
Block* bb = operator()(m->block());
|
268
271
|
for (size_t i = 0, L = bb->length(); i < L; ++i) {
|
269
272
|
// (bb->elements())[i]->tabs(m->tabs());
|
270
273
|
Statement_Obj stm = bb->at(i);
|
@@ -282,9 +285,9 @@ namespace Sass {
|
|
282
285
|
return bubble(m);
|
283
286
|
}
|
284
287
|
|
285
|
-
|
288
|
+
Statement* Cssize::bubble(Directive* m)
|
286
289
|
{
|
287
|
-
|
290
|
+
Block* bb = SASS_MEMORY_NEW(Block, this->parent()->pstate());
|
288
291
|
Has_Block_Obj new_rule = Cast<Has_Block>(SASS_MEMORY_COPY(this->parent()));
|
289
292
|
new_rule->block(bb);
|
290
293
|
new_rule->tabs(this->parent()->tabs());
|
@@ -299,16 +302,16 @@ namespace Sass {
|
|
299
302
|
wrapper_block);
|
300
303
|
if (m->value()) mm->value(m->value());
|
301
304
|
|
302
|
-
|
305
|
+
Bubble* bubble = SASS_MEMORY_NEW(Bubble, mm->pstate(), mm);
|
303
306
|
return bubble;
|
304
307
|
}
|
305
308
|
|
306
|
-
|
309
|
+
Statement* Cssize::bubble(At_Root_Block* m)
|
307
310
|
{
|
308
311
|
if (!m || !m->block()) return NULL;
|
309
|
-
|
312
|
+
Block* bb = SASS_MEMORY_NEW(Block, this->parent()->pstate());
|
310
313
|
Has_Block_Obj new_rule = Cast<Has_Block>(SASS_MEMORY_COPY(this->parent()));
|
311
|
-
|
314
|
+
Block* wrapper_block = SASS_MEMORY_NEW(Block, m->block()->pstate());
|
312
315
|
if (new_rule) {
|
313
316
|
new_rule->block(bb);
|
314
317
|
new_rule->tabs(this->parent()->tabs());
|
@@ -316,52 +319,52 @@ namespace Sass {
|
|
316
319
|
wrapper_block->append(new_rule);
|
317
320
|
}
|
318
321
|
|
319
|
-
|
322
|
+
At_Root_Block* mm = SASS_MEMORY_NEW(At_Root_Block,
|
320
323
|
m->pstate(),
|
321
324
|
wrapper_block,
|
322
325
|
m->expression());
|
323
|
-
|
326
|
+
Bubble* bubble = SASS_MEMORY_NEW(Bubble, mm->pstate(), mm);
|
324
327
|
return bubble;
|
325
328
|
}
|
326
329
|
|
327
|
-
|
330
|
+
Statement* Cssize::bubble(Supports_Block* m)
|
328
331
|
{
|
329
332
|
Ruleset_Obj parent = Cast<Ruleset>(SASS_MEMORY_COPY(this->parent()));
|
330
333
|
|
331
|
-
|
332
|
-
|
334
|
+
Block* bb = SASS_MEMORY_NEW(Block, parent->block()->pstate());
|
335
|
+
Ruleset* new_rule = SASS_MEMORY_NEW(Ruleset,
|
333
336
|
parent->pstate(),
|
334
337
|
parent->selector(),
|
335
338
|
bb);
|
336
339
|
new_rule->tabs(parent->tabs());
|
337
340
|
new_rule->block()->concat(m->block());
|
338
341
|
|
339
|
-
|
342
|
+
Block* wrapper_block = SASS_MEMORY_NEW(Block, m->block()->pstate());
|
340
343
|
wrapper_block->append(new_rule);
|
341
|
-
|
344
|
+
Supports_Block* mm = SASS_MEMORY_NEW(Supports_Block,
|
342
345
|
m->pstate(),
|
343
346
|
m->condition(),
|
344
347
|
wrapper_block);
|
345
348
|
|
346
349
|
mm->tabs(m->tabs());
|
347
350
|
|
348
|
-
|
351
|
+
Bubble* bubble = SASS_MEMORY_NEW(Bubble, mm->pstate(), mm);
|
349
352
|
return bubble;
|
350
353
|
}
|
351
354
|
|
352
|
-
|
355
|
+
Statement* Cssize::bubble(Media_Block* m)
|
353
356
|
{
|
354
357
|
Ruleset_Obj parent = Cast<Ruleset>(SASS_MEMORY_COPY(this->parent()));
|
355
358
|
|
356
|
-
|
357
|
-
|
359
|
+
Block* bb = SASS_MEMORY_NEW(Block, parent->block()->pstate());
|
360
|
+
Ruleset* new_rule = SASS_MEMORY_NEW(Ruleset,
|
358
361
|
parent->pstate(),
|
359
362
|
parent->selector(),
|
360
363
|
bb);
|
361
364
|
new_rule->tabs(parent->tabs());
|
362
365
|
new_rule->block()->concat(m->block());
|
363
366
|
|
364
|
-
|
367
|
+
Block* wrapper_block = SASS_MEMORY_NEW(Block, m->block()->pstate());
|
365
368
|
wrapper_block->append(new_rule);
|
366
369
|
Media_Block_Obj mm = SASS_MEMORY_NEW(Media_Block,
|
367
370
|
m->pstate(),
|
@@ -373,17 +376,17 @@ namespace Sass {
|
|
373
376
|
return SASS_MEMORY_NEW(Bubble, mm->pstate(), mm);
|
374
377
|
}
|
375
378
|
|
376
|
-
bool Cssize::bubblable(
|
379
|
+
bool Cssize::bubblable(Statement* s)
|
377
380
|
{
|
378
381
|
return Cast<Ruleset>(s) || s->bubbles();
|
379
382
|
}
|
380
383
|
|
381
|
-
|
384
|
+
Block* Cssize::flatten(Block* b)
|
382
385
|
{
|
383
|
-
|
386
|
+
Block* result = SASS_MEMORY_NEW(Block, b->pstate(), 0, b->is_root());
|
384
387
|
for (size_t i = 0, L = b->length(); i < L; ++i) {
|
385
|
-
|
386
|
-
if (
|
388
|
+
Statement* ss = b->at(i);
|
389
|
+
if (Block* bb = Cast<Block>(ss)) {
|
387
390
|
Block_Obj bs = flatten(bb);
|
388
391
|
for (size_t j = 0, K = bs->length(); j < K; ++j) {
|
389
392
|
result->append(bs->at(j));
|
@@ -396,7 +399,7 @@ namespace Sass {
|
|
396
399
|
return result;
|
397
400
|
}
|
398
401
|
|
399
|
-
std::vector<std::pair<bool, Block_Obj>> Cssize::slice_by_bubble(
|
402
|
+
std::vector<std::pair<bool, Block_Obj>> Cssize::slice_by_bubble(Block* b)
|
400
403
|
{
|
401
404
|
std::vector<std::pair<bool, Block_Obj>> results;
|
402
405
|
|
@@ -411,7 +414,7 @@ namespace Sass {
|
|
411
414
|
}
|
412
415
|
else
|
413
416
|
{
|
414
|
-
|
417
|
+
Block* wrapper_block = SASS_MEMORY_NEW(Block, value->pstate());
|
415
418
|
wrapper_block->append(value);
|
416
419
|
results.push_back(std::make_pair(key, wrapper_block));
|
417
420
|
}
|
@@ -419,9 +422,9 @@ namespace Sass {
|
|
419
422
|
return results;
|
420
423
|
}
|
421
424
|
|
422
|
-
|
425
|
+
Block* Cssize::debubble(Block* children, Statement* parent)
|
423
426
|
{
|
424
|
-
Has_Block_Obj previous_parent
|
427
|
+
Has_Block_Obj previous_parent;
|
425
428
|
std::vector<std::pair<bool, Block_Obj>> baz = slice_by_bubble(children);
|
426
429
|
Block_Obj result = SASS_MEMORY_NEW(Block, children->pstate());
|
427
430
|
|
@@ -448,12 +451,12 @@ namespace Sass {
|
|
448
451
|
|
449
452
|
for (size_t j = 0, K = slice->length(); j < K; ++j)
|
450
453
|
{
|
451
|
-
|
454
|
+
Statement* ss;
|
452
455
|
Statement_Obj stm = slice->at(j);
|
453
456
|
// this has to go now here (too bad)
|
454
457
|
Bubble_Obj node = Cast<Bubble>(stm);
|
455
|
-
|
456
|
-
|
458
|
+
Media_Block* m1 = NULL;
|
459
|
+
Media_Block* m2 = NULL;
|
457
460
|
if (parent) m1 = Cast<Media_Block>(parent);
|
458
461
|
if (node) m2 = Cast<Media_Block>(node->node());
|
459
462
|
if (!parent ||
|
@@ -493,11 +496,11 @@ namespace Sass {
|
|
493
496
|
children->length(),
|
494
497
|
children->is_root());
|
495
498
|
|
496
|
-
|
499
|
+
Block* wrapper = flatten(bb);
|
497
500
|
wrapper_block->append(wrapper);
|
498
501
|
|
499
502
|
if (wrapper->length()) {
|
500
|
-
previous_parent =
|
503
|
+
previous_parent = {};
|
501
504
|
}
|
502
505
|
|
503
506
|
if (wrapper_block) {
|
@@ -509,16 +512,11 @@ namespace Sass {
|
|
509
512
|
return flatten(result);
|
510
513
|
}
|
511
514
|
|
512
|
-
|
513
|
-
{
|
514
|
-
return static_cast<Statement_Ptr>(n);
|
515
|
-
}
|
516
|
-
|
517
|
-
void Cssize::append_block(Block_Ptr b, Block_Ptr cur)
|
515
|
+
void Cssize::append_block(Block* b, Block* cur)
|
518
516
|
{
|
519
517
|
for (size_t i = 0, L = b->length(); i < L; ++i) {
|
520
518
|
Statement_Obj ith = b->at(i)->perform(this);
|
521
|
-
if (
|
519
|
+
if (Block* bb = Cast<Block>(ith)) {
|
522
520
|
for (size_t j = 0, K = bb->length(); j < K; ++j) {
|
523
521
|
cur->append(bb->at(j));
|
524
522
|
}
|
@@ -529,9 +527,9 @@ namespace Sass {
|
|
529
527
|
}
|
530
528
|
}
|
531
529
|
|
532
|
-
|
530
|
+
List* Cssize::merge_media_queries(Media_Block* m1, Media_Block* m2)
|
533
531
|
{
|
534
|
-
|
532
|
+
List* qq = SASS_MEMORY_NEW(List,
|
535
533
|
m1->media_queries()->pstate(),
|
536
534
|
m1->media_queries()->length(),
|
537
535
|
SASS_COMMA);
|
@@ -540,9 +538,9 @@ namespace Sass {
|
|
540
538
|
for (size_t j = 0, K = m2->media_queries()->length(); j < K; j++) {
|
541
539
|
Expression_Obj l1 = m1->media_queries()->at(i);
|
542
540
|
Expression_Obj l2 = m2->media_queries()->at(j);
|
543
|
-
|
544
|
-
|
545
|
-
|
541
|
+
Media_Query* mq1 = Cast<Media_Query>(l1);
|
542
|
+
Media_Query* mq2 = Cast<Media_Query>(l2);
|
543
|
+
Media_Query* mq = merge_media_query(mq1, mq2);
|
546
544
|
if (mq) qq->append(mq);
|
547
545
|
}
|
548
546
|
}
|
@@ -551,7 +549,7 @@ namespace Sass {
|
|
551
549
|
}
|
552
550
|
|
553
551
|
|
554
|
-
|
552
|
+
Media_Query* Cssize::merge_media_query(Media_Query* mq1, Media_Query* mq2)
|
555
553
|
{
|
556
554
|
|
557
555
|
std::string type;
|
@@ -559,7 +557,7 @@ namespace Sass {
|
|
559
557
|
|
560
558
|
std::string m1 = std::string(mq1->is_restricted() ? "only" : mq1->is_negated() ? "not" : "");
|
561
559
|
std::string t1 = mq1->media_type() ? mq1->media_type()->to_string(ctx.c_options) : "";
|
562
|
-
std::string m2 = std::string(mq2->is_restricted() ? "only" :
|
560
|
+
std::string m2 = std::string(mq2->is_restricted() ? "only" : mq2->is_negated() ? "not" : "");
|
563
561
|
std::string t2 = mq2->media_type() ? mq2->media_type()->to_string(ctx.c_options) : "";
|
564
562
|
|
565
563
|
|
@@ -587,9 +585,9 @@ namespace Sass {
|
|
587
585
|
mod = m1.empty() ? m2 : m1;
|
588
586
|
}
|
589
587
|
|
590
|
-
|
588
|
+
Media_Query* mm = SASS_MEMORY_NEW(Media_Query,
|
591
589
|
mq1->pstate(),
|
592
|
-
|
590
|
+
{},
|
593
591
|
mq1->length() + mq2->length(),
|
594
592
|
mod == "not",
|
595
593
|
mod == "only");
|