sassc 2.2.1 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (147) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +2 -0
  3. data/CHANGELOG.md +18 -0
  4. data/Rakefile +1 -3
  5. data/ext/extconf.rb +13 -5
  6. data/ext/libsass/VERSION +1 -1
  7. data/ext/libsass/include/sass/base.h +2 -1
  8. data/ext/libsass/include/sass/context.h +4 -0
  9. data/ext/libsass/src/MurmurHash2.hpp +91 -0
  10. data/ext/libsass/src/ast.cpp +158 -168
  11. data/ext/libsass/src/ast.hpp +389 -230
  12. data/ext/libsass/src/ast_def_macros.hpp +18 -10
  13. data/ext/libsass/src/ast_fwd_decl.cpp +4 -3
  14. data/ext/libsass/src/ast_fwd_decl.hpp +98 -165
  15. data/ext/libsass/src/ast_helpers.hpp +292 -0
  16. data/ext/libsass/src/ast_sel_cmp.cpp +219 -732
  17. data/ext/libsass/src/ast_sel_super.cpp +539 -0
  18. data/ext/libsass/src/ast_sel_unify.cpp +207 -212
  19. data/ext/libsass/src/ast_sel_weave.cpp +616 -0
  20. data/ext/libsass/src/ast_selectors.cpp +594 -1026
  21. data/ext/libsass/src/ast_selectors.hpp +339 -385
  22. data/ext/libsass/src/ast_supports.cpp +36 -52
  23. data/ext/libsass/src/ast_supports.hpp +29 -29
  24. data/ext/libsass/src/ast_values.cpp +271 -84
  25. data/ext/libsass/src/ast_values.hpp +116 -107
  26. data/ext/libsass/src/backtrace.cpp +9 -9
  27. data/ext/libsass/src/backtrace.hpp +5 -5
  28. data/ext/libsass/src/base64vlq.cpp +2 -2
  29. data/ext/libsass/src/base64vlq.hpp +1 -1
  30. data/ext/libsass/src/bind.cpp +18 -18
  31. data/ext/libsass/src/bind.hpp +1 -1
  32. data/ext/libsass/src/c2ast.cpp +3 -3
  33. data/ext/libsass/src/c2ast.hpp +1 -1
  34. data/ext/libsass/src/cencode.c +4 -6
  35. data/ext/libsass/src/check_nesting.cpp +40 -41
  36. data/ext/libsass/src/check_nesting.hpp +6 -2
  37. data/ext/libsass/src/color_maps.cpp +14 -13
  38. data/ext/libsass/src/color_maps.hpp +1 -9
  39. data/ext/libsass/src/constants.cpp +5 -0
  40. data/ext/libsass/src/constants.hpp +6 -0
  41. data/ext/libsass/src/context.cpp +92 -119
  42. data/ext/libsass/src/context.hpp +41 -53
  43. data/ext/libsass/src/cssize.cpp +66 -149
  44. data/ext/libsass/src/cssize.hpp +17 -23
  45. data/ext/libsass/src/dart_helpers.hpp +199 -0
  46. data/ext/libsass/src/debugger.hpp +451 -295
  47. data/ext/libsass/src/emitter.cpp +15 -16
  48. data/ext/libsass/src/emitter.hpp +10 -12
  49. data/ext/libsass/src/environment.cpp +27 -27
  50. data/ext/libsass/src/environment.hpp +29 -24
  51. data/ext/libsass/src/error_handling.cpp +62 -41
  52. data/ext/libsass/src/error_handling.hpp +61 -51
  53. data/ext/libsass/src/eval.cpp +167 -281
  54. data/ext/libsass/src/eval.hpp +27 -29
  55. data/ext/libsass/src/eval_selectors.cpp +75 -0
  56. data/ext/libsass/src/expand.cpp +275 -222
  57. data/ext/libsass/src/expand.hpp +36 -16
  58. data/ext/libsass/src/extender.cpp +1188 -0
  59. data/ext/libsass/src/extender.hpp +399 -0
  60. data/ext/libsass/src/extension.cpp +43 -0
  61. data/ext/libsass/src/extension.hpp +89 -0
  62. data/ext/libsass/src/file.cpp +81 -72
  63. data/ext/libsass/src/file.hpp +28 -37
  64. data/ext/libsass/src/fn_colors.cpp +20 -18
  65. data/ext/libsass/src/fn_lists.cpp +30 -29
  66. data/ext/libsass/src/fn_maps.cpp +3 -3
  67. data/ext/libsass/src/fn_miscs.cpp +34 -46
  68. data/ext/libsass/src/fn_numbers.cpp +20 -13
  69. data/ext/libsass/src/fn_selectors.cpp +98 -128
  70. data/ext/libsass/src/fn_strings.cpp +47 -33
  71. data/ext/libsass/src/fn_utils.cpp +31 -29
  72. data/ext/libsass/src/fn_utils.hpp +17 -11
  73. data/ext/libsass/src/inspect.cpp +186 -148
  74. data/ext/libsass/src/inspect.hpp +31 -29
  75. data/ext/libsass/src/lexer.cpp +20 -82
  76. data/ext/libsass/src/lexer.hpp +5 -16
  77. data/ext/libsass/src/listize.cpp +23 -37
  78. data/ext/libsass/src/listize.hpp +8 -9
  79. data/ext/libsass/src/mapping.hpp +1 -0
  80. data/ext/libsass/src/memory/allocator.cpp +48 -0
  81. data/ext/libsass/src/memory/allocator.hpp +138 -0
  82. data/ext/libsass/src/memory/config.hpp +20 -0
  83. data/ext/libsass/src/memory/memory_pool.hpp +186 -0
  84. data/ext/libsass/src/memory/{SharedPtr.cpp → shared_ptr.cpp} +2 -2
  85. data/ext/libsass/src/memory/{SharedPtr.hpp → shared_ptr.hpp} +55 -9
  86. data/ext/libsass/src/memory.hpp +12 -0
  87. data/ext/libsass/src/operation.hpp +71 -61
  88. data/ext/libsass/src/operators.cpp +19 -18
  89. data/ext/libsass/src/operators.hpp +11 -11
  90. data/ext/libsass/src/ordered_map.hpp +112 -0
  91. data/ext/libsass/src/output.cpp +45 -64
  92. data/ext/libsass/src/output.hpp +6 -6
  93. data/ext/libsass/src/parser.cpp +512 -700
  94. data/ext/libsass/src/parser.hpp +89 -97
  95. data/ext/libsass/src/parser_selectors.cpp +189 -0
  96. data/ext/libsass/src/permutate.hpp +164 -0
  97. data/ext/libsass/src/plugins.cpp +7 -7
  98. data/ext/libsass/src/plugins.hpp +8 -8
  99. data/ext/libsass/src/position.cpp +7 -26
  100. data/ext/libsass/src/position.hpp +44 -21
  101. data/ext/libsass/src/prelexer.cpp +6 -6
  102. data/ext/libsass/src/remove_placeholders.cpp +55 -56
  103. data/ext/libsass/src/remove_placeholders.hpp +21 -18
  104. data/ext/libsass/src/sass.cpp +16 -15
  105. data/ext/libsass/src/sass.hpp +10 -5
  106. data/ext/libsass/src/sass2scss.cpp +4 -4
  107. data/ext/libsass/src/sass_context.cpp +91 -122
  108. data/ext/libsass/src/sass_context.hpp +2 -2
  109. data/ext/libsass/src/sass_functions.cpp +1 -1
  110. data/ext/libsass/src/sass_values.cpp +8 -11
  111. data/ext/libsass/src/settings.hpp +19 -0
  112. data/ext/libsass/src/source.cpp +69 -0
  113. data/ext/libsass/src/source.hpp +95 -0
  114. data/ext/libsass/src/source_data.hpp +32 -0
  115. data/ext/libsass/src/source_map.cpp +22 -18
  116. data/ext/libsass/src/source_map.hpp +12 -9
  117. data/ext/libsass/src/stylesheet.cpp +22 -0
  118. data/ext/libsass/src/stylesheet.hpp +57 -0
  119. data/ext/libsass/src/to_value.cpp +2 -2
  120. data/ext/libsass/src/to_value.hpp +1 -1
  121. data/ext/libsass/src/units.cpp +24 -22
  122. data/ext/libsass/src/units.hpp +8 -8
  123. data/ext/libsass/src/utf8_string.cpp +9 -10
  124. data/ext/libsass/src/utf8_string.hpp +7 -6
  125. data/ext/libsass/src/util.cpp +48 -50
  126. data/ext/libsass/src/util.hpp +20 -21
  127. data/ext/libsass/src/util_string.cpp +111 -61
  128. data/ext/libsass/src/util_string.hpp +62 -8
  129. data/ext/libsass/src/values.cpp +12 -12
  130. data/lib/sassc/engine.rb +5 -3
  131. data/lib/sassc/functions_handler.rb +8 -8
  132. data/lib/sassc/native.rb +4 -6
  133. data/lib/sassc/script.rb +4 -4
  134. data/lib/sassc/version.rb +1 -1
  135. data/test/functions_test.rb +18 -1
  136. data/test/native_test.rb +4 -4
  137. metadata +29 -15
  138. data/ext/libsass/src/extend.cpp +0 -2132
  139. data/ext/libsass/src/extend.hpp +0 -86
  140. data/ext/libsass/src/node.cpp +0 -322
  141. data/ext/libsass/src/node.hpp +0 -118
  142. data/ext/libsass/src/paths.hpp +0 -71
  143. data/ext/libsass/src/sass_util.cpp +0 -152
  144. data/ext/libsass/src/sass_util.hpp +0 -256
  145. data/ext/libsass/src/subset_map.cpp +0 -58
  146. data/ext/libsass/src/subset_map.hpp +0 -76
  147. data/lib/sassc/native/lib_c.rb +0 -21
