Skip to content

Commit

Permalink
Rename SimpleSequence_Selector to Compound_Selector
Browse files Browse the repository at this point in the history
Reverts sass#2101
  • Loading branch information
mgreter committed Nov 26, 2016
1 parent c94322e commit 26c208f
Show file tree
Hide file tree
Showing 18 changed files with 157 additions and 157 deletions.
104 changes: 52 additions & 52 deletions src/ast.cpp

Large diffs are not rendered by default.

68 changes: 34 additions & 34 deletions src/ast.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1998,13 +1998,13 @@ namespace Sass {
}

virtual ~Simple_Selector() = 0;
virtual SimpleSequence_Selector* unify_with(SimpleSequence_Selector*, Context&);
virtual Compound_Selector* unify_with(Compound_Selector*, Context&);
virtual bool has_parent_ref() { return false; };
virtual bool has_real_parent_ref() { return false; };
virtual bool is_pseudo_element() { return false; }
virtual bool is_pseudo_class() { return false; }

virtual bool is_superselector_of(SimpleSequence_Selector* sub) { return false; }
virtual bool is_superselector_of(Compound_Selector* sub) { return false; }

bool operator==(const Simple_Selector& rhs) const;
inline bool operator!=(const Simple_Selector& rhs) const { return !(*this == rhs); }
Expand All @@ -2020,7 +2020,7 @@ namespace Sass {
// The Parent Selector Expression.
//////////////////////////////////
// parent selectors can occur in selectors but also
// inside strings in declarations (SimpleSequence_Selector).
// inside strings in declarations (Compound_Selector).
// only one simple parent selector means the first case.
class Parent_Selector : public Simple_Selector {
ADD_PROPERTY(bool, real)
Expand Down Expand Up @@ -2074,7 +2074,7 @@ namespace Sass {
else return Constants::Specificity_Element;
}
virtual Simple_Selector* unify_with(Simple_Selector*, Context&);
virtual SimpleSequence_Selector* unify_with(SimpleSequence_Selector*, Context&);
virtual Compound_Selector* unify_with(Compound_Selector*, Context&);
ATTACH_OPERATIONS()
};

Expand All @@ -2094,7 +2094,7 @@ namespace Sass {
{
return Constants::Specificity_Class;
}
virtual SimpleSequence_Selector* unify_with(SimpleSequence_Selector*, Context&);
virtual Compound_Selector* unify_with(Compound_Selector*, Context&);
ATTACH_OPERATIONS()
};

Expand All @@ -2114,7 +2114,7 @@ namespace Sass {
{
return Constants::Specificity_ID;
}
virtual SimpleSequence_Selector* unify_with(SimpleSequence_Selector*, Context&);
virtual Compound_Selector* unify_with(Compound_Selector*, Context&);
ATTACH_OPERATIONS()
};

Expand Down Expand Up @@ -2210,7 +2210,7 @@ namespace Sass {
bool operator==(const Pseudo_Selector& rhs) const;
bool operator<(const Simple_Selector& rhs) const;
bool operator<(const Pseudo_Selector& rhs) const;
virtual SimpleSequence_Selector* unify_with(SimpleSequence_Selector*, Context&);
virtual Compound_Selector* unify_with(Compound_Selector*, Context&);
ATTACH_OPERATIONS()
};

Expand Down Expand Up @@ -2268,7 +2268,7 @@ namespace Sass {
// any parent references or placeholders, to simplify expansion.
////////////////////////////////////////////////////////////////////////////
typedef std::set<Sequence_Selector*, Sequence_Selector_Pointer_Compare> SourcesSet;
class SimpleSequence_Selector : public Selector, public Vectorized<Simple_Selector*> {
class Compound_Selector : public Selector, public Vectorized<Simple_Selector*> {
private:
SourcesSet sources_;
ADD_PROPERTY(bool, extended);
Expand All @@ -2280,7 +2280,7 @@ namespace Sass {
// if (s->has_placeholder()) has_placeholder(true);
}
public:
SimpleSequence_Selector(ParserState pstate, size_t s = 0)
Compound_Selector(ParserState pstate, size_t s = 0)
: Selector(pstate),
Vectorized<Simple_Selector*>(s),
extended_(false),
Expand All @@ -2293,22 +2293,22 @@ namespace Sass {
return false;
};

SimpleSequence_Selector& operator<<(Simple_Selector* element);
Compound_Selector& operator<<(Simple_Selector* element);

bool is_universal() const
{
return length() == 1 && (*this)[0]->is_universal();
}

Sequence_Selector* to_complex(Memory_Manager& mem);
SimpleSequence_Selector* unify_with(SimpleSequence_Selector* rhs, Context& ctx);
Compound_Selector* unify_with(Compound_Selector* rhs, Context& ctx);
// virtual Placeholder_Selector* find_placeholder();
virtual bool has_parent_ref();
virtual bool has_real_parent_ref();
Simple_Selector* base()
{
// Implement non-const in terms of const. Safe to const_cast since this method is non-const
return const_cast<Simple_Selector*>(static_cast<const SimpleSequence_Selector*>(this)->base());
return const_cast<Simple_Selector*>(static_cast<const Compound_Selector*>(this)->base());
}
const Simple_Selector* base() const {
if (length() == 0) return 0;
Expand All @@ -2317,7 +2317,7 @@ namespace Sass {
return (*this)[0];
return 0;
}
virtual bool is_superselector_of(SimpleSequence_Selector* sub, std::string wrapped = "");
virtual bool is_superselector_of(Compound_Selector* sub, std::string wrapped = "");
virtual bool is_superselector_of(Sequence_Selector* sub, std::string wrapped = "");
virtual bool is_superselector_of(Selector_List* sub, std::string wrapped = "");
virtual size_t hash()
Expand Down Expand Up @@ -2361,18 +2361,18 @@ namespace Sass {
}
std::vector<std::string> to_str_vec(); // sometimes need to convert to a flat "by-value" data structure

bool operator<(const SimpleSequence_Selector& rhs) const;
bool operator<(const Compound_Selector& rhs) const;

bool operator==(const SimpleSequence_Selector& rhs) const;
inline bool operator!=(const SimpleSequence_Selector& rhs) const { return !(*this == rhs); }
bool operator==(const Compound_Selector& rhs) const;
inline bool operator!=(const Compound_Selector& rhs) const { return !(*this == rhs); }

SourcesSet& sources() { return sources_; }
void clearSources() { sources_.clear(); }
void mergeSources(SourcesSet& sources, Context& ctx);

SimpleSequence_Selector* clone(Context&) const; // does not clone the Simple_Selector*s
Compound_Selector* clone(Context&) const; // does not clone the Simple_Selector*s

SimpleSequence_Selector* minus(SimpleSequence_Selector* rhs, Context& ctx);
Compound_Selector* minus(Compound_Selector* rhs, Context& ctx);
ATTACH_OPERATIONS()
};

Expand All @@ -2386,7 +2386,7 @@ namespace Sass {
enum Combinator { ANCESTOR_OF, PARENT_OF, PRECEDES, ADJACENT_TO, REFERENCE };
private:
ADD_PROPERTY(Combinator, combinator)
ADD_PROPERTY(SimpleSequence_Selector*, head)
ADD_PROPERTY(Compound_Selector*, head)
ADD_PROPERTY(Sequence_Selector*, tail)
ADD_PROPERTY(String*, reference);
public:
Expand All @@ -2397,7 +2397,7 @@ namespace Sass {
};
Sequence_Selector(ParserState pstate,
Combinator c = ANCESTOR_OF,
SimpleSequence_Selector* h = 0,
Compound_Selector* h = 0,
Sequence_Selector* t = 0,
String* r = 0)
: Selector(pstate),
Expand Down Expand Up @@ -2453,7 +2453,7 @@ namespace Sass {

size_t length() const;
Selector_List* resolve_parent_refs(Context& ctx, Selector_List* parents, bool implicit_parent = true);
virtual bool is_superselector_of(SimpleSequence_Selector* sub, std::string wrapping = "");
virtual bool is_superselector_of(Compound_Selector* sub, std::string wrapping = "");
virtual bool is_superselector_of(Sequence_Selector* sub, std::string wrapping = "");
virtual bool is_superselector_of(Selector_List* sub, std::string wrapping = "");
// virtual Placeholder_Selector* find_placeholder();
Expand Down Expand Up @@ -2504,7 +2504,7 @@ namespace Sass {

SourcesSet srcs;

SimpleSequence_Selector* pHead = head();
Compound_Selector* pHead = head();
Sequence_Selector* pTail = tail();

if (pHead) {
Expand All @@ -2523,7 +2523,7 @@ namespace Sass {
// members.map! {|m| m.is_a?(SimpleSequence) ? m.with_more_sources(sources) : m}
Sequence_Selector* pIter = this;
while (pIter) {
SimpleSequence_Selector* pHead = pIter->head();
Compound_Selector* pHead = pIter->head();

if (pHead) {
pHead->mergeSources(sources, ctx);
Expand All @@ -2535,7 +2535,7 @@ namespace Sass {
void clearSources() {
Sequence_Selector* pIter = this;
while (pIter) {
SimpleSequence_Selector* pHead = pIter->head();
Compound_Selector* pHead = pIter->head();

if (pHead) {
pHead->clearSources();
Expand All @@ -2544,14 +2544,14 @@ namespace Sass {
pIter = pIter->tail();
}
}
Sequence_Selector* clone(Context&) const; // does not clone SimpleSequence_Selector*s
Sequence_Selector* cloneFully(Context&) const; // clones SimpleSequence_Selector*s
// std::vector<SimpleSequence_Selector*> to_vector();
Sequence_Selector* clone(Context&) const; // does not clone Compound_Selector*s
Sequence_Selector* cloneFully(Context&) const; // clones Compound_Selector*s
// std::vector<Compound_Selector*> to_vector();
ATTACH_OPERATIONS()
};

typedef std::deque<Sequence_Selector*> ComplexSelectorDeque;
typedef Subset_Map<std::string, std::pair<Sequence_Selector*, SimpleSequence_Selector*> > ExtensionSubsetMap;
typedef Subset_Map<std::string, std::pair<Sequence_Selector*, Compound_Selector*> > ExtensionSubsetMap;

///////////////////////////////////
// Comma-separated selector groups.
Expand All @@ -2572,7 +2572,7 @@ namespace Sass {
void remove_parent_selectors();
// virtual Placeholder_Selector* find_placeholder();
Selector_List* resolve_parent_refs(Context& ctx, Selector_List* parents, bool implicit_parent = true);
virtual bool is_superselector_of(SimpleSequence_Selector* sub, std::string wrapping = "");
virtual bool is_superselector_of(Compound_Selector* sub, std::string wrapping = "");
virtual bool is_superselector_of(Sequence_Selector* sub, std::string wrapping = "");
virtual bool is_superselector_of(Selector_List* sub, std::string wrapping = "");
Selector_List* unify_with(Selector_List*, Context&);
Expand Down Expand Up @@ -2614,8 +2614,8 @@ namespace Sass {
}
return false;
}
Selector_List* clone(Context&) const; // does not clone SimpleSequence_Selector*s
Selector_List* cloneFully(Context&) const; // clones SimpleSequence_Selector*s
Selector_List* clone(Context&) const; // does not clone Compound_Selector*s
Selector_List* cloneFully(Context&) const; // clones Compound_Selector*s
virtual bool operator==(const Selector& rhs) const;
virtual bool operator==(const Selector_List& rhs) const;
// Selector Lists can be compared to comma lists
Expand All @@ -2630,10 +2630,10 @@ namespace Sass {
// is required for proper stl collection ordering) is implemented using string comparision. This gives stable sorting
// behavior, and can be used to determine if the selectors would have exactly idential output. operator== matches the
// ruby sass implementations for eql, which sometimes perform order independent comparisions (like set comparisons of the
// members of a SimpleSequence (SimpleSequence_Selector)).
// members of a SimpleSequence (Compound_Selector)).
//
// Due to the reliance on operator== and operater< behavior, this templated method is currently only intended for
// use with SimpleSequence_Selector and Sequence_Selector objects.
// use with Compound_Selector and Sequence_Selector objects.
if (simpleSelectorOrderDependent) {
return !(one < two) && !(two < one);
} else {
Expand All @@ -2643,7 +2643,7 @@ namespace Sass {

// compare function for sorting and probably other other uses
struct cmp_complex_selector { inline bool operator() (const Sequence_Selector* l, const Sequence_Selector* r) { return (*l < *r); } };
struct cmp_compound_selector { inline bool operator() (const SimpleSequence_Selector* l, const SimpleSequence_Selector* r) { return (*l < *r); } };
struct cmp_compound_selector { inline bool operator() (const Compound_Selector* l, const Compound_Selector* r) { return (*l < *r); } };
struct cmp_simple_selector { inline bool operator() (const Simple_Selector* l, const Simple_Selector* r) { return (*l < *r); } };

}
Expand Down
4 changes: 2 additions & 2 deletions src/ast_factory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ namespace Sass {
Placeholder_Selector* new_Placeholder_Selector(std::string p, size_t l, std::string n);
Pseudo_Selector* new_Pseudo_Selector(std::string p, size_t l, std::string n, Expression* expr = 0);
Wrapped_Selector* new_Wrapped_Selector(std::string p, size_t l, std::string n, Simple_Base* sel);
SimpleSequence_Selector* new_SimpleSequence_Selector(std::string p, size_t l, size_t s = 0);
Sequence_Selector* new_Sequence_Selector(std::string p, size_t l, Sequence_Selector::Combinator c, Sequence_Selector* ctx, SimpleSequence_Selector* sel);
Compound_Selector* new_Compound_Selector(std::string p, size_t l, size_t s = 0);
Sequence_Selector* new_Sequence_Selector(std::string p, size_t l, Sequence_Selector::Combinator c, Sequence_Selector* ctx, Compound_Selector* sel);
Selector_List* new_Selector_List(std::string p, size_t l, size_t s = 0);
};
}
Expand Down
2 changes: 1 addition & 1 deletion src/ast_fwd_decl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ namespace Sass {
class Attribute_Selector;
class Pseudo_Selector;
class Wrapped_Selector;
class SimpleSequence_Selector;
class Compound_Selector;
class Sequence_Selector;
class Selector_List;

Expand Down
2 changes: 1 addition & 1 deletion src/context.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ namespace Sass {
std::vector<char*> strings;
std::vector<Resource> resources;
std::map<const std::string, const StyleSheet> sheets;
Subset_Map<std::string, std::pair<Sequence_Selector*, SimpleSequence_Selector*> > subset_map;
Subset_Map<std::string, std::pair<Sequence_Selector*, Compound_Selector*> > subset_map;
std::vector<Sass_Import_Entry> import_stack;

struct Sass_Compiler* c_compiler;
Expand Down
8 changes: 4 additions & 4 deletions src/debugger.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,9 @@ inline void debug_ast(AST_Node* node, std::string ind, Env* env)
}
SourcesSet set = selector->sources();
// debug_sources_set(set, ind + " @--> ");
} else if (dynamic_cast<SimpleSequence_Selector*>(node)) {
SimpleSequence_Selector* selector = dynamic_cast<SimpleSequence_Selector*>(node);
std::cerr << ind << "SimpleSequence_Selector " << selector;
} else if (dynamic_cast<Compound_Selector*>(node)) {
Compound_Selector* selector = dynamic_cast<Compound_Selector*>(node);
std::cerr << ind << "Compound_Selector " << selector;
std::cerr << " (" << pstate_source_position(node) << ")";
std::cerr << " <" << selector->hash() << ">";
std::cerr << " [weight:" << longToHex(selector->specificity()) << "]";
Expand Down Expand Up @@ -763,7 +763,7 @@ inline void debug_subset_map(Sass::ExtensionSubsetMap& map, std::string ind = ""
if (ind == "") std::cerr << "#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n";
}

typedef std::pair<Sequence_Selector*, SimpleSequence_Selector*> ExtensionPair;
typedef std::pair<Sequence_Selector*, Compound_Selector*> ExtensionPair;
typedef std::vector<ExtensionPair> SubsetMapEntries;

inline void debug_subset_entries(SubsetMapEntries* entries, std::string ind = "")
Expand Down
4 changes: 2 additions & 2 deletions src/expand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -581,14 +581,14 @@ namespace Sass {
std::string sel_str(contextualized->to_string(ctx.c_options));
error("Can't extend " + sel_str + ": can't extend nested selectors", c->pstate(), backtrace());
}
SimpleSequence_Selector* placeholder = c->head();
Compound_Selector* placeholder = c->head();
if (contextualized->is_optional()) placeholder->is_optional(true);
for (size_t i = 0, L = extender->length(); i < L; ++i) {
Sequence_Selector* sel = (*extender)[i];
if (!(sel->head() && sel->head()->length() > 0 &&
dynamic_cast<Parent_Selector*>((*sel->head())[0])))
{
SimpleSequence_Selector* hh = SASS_MEMORY_NEW(ctx.mem, SimpleSequence_Selector, (*extender)[i]->pstate());
Compound_Selector* hh = SASS_MEMORY_NEW(ctx.mem, Compound_Selector, (*extender)[i]->pstate());
hh->media_block((*extender)[i]->media_block());
Sequence_Selector* ssel = SASS_MEMORY_NEW(ctx.mem, Sequence_Selector, (*extender)[i]->pstate());
ssel->media_block((*extender)[i]->media_block());
Expand Down
Loading

0 comments on commit 26c208f

Please sign in to comment.