Skip to content

Commit

Permalink
Remove obsolete stuff from CRTP implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
mgreter committed Jan 12, 2016
1 parent d8482ad commit db979ca
Show file tree
Hide file tree
Showing 11 changed files with 81 additions and 96 deletions.
4 changes: 1 addition & 3 deletions src/cssize.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ namespace Sass {

public:
Cssize(Context&, Backtrace*);
virtual ~Cssize() { }

using Operation<Statement*>::operator();
~Cssize() { }

Statement* operator()(Block*);
Statement* operator()(Ruleset*);
Expand Down
4 changes: 1 addition & 3 deletions src/eval.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,13 @@ namespace Sass {
Context& ctx;
Listize listize;
Eval(Expand& exp);
virtual ~Eval();
~Eval();

Env* environment();
Context& context();
Selector_List* selector();
Backtrace* backtrace();

using Operation<Expression*>::operator();

// for evaluating function bodies
Expression* operator()(Block*);
Expression* operator()(Assignment*);
Expand Down
4 changes: 1 addition & 3 deletions src/expand.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@ namespace Sass {

public:
Expand(Context&, Env*, Backtrace*);
virtual ~Expand() { }

using Operation<Statement*>::operator();
~Expand() { }

Statement* operator()(Block*);
Statement* operator()(Ruleset*);
Expand Down
4 changes: 1 addition & 3 deletions src/extend.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ namespace Sass {
static Node subweave(Node& one, Node& two, Context& ctx);
static Selector_List* extendSelectorList(Selector_List* pSelectorList, Context& ctx, ExtensionSubsetMap& subset_map, bool isReplace, bool& extendedSomething);
Extend(Context&, ExtensionSubsetMap&);
virtual ~Extend() { }

using Operation<void>::operator();
~Extend() { }

void operator()(Block*);
void operator()(Ruleset*);
Expand Down
4 changes: 1 addition & 3 deletions src/listize.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ namespace Sass {

public:
Listize(Context&);
virtual ~Listize() { }

using Operation<Expression*>::operator();
~Listize() { }

Expression* operator()(Selector_List*);
Expression* operator()(Complex_Selector*);
Expand Down
139 changes: 69 additions & 70 deletions src/operation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,84 +88,83 @@ namespace Sass {
template <typename T, typename D>
class Operation_CRTP : public Operation<T> {
public:
virtual T operator()(AST_Node* x) { return static_cast<D*>(this)->fallback(x); }
virtual ~Operation_CRTP() = 0;
D& impl() { return static_cast<D&>(*this); }
public:
T operator()(AST_Node* x) { return static_cast<D*>(this)->fallback(x); }
// statements
virtual T operator()(Block* x) { return static_cast<D*>(this)->fallback(x); }
virtual T operator()(Ruleset* x) { return static_cast<D*>(this)->fallback(x); }
virtual T operator()(Propset* x) { return static_cast<D*>(this)->fallback(x); }
virtual T operator()(Bubble* x) { return static_cast<D*>(this)->fallback(x); }
virtual T operator()(Supports_Block* x) { return static_cast<D*>(this)->fallback(x); }
virtual T operator()(Media_Block* x) { return static_cast<D*>(this)->fallback(x); }
virtual T operator()(At_Root_Block* x) { return static_cast<D*>(this)->fallback(x); }
virtual T operator()(At_Rule* x) { return static_cast<D*>(this)->fallback(x); }
virtual T operator()(Keyframe_Rule* x) { return static_cast<D*>(this)->fallback(x); }
virtual T operator()(Declaration* x) { return static_cast<D*>(this)->fallback(x); }
virtual T operator()(Assignment* x) { return static_cast<D*>(this)->fallback(x); }
virtual T operator()(Import* x) { return static_cast<D*>(this)->fallback(x); }
virtual T operator()(Import_Stub* x) { return static_cast<D*>(this)->fallback(x); }
virtual T operator()(Warning* x) { return static_cast<D*>(this)->fallback(x); }
virtual T operator()(Error* x) { return static_cast<D*>(this)->fallback(x); }
virtual T operator()(Debug* x) { return static_cast<D*>(this)->fallback(x); }
virtual T operator()(Comment* x) { return static_cast<D*>(this)->fallback(x); }
virtual T operator()(If* x) { return static_cast<D*>(this)->fallback(x); }
virtual T operator()(For* x) { return static_cast<D*>(this)->fallback(x); }
virtual T operator()(Each* x) { return static_cast<D*>(this)->fallback(x); }
virtual T operator()(While* x) { return static_cast<D*>(this)->fallback(x); }
virtual T operator()(Return* x) { return static_cast<D*>(this)->fallback(x); }
virtual T operator()(Content* x) { return static_cast<D*>(this)->fallback(x); }
virtual T operator()(Extension* x) { return static_cast<D*>(this)->fallback(x); }
virtual T operator()(Definition* x) { return static_cast<D*>(this)->fallback(x); }
virtual T operator()(Mixin_Call* x) { return static_cast<D*>(this)->fallback(x); }
T operator()(Block* x) { return static_cast<D*>(this)->fallback(x); }
T operator()(Ruleset* x) { return static_cast<D*>(this)->fallback(x); }
T operator()(Propset* x) { return static_cast<D*>(this)->fallback(x); }
T operator()(Bubble* x) { return static_cast<D*>(this)->fallback(x); }
T operator()(Supports_Block* x) { return static_cast<D*>(this)->fallback(x); }
T operator()(Media_Block* x) { return static_cast<D*>(this)->fallback(x); }
T operator()(At_Root_Block* x) { return static_cast<D*>(this)->fallback(x); }
T operator()(At_Rule* x) { return static_cast<D*>(this)->fallback(x); }
T operator()(Keyframe_Rule* x) { return static_cast<D*>(this)->fallback(x); }
T operator()(Declaration* x) { return static_cast<D*>(this)->fallback(x); }
T operator()(Assignment* x) { return static_cast<D*>(this)->fallback(x); }
T operator()(Import* x) { return static_cast<D*>(this)->fallback(x); }
T operator()(Import_Stub* x) { return static_cast<D*>(this)->fallback(x); }
T operator()(Warning* x) { return static_cast<D*>(this)->fallback(x); }
T operator()(Error* x) { return static_cast<D*>(this)->fallback(x); }
T operator()(Debug* x) { return static_cast<D*>(this)->fallback(x); }
T operator()(Comment* x) { return static_cast<D*>(this)->fallback(x); }
T operator()(If* x) { return static_cast<D*>(this)->fallback(x); }
T operator()(For* x) { return static_cast<D*>(this)->fallback(x); }
T operator()(Each* x) { return static_cast<D*>(this)->fallback(x); }
T operator()(While* x) { return static_cast<D*>(this)->fallback(x); }
T operator()(Return* x) { return static_cast<D*>(this)->fallback(x); }
T operator()(Content* x) { return static_cast<D*>(this)->fallback(x); }
T operator()(Extension* x) { return static_cast<D*>(this)->fallback(x); }
T operator()(Definition* x) { return static_cast<D*>(this)->fallback(x); }
T operator()(Mixin_Call* x) { return static_cast<D*>(this)->fallback(x); }
// expressions
virtual T operator()(List* x) { return static_cast<D*>(this)->fallback(x); }
virtual T operator()(Map* x) { return static_cast<D*>(this)->fallback(x); }
virtual T operator()(Binary_Expression* x) { return static_cast<D*>(this)->fallback(x); }
virtual T operator()(Unary_Expression* x) { return static_cast<D*>(this)->fallback(x); }
virtual T operator()(Function_Call* x) { return static_cast<D*>(this)->fallback(x); }
virtual T operator()(Function_Call_Schema* x) { return static_cast<D*>(this)->fallback(x); }
virtual T operator()(Custom_Warning* x) { return static_cast<D*>(this)->fallback(x); }
virtual T operator()(Custom_Error* x) { return static_cast<D*>(this)->fallback(x); }
virtual T operator()(Variable* x) { return static_cast<D*>(this)->fallback(x); }
virtual T operator()(Textual* x) { return static_cast<D*>(this)->fallback(x); }
virtual T operator()(Number* x) { return static_cast<D*>(this)->fallback(x); }
virtual T operator()(Color* x) { return static_cast<D*>(this)->fallback(x); }
virtual T operator()(Boolean* x) { return static_cast<D*>(this)->fallback(x); }
virtual T operator()(String_Schema* x) { return static_cast<D*>(this)->fallback(x); }
virtual T operator()(String_Constant* x) { return static_cast<D*>(this)->fallback(x); }
virtual T operator()(String_Quoted* x) { return static_cast<D*>(this)->fallback(x); }
virtual T operator()(Supports_Condition* x) { return static_cast<D*>(this)->fallback(x); }
virtual T operator()(Supports_Operator* x) { return static_cast<D*>(this)->fallback(x); }
virtual T operator()(Supports_Negation* x) { return static_cast<D*>(this)->fallback(x); }
virtual T operator()(Supports_Declaration* x) { return static_cast<D*>(this)->fallback(x); }
virtual T operator()(Supports_Interpolation* x) { return static_cast<D*>(this)->fallback(x); }
virtual T operator()(Media_Query* x) { return static_cast<D*>(this)->fallback(x); }
virtual T operator()(Media_Query_Expression* x) { return static_cast<D*>(this)->fallback(x); }
virtual T operator()(At_Root_Expression* x) { return static_cast<D*>(this)->fallback(x); }
virtual T operator()(Null* x) { return static_cast<D*>(this)->fallback(x); }
virtual T operator()(Parent_Selector* x) { return static_cast<D*>(this)->fallback(x); }
T operator()(List* x) { return static_cast<D*>(this)->fallback(x); }
T operator()(Map* x) { return static_cast<D*>(this)->fallback(x); }
T operator()(Binary_Expression* x) { return static_cast<D*>(this)->fallback(x); }
T operator()(Unary_Expression* x) { return static_cast<D*>(this)->fallback(x); }
T operator()(Function_Call* x) { return static_cast<D*>(this)->fallback(x); }
T operator()(Function_Call_Schema* x) { return static_cast<D*>(this)->fallback(x); }
T operator()(Custom_Warning* x) { return static_cast<D*>(this)->fallback(x); }
T operator()(Custom_Error* x) { return static_cast<D*>(this)->fallback(x); }
T operator()(Variable* x) { return static_cast<D*>(this)->fallback(x); }
T operator()(Textual* x) { return static_cast<D*>(this)->fallback(x); }
T operator()(Number* x) { return static_cast<D*>(this)->fallback(x); }
T operator()(Color* x) { return static_cast<D*>(this)->fallback(x); }
T operator()(Boolean* x) { return static_cast<D*>(this)->fallback(x); }
T operator()(String_Schema* x) { return static_cast<D*>(this)->fallback(x); }
T operator()(String_Constant* x) { return static_cast<D*>(this)->fallback(x); }
T operator()(String_Quoted* x) { return static_cast<D*>(this)->fallback(x); }
T operator()(Supports_Condition* x) { return static_cast<D*>(this)->fallback(x); }
T operator()(Supports_Operator* x) { return static_cast<D*>(this)->fallback(x); }
T operator()(Supports_Negation* x) { return static_cast<D*>(this)->fallback(x); }
T operator()(Supports_Declaration* x) { return static_cast<D*>(this)->fallback(x); }
T operator()(Supports_Interpolation* x) { return static_cast<D*>(this)->fallback(x); }
T operator()(Media_Query* x) { return static_cast<D*>(this)->fallback(x); }
T operator()(Media_Query_Expression* x) { return static_cast<D*>(this)->fallback(x); }
T operator()(At_Root_Expression* x) { return static_cast<D*>(this)->fallback(x); }
T operator()(Null* x) { return static_cast<D*>(this)->fallback(x); }
T operator()(Parent_Selector* x) { return static_cast<D*>(this)->fallback(x); }
// parameters and arguments
virtual T operator()(Parameter* x) { return static_cast<D*>(this)->fallback(x); }
virtual T operator()(Parameters* x) { return static_cast<D*>(this)->fallback(x); }
virtual T operator()(Argument* x) { return static_cast<D*>(this)->fallback(x); }
virtual T operator()(Arguments* x) { return static_cast<D*>(this)->fallback(x); }
T operator()(Parameter* x) { return static_cast<D*>(this)->fallback(x); }
T operator()(Parameters* x) { return static_cast<D*>(this)->fallback(x); }
T operator()(Argument* x) { return static_cast<D*>(this)->fallback(x); }
T operator()(Arguments* x) { return static_cast<D*>(this)->fallback(x); }
// selectors
virtual T operator()(Selector_Schema* x) { return static_cast<D*>(this)->fallback(x); }
virtual T operator()(Selector_Placeholder* x) { return static_cast<D*>(this)->fallback(x); }
virtual T operator()(Type_Selector* x) { return static_cast<D*>(this)->fallback(x); }
virtual T operator()(Selector_Qualifier* x) { return static_cast<D*>(this)->fallback(x); }
virtual T operator()(Attribute_Selector* x) { return static_cast<D*>(this)->fallback(x); }
virtual T operator()(Pseudo_Selector* x) { return static_cast<D*>(this)->fallback(x); }
virtual T operator()(Wrapped_Selector* x) { return static_cast<D*>(this)->fallback(x); }
virtual T operator()(Compound_Selector* x) { return static_cast<D*>(this)->fallback(x); }
virtual T operator()(Complex_Selector* x) { return static_cast<D*>(this)->fallback(x); }
virtual T operator()(Selector_List* x) { return static_cast<D*>(this)->fallback(x); }
T operator()(Selector_Schema* x) { return static_cast<D*>(this)->fallback(x); }
T operator()(Selector_Placeholder* x) { return static_cast<D*>(this)->fallback(x); }
T operator()(Type_Selector* x) { return static_cast<D*>(this)->fallback(x); }
T operator()(Selector_Qualifier* x) { return static_cast<D*>(this)->fallback(x); }
T operator()(Attribute_Selector* x) { return static_cast<D*>(this)->fallback(x); }
T operator()(Pseudo_Selector* x) { return static_cast<D*>(this)->fallback(x); }
T operator()(Wrapped_Selector* x) { return static_cast<D*>(this)->fallback(x); }
T operator()(Compound_Selector* x) { return static_cast<D*>(this)->fallback(x); }
T operator()(Complex_Selector* x) { return static_cast<D*>(this)->fallback(x); }
T operator()(Selector_List* x) { return static_cast<D*>(this)->fallback(x); }

template <typename U>
T fallback(U x) { return T(); }
};
template<typename T, typename D>
inline Operation_CRTP<T, D>::~Operation_CRTP() { }

}

Expand Down
3 changes: 2 additions & 1 deletion src/output.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,8 @@ namespace Sass {
}

if (b->is_invisible() || b->length() == 0) {
return append_string(" {}");
append_optional_space();
return append_string("{}");
}

append_scope_opener();
Expand Down
4 changes: 1 addition & 3 deletions src/remove_placeholders.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ namespace Sass {

public:
Remove_Placeholders(Context&);
virtual ~Remove_Placeholders() { }

using Operation<void>::operator();
~Remove_Placeholders() { }

void operator()(Block*);
void operator()(Ruleset*);
Expand Down
4 changes: 1 addition & 3 deletions src/to_c.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,13 @@
namespace Sass {

class To_C : public Operation_CRTP<union Sass_Value*, To_C> {
// import all the class-specific methods and override as desired
using Operation<union Sass_Value*>::operator();
// override this to define a catch-all
union Sass_Value* fallback_impl(AST_Node* n);

public:

To_C() { }
virtual ~To_C() { }
~To_C() { }

union Sass_Value* operator()(Boolean*);
union Sass_Value* operator()(Number*);
Expand Down
5 changes: 2 additions & 3 deletions src/to_string.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ namespace Sass {
class Null;

class To_String : public Operation_CRTP<std::string, To_String> {
// import all the class-specific methods and override as desired
using Operation<std::string>::operator();

// override this to define a catch-all
std::string fallback_impl(AST_Node* n);

Expand All @@ -23,7 +22,7 @@ namespace Sass {
public:

To_String(Context* ctx = 0, bool in_declaration = true, bool in_debug = false);
virtual ~To_String();
~To_String();

std::string operator()(Null* n);
std::string operator()(String_Schema*);
Expand Down
2 changes: 1 addition & 1 deletion src/to_value.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace Sass {
To_Value(Context& ctx, Memory_Manager& mem)
: ctx(ctx), mem(mem)
{ }
virtual ~To_Value() { }
~To_Value() { }
using Operation<Value*>::operator();

Value* operator()(Argument*);
Expand Down

0 comments on commit db979ca

Please sign in to comment.