@@ -0,0 +1,32 @@
1
+ #ifndef SASS_SOURCE_DATA_H
2
+ #define SASS_SOURCE_DATA_H
3
+
4
+ #include "sass.hpp"
5
+ #include "memory.hpp"
6
+
7
+ namespace Sass {
8
+
9
+ class SourceSpan;
10
+
11
+ class SourceData :
12
+ public SharedObj {
13
+ public:
14
+ SourceData();
15
+ virtual size_t size() const = 0;
16
+ virtual size_t getSrcId() const = 0;
17
+ virtual const char* end() const = 0;
18
+ virtual const char* begin() const = 0;
19
+ virtual const char* getPath() const = 0;
20
+ // virtual Offset getPosition() const = 0;
21
+ virtual const char* getRawData() const = 0;
22
+ virtual SourceSpan getSourceSpan() = 0;
23
+
24
+ sass::string to_string() const override {
25
+ return sass::string{ begin(), end() };
26
+ }
27
+ ~SourceData() {}
28
+ };
29
+
30
+ }
31
+
32
+ #endif
@@ -15,13 +15,13 @@
15
15
 
16
16
  namespace Sass {
17
17
  SourceMap::SourceMap() : current_position(0, 0, 0), file("stdin") { }
18
- SourceMap::SourceMap(const std::string& file) : current_position(0, 0, 0), file(file) { }
18
+ SourceMap::SourceMap(const sass::string& file) : current_position(0, 0, 0), file(file) { }
19
19
 
20
- std::string SourceMap::render_srcmap(Context &ctx) {
20
+ sass::string SourceMap::render_srcmap(Context &ctx) {
21
21
 
22
22
  const bool include_sources = ctx.c_options.source_map_contents;
23
- const std::vector<std::string> links = ctx.srcmap_links;
24
- const std::vector<Resource>& sources(ctx.resources);
23
+ const sass::vector<sass::string> links = ctx.srcmap_links;
24
+ const sass::vector<Resource>& sources(ctx.resources);
25
25
 
26
26
  JsonNode* json_srcmap = json_mkobject();
27
27
 
@@ -39,7 +39,7 @@ namespace Sass {
39
39
 
40
40
  JsonNode *json_sources = json_mkarray();
41
41
  for (size_t i = 0; i < source_index.size(); ++i) {
42
- std::string source(links[source_index[i]]);
42
+ sass::string source(links[source_index[i]]);
43
43
  if (ctx.c_options.source_map_file_urls) {
44
44
  source = File::rel2abs(source);
45
45
  // check for windows abs path
@@ -72,19 +72,19 @@ namespace Sass {
72
72
  // no problem as we do not alter any identifiers
73
73
  json_append_member(json_srcmap, "names", json_names);
74
74
 
75
- std::string mappings = serialize_mappings();
75
+ sass::string mappings = serialize_mappings();
76
76
  JsonNode *json_mappings = json_mkstring(mappings.c_str());
77
77
  json_append_member(json_srcmap, "mappings", json_mappings);
78
78
 
79
79
  char *str = json_stringify(json_srcmap, "\t");
80
- std::string result = std::string(str);
80
+ sass::string result = sass::string(str);
81
81
  free(str);
82
82
  json_delete(json_srcmap);
83
83
  return result;
84
84
  }
85
85
 
86
- std::string SourceMap::serialize_mappings() {
87
- std::string result = "";
86
+ sass::string SourceMap::serialize_mappings() {
87
+ sass::string result = "";
88
88
 
89
89
  size_t previous_generated_line = 0;
90
90
  size_t previous_generated_column = 0;
@@ -101,7 +101,7 @@ namespace Sass {
101
101
  if (generated_line != previous_generated_line) {
102
102
  previous_generated_column = 0;
103
103
  if (generated_line > previous_generated_line) {
104
- result += std::string(generated_line - previous_generated_line, ';');
104
+ result += sass::string(generated_line - previous_generated_line, ';');
105
105
  previous_generated_line = generated_line;
106
106
  }
107
107
  }
@@ -175,23 +175,27 @@ namespace Sass {
175
175
 
176
176
  void SourceMap::add_open_mapping(const AST_Node* node)
177
177
  {
178
- mappings.push_back(Mapping(node->pstate(), current_position));
178
+ const SourceSpan& span(node->pstate());
179
+ Position from(span.getSrcId(), span.position);
180
+ mappings.push_back(Mapping(from, current_position));
179
181
  }
180
182
 
181
183
  void SourceMap::add_close_mapping(const AST_Node* node)
182
184
  {
183
- mappings.push_back(Mapping(node->pstate() + node->pstate().offset, current_position));
185
+ const SourceSpan& span(node->pstate());
186
+ Position to(span.getSrcId(), span.position + span.offset);
187
+ mappings.push_back(Mapping(to, current_position));
184
188
  }
185
189
 
186
- ParserState SourceMap::remap(const ParserState& pstate) {
190
+ SourceSpan SourceMap::remap(const SourceSpan& pstate) {
187
191
  for (size_t i = 0; i < mappings.size(); ++i) {
188
192
  if (
189
- mappings[i].generated_position.file == pstate.file &&
190
- mappings[i].generated_position.line == pstate.line &&
191
- mappings[i].generated_position.column == pstate.column
192
- ) return ParserState(pstate.path, pstate.src, mappings[i].original_position, pstate.offset);
193
+ mappings[i].generated_position.file == pstate.getSrcId() &&
194
+ mappings[i].generated_position.line == pstate.position.line &&
195
+ mappings[i].generated_position.column == pstate.position.column
196
+ ) return SourceSpan(pstate.source, mappings[i].original_position, pstate.offset);
193
197
  }
194
- return ParserState(pstate.path, pstate.src, Position(-1, -1, -1), Offset(0, 0));
198
+ return SourceSpan(pstate.source, Position(-1, -1, -1), Offset(0, 0));
195
199
 
196
200
  }
197
201
 
@@ -9,6 +9,9 @@
9
9
  #include "position.hpp"
10
10
  #include "mapping.hpp"
11
11
 
12
+ #include "backtrace.hpp"
13
+ #include "memory.hpp"
14
+
12
15
  #define VECTOR_PUSH(vec, ins) vec.insert(vec.end(), ins.begin(), ins.end())
13
16
  #define VECTOR_UNSHIFT(vec, ins) vec.insert(vec.begin(), ins.begin(), ins.end())
14
17
 
@@ -20,9 +23,9 @@ namespace Sass {
20
23
  class SourceMap {
21
24
 
22
25
  public:
23
- std::vector<size_t> source_index;
26
+ sass::vector<size_t> source_index;
24
27
  SourceMap();
25
- SourceMap(const std::string& file);
28
+ SourceMap(const sass::string& file);
26
29
 
27
30
  void append(const Offset& offset);
28
31
  void prepend(const Offset& offset);
@@ -31,17 +34,17 @@ namespace Sass {
31
34
  void add_open_mapping(const AST_Node* node);
32
35
  void add_close_mapping(const AST_Node* node);
33
36
 
34
- std::string render_srcmap(Context &ctx);
35
- ParserState remap(const ParserState& pstate);
37
+ sass::string render_srcmap(Context &ctx);
38
+ SourceSpan remap(const SourceSpan& pstate);
36
39
 
37
40
  private:
38
41
 
39
- std::string serialize_mappings();
42
+ sass::string serialize_mappings();
40
43
 
41
- std::vector<Mapping> mappings;
44
+ sass::vector<Mapping> mappings;
42
45
  Position current_position;
43
46
  public:
44
- std::string file;
47
+ sass::string file;
45
48
  private:
46
49
  Base64VLQ base64vlq;
47
50
  };
@@ -49,11 +52,11 @@ private:
49
52
  class OutputBuffer {
50
53
  public:
51
54
  OutputBuffer(void)
52
- : buffer(""),
55
+ : buffer(),
53
56
  smap()
54
57
  { }
55
58
  public:
56
- std::string buffer;
59
+ sass::string buffer;
57
60
  SourceMap smap;
58
61
  };
59
62
 
@@ -0,0 +1,22 @@
1
+ // sass.hpp must go before all system headers to get the
2
+ // __EXTENSIONS__ fix on Solaris.
3
+ #include "sass.hpp"
4
+
5
+ #include "stylesheet.hpp"
6
+
7
+ namespace Sass {
8
+
9
+ // Constructor
10
+ Sass::StyleSheet::StyleSheet(const Resource& res, Block_Obj root) :
11
+ Resource(res),
12
+ root(root)
13
+ {
14
+ }
15
+
16
+ StyleSheet::StyleSheet(const StyleSheet& sheet) :
17
+ Resource(sheet),
18
+ root(sheet.root)
19
+ {
20
+ }
21
+
22
+ }
@@ -0,0 +1,57 @@
1
+ #ifndef SASS_STYLESHEET_H
2
+ #define SASS_STYLESHEET_H
3
+
4
+ // sass.hpp must go before all system headers to get the
5
+ // __EXTENSIONS__ fix on Solaris.
6
+ #include "sass.hpp"
7
+
8
+ #include "ast_fwd_decl.hpp"
9
+ #include "extender.hpp"
10
+ #include "file.hpp"
11
+
12
+ namespace Sass {
13
+
14
+ // parsed stylesheet from loaded resource
15
+ // this should be a `Module` for sass 4.0
16
+ class StyleSheet : public Resource {
17
+ public:
18
+
19
+ // The canonical URL for this module's source file. This may be `null`
20
+ // if the module was loaded from a string without a URL provided.
21
+ // Uri get url;
22
+
23
+ // Modules that this module uses.
24
+ // List<Module> get upstream;
25
+
26
+ // The module's variables.
27
+ // Map<String, Value> get variables;
28
+
29
+ // The module's functions. Implementations must ensure
30
+ // that each [Callable] is stored under its own name.
31
+ // Map<String, Callable> get functions;
32
+
33
+ // The module's mixins. Implementations must ensure that
34
+ // each [Callable] is stored under its own name.
35
+ // Map<String, Callable> get mixins;
36
+
37
+ // The extensions defined in this module, which is also able to update
38
+ // [css]'s style rules in-place based on downstream extensions.
39
+ // Extender extender;
40
+
41
+ // The module's CSS tree.
42
+ Block_Obj root;
43
+
44
+ public:
45
+
46
+ // default argument constructor
47
+ StyleSheet(const Resource& res, Block_Obj root);
48
+
49
+ // Copy constructor
50
+ StyleSheet(const StyleSheet& res);
51
+
52
+ };
53
+
54
+
55
+ }
56
+
57
+ #endif
@@ -95,8 +95,8 @@ namespace Sass {
95
95
  return arg->value()->perform(this);
96
96
  }
97
97
 
98
- // Selector_List is converted to a string
99
- Value* To_Value::operator()(Selector_List* s)
98
+ // SelectorList is converted to a string
99
+ Value* To_Value::operator()(SelectorList* s)
100
100
  {
101
101
  return SASS_MEMORY_NEW(String_Quoted,
102
102
  s->pstate(),
@@ -36,7 +36,7 @@ namespace Sass {
36
36
  Value* operator()(Function*);
37
37
 
38
38
  // convert to string via `To_String`
39
- Value* operator()(Selector_List*);
39
+ Value* operator()(SelectorList*);
40
40
  Value* operator()(Binary_Expression*);
41
41
 
42
42
  };
@@ -1,5 +1,7 @@
1
1
  #include "sass.hpp"
2
+ #include <map>
2
3
  #include <stdexcept>
4
+ #include <algorithm>
3
5
  #include "units.hpp"
4
6
  #include "error_handling.hpp"
5
7
 
@@ -63,7 +65,7 @@ namespace Sass {
63
65
  }
64
66
  };
65
67
 
66
- std::string get_unit_class(UnitType unit)
68
+ sass::string get_unit_class(UnitType unit)
67
69
  {
68
70
  switch (unit & 0xFF00)
69
71
  {
@@ -89,7 +91,7 @@ namespace Sass {
89
91
  }
90
92
  };
91
93
 
92
- UnitType string_to_unit(const std::string& s)
94
+ UnitType string_to_unit(const sass::string& s)
93
95
  {
94
96
  // size units
95
97
  if (s == "px") return UnitType::PX;
@@ -147,7 +149,7 @@ namespace Sass {
147
149
  }
148
150
  }
149
151
 
150
- std::string unit_to_class(const std::string& s)
152
+ sass::string unit_to_class(const sass::string& s)
151
153
  {
152
154
  if (s == "px") return "LENGTH";
153
155
  else if (s == "pt") return "LENGTH";
@@ -175,7 +177,7 @@ namespace Sass {
175
177
  }
176
178
 
177
179
  // throws incompatibleUnits exceptions
178
- double conversion_factor(const std::string& s1, const std::string& s2)
180
+ double conversion_factor(const sass::string& s1, const sass::string& s2)
179
181
  {
180
182
  // assert for same units
181
183
  if (s1 == s2) return 1;
@@ -217,7 +219,7 @@ namespace Sass {
217
219
  return 0;
218
220
  }
219
221
 
220
- double convert_units(const std::string& lhs, const std::string& rhs, int& lhsexp, int& rhsexp)
222
+ double convert_units(const sass::string& lhs, const sass::string& rhs, int& lhsexp, int& rhsexp)
221
223
  {
222
224
  double f = 0;
223
225
  // do not convert same ones
@@ -281,7 +283,7 @@ namespace Sass {
281
283
  double factor = 1;
282
284
 
283
285
  for (size_t i = 0; i < iL; i++) {
284
- std::string &lhs = numerators[i];
286
+ sass::string &lhs = numerators[i];
285
287
  UnitType ulhs = string_to_unit(lhs);
286
288
  if (ulhs == UNKNOWN) continue;
287
289
  UnitClass clhs = get_unit_type(ulhs);
@@ -294,7 +296,7 @@ namespace Sass {
294
296
  }
295
297
 
296
298
  for (size_t n = 0; n < nL; n++) {
297
- std::string &rhs = denominators[n];
299
+ sass::string &rhs = denominators[n];
298
300
  UnitType urhs = string_to_unit(rhs);
299
301
  if (urhs == UNKNOWN) continue;
300
302
  UnitClass crhs = get_unit_type(urhs);
@@ -326,9 +328,9 @@ namespace Sass {
326
328
  // it seems that a map table will fit nicely to do this
327
329
  // we basically construct exponents for each unit
328
330
  // has the advantage that they will be pre-sorted
329
- std::map<std::string, int> exponents;
331
+ std::map<sass::string, int> exponents;
330
332
 
331
- // initialize by summing up occurences in unit vectors
333
+ // initialize by summing up occurrences in unit vectors
332
334
  // this will already cancel out equivalent units (e.q. px/px)
333
335
  for (size_t i = 0; i < iL; i ++) exponents[numerators[i]] += 1;
334
336
  for (size_t n = 0; n < nL; n ++) exponents[denominators[n]] -= 1;
@@ -339,7 +341,7 @@ namespace Sass {
339
341
  // convert between compatible units
340
342
  for (size_t i = 0; i < iL; i++) {
341
343
  for (size_t n = 0; n < nL; n++) {
342
- std::string &lhs = numerators[i], &rhs = denominators[n];
344
+ sass::string &lhs = numerators[i], &rhs = denominators[n];
343
345
  int &lhsexp = exponents[lhs], &rhsexp = exponents[rhs];
344
346
  double f(convert_units(lhs, rhs, lhsexp, rhsexp));
345
347
  if (f == 0) continue;
@@ -365,9 +367,9 @@ namespace Sass {
365
367
 
366
368
  }
367
369
 
368
- std::string Units::unit() const
370
+ sass::string Units::unit() const
369
371
  {
370
- std::string u;
372
+ sass::string u;
371
373
  size_t iL = numerators.size();
372
374
  size_t nL = denominators.size();
373
375
  for (size_t i = 0; i < iL; i += 1) {
@@ -394,15 +396,15 @@ namespace Sass {
394
396
  denominators.size() == 0;
395
397
  }
396
398
 
397
- // this does not cover all cases (multiple prefered units)
399
+ // this does not cover all cases (multiple preferred units)
398
400
  double Units::convert_factor(const Units& r) const
399
401
  {
400
402
 
401
- std::vector<std::string> miss_nums(0);
402
- std::vector<std::string> miss_dens(0);
403
+ sass::vector<sass::string> miss_nums(0);
404
+ sass::vector<sass::string> miss_dens(0);
403
405
  // create copy since we need these for state keeping
404
- std::vector<std::string> r_nums(r.numerators);
405
- std::vector<std::string> r_dens(r.denominators);
406
+ sass::vector<sass::string> r_nums(r.numerators);
407
+ sass::vector<sass::string> r_dens(r.denominators);
406
408
 
407
409
  auto l_num_it = numerators.begin();
408
410
  auto l_num_end = numerators.end();
@@ -417,7 +419,7 @@ namespace Sass {
417
419
  while (l_num_it != l_num_end)
418
420
  {
419
421
  // get and increment afterwards
420
- const std::string l_num = *(l_num_it ++);
422
+ const sass::string l_num = *(l_num_it ++);
421
423
 
422
424
  auto r_num_it = r_nums.begin(), r_num_end = r_nums.end();
423
425
 
@@ -426,7 +428,7 @@ namespace Sass {
426
428
  while (r_num_it != r_num_end)
427
429
  {
428
430
  // get and increment afterwards
429
- const std::string r_num = *(r_num_it);
431
+ const sass::string r_num = *(r_num_it);
430
432
  // get possible conversion factor for units
431
433
  double conversion = conversion_factor(l_num, r_num);
432
434
  // skip incompatible numerator
@@ -454,7 +456,7 @@ namespace Sass {
454
456
  while (l_den_it != l_den_end)
455
457
  {
456
458
  // get and increment afterwards
457
- const std::string l_den = *(l_den_it ++);
459
+ const sass::string l_den = *(l_den_it ++);
458
460
 
459
461
  auto r_den_it = r_dens.begin();
460
462
  auto r_den_end = r_dens.end();
@@ -464,8 +466,8 @@ namespace Sass {
464
466
  while (r_den_it != r_den_end)
465
467
  {
466
468
  // get and increment afterwards
467
- const std::string r_den = *(r_den_it);
468
- // get possible converstion factor for units
469
+ const sass::string r_den = *(r_den_it);
470
+ // get possible conversion factor for units
469
471
  double conversion = conversion_factor(l_den, r_den);
470
472
  // skip incompatible denominator
471
473
  if (conversion == 0) {
@@ -55,8 +55,8 @@ namespace Sass {
55
55
 
56
56
  class Units {
57
57
  public:
58
- std::vector<std::string> numerators;
59
- std::vector<std::string> denominators;
58
+ sass::vector<sass::string> numerators;
59
+ sass::vector<sass::string> denominators;
60
60
  public:
61
61
  // default constructor
62
62
  Units() :
@@ -69,7 +69,7 @@ namespace Sass {
69
69
  denominators(ptr->denominators)
70
70
  { }
71
71
  // convert to string
72
- std::string unit() const;
72
+ sass::string unit() const;
73
73
  // get if units are empty
74
74
  bool is_unitless() const;
75
75
  // return if valid for css
@@ -95,15 +95,15 @@ namespace Sass {
95
95
  extern const double resolution_conversion_factors[3][3];
96
96
 
97
97
  UnitType get_main_unit(const UnitClass unit);
98
- enum Sass::UnitType string_to_unit(const std::string&);
98
+ enum Sass::UnitType string_to_unit(const sass::string&);
99
99
  const char* unit_to_string(Sass::UnitType unit);
100
100
  enum Sass::UnitClass get_unit_type(Sass::UnitType unit);
101
- std::string get_unit_class(Sass::UnitType unit);
102
- std::string unit_to_class(const std::string&);
101
+ sass::string get_unit_class(Sass::UnitType unit);
102
+ sass::string unit_to_class(const sass::string&);
103
103
  // throws incompatibleUnits exceptions
104
- double conversion_factor(const std::string&, const std::string&);
104
+ double conversion_factor(const sass::string&, const sass::string&);
105
105
  double conversion_factor(UnitType, UnitType, UnitClass, UnitClass);
106
- double convert_units(const std::string&, const std::string&, int&, int&);
106
+ double convert_units(const sass::string&, const sass::string&, int&, int&);
107
107
 
108
108
  }
109
109
 
@@ -11,7 +11,6 @@
11
11
 
12
12
  namespace Sass {
13
13
  namespace UTF_8 {
14
- using std::string;
15
14
 
16
15
  // naming conventions:
17
16
  // offset: raw byte offset (0 based)
@@ -19,25 +18,25 @@ namespace Sass {
19
18
  // index: code point offset (1 based or negative)
20
19
 
21
20
  // function that will count the number of code points (utf-8 characters) from the given beginning to the given end
22
- size_t code_point_count(const string& str, size_t start, size_t end) {
21
+ size_t code_point_count(const sass::string& str, size_t start, size_t end) {
23
22
  return utf8::distance(str.begin() + start, str.begin() + end);
24
23
  }
25
24
 
26
- size_t code_point_count(const string& str) {
25
+ size_t code_point_count(const sass::string& str) {
27
26
  return utf8::distance(str.begin(), str.end());
28
27
  }
29
28
 
30
29
  // function that will return the byte offset at a code point position
31
- size_t offset_at_position(const string& str, size_t position) {
32
- string::const_iterator it = str.begin();
30
+ size_t offset_at_position(const sass::string& str, size_t position) {
31
+ sass::string::const_iterator it = str.begin();
33
32
  utf8::advance(it, position, str.end());
34
33
  return std::distance(str.begin(), it);
35
34
  }
36
35
 
37
36
  // function that returns number of bytes in a character at offset
38
- size_t code_point_size_at_offset(const string& str, size_t offset) {
37
+ size_t code_point_size_at_offset(const sass::string& str, size_t offset) {
39
38
  // get iterator from string and forward by offset
40
- string::const_iterator stop = str.begin() + offset;
39
+ sass::string::const_iterator stop = str.begin() + offset;
41
40
  // check if beyond boundary
42
41
  if (stop == str.end()) return 0;
43
42
  // advance by one code point
@@ -78,9 +77,9 @@ namespace Sass {
78
77
  using std::wstring;
79
78
 
80
79
  // convert from utf16/wide string to utf8 string
81
- string convert_from_utf16(const wstring& utf16)
80
+ sass::string convert_from_utf16(const wstring& utf16)
82
81
  {
83
- string utf8;
82
+ sass::string utf8;
84
83
  // pre-allocate expected memory
85
84
  utf8.reserve(sizeof(utf16)/2);
86
85
  utf8::utf16to8(utf16.begin(), utf16.end(),
@@ -89,7 +88,7 @@ namespace Sass {
89
88
  }
90
89
 
91
90
  // convert from utf8 string to utf16/wide string
92
- wstring convert_to_utf16(const string& utf8)
91
+ wstring convert_to_utf16(const sass::string& utf8)
93
92
  {
94
93
  wstring utf16;
95
94
  // pre-allocate expected memory
@@ -3,6 +3,7 @@
3
3
 
4
4
  #include <string>
5
5
  #include "utf8.h"
6
+ #include "memory.hpp"
6
7
 
7
8
  namespace Sass {
8
9
  namespace UTF_8 {
@@ -13,22 +14,22 @@ namespace Sass {
13
14
  // index: code point offset (1 based or negative)
14
15
 
15
16
  // function that will count the number of code points (utf-8 characters) from the beginning to the given end
16
- size_t code_point_count(const std::string& str, size_t start, size_t end);
17
- size_t code_point_count(const std::string& str);
17
+ size_t code_point_count(const sass::string& str, size_t start, size_t end);
18
+ size_t code_point_count(const sass::string& str);
18
19
 
19
20
  // function that will return the byte offset of a code point in a
20
- size_t offset_at_position(const std::string& str, size_t position);
21
+ size_t offset_at_position(const sass::string& str, size_t position);
21
22
 
22
23
  // function that returns number of bytes in a character in a string
23
- size_t code_point_size_at_offset(const std::string& str, size_t offset);
24
+ size_t code_point_size_at_offset(const sass::string& str, size_t offset);
24
25
 
25
26
  // function that will return a normalized index, given a crazy one
26
27
  size_t normalize_index(int index, size_t len);
27
28
 
28
29
  #ifdef _WIN32
29
30
  // functions to handle unicode paths on windows
30
- std::string convert_from_utf16(const std::wstring& wstr);
31
- std::wstring convert_to_utf16(const std::string& str);
31
+ sass::string convert_from_utf16(const std::wstring& wstr);
32
+ std::wstring convert_to_utf16(const sass::string& str);
32
33
  #endif
33
34
 
34
35
  }