|
| 1 | +```C |
| 2 | +// Input behaviours |
| 3 | +enum Sass_Input_Style { |
| 4 | + SASS_CONTEXT_NULL, |
| 5 | + SASS_CONTEXT_FILE, |
| 6 | + SASS_CONTEXT_DATA, |
| 7 | + SASS_CONTEXT_FOLDER |
| 8 | +}; |
| 9 | + |
| 10 | +// simple linked list |
| 11 | +struct string_list { |
| 12 | + string_list* next; |
| 13 | + char* string; |
| 14 | +}; |
| 15 | + |
| 16 | +// sass config options structure |
| 17 | +struct Sass_Options { |
| 18 | + |
| 19 | + // Precision for fractional numbers |
| 20 | + int precision; |
| 21 | + |
| 22 | + // Output style for the generated css code |
| 23 | + // A value from above SASS_STYLE_* constants |
| 24 | + enum Sass_Output_Style output_style; |
| 25 | + |
| 26 | + // Emit comments in the generated CSS indicating |
| 27 | + // the corresponding source line. |
| 28 | + bool source_comments; |
| 29 | + |
| 30 | + // embed sourceMappingUrl as data uri |
| 31 | + bool source_map_embed; |
| 32 | + |
| 33 | + // embed include contents in maps |
| 34 | + bool source_map_contents; |
| 35 | + |
| 36 | + // Disable sourceMappingUrl in css output |
| 37 | + bool omit_source_map_url; |
| 38 | + |
| 39 | + // Treat source_string as sass (as opposed to scss) |
| 40 | + bool is_indented_syntax_src; |
| 41 | + |
| 42 | + // The input path is used for source map |
| 43 | + // generation. It can be used to define |
| 44 | + // something with string compilation or to |
| 45 | + // overload the input file path. It is |
| 46 | + // set to "stdin" for data contexts and |
| 47 | + // to the input file on file contexts. |
| 48 | + char* input_path; |
| 49 | + |
| 50 | + // The output path is used for source map |
| 51 | + // generation. LibSass will not write to |
| 52 | + // this file, it is just used to create |
| 53 | + // information in source-maps etc. |
| 54 | + char* output_path; |
| 55 | + |
| 56 | + // String to be used for indentation |
| 57 | + const char* indent; |
| 58 | + // String to be used to for line feeds |
| 59 | + const char* linefeed; |
| 60 | + |
| 61 | + // Colon-separated list of paths |
| 62 | + // Semicolon-separated on Windows |
| 63 | + // Note: It may be better to use |
| 64 | + // array interface instead |
| 65 | + char* include_path; |
| 66 | + char* plugin_path; |
| 67 | + |
| 68 | + // Include paths (linked string list) |
| 69 | + struct string_list* include_paths; |
| 70 | + // Plugin paths (linked string list) |
| 71 | + struct string_list* plugin_paths; |
| 72 | + |
| 73 | + // Path to source map file |
| 74 | + // Enables source map generation |
| 75 | + // Used to create sourceMappingUrl |
| 76 | + char* source_map_file; |
| 77 | + |
| 78 | + // Directly inserted in source maps |
| 79 | + char* source_map_root; |
| 80 | + |
| 81 | + // Custom functions that can be called from sccs code |
| 82 | + Sass_C_Function_List c_functions; |
| 83 | + |
| 84 | + // Callback to overload imports |
| 85 | + Sass_C_Import_Callback importer; |
| 86 | + |
| 87 | +}; |
| 88 | + |
| 89 | +// base for all contexts |
| 90 | +struct Sass_Context : Sass_Options |
| 91 | +{ |
| 92 | + |
| 93 | + // store context type info |
| 94 | + enum Sass_Input_Style type; |
| 95 | + |
| 96 | + // generated output data |
| 97 | + char* output_string; |
| 98 | + |
| 99 | + // generated source map json |
| 100 | + char* source_map_string; |
| 101 | + |
| 102 | + // error status |
| 103 | + int error_status; |
| 104 | + char* error_json; |
| 105 | + char* error_text; |
| 106 | + char* error_message; |
| 107 | + // error position |
| 108 | + char* error_file; |
| 109 | + size_t error_line; |
| 110 | + size_t error_column; |
| 111 | + |
| 112 | + // report imported files |
| 113 | + char** included_files; |
| 114 | + |
| 115 | +}; |
| 116 | + |
| 117 | +// struct for file compilation |
| 118 | +struct Sass_File_Context : Sass_Context { |
| 119 | + |
| 120 | + // no additional fields required |
| 121 | + // input_path is already on options |
| 122 | + |
| 123 | +}; |
| 124 | + |
| 125 | +// struct for data compilation |
| 126 | +struct Sass_Data_Context : Sass_Context { |
| 127 | + |
| 128 | + // provided source string |
| 129 | + char* source_string; |
| 130 | + |
| 131 | +}; |
| 132 | + |
| 133 | +// Compiler states |
| 134 | +enum Sass_Compiler_State { |
| 135 | + SASS_COMPILER_CREATED, |
| 136 | + SASS_COMPILER_PARSED, |
| 137 | + SASS_COMPILER_EXECUTED |
| 138 | +}; |
| 139 | + |
| 140 | +// link c and cpp context |
| 141 | +struct Sass_Compiler { |
| 142 | + // progress status |
| 143 | + Sass_Compiler_State state; |
| 144 | + // original c context |
| 145 | + Sass_Context* c_ctx; |
| 146 | + // Sass::Context |
| 147 | + void* cpp_ctx; |
| 148 | + // Sass::Block |
| 149 | + void* root; |
| 150 | +}; |
| 151 | +``` |
| 152 | + |
0 commit comments