| 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 | // sass config options structure |
| 11 | struct Sass_Inspect_Options { |
| 12 | |
| 13 | // Output style for the generated css code |
| 14 | // A value from above SASS_STYLE_* constants |
| 15 | enum Sass_Output_Style output_style; |
| 16 | |
| 17 | // Precision for fractional numbers |
| 18 | int precision; |
| 19 | |
| 20 | }; |
| 21 | |
| 22 | // sass config options structure |
| 23 | struct Sass_Output_Options : Sass_Inspect_Options { |
| 24 | |
| 25 | // String to be used for indentation |
| 26 | const char* indent; |
| 27 | // String to be used to for line feeds |
| 28 | const char* linefeed; |
| 29 | |
| 30 | // Emit comments in the generated CSS indicating |
| 31 | // the corresponding source line. |
| 32 | bool source_comments; |
| 33 | |
| 34 | }; |
| 35 | |
| 36 | // sass config options structure |
| 37 | struct Sass_Options : Sass_Output_Options { |
| 38 | |
| 39 | // embed sourceMappingUrl as data uri |
| 40 | bool source_map_embed; |
| 41 | |
| 42 | // embed include contents in maps |
| 43 | bool source_map_contents; |
| 44 | |
| 45 | // create file urls for sources |
| 46 | bool source_map_file_urls; |
| 47 | |
| 48 | // Disable sourceMappingUrl in css output |
| 49 | bool omit_source_map_url; |
| 50 | |
| 51 | // Treat source_string as sass (as opposed to scss) |
| 52 | bool is_indented_syntax_src; |
| 53 | |
| 54 | // The input path is used for source map |
| 55 | // generation. It can be used to define |
| 56 | // something with string compilation or to |
| 57 | // overload the input file path. It is |
| 58 | // set to "stdin" for data contexts and |
| 59 | // to the input file on file contexts. |
| 60 | char* input_path; |
| 61 | |
| 62 | // The output path is used for source map |
| 63 | // generation. LibSass will not write to |
| 64 | // this file, it is just used to create |
| 65 | // information in source-maps etc. |
| 66 | char* output_path; |
| 67 | |
| 68 | // Colon-separated list of paths |
| 69 | // Semicolon-separated on Windows |
| 70 | // Maybe use array interface instead? |
| 71 | char* include_path; |
| 72 | char* plugin_path; |
| 73 | |
| 74 | // Include paths (linked string list) |
| 75 | struct string_list* include_paths; |
| 76 | // Plugin paths (linked string list) |
| 77 | struct string_list* plugin_paths; |
| 78 | |
| 79 | // Path to source map file |
| 80 | // Enables source map generation |
| 81 | // Used to create sourceMappingUrl |
| 82 | char* source_map_file; |
| 83 | |
| 84 | // Directly inserted in source maps |
| 85 | char* source_map_root; |
| 86 | |
| 87 | // Custom functions that can be called from sccs code |
| 88 | Sass_Function_List c_functions; |
| 89 | |
| 90 | // Callback to overload imports |
| 91 | Sass_Importer_List c_importers; |
| 92 | |
| 93 | // List of custom headers |
| 94 | Sass_Importer_List c_headers; |
| 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 | 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 | // Compiler states |
| 145 | enum Sass_Compiler_State { |
| 146 | SASS_COMPILER_CREATED, |
| 147 | SASS_COMPILER_PARSED, |
| 148 | SASS_COMPILER_EXECUTED |
| 149 | }; |
| 150 | |
| 151 | // link c and cpp context |
| 152 | struct Sass_Compiler { |
| 153 | // progress status |
| 154 | Sass_Compiler_State state; |
| 155 | // original c context |
| 156 | Sass_Context* c_ctx; |
| 157 | // Sass::Context |
| 158 | Sass::Context* cpp_ctx; |
| 159 | // Sass::Block |
| 160 | Sass::Block_Obj root; |
| 161 | }; |
| 162 | ``` |
| 163 |