sassc 1.8.1 → 1.8.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +3 -1
  3. data/ext/libsass/Makefile +10 -6
  4. data/ext/libsass/Readme.md +4 -4
  5. data/ext/libsass/appveyor.yml +16 -1
  6. data/ext/libsass/docs/README.md +1 -1
  7. data/ext/libsass/docs/api-context-example.md +1 -1
  8. data/ext/libsass/docs/api-context.md +1 -1
  9. data/ext/libsass/docs/api-doc.md +1 -1
  10. data/ext/libsass/docs/api-function-example.md +12 -3
  11. data/ext/libsass/docs/api-function-internal.md +4 -4
  12. data/ext/libsass/docs/api-function.md +15 -13
  13. data/ext/libsass/docs/api-importer-internal.md +9 -4
  14. data/ext/libsass/docs/api-value.md +1 -1
  15. data/ext/libsass/docs/build-shared-library.md +3 -3
  16. data/ext/libsass/docs/custom-functions-internal.md +1 -1
  17. data/ext/libsass/docs/{plugins.go → plugins.md} +0 -0
  18. data/ext/libsass/script/ci-build-libsass +25 -36
  19. data/ext/libsass/script/ci-install-deps +3 -8
  20. data/ext/libsass/script/ci-report-coverage +17 -13
  21. data/ext/libsass/src/ast.cpp +102 -7
  22. data/ext/libsass/src/ast.hpp +53 -27
  23. data/ext/libsass/src/ast_def_macros.hpp +8 -0
  24. data/ext/libsass/src/ast_fwd_decl.hpp +3 -2
  25. data/ext/libsass/src/backtrace.hpp +1 -1
  26. data/ext/libsass/src/bind.cpp +28 -17
  27. data/ext/libsass/src/bind.hpp +1 -1
  28. data/ext/libsass/src/context.cpp +441 -184
  29. data/ext/libsass/src/context.hpp +79 -82
  30. data/ext/libsass/src/debugger.hpp +3 -1
  31. data/ext/libsass/src/emitter.cpp +18 -17
  32. data/ext/libsass/src/emitter.hpp +5 -2
  33. data/ext/libsass/src/error_handling.cpp +78 -7
  34. data/ext/libsass/src/error_handling.hpp +50 -9
  35. data/ext/libsass/src/eval.cpp +100 -36
  36. data/ext/libsass/src/eval.hpp +5 -5
  37. data/ext/libsass/src/expand.cpp +32 -3
  38. data/ext/libsass/src/extend.cpp +1 -1
  39. data/ext/libsass/src/file.cpp +39 -27
  40. data/ext/libsass/src/file.hpp +67 -13
  41. data/ext/libsass/src/functions.cpp +39 -32
  42. data/ext/libsass/src/inspect.cpp +21 -21
  43. data/ext/libsass/src/json.cpp +1 -1
  44. data/ext/libsass/src/lexer.hpp +33 -4
  45. data/ext/libsass/src/output.cpp +11 -11
  46. data/ext/libsass/src/parser.cpp +28 -130
  47. data/ext/libsass/src/parser.hpp +0 -4
  48. data/ext/libsass/src/prelexer.cpp +8 -5
  49. data/ext/libsass/src/prelexer.hpp +1 -3
  50. data/ext/libsass/src/sass_context.cpp +52 -241
  51. data/ext/libsass/src/sass_context.hpp +156 -0
  52. data/ext/libsass/src/sass_functions.cpp +1 -26
  53. data/ext/libsass/src/sass_functions.hpp +32 -0
  54. data/ext/libsass/src/sass_interface.cpp +14 -48
  55. data/ext/libsass/src/sass_values.cpp +3 -77
  56. data/ext/libsass/src/sass_values.hpp +81 -0
  57. data/ext/libsass/src/source_map.cpp +7 -7
  58. data/ext/libsass/src/source_map.hpp +1 -4
  59. data/ext/libsass/src/to_string.cpp +4 -3
  60. data/ext/libsass/src/to_string.hpp +2 -1
  61. data/ext/libsass/src/util.cpp +34 -16
  62. data/ext/libsass/src/util.hpp +10 -8
  63. data/lib/sassc/version.rb +1 -1
  64. data/lib/tasks/libsass.rb +1 -1
  65. data/test/custom_importer_test.rb +6 -4
  66. data/test/engine_test.rb +5 -3
  67. data/test/functions_test.rb +1 -0
  68. data/test/native_test.rb +1 -1
  69. metadata +6 -4
  70. data/ext/libsass/script/coveralls-debug +0 -32
