Skip to content

Commit

Permalink
Merge pull request sass#1387 from mgreter/fix/pointer-compare
Browse files Browse the repository at this point in the history
Remove pointer compare functions
  • Loading branch information
mgreter committed Jul 26, 2015
2 parents 7014f55 + b4e24d7 commit d17ab21
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 103 deletions.
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,10 @@ ifeq ($(UNAME),Darwin)
endif

ifneq (MinGW,$(UNAME))
ifneq (FreeBSD,$(UNAME))
LDFLAGS += -ldl
LDLIBS += -ldl
endif
ifneq (FreeBSD,$(UNAME))
LDFLAGS += -ldl
LDLIBS += -ldl
endif
endif

ifneq ($(BUILD),shared)
Expand Down
110 changes: 25 additions & 85 deletions src/ast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1469,50 +1469,35 @@ namespace Sass {
return string();
}

bool Custom_Warning::operator== (const Expression* rhs) const
bool Custom_Warning::operator== (const Expression& rhs) const
{
if (const Custom_Warning* r = dynamic_cast<const Custom_Warning*>(rhs)) {
if (const Custom_Warning* r = dynamic_cast<const Custom_Warning*>(&rhs)) {
return message() == r->message();
}
return false;
}

bool Custom_Warning::operator== (const Expression& rhs) const
{
return operator==(&rhs);
}

bool Custom_Error::operator== (const Expression* rhs) const
bool Custom_Error::operator== (const Expression& rhs) const
{
if (const Custom_Error* r = dynamic_cast<const Custom_Error*>(rhs)) {
if (const Custom_Error* r = dynamic_cast<const Custom_Error*>(&rhs)) {
return message() == r->message();
}
return false;
}

bool Custom_Error::operator== (const Expression& rhs) const
{
return operator==(&rhs);
}

bool Number::operator== (const Expression* rhs) const
bool Number::operator== (const Expression& rhs) const
{
if (const Number* r = dynamic_cast<const Number*>(rhs)) {
if (const Number* r = dynamic_cast<const Number*>(&rhs)) {
return (value() == r->value()) &&
(numerator_units_ == r->numerator_units_) &&
(denominator_units_ == r->denominator_units_);
}
return false;
}

bool Number::operator== (const Expression& rhs) const
{
return operator==(&rhs);
}

bool Number::operator< (const Number* rhs) const
bool Number::operator< (const Number& rhs) const
{
Number tmp_r(*rhs);
Number tmp_r(rhs);
tmp_r.normalize(find_convertible_unit());
string l_unit(unit());
string r_unit(tmp_r.unit());
Expand All @@ -1522,44 +1507,29 @@ namespace Sass {
return value() < tmp_r.value();
}

bool Number::operator< (const Number& rhs) const
{
return operator<(&rhs);
}

bool String_Quoted::operator== (const Expression* rhs) const
bool String_Quoted::operator== (const Expression& rhs) const
{
if (const String_Quoted* qstr = dynamic_cast<const String_Quoted*>(rhs)) {
if (const String_Quoted* qstr = dynamic_cast<const String_Quoted*>(&rhs)) {
return (value() == qstr->value());
} else if (const String_Constant* cstr = dynamic_cast<const String_Constant*>(rhs)) {
} else if (const String_Constant* cstr = dynamic_cast<const String_Constant*>(&rhs)) {
return (value() == cstr->value());
}
return false;
}

bool String_Quoted::operator== (const Expression& rhs) const
{
return operator==(&rhs);
}

bool String_Constant::operator== (const Expression* rhs) const
bool String_Constant::operator== (const Expression& rhs) const
{
if (const String_Quoted* qstr = dynamic_cast<const String_Quoted*>(rhs)) {
if (const String_Quoted* qstr = dynamic_cast<const String_Quoted*>(&rhs)) {
return (value() == qstr->value());
} else if (const String_Constant* cstr = dynamic_cast<const String_Constant*>(rhs)) {
} else if (const String_Constant* cstr = dynamic_cast<const String_Constant*>(&rhs)) {
return (value() == cstr->value());
}
return false;
}

bool String_Constant::operator== (const Expression& rhs) const
{
return operator==(&rhs);
}

bool String_Schema::operator== (const Expression* rhs) const
bool String_Schema::operator== (const Expression& rhs) const
{
if (const String_Schema* r = dynamic_cast<const String_Schema*>(rhs)) {
if (const String_Schema* r = dynamic_cast<const String_Schema*>(&rhs)) {
if (length() != r->length()) return false;
for (size_t i = 0, L = length(); i < L; ++i) {
Expression* rv = (*r)[i];
Expand All @@ -1572,27 +1542,17 @@ namespace Sass {
return false;
}

bool String_Schema::operator== (const Expression& rhs) const
{
return operator==(&rhs);
}

bool Boolean::operator== (const Expression* rhs) const
bool Boolean::operator== (const Expression& rhs) const
{
if (const Boolean* r = dynamic_cast<const Boolean*>(rhs)) {
if (const Boolean* r = dynamic_cast<const Boolean*>(&rhs)) {
return (value() == r->value());
}
return false;
}

bool Boolean::operator== (const Expression& rhs) const
{
return operator==(&rhs);
}

bool Color::operator== (const Expression* rhs) const
bool Color::operator== (const Expression& rhs) const
{
if (const Color* r = dynamic_cast<const Color*>(rhs)) {
if (const Color* r = dynamic_cast<const Color*>(&rhs)) {
return r_ == r->r() &&
g_ == r->g() &&
b_ == r->b() &&
Expand All @@ -1601,14 +1561,9 @@ namespace Sass {
return false;
}

bool Color::operator== (const Expression& rhs) const
{
return operator==(&rhs);
}

bool List::operator== (const Expression* rhs) const
bool List::operator== (const Expression& rhs) const
{
if (const List* r = dynamic_cast<const List*>(rhs)) {
if (const List* r = dynamic_cast<const List*>(&rhs)) {
if (length() != r->length()) return false;
if (separator() != r->separator()) return false;
for (size_t i = 0, L = length(); i < L; ++i) {
Expand All @@ -1622,14 +1577,9 @@ namespace Sass {
return false;
}

bool List::operator== (const Expression& rhs) const
{
return operator==(&rhs);
}

bool Map::operator== (const Expression* rhs) const
bool Map::operator== (const Expression& rhs) const
{
if (const Map* r = dynamic_cast<const Map*>(rhs)) {
if (const Map* r = dynamic_cast<const Map*>(&rhs)) {
if (length() != r->length()) return false;
for (auto key : keys()) {
Expression* lv = at(key);
Expand All @@ -1642,19 +1592,9 @@ namespace Sass {
return false;
}

bool Map::operator== (const Expression& rhs) const
{
return operator==(&rhs);
}

bool Null::operator== (const Expression* rhs) const
{
return rhs->concrete_type() == NULL_VAL;
}

bool Null::operator== (const Expression& rhs) const
{
return operator==(&rhs);
return rhs.concrete_type() == NULL_VAL;
}

size_t List::size() const {
Expand Down
14 changes: 0 additions & 14 deletions src/ast.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ namespace Sass {
: Expression(pstate, d, e, i, ct)
{ }
virtual bool operator== (const Expression& rhs) const = 0;
virtual bool operator== (const Expression* rhs) const = 0;
virtual string to_string(bool compressed = false, int precision = 5) const = 0;
};
}
Expand Down Expand Up @@ -819,7 +818,6 @@ namespace Sass {
}

virtual bool operator== (const Expression& rhs) const;
virtual bool operator== (const Expression* rhs) const;
virtual string to_string(bool compressed = false, int precision = 5) const;

ATTACH_OPERATIONS()
Expand Down Expand Up @@ -853,7 +851,6 @@ namespace Sass {
}

virtual bool operator== (const Expression& rhs) const;
virtual bool operator== (const Expression* rhs) const;
virtual string to_string(bool compressed = false, int precision = 5) const;

ATTACH_OPERATIONS()
Expand Down Expand Up @@ -1213,9 +1210,7 @@ namespace Sass {
}

virtual bool operator< (const Number& rhs) const;
virtual bool operator< (const Number* rhs) const;
virtual bool operator== (const Expression& rhs) const;
virtual bool operator== (const Expression* rhs) const;
virtual string to_string(bool compressed = false, int precision = 5) const;

ATTACH_OPERATIONS()
Expand Down Expand Up @@ -1252,7 +1247,6 @@ namespace Sass {
}

virtual bool operator== (const Expression& rhs) const;
virtual bool operator== (const Expression* rhs) const;
virtual string to_string(bool compressed = false, int precision = 5) const;

ATTACH_OPERATIONS()
Expand All @@ -1268,7 +1262,6 @@ namespace Sass {
: Value(pstate), message_(msg)
{ concrete_type(C_ERROR); }
virtual bool operator== (const Expression& rhs) const;
virtual bool operator== (const Expression* rhs) const;
virtual string to_string(bool compressed = false, int precision = 5) const;
ATTACH_OPERATIONS()
};
Expand All @@ -1283,7 +1276,6 @@ namespace Sass {
: Value(pstate), message_(msg)
{ concrete_type(C_WARNING); }
virtual bool operator== (const Expression& rhs) const;
virtual bool operator== (const Expression* rhs) const;
virtual string to_string(bool compressed = false, int precision = 5) const;
ATTACH_OPERATIONS()
};
Expand Down Expand Up @@ -1313,7 +1305,6 @@ namespace Sass {
}

virtual bool operator== (const Expression& rhs) const;
virtual bool operator== (const Expression* rhs) const;
virtual string to_string(bool compressed = false, int precision = 5) const;

ATTACH_OPERATIONS()
Expand All @@ -1332,7 +1323,6 @@ namespace Sass {
static string type_name() { return "string"; }
virtual ~String() = 0;
virtual bool operator==(const Expression& rhs) const = 0;
virtual bool operator==(const Expression* rhs) const = 0;
virtual string to_string(bool compressed = false, int precision = 5) const = 0;
ATTACH_OPERATIONS()
};
Expand Down Expand Up @@ -1362,7 +1352,6 @@ namespace Sass {
}

virtual bool operator==(const Expression& rhs) const;
virtual bool operator==(const Expression* rhs) const;
virtual string to_string(bool compressed = false, int precision = 5) const;

ATTACH_OPERATIONS()
Expand Down Expand Up @@ -1402,7 +1391,6 @@ namespace Sass {
}

virtual bool operator==(const Expression& rhs) const;
virtual bool operator==(const Expression* rhs) const;
virtual string to_string(bool compressed = false, int precision = 5) const;

// static char auto_quote() { return '*'; }
Expand All @@ -1423,7 +1411,6 @@ namespace Sass {
value_ = unquote(value_, &quote_mark_);
}
virtual bool operator==(const Expression& rhs) const;
virtual bool operator==(const Expression* rhs) const;
virtual string to_string(bool compressed = false, int precision = 5) const;
ATTACH_OPERATIONS()
};
Expand Down Expand Up @@ -1589,7 +1576,6 @@ namespace Sass {
}

virtual bool operator== (const Expression& rhs) const;
virtual bool operator== (const Expression* rhs) const;
virtual string to_string(bool compressed = false, int precision = 5) const;

ATTACH_OPERATIONS()
Expand Down

0 comments on commit d17ab21

Please sign in to comment.