From 583eac12a7ac1056e932bebc84b93e780bf0bb1d Mon Sep 17 00:00:00 2001 From: Marcel Greter Date: Tue, 23 Jun 2015 22:52:03 +0200 Subject: [PATCH] Adds default CRTP visitor for `String_Quoted` --- inspect.cpp | 3 --- operation.hpp | 2 ++ output.cpp | 18 +++++++----------- to_c.cpp | 4 ++-- to_string.cpp | 5 +++++ 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/inspect.cpp b/inspect.cpp index 9d1faf59dd..203b57fd71 100644 --- a/inspect.cpp +++ b/inspect.cpp @@ -642,9 +642,6 @@ namespace Sass { void Inspect::operator()(String_Constant* s) { - if (String_Quoted* quoted = dynamic_cast(s)) { - return Inspect::operator()(quoted); - } append_token(s->value(), s); } diff --git a/operation.hpp b/operation.hpp index a3dd6b8636..c4b06aff60 100644 --- a/operation.hpp +++ b/operation.hpp @@ -54,6 +54,7 @@ namespace Sass { virtual T operator()(Color* x) = 0; virtual T operator()(Boolean* x) = 0; virtual T operator()(String_Schema* x) = 0; + virtual T operator()(String_Quoted* x) = 0; virtual T operator()(String_Constant* x) = 0; virtual T operator()(Supports_Query* x) = 0; virtual T operator()(Supports_Condition* x)= 0; @@ -129,6 +130,7 @@ namespace Sass { virtual T operator()(Boolean* x) { return static_cast(this)->fallback(x); } virtual T operator()(String_Schema* x) { return static_cast(this)->fallback(x); } virtual T operator()(String_Constant* x) { return static_cast(this)->fallback(x); } + virtual T operator()(String_Quoted* x) { return static_cast(this)->fallback(x); } virtual T operator()(Supports_Query* x) { return static_cast(this)->fallback(x); } virtual T operator()(Supports_Condition* x) { return static_cast(this)->fallback(x); } virtual T operator()(Media_Query* x) { return static_cast(this)->fallback(x); } diff --git a/output.cpp b/output.cpp index 1589d5e6e9..691f4601d1 100644 --- a/output.cpp +++ b/output.cpp @@ -381,18 +381,14 @@ namespace Sass { void Output::operator()(String_Constant* s) { - if (String_Quoted* quoted = dynamic_cast(s)) { - return Output::operator()(quoted); + string value(s->value()); + if (s->can_compress_whitespace() && output_style() == COMPRESSED) { + value.erase(std::remove_if(value.begin(), value.end(), ::isspace), value.end()); + } + if (!in_comment) { + append_token(string_to_output(value), s); } else { - string value(s->value()); - if (s->can_compress_whitespace() && output_style() == COMPRESSED) { - value.erase(std::remove_if(value.begin(), value.end(), ::isspace), value.end()); - } - if (!in_comment) { - append_token(string_to_output(value), s); - } else { - append_token(value, s); - } + append_token(value, s); } } diff --git a/to_c.cpp b/to_c.cpp index 869aa82182..3438f618b1 100644 --- a/to_c.cpp +++ b/to_c.cpp @@ -19,11 +19,11 @@ namespace Sass { { return sass_make_color(c->r(), c->g(), c->b(), c->a()); } Sass_Value* To_C::operator()(String_Constant* s) - { + { if (s->quote_mark()) { return sass_make_qstring(s->value().c_str()); } else { - return sass_make_string(s->value().c_str()); + return sass_make_string(s->value().c_str()); } } diff --git a/to_string.cpp b/to_string.cpp index cedd8f4145..fde1fe5d5d 100644 --- a/to_string.cpp +++ b/to_string.cpp @@ -29,6 +29,11 @@ namespace Sass { return s->value(); } + inline string To_String::operator()(String_Quoted* s) + { + return s->value(); + } + inline string To_String::operator()(Null* n) { return ""; } }