@@ -2,17 +2,11 @@
2
2
  #include "util.hpp"
3
3
  #include "context.hpp"
4
4
  #include "sass/functions.h"
5
+ #include "sass_functions.hpp"
5
6
 
6
7
  extern "C" {
7
8
  using namespace Sass;
8
9
 
9
- // Struct to hold custom function callback
10
- struct Sass_Function {
11
- const char* signature;
12
- Sass_Function_Fn function;
13
- void* cookie;
14
- };
15
-
16
10
  Sass_Function_List ADDCALL sass_make_function_list(size_t length)
17
11
  {
18
12
  return (Sass_Function_List) calloc(length + 1, sizeof(Sass_Function_Entry));
@@ -36,25 +30,6 @@ extern "C" {
36
30
  Sass_Function_Fn ADDCALL sass_function_get_function(Sass_Function_Entry cb) { return cb->function; }
37
31
  void* ADDCALL sass_function_get_cookie(Sass_Function_Entry cb) { return cb->cookie; }
38
32
 
39
- // External import entry
40
- struct Sass_Import {
41
- char* imp_path; // path as found in the import statement
42
- char *abs_path; // path after importer has resolved it
43
- char* source;
44
- char* srcmap;
45
- // error handling
46
- char* error;
47
- size_t line;
48
- size_t column;
49
- };
50
-
51
- // Struct to hold importer callback
52
- struct Sass_Importer {
53
- Sass_Importer_Fn importer;
54
- double priority;
55
- void* cookie;
56
- };
57
-
58
33
  Sass_Importer_Entry ADDCALL sass_make_importer(Sass_Importer_Fn importer, double priority, void* cookie)
59
34
  {
60
35
  Sass_Importer_Entry cb = (Sass_Importer_Entry) calloc(1, sizeof(Sass_Importer));
@@ -0,0 +1,32 @@
1
+ #ifndef SASS_SASS_FUNCTIONS_H
2
+ #define SASS_SASS_FUNCTIONS_H
3
+
4
+ #include "sass.h"
5
+
6
+ // Struct to hold custom function callback
7
+ struct Sass_Function {
8
+ const char* signature;
9
+ Sass_Function_Fn function;
10
+ void* cookie;
11
+ };
12
+
13
+ // External import entry
14
+ struct Sass_Import {
15
+ char* imp_path; // path as found in the import statement
16
+ char *abs_path; // path after importer has resolved it
17
+ char* source;
18
+ char* srcmap;
19
+ // error handling
20
+ char* error;
21
+ size_t line;
22
+ size_t column;
23
+ };
24
+
25
+ // Struct to hold importer callback
26
+ struct Sass_Importer {
27
+ Sass_Importer_Fn importer;
28
+ double priority;
29
+ void* cookie;
30
+ };
31
+
32
+ #endif
@@ -69,26 +69,8 @@ extern "C" {
69
69
  else {
70
70
  output_path = c_ctx->output_path;
71
71
  }
72
- Context cpp_ctx(
73
- Context::Data().source_c_str(c_ctx->source_string)
74
- .output_path(output_path)
75
- .output_style((Output_Style) c_ctx->options.output_style)
76
- .is_indented_syntax_src(c_ctx->options.is_indented_syntax_src)
77
- .source_comments(c_ctx->options.source_comments)
78
- .source_map_file(safe_str(c_ctx->options.source_map_file))
79
- .source_map_root(safe_str(c_ctx->options.source_map_root))
80
- .source_map_embed(c_ctx->options.source_map_embed)
81
- .source_map_contents(c_ctx->options.source_map_contents)
82
- .omit_source_map_url(c_ctx->options.omit_source_map_url)
83
- .include_paths_c_str(c_ctx->options.include_paths)
84
- .plugin_paths_c_str(c_ctx->options.plugin_paths)
85
- // .include_paths_array(0)
86
- // .plugin_paths_array(0)
87
- .include_paths(std::vector<std::string>())
88
- .plugin_paths(std::vector<std::string>())
89
- .precision(c_ctx->options.precision ? c_ctx->options.precision : 5)
90
- .indent(c_ctx->options.indent ? c_ctx->options.indent : " ")
91
- .linefeed(c_ctx->options.linefeed ? c_ctx->options.linefeed : LFEED)
72
+ Data_Context cpp_ctx(
73
+ (Sass_Data_Context*) 0
92
74
  );
93
75
  if (c_ctx->c_functions) {
94
76
  Sass_Function_List this_func_data = c_ctx->c_functions;
@@ -97,17 +79,18 @@ extern "C" {
97
79
  ++this_func_data;
98
80
  }
99
81
  }
100
- c_ctx->output_string = cpp_ctx.compile_string();
101
- c_ctx->source_map_string = cpp_ctx.generate_source_map();
82
+ Block* root = cpp_ctx.parse();
83
+ c_ctx->output_string = cpp_ctx.render(root);
84
+ c_ctx->source_map_string = cpp_ctx.render_srcmap();
102
85
  c_ctx->error_message = 0;
103
86
  c_ctx->error_status = 0;
104
87
 
105
88
  if (copy_strings(cpp_ctx.get_included_files(true), &c_ctx->included_files, 1) == NULL)
106
89
  throw(std::bad_alloc());
107
90
  }
108
- catch (Error_Invalid& e) {
91
+ catch (Exception::InvalidSass& e) {
109
92
  std::stringstream msg_stream;
110
- msg_stream << e.pstate.path << ":" << e.pstate.line << ": " << e.message << std::endl;
93
+ msg_stream << e.pstate.path << ":" << e.pstate.line << ": " << e.what() << std::endl;
111
94
  c_ctx->error_message = sass_strdup(msg_stream.str().c_str());
112
95
  c_ctx->error_status = 1;
113
96
  c_ctx->output_string = 0;
@@ -162,26 +145,8 @@ extern "C" {
162
145
  else {
163
146
  output_path = c_ctx->output_path;
164
147
  }
165
- Context cpp_ctx(
166
- Context::Data().entry_point(input_path)
167
- .output_path(output_path)
168
- .output_style((Output_Style) c_ctx->options.output_style)
169
- .is_indented_syntax_src(c_ctx->options.is_indented_syntax_src)
170
- .source_comments(c_ctx->options.source_comments)
171
- .source_map_file(safe_str(c_ctx->options.source_map_file))
172
- .source_map_root(safe_str(c_ctx->options.source_map_root))
173
- .source_map_embed(c_ctx->options.source_map_embed)
174
- .source_map_contents(c_ctx->options.source_map_contents)
175
- .omit_source_map_url(c_ctx->options.omit_source_map_url)
176
- .include_paths_c_str(c_ctx->options.include_paths)
177
- .plugin_paths_c_str(c_ctx->options.plugin_paths)
178
- // .include_paths_array(0)
179
- // .plugin_paths_array(0)
180
- .include_paths(std::vector<std::string>())
181
- .plugin_paths(std::vector<std::string>())
182
- .precision(c_ctx->options.precision ? c_ctx->options.precision : 5)
183
- .indent(c_ctx->options.indent ? c_ctx->options.indent : " ")
184
- .linefeed(c_ctx->options.linefeed ? c_ctx->options.linefeed : LFEED)
148
+ File_Context cpp_ctx(
149
+ (Sass_File_Context*) 0
185
150
  );
186
151
  if (c_ctx->c_functions) {
187
152
  Sass_Function_List this_func_data = c_ctx->c_functions;
@@ -190,17 +155,18 @@ extern "C" {
190
155
  ++this_func_data;
191
156
  }
192
157
  }
193
- c_ctx->output_string = cpp_ctx.compile_file();
194
- c_ctx->source_map_string = cpp_ctx.generate_source_map();
158
+ Block* root = cpp_ctx.parse();
159
+ c_ctx->output_string = cpp_ctx.render(root);
160
+ c_ctx->source_map_string = cpp_ctx.render_srcmap();
195
161
  c_ctx->error_message = 0;
196
162
  c_ctx->error_status = 0;
197
163
 
198
164
  if (copy_strings(cpp_ctx.get_included_files(false), &c_ctx->included_files) == NULL)
199
165
  throw(std::bad_alloc());
200
166
  }
201
- catch (Error_Invalid& e) {
167
+ catch (Exception::InvalidSass& e) {
202
168
  std::stringstream msg_stream;
203
- msg_stream << e.pstate.path << ":" << e.pstate.line << ": " << e.message << std::endl;
169
+ msg_stream << e.pstate.path << ":" << e.pstate.line << ": " << e.what() << std::endl;
204
170
  c_ctx->error_message = sass_strdup(msg_stream.str().c_str());
205
171
  c_ctx->error_status = 1;
206
172
  c_ctx->output_string = 0;
@@ -4,85 +4,11 @@
4
4
  #include "eval.hpp"
5
5
  #include "values.hpp"
6
6
  #include "sass/values.h"
7
+ #include "sass_values.hpp"
7
8
 
8
9
  extern "C" {
9
10
  using namespace Sass;
10
11
 
11
- struct Sass_Unknown {
12
- enum Sass_Tag tag;
13
- };
14
-
15
- struct Sass_Boolean {
16
- enum Sass_Tag tag;
17
- bool value;
18
- };
19
-
20
- struct Sass_Number {
21
- enum Sass_Tag tag;
22
- double value;
23
- char* unit;
24
- };
25
-
26
- struct Sass_Color {
27
- enum Sass_Tag tag;
28
- double r;
29
- double g;
30
- double b;
31
- double a;
32
- };
33
-
34
- struct Sass_String {
35
- enum Sass_Tag tag;
36
- bool quoted;
37
- char* value;
38
- };
39
-
40
- struct Sass_List {
41
- enum Sass_Tag tag;
42
- enum Sass_Separator separator;
43
- size_t length;
44
- // null terminated "array"
45
- union Sass_Value** values;
46
- };
47
-
48
- struct Sass_Map {
49
- enum Sass_Tag tag;
50
- size_t length;
51
- struct Sass_MapPair* pairs;
52
- };
53
-
54
- struct Sass_Null {
55
- enum Sass_Tag tag;
56
- };
57
-
58
- struct Sass_Error {
59
- enum Sass_Tag tag;
60
- char* message;
61
- };
62
-
63
- struct Sass_Warning {
64
- enum Sass_Tag tag;
65
- char* message;
66
- };
67
-
68
- union Sass_Value {
69
- struct Sass_Unknown unknown;
70
- struct Sass_Boolean boolean;
71
- struct Sass_Number number;
72
- struct Sass_Color color;
73
- struct Sass_String string;
74
- struct Sass_List list;
75
- struct Sass_Map map;
76
- struct Sass_Null null;
77
- struct Sass_Error error;
78
- struct Sass_Warning warning;
79
- };
80
-
81
- struct Sass_MapPair {
82
- union Sass_Value* key;
83
- union Sass_Value* value;
84
- };
85
-
86
12
  // Return the sass tag for a generic sass value
87
13
  enum Sass_Tag ADDCALL sass_value_get_tag(const union Sass_Value* v) { return v->unknown.tag; }
88
14
 
@@ -411,8 +337,8 @@ extern "C" {
411
337
  }
412
338
 
413
339
  // simply pass the error message back to the caller for now
414
- catch (Error_Invalid& e) { return sass_make_error(e.message.c_str()); }
415
- catch (std::bad_alloc& ba) { return sass_make_error("memory exhausted"); }
340
+ catch (Exception::InvalidSass& e) { return sass_make_error(e.what()); }
341
+ catch (std::bad_alloc&) { return sass_make_error("memory exhausted"); }
416
342
  catch (std::exception& e) { return sass_make_error(e.what()); }
417
343
  catch (std::string& e) { return sass_make_error(e.c_str()); }
418
344
  catch (const char* e) { return sass_make_error(e); }
@@ -0,0 +1,81 @@
1
+ #ifndef SASS_SASS_VALUES_H
2
+ #define SASS_SASS_VALUES_H
3
+
4
+ #include "sass.h"
5
+
6
+ struct Sass_Unknown {
7
+ enum Sass_Tag tag;
8
+ };
9
+
10
+ struct Sass_Boolean {
11
+ enum Sass_Tag tag;
12
+ bool value;
13
+ };
14
+
15
+ struct Sass_Number {
16
+ enum Sass_Tag tag;
17
+ double value;
18
+ char* unit;
19
+ };
20
+
21
+ struct Sass_Color {
22
+ enum Sass_Tag tag;
23
+ double r;
24
+ double g;
25
+ double b;
26
+ double a;
27
+ };
28
+
29
+ struct Sass_String {
30
+ enum Sass_Tag tag;
31
+ bool quoted;
32
+ char* value;
33
+ };
34
+
35
+ struct Sass_List {
36
+ enum Sass_Tag tag;
37
+ enum Sass_Separator separator;
38
+ size_t length;
39
+ // null terminated "array"
40
+ union Sass_Value** values;
41
+ };
42
+
43
+ struct Sass_Map {
44
+ enum Sass_Tag tag;
45
+ size_t length;
46
+ struct Sass_MapPair* pairs;
47
+ };
48
+
49
+ struct Sass_Null {
50
+ enum Sass_Tag tag;
51
+ };
52
+
53
+ struct Sass_Error {
54
+ enum Sass_Tag tag;
55
+ char* message;
56
+ };
57
+
58
+ struct Sass_Warning {
59
+ enum Sass_Tag tag;
60
+ char* message;
61
+ };
62
+
63
+ union Sass_Value {
64
+ struct Sass_Unknown unknown;
65
+ struct Sass_Boolean boolean;
66
+ struct Sass_Number number;
67
+ struct Sass_Color color;
68
+ struct Sass_String string;
69
+ struct Sass_List list;
70
+ struct Sass_Map map;
71
+ struct Sass_Null null;
72
+ struct Sass_Error error;
73
+ struct Sass_Warning warning;
74
+ };
75
+
76
+ struct Sass_MapPair {
77
+ union Sass_Value* key;
78
+ union Sass_Value* value;
79
+ };
80
+
81
+ #endif
@@ -14,11 +14,11 @@ namespace Sass {
14
14
  SourceMap::SourceMap() : current_position(0, 0, 0), file("stdin") { }
15
15
  SourceMap::SourceMap(const std::string& file) : current_position(0, 0, 0), file(file) { }
16
16
 
17
- std::string SourceMap::generate_source_map(Context &ctx) {
17
+ std::string SourceMap::render_srcmap(Context &ctx) {
18
18
 
19
- const bool include_sources = ctx.source_map_contents;
20
- const std::vector<std::string> includes = ctx.include_links;
21
- const std::vector<char*> sources = ctx.sources;
19
+ const bool include_sources = ctx.c_options->source_map_contents;
20
+ const std::vector<std::string> links = ctx.srcmap_links;
21
+ const std::vector<Resource>& sources(ctx.resources);
22
22
 
23
23
  JsonNode* json_srcmap = json_mkobject();
24
24
 
@@ -36,7 +36,7 @@ namespace Sass {
36
36
 
37
37
  JsonNode *json_includes = json_mkarray();
38
38
  for (size_t i = 0; i < source_index.size(); ++i) {
39
- const char *include = includes[source_index[i]].c_str();
39
+ const char *include = links[source_index[i]].c_str();
40
40
  JsonNode *json_include = json_mkstring(include);
41
41
  json_append_element(json_includes, json_include);
42
42
  }
@@ -45,8 +45,8 @@ namespace Sass {
45
45
  if (include_sources) {
46
46
  JsonNode *json_contents = json_mkarray();
47
47
  for (size_t i = 0; i < source_index.size(); ++i) {
48
- const char *content = sources[source_index[i]];
49
- JsonNode *json_content = json_mkstring(content);
48
+ const Resource& resource(sources[source_index[i]]);
49
+ JsonNode *json_content = json_mkstring(resource.contents);
50
50
  json_append_element(json_contents, json_content);
51
51
  }
52
52
  if (json_contents->children.head)
@@ -24,9 +24,6 @@ namespace Sass {
24
24
  SourceMap();
25
25
  SourceMap(const std::string& file);
26
26
 
27
- void setFile(const std::string& str) {
28
- file = str;
29
- }
30
27
  void append(const Offset& offset);
31
28
  void prepend(const Offset& offset);
32
29
  void append(const OutputBuffer& out);
@@ -34,7 +31,7 @@ namespace Sass {
34
31
  void add_open_mapping(AST_Node* node);
35
32
  void add_close_mapping(AST_Node* node);
36
33
 
37
- std::string generate_source_map(Context &ctx);
34
+ std::string render_srcmap(Context &ctx);
38
35
  ParserState remap(const ParserState& pstate);
39
36
 
40
37
  private:
@@ -10,8 +10,8 @@
10
10
 
11
11
  namespace Sass {
12
12
 
13
- To_String::To_String(Context* ctx, bool in_declaration)
14
- : ctx(ctx), in_declaration(in_declaration) { }
13
+ To_String::To_String(Context* ctx, bool in_declaration, bool in_debug)
14
+ : ctx(ctx), in_declaration(in_declaration), in_debug(in_debug) { }
15
15
  To_String::~To_String() { }
16
16
 
17
17
  inline std::string To_String::fallback_impl(AST_Node* n)
@@ -19,6 +19,7 @@ namespace Sass {
19
19
  Emitter emitter(ctx);
20
20
  Inspect i(emitter);
21
21
  i.in_declaration = in_declaration;
22
+ i.in_debug = in_debug;
22
23
  if (n) n->perform(&i);
23
24
  return i.get_buffer();
24
25
  }
@@ -43,5 +44,5 @@ namespace Sass {
43
44
  }
44
45
 
45
46
  inline std::string To_String::operator()(Null* n)
46
- { return ""; }
47
+ { return in_debug ? "null" : ""; }
47
48
  }
@@ -18,10 +18,11 @@ namespace Sass {
18
18
 
19
19
  Context* ctx;
20
20
  bool in_declaration;
21
+ bool in_debug;
21
22
 
22
23
  public:
23
24
 
24
- To_String(Context* ctx = 0, bool in_declaration = true);
25
+ To_String(Context* ctx = 0, bool in_declaration = true, bool in_debug = false);
25
26
  virtual ~To_String();
26
27
 
27
28
  std::string operator()(Null* n);