sass_context.h 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. #ifndef SASS_C_CONTEXT
  2. #define SASS_C_CONTEXT
  3. #include <stddef.h>
  4. #include <stdbool.h>
  5. #include "sass.h"
  6. #ifdef __cplusplus
  7. extern "C" {
  8. #endif
  9. // Forward declaration
  10. struct Sass_Compiler;
  11. // Forward declaration
  12. struct Sass_Options;
  13. struct Sass_Context; // : Sass_Options
  14. struct Sass_File_Context; // : Sass_Context
  15. struct Sass_Data_Context; // : Sass_Context
  16. // Create and initialize an option struct
  17. ADDAPI struct Sass_Options* ADDCALL sass_make_options (void);
  18. // Create and initialize a specific context
  19. ADDAPI struct Sass_File_Context* ADDCALL sass_make_file_context (const char* input_path);
  20. ADDAPI struct Sass_Data_Context* ADDCALL sass_make_data_context (char* source_string);
  21. // Call the compilation step for the specific context
  22. ADDAPI int ADDCALL sass_compile_file_context (struct Sass_File_Context* ctx);
  23. ADDAPI int ADDCALL sass_compile_data_context (struct Sass_Data_Context* ctx);
  24. // Create a sass compiler instance for more control
  25. ADDAPI struct Sass_Compiler* ADDCALL sass_make_file_compiler (struct Sass_File_Context* file_ctx);
  26. ADDAPI struct Sass_Compiler* ADDCALL sass_make_data_compiler (struct Sass_Data_Context* data_ctx);
  27. // Execute the different compilation steps individually
  28. // Usefull if you only want to query the included files
  29. ADDAPI int ADDCALL sass_compiler_parse(struct Sass_Compiler* compiler);
  30. ADDAPI int ADDCALL sass_compiler_execute(struct Sass_Compiler* compiler);
  31. // Release all memory allocated with the compiler
  32. // This does _not_ include any contexts or options
  33. ADDAPI void ADDCALL sass_delete_compiler(struct Sass_Compiler* compiler);
  34. // Release all memory allocated and also ourself
  35. ADDAPI void ADDCALL sass_delete_file_context (struct Sass_File_Context* ctx);
  36. ADDAPI void ADDCALL sass_delete_data_context (struct Sass_Data_Context* ctx);
  37. // Getters for context from specific implementation
  38. ADDAPI struct Sass_Context* ADDCALL sass_file_context_get_context (struct Sass_File_Context* file_ctx);
  39. ADDAPI struct Sass_Context* ADDCALL sass_data_context_get_context (struct Sass_Data_Context* data_ctx);
  40. // Getters for context options from Sass_Context
  41. ADDAPI struct Sass_Options* ADDCALL sass_context_get_options (struct Sass_Context* ctx);
  42. ADDAPI struct Sass_Options* ADDCALL sass_file_context_get_options (struct Sass_File_Context* file_ctx);
  43. ADDAPI struct Sass_Options* ADDCALL sass_data_context_get_options (struct Sass_Data_Context* data_ctx);
  44. ADDAPI void ADDCALL sass_file_context_set_options (struct Sass_File_Context* file_ctx, struct Sass_Options* opt);
  45. ADDAPI void ADDCALL sass_data_context_set_options (struct Sass_Data_Context* data_ctx, struct Sass_Options* opt);
  46. // Getters for options
  47. ADDAPI int ADDCALL sass_option_get_precision (struct Sass_Options* options);
  48. ADDAPI enum Sass_Output_Style ADDCALL sass_option_get_output_style (struct Sass_Options* options);
  49. ADDAPI bool ADDCALL sass_option_get_source_comments (struct Sass_Options* options);
  50. ADDAPI bool ADDCALL sass_option_get_source_map_embed (struct Sass_Options* options);
  51. ADDAPI bool ADDCALL sass_option_get_source_map_contents (struct Sass_Options* options);
  52. ADDAPI bool ADDCALL sass_option_get_omit_source_map_url (struct Sass_Options* options);
  53. ADDAPI bool ADDCALL sass_option_get_is_indented_syntax_src (struct Sass_Options* options);
  54. ADDAPI const char* ADDCALL sass_option_get_input_path (struct Sass_Options* options);
  55. ADDAPI const char* ADDCALL sass_option_get_output_path (struct Sass_Options* options);
  56. ADDAPI const char* ADDCALL sass_option_get_image_path (struct Sass_Options* options);
  57. ADDAPI const char* ADDCALL sass_option_get_include_path (struct Sass_Options* options);
  58. ADDAPI const char* ADDCALL sass_option_get_source_map_file (struct Sass_Options* options);
  59. ADDAPI Sass_C_Function_List ADDCALL sass_option_get_c_functions (struct Sass_Options* options);
  60. ADDAPI Sass_C_Import_Callback ADDCALL sass_option_get_importer (struct Sass_Options* options);
  61. // Setters for options
  62. ADDAPI void ADDCALL sass_option_set_precision (struct Sass_Options* options, int precision);
  63. ADDAPI void ADDCALL sass_option_set_output_style (struct Sass_Options* options, enum Sass_Output_Style output_style);
  64. ADDAPI void ADDCALL sass_option_set_source_comments (struct Sass_Options* options, bool source_comments);
  65. ADDAPI void ADDCALL sass_option_set_source_map_embed (struct Sass_Options* options, bool source_map_embed);
  66. ADDAPI void ADDCALL sass_option_set_source_map_contents (struct Sass_Options* options, bool source_map_contents);
  67. ADDAPI void ADDCALL sass_option_set_omit_source_map_url (struct Sass_Options* options, bool omit_source_map_url);
  68. ADDAPI void ADDCALL sass_option_set_is_indented_syntax_src (struct Sass_Options* options, bool is_indented_syntax_src);
  69. ADDAPI void ADDCALL sass_option_set_input_path (struct Sass_Options* options, const char* input_path);
  70. ADDAPI void ADDCALL sass_option_set_output_path (struct Sass_Options* options, const char* output_path);
  71. ADDAPI void ADDCALL sass_option_set_image_path (struct Sass_Options* options, const char* image_path);
  72. ADDAPI void ADDCALL sass_option_set_include_path (struct Sass_Options* options, const char* include_path);
  73. ADDAPI void ADDCALL sass_option_set_source_map_file (struct Sass_Options* options, const char* source_map_file);
  74. ADDAPI void ADDCALL sass_option_set_c_functions (struct Sass_Options* options, Sass_C_Function_List c_functions);
  75. ADDAPI void ADDCALL sass_option_set_importer (struct Sass_Options* options, Sass_C_Import_Callback importer);
  76. // Getter for context
  77. ADDAPI const char* ADDCALL sass_context_get_output_string (struct Sass_Context* ctx);
  78. ADDAPI int ADDCALL sass_context_get_error_status (struct Sass_Context* ctx);
  79. ADDAPI const char* ADDCALL sass_context_get_error_json (struct Sass_Context* ctx);
  80. ADDAPI const char* ADDCALL sass_context_get_error_message (struct Sass_Context* ctx);
  81. ADDAPI const char* ADDCALL sass_context_get_error_file (struct Sass_Context* ctx);
  82. ADDAPI size_t ADDCALL sass_context_get_error_line (struct Sass_Context* ctx);
  83. ADDAPI size_t ADDCALL sass_context_get_error_column (struct Sass_Context* ctx);
  84. ADDAPI const char* ADDCALL sass_context_get_source_map_string (struct Sass_Context* ctx);
  85. ADDAPI char** ADDCALL sass_context_get_included_files (struct Sass_Context* ctx);
  86. // Take ownership of memory (value on context is set to 0)
  87. ADDAPI char* ADDCALL sass_context_take_error_json (struct Sass_Context* ctx);
  88. ADDAPI char* ADDCALL sass_context_take_error_message (struct Sass_Context* ctx);
  89. ADDAPI char* ADDCALL sass_context_take_error_file (struct Sass_Context* ctx);
  90. ADDAPI char* ADDCALL sass_context_take_output_string (struct Sass_Context* ctx);
  91. ADDAPI char* ADDCALL sass_context_take_source_map_string (struct Sass_Context* ctx);
  92. // Push function for include paths (no manipulation support for now)
  93. ADDAPI void ADDCALL sass_option_push_include_path (struct Sass_Options* options, const char* path);
  94. #ifdef __cplusplus
  95. } // __cplusplus defined.
  96. #endif
  97. #endif