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
@@ -15,6 +15,7 @@ namespace Sass {
15
15
  // Match Sass boolean keywords.
16
16
  const char* kwd_true(const char* src);
17
17
  const char* kwd_false(const char* src);
18
+ const char* kwd_only(const char* src);
18
19
  const char* kwd_and(const char* src);
19
20
  const char* kwd_or(const char* src);
20
21
  const char* kwd_not(const char* src);
@@ -337,9 +338,6 @@ namespace Sass {
337
338
  const char* ie_keyword_arg_value(const char* src);
338
339
  const char* ie_keyword_arg_property(const char* src);
339
340
 
340
- // match urls
341
- const char* url(const char* src);
342
-
343
341
  // match url()
344
342
  const char* H(const char* src);
345
343
  const char* W(const char* src);
@@ -9,6 +9,7 @@
9
9
  #include "json.hpp"
10
10
  #include "util.hpp"
11
11
  #include "context.hpp"
12
+ #include "sass_context.hpp"
12
13
  #include "ast_fwd_decl.hpp"
13
14
  #include "error_handling.hpp"
14
15
 
@@ -17,161 +18,15 @@
17
18
  extern "C" {
18
19
  using namespace Sass;
19
20
 
20
- // Input behaviours
21
- enum Sass_Input_Style {
22
- SASS_CONTEXT_NULL,
23
- SASS_CONTEXT_FILE,
24
- SASS_CONTEXT_DATA,
25
- SASS_CONTEXT_FOLDER
26
- };
27
-
28
- // simple linked list
29
- struct string_list {
30
- string_list* next;
31
- char* string;
32
- };
33
-
34
- // sass config options structure
35
- struct Sass_Options {
36
-
37
- // Precision for fractional numbers
38
- int precision;
39
-
40
- // Output style for the generated css code
41
- // A value from above SASS_STYLE_* constants
42
- enum Sass_Output_Style output_style;
43
-
44
- // Emit comments in the generated CSS indicating
45
- // the corresponding source line.
46
- bool source_comments;
47
-
48
- // embed sourceMappingUrl as data uri
49
- bool source_map_embed;
50
-
51
- // embed include contents in maps
52
- bool source_map_contents;
53
-
54
- // Disable sourceMappingUrl in css output
55
- bool omit_source_map_url;
56
-
57
- // Treat source_string as sass (as opposed to scss)
58
- bool is_indented_syntax_src;
59
-
60
- // The input path is used for source map
61
- // generation. It can be used to define
62
- // something with string compilation or to
63
- // overload the input file path. It is
64
- // set to "stdin" for data contexts and
65
- // to the input file on file contexts.
66
- char* input_path;
67
-
68
- // The output path is used for source map
69
- // generation. Libsass will not write to
70
- // this file, it is just used to create
71
- // information in source-maps etc.
72
- char* output_path;
73
-
74
- // String to be used for indentation
75
- const char* indent;
76
- // String to be used to for line feeds
77
- const char* linefeed;
78
-
79
- // Colon-separated list of paths
80
- // Semicolon-separated on Windows
81
- // Maybe use array interface instead?
82
- char* include_path;
83
- char* plugin_path;
84
-
85
- // Include paths (linked string list)
86
- struct string_list* include_paths;
87
- // Plugin paths (linked string list)
88
- struct string_list* plugin_paths;
89
-
90
- // Path to source map file
91
- // Enables source map generation
92
- // Used to create sourceMappingUrl
93
- char* source_map_file;
94
-
95
- // Directly inserted in source maps
96
- char* source_map_root;
97
-
98
- // Custom functions that can be called from sccs code
99
- Sass_Function_List c_functions;
100
-
101
- // List of custom importers
102
- Sass_Importer_List c_importers;
103
-
104
- // List of custom headers
105
- Sass_Importer_List c_headers;
106
-
107
- };
108
-
109
- // base for all contexts
110
- struct Sass_Context : Sass_Options
111
- {
112
-
113
- // store context type info
114
- enum Sass_Input_Style type;
115
-
116
- // generated output data
117
- char* output_string;
118
-
119
- // generated source map json
120
- char* source_map_string;
121
-
122
- // error status
123
- int error_status;
124
- char* error_json;
125
- char* error_text;
126
- char* error_message;
127
- // error position
128
- char* error_file;
129
- size_t error_line;
130
- size_t error_column;
131
- const char* error_src;
132
-
133
- // report imported files
134
- char** included_files;
135
-
136
- };
137
-
138
- // struct for file compilation
139
- struct Sass_File_Context : Sass_Context {
140
-
141
- // no additional fields required
142
- // input_path is already on options
143
-
144
- };
145
-
146
- // struct for data compilation
147
- struct Sass_Data_Context : Sass_Context {
148
-
149
- // provided source string
150
- char* source_string;
151
-
152
- };
153
-
154
- // link c and cpp context
155
- struct Sass_Compiler {
156
- // progress status
157
- Sass_Compiler_State state;
158
- // original c context
159
- Sass_Context* c_ctx;
160
- // Sass::Context
161
- Context* cpp_ctx;
162
- // Sass::Block
163
- Block* root;
164
- };
165
-
166
21
  static void copy_options(struct Sass_Options* to, struct Sass_Options* from) { *to = *from; }
167
22
 
168
23
  #define IMPLEMENT_SASS_OPTION_ACCESSOR(type, option) \
169
24
  type ADDCALL sass_option_get_##option (struct Sass_Options* options) { return options->option; } \
170
25
  void ADDCALL sass_option_set_##option (struct Sass_Options* options, type option) { options->option = option; }
171
- #define IMPLEMENT_SASS_OPTION_STRING_ACCESSOR(type, option) \
172
- type ADDCALL sass_option_get_##option (struct Sass_Options* options) { return options->option; } \
26
+ #define IMPLEMENT_SASS_OPTION_STRING_ACCESSOR(type, option, def) \
27
+ type ADDCALL sass_option_get_##option (struct Sass_Options* options) { return safe_str(options->option, def); } \
173
28
  void ADDCALL sass_option_set_##option (struct Sass_Options* options, type option) \
174
- { free(options->option); options->option = option ? sass_strdup(option) : 0; }
29
+ { free(options->option); options->option = option || def ? sass_strdup(option ? option : def) : 0; }
175
30
 
176
31
  #define IMPLEMENT_SASS_CONTEXT_GETTER(type, option) \
177
32
  type ADDCALL sass_context_get_##option (struct Sass_Context* ctx) { return ctx->option; }
@@ -183,24 +38,26 @@ extern "C" {
183
38
  try {
184
39
  throw;
185
40
  }
186
- catch (Error_Invalid& e) {
41
+ catch (Exception::Base& e) {
187
42
  std::stringstream msg_stream;
188
43
  std::string cwd(Sass::File::get_cwd());
189
- std::string rel_path(Sass::File::resolve_relative_path(e.pstate.path, cwd, cwd));
44
+ std::string rel_path(Sass::File::abs2rel(e.pstate.path, cwd, cwd));
190
45
 
191
46
  std::string msg_prefix("Error: ");
192
47
  bool got_newline = false;
193
48
  msg_stream << msg_prefix;
194
- for (char chr : e.message) {
195
- if (chr == '\r') {
49
+ const char* msg = e.what();
50
+ while(msg && *msg) {
51
+ if (*msg == '\r') {
196
52
  got_newline = true;
197
- } else if (chr == '\n') {
53
+ } else if (*msg == '\n') {
198
54
  got_newline = true;
199
55
  } else if (got_newline) {
200
56
  msg_stream << std::string(msg_prefix.size(), ' ');
201
57
  got_newline = false;
202
58
  }
203
- msg_stream << chr;
59
+ msg_stream << *msg;
60
+ ++ msg;
204
61
  }
205
62
  if (!got_newline) msg_stream << "\n";
206
63
  msg_stream << std::string(msg_prefix.size(), ' ');
@@ -233,12 +90,12 @@ extern "C" {
233
90
  json_append_member(json_err, "file", json_mkstring(e.pstate.path));
234
91
  json_append_member(json_err, "line", json_mknumber((double)(e.pstate.line+1)));
235
92
  json_append_member(json_err, "column", json_mknumber((double)(e.pstate.column+1)));
236
- json_append_member(json_err, "message", json_mkstring(e.message.c_str()));
93
+ json_append_member(json_err, "message", json_mkstring(e.what()));
237
94
  json_append_member(json_err, "formatted", json_mkstring(msg_stream.str().c_str()));
238
95
 
239
96
  c_ctx->error_json = json_stringify(json_err, " ");;
240
97
  c_ctx->error_message = sass_strdup(msg_stream.str().c_str());
241
- c_ctx->error_text = sass_strdup(e.message.c_str());
98
+ c_ctx->error_text = sass_strdup(e.what());
242
99
  c_ctx->error_status = 1;
243
100
  c_ctx->error_file = sass_strdup(e.pstate.path);
244
101
  c_ctx->error_line = e.pstate.line+1;
@@ -322,19 +179,10 @@ extern "C" {
322
179
  }
323
180
 
324
181
  // generic compilation function (not exported, use file/data compile instead)
325
- static Sass_Compiler* sass_prepare_context (Sass_Context* c_ctx, Context::Data cpp_opt) throw()
182
+ static Sass_Compiler* sass_prepare_context (Sass_Context* c_ctx, Context* cpp_ctx) throw()
326
183
  {
327
184
  try {
328
185
 
329
- // get input/output path from options
330
- std::string input_path = safe_str(c_ctx->input_path);
331
- std::string output_path = safe_str(c_ctx->output_path);
332
- // maybe we can extract an output path from input path
333
- if (output_path == "" && input_path != "") {
334
- int lastindex = static_cast<int>(input_path.find_last_of("."));
335
- output_path = (lastindex > -1 ? input_path.substr(0, lastindex) : input_path) + ".css";
336
- }
337
-
338
186
  // convert include path linked list to static array
339
187
  struct string_list* inc = c_ctx->include_paths;
340
188
  // very poor loop to get the length of the linked list
@@ -365,31 +213,6 @@ extern "C" {
365
213
  imp = imp->next;
366
214
  }
367
215
 
368
- // transfer the options to c++
369
- cpp_opt.c_compiler(0)
370
- .c_options(c_ctx)
371
- .input_path(input_path)
372
- .output_path(output_path)
373
- .output_style((Output_Style) c_ctx->output_style)
374
- .is_indented_syntax_src(c_ctx->is_indented_syntax_src)
375
- .source_comments(c_ctx->source_comments)
376
- .source_map_file(safe_str(c_ctx->source_map_file))
377
- .source_map_root(safe_str(c_ctx->source_map_root))
378
- .source_map_embed(c_ctx->source_map_embed)
379
- .source_map_contents(c_ctx->source_map_contents)
380
- .omit_source_map_url(c_ctx->omit_source_map_url)
381
- .include_paths_c_str(c_ctx->include_path)
382
- .plugin_paths_c_str(c_ctx->plugin_path)
383
- // .include_paths_array(include_paths)
384
- // .plugin_paths_array(plugin_paths)
385
- .include_paths(std::vector<std::string>())
386
- .plugin_paths(std::vector<std::string>())
387
- .precision(c_ctx->precision)
388
- .linefeed(c_ctx->linefeed)
389
- .indent(c_ctx->indent);
390
-
391
- // create new c++ Context
392
- Context* cpp_ctx = new Context(cpp_opt);
393
216
  // free intermediate data
394
217
  free(include_paths);
395
218
  free(plugin_paths);
@@ -476,15 +299,12 @@ extern "C" {
476
299
 
477
300
  // maybe skip some entries of included files
478
301
  // we do not include stdin for data contexts
479
- bool skip = false;
480
-
481
- // dispatch to the correct render function
482
- if (c_ctx->type == SASS_CONTEXT_FILE) {
483
- root = cpp_ctx->parse_file();
484
- } else if (c_ctx->type == SASS_CONTEXT_DATA) {
485
- root = cpp_ctx->parse_string();
486
- skip = true; // skip first entry of includes
487
- }
302
+ bool skip = c_ctx->type == SASS_CONTEXT_DATA;
303
+
304
+ // dispatch parse call
305
+ root = cpp_ctx->parse();
306
+ // abort on errors
307
+ if (!root) return 0;
488
308
 
489
309
  // skip all prefixed files? (ToDo: check srcmap)
490
310
  // IMO source-maps should point to headers already
@@ -492,10 +312,9 @@ extern "C" {
492
312
  // remove completely once this is tested
493
313
  size_t headers = cpp_ctx->head_imports;
494
314
 
495
- // copy the included files on to the context (dont forget to free)
496
- if (root)
497
- if (copy_strings(cpp_ctx->get_included_files(skip, headers), &c_ctx->included_files) == NULL)
498
- throw(std::bad_alloc());
315
+ // copy the included files on to the context (dont forget to free later)
316
+ if (copy_strings(cpp_ctx->get_included_files(skip, headers), &c_ctx->included_files) == NULL)
317
+ throw(std::bad_alloc());
499
318
 
500
319
  // return parsed block
501
320
  return root;
@@ -510,11 +329,11 @@ extern "C" {
510
329
  }
511
330
 
512
331
  // generic compilation function (not exported, use file/data compile instead)
513
- static int sass_compile_context (Sass_Context* c_ctx, Context::Data cpp_opt)
332
+ static int sass_compile_context (Sass_Context* c_ctx, Context* cpp_ctx)
514
333
  {
515
334
 
516
335
  // prepare sass compiler with context and options
517
- Sass_Compiler* compiler = sass_prepare_context(c_ctx, cpp_opt);
336
+ Sass_Compiler* compiler = sass_prepare_context(c_ctx, cpp_ctx);
518
337
 
519
338
  try {
520
339
  // call each compiler step
@@ -576,54 +395,46 @@ extern "C" {
576
395
  return ctx;
577
396
  }
578
397
 
579
- struct Sass_Compiler* ADDCALL sass_make_file_compiler (struct Sass_File_Context* c_ctx)
398
+ struct Sass_Compiler* ADDCALL sass_make_data_compiler (struct Sass_Data_Context* data_ctx)
580
399
  {
581
- if (c_ctx == 0) return 0;
582
- Context::Data cpp_opt = Context::Data();
583
- cpp_opt.entry_point(c_ctx->input_path);
584
- return sass_prepare_context(c_ctx, cpp_opt);
400
+ if (data_ctx == 0) return 0;
401
+ Context* cpp_ctx = new Data_Context(data_ctx);
402
+ return sass_prepare_context(data_ctx, cpp_ctx);
585
403
  }
586
404
 
587
- struct Sass_Compiler* ADDCALL sass_make_data_compiler (struct Sass_Data_Context* c_ctx)
405
+ struct Sass_Compiler* ADDCALL sass_make_file_compiler (struct Sass_File_Context* file_ctx)
588
406
  {
589
- if (c_ctx == 0) return 0;
590
- Context::Data cpp_opt = Context::Data();
591
- cpp_opt.source_c_str(c_ctx->source_string);
592
- c_ctx->source_string = 0; // passed away
593
- return sass_prepare_context(c_ctx, cpp_opt);
407
+ if (file_ctx == 0) return 0;
408
+ Context* cpp_ctx = new File_Context(file_ctx);
409
+ return sass_prepare_context(file_ctx, cpp_ctx);
594
410
  }
595
411
 
596
412
  int ADDCALL sass_compile_data_context(Sass_Data_Context* data_ctx)
597
413
  {
598
414
  if (data_ctx == 0) return 1;
599
- Sass_Context* c_ctx = data_ctx;
600
- if (c_ctx->error_status)
601
- return c_ctx->error_status;
602
- Context::Data cpp_opt = Context::Data();
415
+ if (data_ctx->error_status)
416
+ return data_ctx->error_status;
603
417
  try {
604
418
  if (data_ctx->source_string == 0) { throw(std::runtime_error("Data context has no source string")); }
605
419
  if (*data_ctx->source_string == 0) { throw(std::runtime_error("Data context has empty source string")); }
606
- cpp_opt.source_c_str(data_ctx->source_string);
607
- data_ctx->source_string = 0; // passed away
608
420
  }
609
- catch (...) { return handle_errors(c_ctx) | 1; }
610
- return sass_compile_context(c_ctx, cpp_opt);
421
+ catch (...) { return handle_errors(data_ctx) | 1; }
422
+ Context* cpp_ctx = new Data_Context(data_ctx);
423
+ return sass_compile_context(data_ctx, cpp_ctx);
611
424
  }
612
425
 
613
426
  int ADDCALL sass_compile_file_context(Sass_File_Context* file_ctx)
614
427
  {
615
428
  if (file_ctx == 0) return 1;
616
- Sass_Context* c_ctx = file_ctx;
617
- if (c_ctx->error_status)
618
- return c_ctx->error_status;
619
- Context::Data cpp_opt = Context::Data();
429
+ if (file_ctx->error_status)
430
+ return file_ctx->error_status;
620
431
  try {
621
432
  if (file_ctx->input_path == 0) { throw(std::runtime_error("File context has no input path")); }
622
433
  if (*file_ctx->input_path == 0) { throw(std::runtime_error("File context has empty input path")); }
623
- cpp_opt.entry_point(file_ctx->input_path);
624
434
  }
625
- catch (...) { return handle_errors(c_ctx) | 1; }
626
- return sass_compile_context(c_ctx, cpp_opt);
435
+ catch (...) { return handle_errors(file_ctx) | 1; }
436
+ Context* cpp_ctx = new File_Context(file_ctx);
437
+ return sass_compile_context(file_ctx, cpp_ctx);
627
438
  }
628
439
 
629
440
  int ADDCALL sass_compiler_parse(struct Sass_Compiler* compiler)
@@ -655,11 +466,11 @@ extern "C" {
655
466
  Context* cpp_ctx = compiler->cpp_ctx;
656
467
  Block* root = compiler->root;
657
468
  // compile the parsed root block
658
- try { compiler->c_ctx->output_string = cpp_ctx->compile_block(root); }
469
+ try { compiler->c_ctx->output_string = cpp_ctx->render(root); }
659
470
  // pass catched errors to generic error handler
660
471
  catch (...) { return handle_errors(compiler->c_ctx) | 1; }
661
472
  // generate source map json and store on context
662
- compiler->c_ctx->source_map_string = cpp_ctx->generate_source_map();
473
+ compiler->c_ctx->source_map_string = cpp_ctx->render_srcmap();
663
474
  // success
664
475
  return 0;
665
476
  }
@@ -829,12 +640,12 @@ extern "C" {
829
640
  IMPLEMENT_SASS_OPTION_ACCESSOR(Sass_Importer_List, c_headers);
830
641
  IMPLEMENT_SASS_OPTION_ACCESSOR(const char*, indent);
831
642
  IMPLEMENT_SASS_OPTION_ACCESSOR(const char*, linefeed);
832
- IMPLEMENT_SASS_OPTION_STRING_ACCESSOR(const char*, input_path);
833
- IMPLEMENT_SASS_OPTION_STRING_ACCESSOR(const char*, output_path);
834
- IMPLEMENT_SASS_OPTION_STRING_ACCESSOR(const char*, plugin_path);
835
- IMPLEMENT_SASS_OPTION_STRING_ACCESSOR(const char*, include_path);
836
- IMPLEMENT_SASS_OPTION_STRING_ACCESSOR(const char*, source_map_file);
837
- IMPLEMENT_SASS_OPTION_STRING_ACCESSOR(const char*, source_map_root);
643
+ IMPLEMENT_SASS_OPTION_STRING_ACCESSOR(const char*, input_path, 0);
644
+ IMPLEMENT_SASS_OPTION_STRING_ACCESSOR(const char*, output_path, 0);
645
+ IMPLEMENT_SASS_OPTION_STRING_ACCESSOR(const char*, plugin_path, 0);
646
+ IMPLEMENT_SASS_OPTION_STRING_ACCESSOR(const char*, include_path, 0);
647
+ IMPLEMENT_SASS_OPTION_STRING_ACCESSOR(const char*, source_map_file, 0);
648
+ IMPLEMENT_SASS_OPTION_STRING_ACCESSOR(const char*, source_map_root, 0);
838
649
 
839
650
  // Create getter and setters for context
840
651
  IMPLEMENT_SASS_CONTEXT_GETTER(int, error_status);
@@ -0,0 +1,156 @@
1
+ #ifndef SASS_SASS_CONTEXT_H
2
+ #define SASS_SASS_CONTEXT_H
3
+
4
+ #include "sass.h"
5
+ #include "context.hpp"
6
+ #include "ast_fwd_decl.hpp"
7
+
8
+ // Input behaviours
9
+ enum Sass_Input_Style {
10
+ SASS_CONTEXT_NULL,
11
+ SASS_CONTEXT_FILE,
12
+ SASS_CONTEXT_DATA,
13
+ SASS_CONTEXT_FOLDER
14
+ };
15
+
16
+ // simple linked list
17
+ struct string_list {
18
+ string_list* next;
19
+ char* string;
20
+ };
21
+
22
+ // sass config options structure
23
+ struct Sass_Options {
24
+
25
+ // Precision for fractional numbers
26
+ int precision;
27
+
28
+ // Output style for the generated css code
29
+ // A value from above SASS_STYLE_* constants
30
+ enum Sass_Output_Style output_style;
31
+
32
+ // Emit comments in the generated CSS indicating
33
+ // the corresponding source line.
34
+ bool source_comments;
35
+
36
+ // embed sourceMappingUrl as data uri
37
+ bool source_map_embed;
38
+
39
+ // embed include contents in maps
40
+ bool source_map_contents;
41
+
42
+ // Disable sourceMappingUrl in css output
43
+ bool omit_source_map_url;
44
+
45
+ // Treat source_string as sass (as opposed to scss)
46
+ bool is_indented_syntax_src;
47
+
48
+ // The input path is used for source map
49
+ // generation. It can be used to define
50
+ // something with string compilation or to
51
+ // overload the input file path. It is
52
+ // set to "stdin" for data contexts and
53
+ // to the input file on file contexts.
54
+ char* input_path;
55
+
56
+ // The output path is used for source map
57
+ // generation. Libsass will not write to
58
+ // this file, it is just used to create
59
+ // information in source-maps etc.
60
+ char* output_path;
61
+
62
+ // String to be used for indentation
63
+ const char* indent;
64
+ // String to be used to for line feeds
65
+ const char* linefeed;
66
+
67
+ // Colon-separated list of paths
68
+ // Semicolon-separated on Windows
69
+ // Maybe use array interface instead?
70
+ char* include_path;
71
+ char* plugin_path;
72
+
73
+ // Include paths (linked string list)
74
+ struct string_list* include_paths;
75
+ // Plugin paths (linked string list)
76
+ struct string_list* plugin_paths;
77
+
78
+ // Path to source map file
79
+ // Enables source map generation
80
+ // Used to create sourceMappingUrl
81
+ char* source_map_file;
82
+
83
+ // Directly inserted in source maps
84
+ char* source_map_root;
85
+
86
+ // Custom functions that can be called from sccs code
87
+ Sass_Function_List c_functions;
88
+
89
+ // List of custom importers
90
+ Sass_Importer_List c_importers;
91
+
92
+ // List of custom headers
93
+ Sass_Importer_List c_headers;
94
+
95
+ };
96
+
97
+
98
+ // base for all contexts
99
+ struct Sass_Context : Sass_Options
100
+ {
101
+
102
+ // store context type info
103
+ enum Sass_Input_Style type;
104
+
105
+ // generated output data
106
+ char* output_string;
107
+
108
+ // generated source map json
109
+ char* source_map_string;
110
+
111
+ // error status
112
+ int error_status;
113
+ char* error_json;
114
+ char* error_text;
115
+ char* error_message;
116
+ // error position
117
+ char* error_file;
118
+ size_t error_line;
119
+ size_t error_column;
120
+ const char* error_src;
121
+
122
+ // report imported files
123
+ char** included_files;
124
+
125
+ };
126
+
127
+ // struct for file compilation
128
+ struct Sass_File_Context : Sass_Context {
129
+
130
+ // no additional fields required
131
+ // input_path is already on options
132
+
133
+ };
134
+
135
+ // struct for data compilation
136
+ struct Sass_Data_Context : Sass_Context {
137
+
138
+ // provided source string
139
+ char* source_string;
140
+ char* srcmap_string;
141
+
142
+ };
143
+
144
+ // link c and cpp context
145
+ struct Sass_Compiler {
146
+ // progress status
147
+ Sass_Compiler_State state;
148
+ // original c context
149
+ Sass_Context* c_ctx;
150
+ // Sass::Context
151
+ Sass::Context* cpp_ctx;
152
+ // Sass::Block
153
+ Sass::Block* root;
154
+ };
155
+
156
+ #endif