Skip to content

Commit

Permalink
Clean up header includes
Browse files Browse the repository at this point in the history
1. Avoid include cycles. This isn't necessary for amalgamation but makes
   things more obvious.

2. Rename sass2scss namespace to Sass2Scss (upstream PR
   mgreter/sass2scss#43).

   This is necessary for amalgamation.
  • Loading branch information
glebm committed Aug 27, 2019
1 parent fbbadbf commit 3f6371b
Show file tree
Hide file tree
Showing 51 changed files with 159 additions and 69 deletions.
4 changes: 2 additions & 2 deletions include/sass2scss.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
#endif

// add namespace for c++
namespace Sass
namespace Sass2Scss
{

// pretty print options
Expand Down Expand Up @@ -117,4 +117,4 @@ extern "C" {
} // __cplusplus defined.
#endif

#endif
#endif
5 changes: 5 additions & 0 deletions src/ast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
#include "sass.hpp"

#include "ast.hpp"
#include "ast_selectors.hpp"
#include "ast_values.hpp"
#include "emitter.hpp"
#include "inspect.hpp"
#include "util.hpp"

namespace Sass {

Expand Down
4 changes: 0 additions & 4 deletions src/ast.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1052,10 +1052,6 @@ namespace Sass {

}

#include "ast_values.hpp"
#include "ast_supports.hpp"
#include "ast_selectors.hpp"

#ifdef __clang__

// #pragma clang diagnostic pop
Expand Down
6 changes: 6 additions & 0 deletions src/ast2c.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

#include "ast2c.hpp"
#include "ast.hpp"
#include "ast_selectors.hpp"
#include "ast_supports.hpp"
#include "ast_values.hpp"

namespace Sass {

Expand Down Expand Up @@ -77,4 +80,7 @@ namespace Sass {
union Sass_Value* AST2C::operator()(Null* n)
{ return sass_make_null(); }

union Sass_Value* AST2C::fallback(AST_Node* x)
{ return sass_make_error("unknown type for C-API"); }

};
4 changes: 1 addition & 3 deletions src/ast2c.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ namespace Sass {
union Sass_Value* operator()(Argument*);

// return sass error if type is not supported
union Sass_Value* fallback(AST_Node* x)
{ return sass_make_error("unknown type for C-API"); }

union Sass_Value* fallback(AST_Node* x);
};

}
Expand Down
4 changes: 4 additions & 0 deletions src/ast_fwd_decl.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#include "ast.hpp"

#include "ast_selectors.hpp"
#include "ast_supports.hpp"
#include "ast_values.hpp"

namespace Sass {

#define IMPLEMENT_BASE_CAST(T) \
Expand Down
3 changes: 3 additions & 0 deletions src/ast_sel_cmp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
// __EXTENSIONS__ fix on Solaris.
#include "sass.hpp"

#include <unordered_set>

#include "ast_selectors.hpp"
#include "ast_values.hpp"

namespace Sass {

Expand Down
9 changes: 5 additions & 4 deletions src/ast_sel_super.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
// __EXTENSIONS__ fix on Solaris.
#include "sass.hpp"
#include "ast.hpp"

#include "ast_selectors.hpp"
#include "ast_values.hpp"
#include "util_string.hpp"

namespace Sass {
Expand Down Expand Up @@ -76,7 +77,7 @@ namespace Sass {
// That items must be a compound selector
if (auto compound = Cast<CompoundSelector>(complex->at(0))) {
// It must contain the lhs simple selector
if (!compound->contains(simple1)) {
if (!compound->contains(simple1)) {
return false;
}
}
Expand Down Expand Up @@ -386,8 +387,8 @@ namespace Sass {

// Find the first index where `complex2.sublist(i2, afterSuperselector)`
// is a subselector of [compound1]. We stop before the superselector
// would encompass all of [complex2] because we know [complex1] has
// more than one element, and consuming all of [complex2] wouldn't
// would encompass all of [complex2] because we know [complex1] has
// more than one element, and consuming all of [complex2] wouldn't
// leave anything for the rest of [complex1] to match.
size_t afterSuperselector = i2 + 1;
for (; afterSuperselector < complex2.size(); afterSuperselector++) {
Expand Down
5 changes: 4 additions & 1 deletion src/ast_sel_unify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@

#include "ast.hpp"

#include "ast_selectors.hpp"
#include "util.hpp"

namespace Sass {

// ##########################################################################
// Returns the contents of a [SelectorList] that matches only
// Returns the contents of a [SelectorList] that matches only
// elements that are matched by both [complex1] and [complex2].
// If no such list can be produced, returns `null`.
// ##########################################################################
Expand Down
7 changes: 4 additions & 3 deletions src/ast_sel_weave.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "sass.hpp"

#include "ast.hpp"
#include "ast_selectors.hpp"
#include "permutate.hpp"
#include "dart_helpers.hpp"

Expand Down Expand Up @@ -190,7 +191,7 @@ namespace Sass {
// EO getChunks

// ##########################################################################
// If the first element of [queue] has a `::root`
// If the first element of [queue] has a `::root`
// selector, removes and returns that element.
// ##########################################################################
CompoundSelectorObj getFirstIfRoot(std::vector<SelectorComponentObj>& queue) {
Expand Down Expand Up @@ -298,7 +299,7 @@ namespace Sass {
return true;
}
}

std::vector<SelectorComponentObj> combinators1;
while (!components1.empty() && Cast<SelectorCombinator>(components1.back())) {
SelectorCombinatorObj back = Cast<SelectorCombinator>(components1.back());
Expand Down Expand Up @@ -379,7 +380,7 @@ namespace Sass {
else {
CompoundSelectorObj unified = compound1->unifyWith(compound2);
std::vector<std::vector<SelectorComponentObj>> items;

if (!unified.isNull()) {
items.push_back({
unified, nextSiblingCombinator
Expand Down
4 changes: 4 additions & 0 deletions src/ast_selectors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
#include "sass.hpp"

#include "ast.hpp"
#include "ast_selectors.hpp"
#include "ast_values.hpp"
#include "constants.hpp"
#include "permutate.hpp"
#include "util.hpp"
#include "util_string.hpp"

namespace Sass {
Expand Down
1 change: 1 addition & 0 deletions src/ast_supports.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// __EXTENSIONS__ fix on Solaris.
#include "sass.hpp"
#include "ast.hpp"
#include "ast_supports.hpp"


namespace Sass {
Expand Down
21 changes: 9 additions & 12 deletions src/ast_supports.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,20 @@
#include <typeinfo>
#include <algorithm>
#include "sass/base.h"
#include "ast_fwd_decl.hpp"

#include "util.hpp"
#include "units.hpp"
#include "context.hpp"
#include "position.hpp"
#include "ast_def_macros.hpp"
#include "ast_fwd_decl.hpp"
#include "constants.hpp"
#include "operation.hpp"
#include "position.hpp"
#include "inspect.hpp"
#include "source_map.hpp"
#include "context.hpp"
#include "environment.hpp"
#include "error_handling.hpp"
#include "ast_def_macros.hpp"
#include "ast_fwd_decl.hpp"
#include "source_map.hpp"
#include "fn_utils.hpp"
#include "inspect.hpp"
#include "operation.hpp"
#include "position.hpp"
#include "source_map.hpp"
#include "units.hpp"
#include "util.hpp"

#include "sass.h"

Expand Down
2 changes: 2 additions & 0 deletions src/ast_values.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// __EXTENSIONS__ fix on Solaris.
#include "sass.hpp"
#include "ast.hpp"
#include "ast_values.hpp"
#include "util.hpp"

namespace Sass {

Expand Down
3 changes: 3 additions & 0 deletions src/bind.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#include "sass.hpp"
#include "bind.hpp"
#include "ast.hpp"
#include "ast_selectors.hpp"
#include "ast_supports.hpp"
#include "ast_values.hpp"
#include "backtrace.hpp"
#include "context.hpp"
#include "expand.hpp"
Expand Down
5 changes: 5 additions & 0 deletions src/c2ast.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
#include "c2ast.hpp"

#include "ast.hpp"
#include "ast_selectors.hpp"
#include "ast_supports.hpp"
#include "ast_values.hpp"
#include "units.hpp"
#include "position.hpp"
#include "backtrace.hpp"
Expand Down
3 changes: 3 additions & 0 deletions src/check_nesting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
// __EXTENSIONS__ fix on Solaris.
#include "sass.hpp"
#include "ast.hpp"
#include "ast_selectors.hpp"
#include "ast_supports.hpp"
#include "ast_values.hpp"
#include "check_nesting.hpp"

namespace Sass {
Expand Down
1 change: 1 addition & 0 deletions src/color_maps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "sass.hpp"

#include "ast.hpp"
#include "ast_values.hpp"
#include "color_maps.hpp"
#include "util_string.hpp"

Expand Down
3 changes: 3 additions & 0 deletions src/context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
// __EXTENSIONS__ fix on Solaris.
#include "sass.hpp"
#include "ast.hpp"
#include "ast_selectors.hpp"
#include "ast_supports.hpp"
#include "ast_values.hpp"

#include "remove_placeholders.hpp"
#include "sass_functions.hpp"
Expand Down
3 changes: 3 additions & 0 deletions src/cssize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
#include <vector>

#include "cssize.hpp"
#include "ast_selectors.hpp"
#include "ast_supports.hpp"
#include "ast_values.hpp"
#include "context.hpp"

namespace Sass {
Expand Down
2 changes: 1 addition & 1 deletion src/debugger.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ inline std::string debug_values(tsl::ordered_map<T, U, O, V> vec) {
out << "}";
return out.str();
}
template <class T, class U, class O, class V>
inline std::string debug_vec(tsl::ordered_map<T, U, O, V> vec) {
std::stringstream out;
Expand Down
5 changes: 4 additions & 1 deletion src/error_handling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
#include "sass.hpp"

#include "ast.hpp"
#include "ast_selectors.hpp"
#include "ast_values.hpp"
#include "extension.hpp"
#include "prelexer.hpp"
#include "backtrace.hpp"
#include "error_handling.hpp"
Expand Down Expand Up @@ -151,7 +154,7 @@ namespace Sass {
{

}


}

Expand Down
3 changes: 3 additions & 0 deletions src/eval.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@
#include "file.hpp"
#include "eval.hpp"
#include "ast.hpp"
#include "ast_supports.hpp"
#include "constants.hpp"
#include "bind.hpp"
#include "util.hpp"
#include "inspect.hpp"
#include "operation.hpp"
#include "operators.hpp"
#include "environment.hpp"
#include "position.hpp"
Expand Down
4 changes: 3 additions & 1 deletion src/eval.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
// sass.hpp must go before all system headers to get the
// __EXTENSIONS__ fix on Solaris.
#include "sass.hpp"
#include "ast.hpp"
#include "ast_selectors.hpp"
#include "ast_supports.hpp"
#include "ast_values.hpp"

#include "context.hpp"
#include "listize.hpp"
Expand Down
5 changes: 3 additions & 2 deletions src/eval_selectors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
#include "sass.hpp"
#include "expand.hpp"
#include "eval.hpp"
#include "ast.hpp"

#include "ast_selectors.hpp"
#include "ast_supports.hpp"
#include "ast_values.hpp"

namespace Sass {

Expand Down
5 changes: 4 additions & 1 deletion src/expand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
#include <typeinfo>

#include "ast.hpp"
#include "ast_selectors.hpp"
#include "ast_supports.hpp"
#include "ast_values.hpp"
#include "expand.hpp"
#include "bind.hpp"
#include "eval.hpp"
Expand Down Expand Up @@ -96,7 +99,7 @@ namespace Sass {
SelectorListObj Expand::popFromSelectorStack()
{
SelectorListObj last = selector_stack.back();
if (selector_stack.size() > 0)
if (selector_stack.size() > 0)
selector_stack.pop_back();
if (last.isNull()) return {};
return last;
Expand Down
Loading

0 comments on commit 3f6371b

Please sign in to comment.