sassc 2.1.0.pre1-x64-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +17 -0
  3. data/.gitmodules +3 -0
  4. data/.travis.yml +11 -0
  5. data/CHANGELOG.md +66 -0
  6. data/CODE_OF_CONDUCT.md +10 -0
  7. data/Gemfile +2 -0
  8. data/LICENSE.txt +22 -0
  9. data/README.md +68 -0
  10. data/Rakefile +30 -0
  11. data/lib/sassc.rb +57 -0
  12. data/lib/sassc/dependency.rb +17 -0
  13. data/lib/sassc/engine.rb +139 -0
  14. data/lib/sassc/error.rb +37 -0
  15. data/lib/sassc/functions_handler.rb +75 -0
  16. data/lib/sassc/import_handler.rb +50 -0
  17. data/lib/sassc/importer.rb +31 -0
  18. data/lib/sassc/native.rb +70 -0
  19. data/lib/sassc/native/lib_c.rb +21 -0
  20. data/lib/sassc/native/native_context_api.rb +147 -0
  21. data/lib/sassc/native/native_functions_api.rb +164 -0
  22. data/lib/sassc/native/sass2scss_api.rb +10 -0
  23. data/lib/sassc/native/sass_input_style.rb +13 -0
  24. data/lib/sassc/native/sass_output_style.rb +12 -0
  25. data/lib/sassc/native/sass_value.rb +97 -0
  26. data/lib/sassc/native/string_list.rb +10 -0
  27. data/lib/sassc/sass_2_scss.rb +9 -0
  28. data/lib/sassc/script.rb +19 -0
  29. data/lib/sassc/script/functions.rb +8 -0
  30. data/lib/sassc/script/value.rb +137 -0
  31. data/lib/sassc/script/value/bool.rb +32 -0
  32. data/lib/sassc/script/value/color.rb +95 -0
  33. data/lib/sassc/script/value/list.rb +136 -0
  34. data/lib/sassc/script/value/map.rb +69 -0
  35. data/lib/sassc/script/value/number.rb +389 -0
  36. data/lib/sassc/script/value/string.rb +96 -0
  37. data/lib/sassc/script/value_conversion.rb +69 -0
  38. data/lib/sassc/script/value_conversion/base.rb +13 -0
  39. data/lib/sassc/script/value_conversion/bool.rb +13 -0
  40. data/lib/sassc/script/value_conversion/color.rb +18 -0
  41. data/lib/sassc/script/value_conversion/list.rb +25 -0
  42. data/lib/sassc/script/value_conversion/map.rb +21 -0
  43. data/lib/sassc/script/value_conversion/number.rb +13 -0
  44. data/lib/sassc/script/value_conversion/string.rb +17 -0
  45. data/lib/sassc/util.rb +231 -0
  46. data/lib/sassc/util/normalized_map.rb +117 -0
  47. data/lib/sassc/version.rb +5 -0
  48. data/sassc.gemspec +57 -0
  49. data/test/custom_importer_test.rb +127 -0
  50. data/test/engine_test.rb +314 -0
  51. data/test/error_test.rb +29 -0
  52. data/test/fixtures/paths.scss +10 -0
  53. data/test/functions_test.rb +303 -0
  54. data/test/native_test.rb +213 -0
  55. data/test/output_style_test.rb +107 -0
  56. data/test/sass_2_scss_test.rb +14 -0
  57. data/test/test_helper.rb +45 -0
  58. metadata +242 -0
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "pathname"
4
+
5
+ module SassC
6
+
7
+ class BaseError < StandardError; end
8
+ class NotRenderedError < BaseError; end
9
+ class InvalidStyleError < BaseError; end
10
+ class UnsupportedValue < BaseError; end
11
+
12
+ # When dealing with SyntaxErrors,
13
+ # it's important to provide filename and line number information.
14
+ # This will be used in various error reports to users, including backtraces.
15
+
16
+ class SyntaxError < BaseError
17
+
18
+ def initialize(message, filename: nil, line: nil)
19
+ @filename = filename
20
+ @line = line
21
+ super(message)
22
+ end
23
+
24
+ def backtrace
25
+ return nil if super.nil?
26
+ sass_backtrace + super
27
+ end
28
+
29
+ # The backtrace of the error within Sass files.
30
+ def sass_backtrace
31
+ return [] unless @filename && @line
32
+ ["#{@filename}:#{@line}"]
33
+ end
34
+
35
+ end
36
+
37
+ end
@@ -0,0 +1,75 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SassC
4
+ class FunctionsHandler
5
+ def initialize(options)
6
+ @options = options
7
+ end
8
+
9
+ def setup(native_options)
10
+ @callbacks = {}
11
+ @function_names = {}
12
+
13
+ list = Native.make_function_list(Script.custom_functions.count)
14
+
15
+ functions = FunctionWrapper.extend(Script::Functions)
16
+ functions.options = @options
17
+
18
+ Script.custom_functions.each_with_index do |custom_function, i|
19
+ @callbacks[custom_function] = FFI::Function.new(:pointer, [:pointer, :pointer]) do |native_argument_list, cookie|
20
+ begin
21
+ function_arguments = arguments_from_native_list(native_argument_list)
22
+ result = functions.send(custom_function, *function_arguments)
23
+ to_native_value(result)
24
+ rescue StandardError => exception
25
+ # This rescues any exceptions that occur either in value conversion
26
+ # or during the execution of a custom function.
27
+ error(exception.message)
28
+ end
29
+ end
30
+
31
+ @function_names[custom_function] = Script.formatted_function_name(custom_function)
32
+
33
+ callback = Native.make_function(
34
+ @function_names[custom_function],
35
+ @callbacks[custom_function],
36
+ nil
37
+ )
38
+
39
+ Native::function_set_list_entry(list, i, callback)
40
+ end
41
+
42
+ Native::option_set_c_functions(native_options, list)
43
+ end
44
+
45
+ private
46
+
47
+ def arguments_from_native_list(native_argument_list)
48
+ native_argument_list_length = Native.list_get_length(native_argument_list)
49
+
50
+ (0...native_argument_list_length).map do |i|
51
+ native_value = Native.list_get_value(native_argument_list, i)
52
+ Script::ValueConversion.from_native(native_value, @options)
53
+ end.compact
54
+ end
55
+
56
+ def to_native_value(sass_value)
57
+ # if the custom function returns nil, we provide a "default" return
58
+ # value of an empty string
59
+ sass_value ||= SassC::Script::Value::String.new("")
60
+ sass_value.options = @options
61
+ Script::ValueConversion.to_native(sass_value)
62
+ end
63
+
64
+ def error(message)
65
+ $stderr.puts "[SassC::FunctionsHandler] #{message}"
66
+ Native.make_error(message)
67
+ end
68
+
69
+ class FunctionWrapper
70
+ class << self
71
+ attr_accessor :options
72
+ end
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,50 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SassC
4
+ class ImportHandler
5
+ def initialize(options)
6
+ @importer = if options[:importer]
7
+ options[:importer].new(options)
8
+ else
9
+ nil
10
+ end
11
+ end
12
+
13
+ def setup(native_options)
14
+ return unless @importer
15
+
16
+ importer_callback = Native.make_importer(import_function, nil)
17
+
18
+ list = Native.make_function_list(1)
19
+ Native::function_set_list_entry(list, 0, importer_callback)
20
+
21
+ Native.option_set_c_importers(native_options, list)
22
+ end
23
+
24
+ private
25
+
26
+ def import_function
27
+ @import_function ||= FFI::Function.new(:pointer, [:string, :pointer, :pointer]) do |path, importer_entry, compiler|
28
+ last_import = Native::compiler_get_last_import(compiler)
29
+ parent_path = Native::import_get_abs_path(last_import)
30
+
31
+ imports = [*@importer.imports(path, parent_path)]
32
+ imports_to_native(imports)
33
+ end
34
+ end
35
+
36
+ def imports_to_native(imports)
37
+ import_list = Native.make_import_list(imports.size)
38
+
39
+ imports.each_with_index do |import, i|
40
+ source = import.source ? Native.native_string(import.source) : nil
41
+ source_map_path = nil
42
+
43
+ entry = Native.make_import_entry(import.path, source, source_map_path)
44
+ Native.import_set_list_entry(import_list, i, entry)
45
+ end
46
+
47
+ import_list
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SassC
4
+ class Importer
5
+ attr_reader :options
6
+
7
+ def initialize(options)
8
+ @options = options
9
+ end
10
+
11
+ def imports(path, parent_path)
12
+ # A custom importer must override this method.
13
+ # Custom importer may return an Import, or an array of Imports.
14
+ raise NotImplementedError
15
+ end
16
+
17
+ class Import
18
+ attr_accessor :path, :source, :source_map_path
19
+
20
+ def initialize(path, source: nil, source_map_path: nil)
21
+ @path = path
22
+ @source = source
23
+ @source_map_path = source_map_path
24
+ end
25
+
26
+ def to_s
27
+ "Import: #{path} #{source} #{source_map_path}"
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,70 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "ffi"
4
+
5
+ module SassC
6
+ module Native
7
+ extend FFI::Library
8
+
9
+ spec = Gem.loaded_specs["sassc"]
10
+ gem_root = spec.gem_dir
11
+
12
+ dl_ext = (RUBY_PLATFORM =~ /darwin/ ? 'bundle' : 'so')
13
+ ruby_version_so_path = "#{gem_root}/lib/sassc/#{RUBY_VERSION[/\d+.\d+/]}/libsass.#{dl_ext}"
14
+ if File.exist?(ruby_version_so_path)
15
+ ffi_lib ruby_version_so_path
16
+ else
17
+ ffi_lib "#{gem_root}/lib/sassc/libsass.#{dl_ext}"
18
+ end
19
+
20
+ require_relative "native/sass_value"
21
+
22
+ typedef :pointer, :sass_options_ptr
23
+ typedef :pointer, :sass_context_ptr
24
+ typedef :pointer, :sass_file_context_ptr
25
+ typedef :pointer, :sass_data_context_ptr
26
+
27
+ typedef :pointer, :sass_c_function_list_ptr
28
+ typedef :pointer, :sass_c_function_callback_ptr
29
+ typedef :pointer, :sass_value_ptr
30
+
31
+ typedef :pointer, :sass_import_list_ptr
32
+ typedef :pointer, :sass_importer
33
+ typedef :pointer, :sass_import_ptr
34
+
35
+ callback :sass_c_function, [:pointer, :pointer], :pointer
36
+ callback :sass_c_import_function, [:pointer, :pointer, :pointer], :pointer
37
+
38
+ require_relative "native/sass_input_style"
39
+ require_relative "native/sass_output_style"
40
+ require_relative "native/string_list"
41
+ require_relative "native/lib_c"
42
+
43
+ # Remove the redundant "sass_" from the beginning of every method name
44
+ def self.attach_function(*args)
45
+ super if args.size != 3
46
+
47
+ if args[0] =~ /^sass_/
48
+ args.unshift args[0].to_s.sub(/^sass_/, "")
49
+ end
50
+
51
+ super(*args)
52
+ end
53
+
54
+ # https://github.com/ffi/ffi/wiki/Examples#array-of-strings
55
+ def self.return_string_array(ptr)
56
+ ptr.null? ? [] : ptr.get_array_of_string(0).compact
57
+ end
58
+
59
+ def self.native_string(string)
60
+ string = "#{string}\0"
61
+ data = Native::LibC.malloc(string.bytesize)
62
+ data.write_string(string)
63
+ data
64
+ end
65
+
66
+ require_relative "native/native_context_api"
67
+ require_relative "native/native_functions_api"
68
+ require_relative "native/sass2scss_api"
69
+ end
70
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SassC
4
+ module Native
5
+ module LibC
6
+ extend FFI::Library
7
+ ffi_lib FFI::Library::LIBC
8
+
9
+ # memory allocators
10
+ attach_function :malloc, [:size_t], :pointer
11
+ # attach_function :calloc, [:size_t], :pointer
12
+ # attach_function :valloc, [:size_t], :pointer
13
+ # attach_function :realloc, [:pointer, :size_t], :pointer
14
+ # attach_function :free, [:pointer], :void
15
+
16
+ # memory movers
17
+ # attach_function :memcpy, [:pointer, :pointer, :size_t], :pointer
18
+ # attach_function :bcopy, [:pointer, :pointer, :size_t], :void
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,147 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SassC
4
+ module Native
5
+ attach_function :version, :libsass_version, [], :string
6
+
7
+ # Create and initialize an option struct
8
+ # ADDAPI struct Sass_Options* ADDCALL sass_make_options (void);
9
+ attach_function :sass_make_options, [], :sass_options_ptr
10
+
11
+ # Create and initialize a specific context
12
+ # ADDAPI struct Sass_File_Context* ADDCALL sass_make_file_context (const char* input_path);
13
+ # ADDAPI struct Sass_Data_Context* ADDCALL sass_make_data_context (char* source_string);
14
+ attach_function :sass_make_file_context, [:string], :sass_file_context_ptr
15
+ attach_function :_make_data_context, :sass_make_data_context, [:pointer], :sass_data_context_ptr
16
+
17
+ def self.make_data_context(data)
18
+ _make_data_context(Native.native_string(data))
19
+ end
20
+
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
+ attach_function :sass_compile_file_context, [:sass_file_context_ptr], :int
25
+ attach_function :sass_compile_data_context, [:sass_data_context_ptr], :int
26
+
27
+ # Create a sass compiler instance for more control
28
+ # ADDAPI struct Sass_Compiler* ADDCALL sass_make_file_compiler (struct Sass_File_Context* file_ctx);
29
+ # ADDAPI struct Sass_Compiler* ADDCALL sass_make_data_compiler (struct Sass_Data_Context* data_ctx);
30
+
31
+ # Execute the different compilation steps individually
32
+ # Usefull if you only want to query the included files
33
+ # ADDAPI int ADDCALL sass_compiler_parse(struct Sass_Compiler* compiler);
34
+ # ADDAPI int ADDCALL sass_compiler_execute(struct Sass_Compiler* compiler);
35
+
36
+ # Release all memory allocated with the compiler
37
+ # This does _not_ include any contexts or options
38
+ # ADDAPI void ADDCALL sass_delete_compiler(struct Sass_Compiler* compiler);
39
+
40
+ # Release all memory allocated and also ourself
41
+ # ADDAPI void ADDCALL sass_delete_file_context (struct Sass_File_Context* ctx);
42
+ # ADDAPI void ADDCALL sass_delete_data_context (struct Sass_Data_Context* ctx);
43
+ attach_function :sass_delete_file_context, [:sass_file_context_ptr], :void
44
+ attach_function :sass_delete_data_context, [:sass_data_context_ptr], :void
45
+
46
+ # Getters for context from specific implementation
47
+ # ADDAPI struct Sass_Context* ADDCALL sass_file_context_get_context (struct Sass_File_Context* file_ctx);
48
+ # ADDAPI struct Sass_Context* ADDCALL sass_data_context_get_context (struct Sass_Data_Context* data_ctx);
49
+ attach_function :sass_file_context_get_context, [:sass_file_context_ptr], :sass_context_ptr
50
+ attach_function :sass_data_context_get_context, [:sass_data_context_ptr], :sass_context_ptr
51
+
52
+ # Getters for context options from Sass_Context
53
+ # ADDAPI struct Sass_Options* ADDCALL sass_context_get_options (struct Sass_Context* ctx);
54
+ # ADDAPI struct Sass_Options* ADDCALL sass_file_context_get_options (struct Sass_File_Context* file_ctx);
55
+ # ADDAPI struct Sass_Options* ADDCALL sass_data_context_get_options (struct Sass_Data_Context* data_ctx);
56
+ # ADDAPI void ADDCALL sass_file_context_set_options (struct Sass_File_Context* file_ctx, struct Sass_Options* opt);
57
+ # ADDAPI void ADDCALL sass_data_context_set_options (struct Sass_Data_Context* data_ctx, struct Sass_Options* opt);
58
+ attach_function :sass_context_get_options, [:sass_context_ptr], :sass_options_ptr
59
+ attach_function :sass_file_context_get_options, [:sass_file_context_ptr], :sass_options_ptr
60
+ attach_function :sass_data_context_get_options, [:sass_data_context_ptr], :sass_options_ptr
61
+ attach_function :sass_file_context_set_options, [:sass_file_context_ptr, :sass_options_ptr], :void
62
+ attach_function :sass_data_context_set_options, [:sass_data_context_ptr, :sass_options_ptr], :void
63
+
64
+ # Getters for options
65
+ # ADDAPI int ADDCALL sass_option_get_precision (struct Sass_Options* options);
66
+ # ADDAPI enum Sass_Output_Style ADDCALL sass_option_get_output_style (struct Sass_Options* options);
67
+ # ADDAPI bool ADDCALL sass_option_get_source_comments (struct Sass_Options* options);
68
+ # ADDAPI bool ADDCALL sass_option_get_source_map_embed (struct Sass_Options* options);
69
+ # ADDAPI bool ADDCALL sass_option_get_source_map_contents (struct Sass_Options* options);
70
+ # ADDAPI bool ADDCALL sass_option_get_omit_source_map_url (struct Sass_Options* options);
71
+ # ADDAPI bool ADDCALL sass_option_get_is_indented_syntax_src (struct Sass_Options* options);
72
+ # ADDAPI const char* ADDCALL sass_option_get_input_path (struct Sass_Options* options);
73
+ # ADDAPI const char* ADDCALL sass_option_get_output_path (struct Sass_Options* options);
74
+ # ADDAPI const char* ADDCALL sass_option_get_include_path (struct Sass_Options* options);
75
+ # ADDAPI const char* ADDCALL sass_option_get_source_map_file (struct Sass_Options* options);
76
+ # ADDAPI Sass_C_Function_List ADDCALL sass_option_get_c_functions (struct Sass_Options* options);
77
+ attach_function :sass_option_get_precision, [:sass_options_ptr], :int
78
+ attach_function :sass_option_get_output_style, [:sass_options_ptr], SassOutputStyle
79
+ attach_function :sass_option_get_source_comments, [:sass_options_ptr], :bool
80
+ attach_function :sass_option_get_source_map_embed, [:sass_options_ptr], :bool
81
+ attach_function :sass_option_get_source_map_contents, [:sass_options_ptr], :bool
82
+ attach_function :sass_option_get_omit_source_map_url, [:sass_options_ptr], :bool
83
+ attach_function :sass_option_get_is_indented_syntax_src, [:sass_options_ptr], :bool
84
+ attach_function :sass_option_get_input_path, [:sass_options_ptr], :string
85
+ attach_function :sass_option_get_output_path, [:sass_options_ptr], :string
86
+ attach_function :sass_option_get_include_path, [:sass_options_ptr], :string
87
+ attach_function :sass_option_get_source_map_file, [:sass_options_ptr], :string
88
+ attach_function :sass_option_get_c_functions, [:sass_options_ptr], :sass_c_function_list_ptr
89
+ # ADDAPI Sass_C_Import_Callback ADDCALL sass_option_get_importer (struct Sass_Options* options);
90
+
91
+ # Setters for options
92
+ # ADDAPI void ADDCALL sass_option_set_precision (struct Sass_Options* options, int precision);
93
+ # ADDAPI void ADDCALL sass_option_set_output_style (struct Sass_Options* options, enum Sass_Output_Style output_style);
94
+ # ADDAPI void ADDCALL sass_option_set_source_comments (struct Sass_Options* options, bool source_comments);
95
+ # ADDAPI void ADDCALL sass_option_set_source_map_embed (struct Sass_Options* options, bool source_map_embed);
96
+ # ADDAPI void ADDCALL sass_option_set_source_map_contents (struct Sass_Options* options, bool source_map_contents);
97
+ # ADDAPI void ADDCALL sass_option_set_omit_source_map_url (struct Sass_Options* options, bool omit_source_map_url);
98
+ # ADDAPI void ADDCALL sass_option_set_is_indented_syntax_src (struct Sass_Options* options, bool is_indented_syntax_src);
99
+ # ADDAPI void ADDCALL sass_option_set_input_path (struct Sass_Options* options, const char* input_path);
100
+ # ADDAPI void ADDCALL sass_option_set_output_path (struct Sass_Options* options, const char* output_path);
101
+ # ADDAPI void ADDCALL sass_option_set_include_path (struct Sass_Options* options, const char* include_path);
102
+ # ADDAPI void ADDCALL sass_option_set_source_map_file (struct Sass_Options* options, const char* source_map_file);
103
+ # ADDAPI void ADDCALL sass_option_set_c_functions (struct Sass_Options* options, Sass_C_Function_List c_functions);
104
+ # ADDAPI void ADDCALL sass_option_set_c_importers (struct Sass_Options* options, Sass_Importer_List c_importers);
105
+ attach_function :sass_option_set_precision, [:sass_options_ptr, :int], :void
106
+ attach_function :sass_option_set_output_style, [:sass_options_ptr, SassOutputStyle], :void
107
+ attach_function :sass_option_set_source_comments, [:sass_options_ptr, :bool], :void
108
+ attach_function :sass_option_set_source_map_embed, [:sass_options_ptr, :bool], :void
109
+ attach_function :sass_option_set_source_map_contents, [:sass_options_ptr, :bool], :void
110
+ attach_function :sass_option_set_omit_source_map_url, [:sass_options_ptr, :bool], :void
111
+ attach_function :sass_option_set_is_indented_syntax_src, [:sass_options_ptr, :bool], :void
112
+ attach_function :sass_option_set_input_path, [:sass_options_ptr, :string], :void
113
+ attach_function :sass_option_set_output_path, [:sass_options_ptr, :string], :void
114
+ attach_function :sass_option_set_include_path, [:sass_options_ptr, :string], :void
115
+ attach_function :sass_option_set_source_map_file, [:sass_options_ptr, :string], :void
116
+ attach_function :sass_option_set_c_functions, [:sass_options_ptr, :pointer], :void
117
+ attach_function :sass_option_set_c_importers, [:sass_options_ptr, :pointer], :void
118
+ #attach_function :sass_option_set_c_importers, [:sass_options_ptr, :sass_importer], :void
119
+
120
+ # Getter for context
121
+ # ADDAPI const char* ADDCALL sass_context_get_output_string (struct Sass_Context* ctx);
122
+ # ADDAPI int ADDCALL sass_context_get_error_status (struct Sass_Context* ctx);
123
+ # ADDAPI const char* ADDCALL sass_context_get_error_json (struct Sass_Context* ctx);
124
+ # ADDAPI const char* ADDCALL sass_context_get_error_message (struct Sass_Context* ctx);
125
+ # ADDAPI const char* ADDCALL sass_context_get_error_file (struct Sass_Context* ctx);
126
+ # ADDAPI size_t ADDCALL sass_context_get_error_line (struct Sass_Context* ctx);
127
+ # ADDAPI size_t ADDCALL sass_context_get_error_column (struct Sass_Context* ctx);
128
+ # ADDAPI const char* ADDCALL sass_context_get_source_map_string (struct Sass_Context* ctx);
129
+ # ADDAPI char** ADDCALL sass_context_get_included_files (struct Sass_Context* ctx);
130
+ attach_function :sass_context_get_output_string, [:sass_context_ptr], :string
131
+ attach_function :sass_context_get_error_status, [:sass_context_ptr], :int
132
+ attach_function :sass_context_get_error_json, [:sass_context_ptr], :string
133
+ attach_function :sass_context_get_error_message, [:sass_context_ptr], :string
134
+ attach_function :sass_context_get_error_file, [:sass_context_ptr], :string
135
+ attach_function :sass_context_get_error_line, [:sass_context_ptr], :size_t
136
+ attach_function :sass_context_get_error_column, [:sass_context_ptr], :size_t
137
+ attach_function :sass_context_get_source_map_string, [:sass_context_ptr], :string
138
+ attach_function :_context_get_included_files, :sass_context_get_included_files, [:sass_context_ptr], :pointer
139
+
140
+ def self.context_get_included_files(*args)
141
+ return_string_array _context_get_included_files(*args)
142
+ end
143
+
144
+ # ADDAPI Sass_Import_Entry ADDCALL sass_compiler_get_last_import(struct Sass_Compiler* compiler);
145
+ attach_function :sass_compiler_get_last_import, [:pointer], :pointer
146
+ end
147
+ end
@@ -0,0 +1,164 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SassC
4
+ module Native
5
+ # Creators for sass function list and function descriptors
6
+ # ADDAPI Sass_C_Function_List ADDCALL sass_make_function_list (size_t length);
7
+ # ADDAPI Sass_C_Function_Callback ADDCALL sass_make_function (const char* signature, Sass_C_Function fn, void* cookie);
8
+ attach_function :sass_make_function_list, [:size_t], :sass_c_function_list_ptr
9
+ attach_function :sass_make_function, [:string, :sass_c_function, :pointer], :sass_c_function_callback_ptr
10
+
11
+ # Setters and getters for callbacks on function lists
12
+ # ADDAPI Sass_C_Function_Callback ADDCALL sass_function_get_list_entry(Sass_C_Function_List list, size_t pos);
13
+ # ADDAPI void ADDCALL sass_function_set_list_entry(Sass_C_Function_List list, size_t pos, Sass_C_Function_Callback cb);
14
+ attach_function :sass_function_get_list_entry, [:sass_c_function_list_ptr, :size_t], :sass_c_function_callback_ptr
15
+ attach_function :sass_function_set_list_entry, [:sass_c_function_list_ptr, :size_t, :sass_c_function_callback_ptr], :void
16
+
17
+ # ADDAPI union Sass_Value* ADDCALL sass_make_number (double val, const char* unit);
18
+ attach_function :sass_make_number, [:double, :string], :sass_value_ptr
19
+
20
+ # ADDAPI union Sass_Value* ADDCALL sass_make_string (const char* val);
21
+ attach_function :sass_make_string, [:string], :sass_value_ptr
22
+
23
+ # ADDAPI union Sass_Value* ADDCALL sass_make_qstring (const char* val);
24
+ attach_function :sass_make_qstring, [:string], :sass_value_ptr
25
+
26
+ # ADDAPI union Sass_Value* ADDCALL sass_make_color (double r, double g, double b, double a);
27
+ attach_function :sass_make_color, [:double, :double, :double, :double], :sass_value_ptr
28
+
29
+ # ADDAPI union Sass_Value* ADDCALL sass_make_map (size_t len);
30
+ attach_function :sass_make_map, [:size_t], :sass_value_ptr
31
+
32
+ # ADDAPI union Sass_Value* ADDCALL sass_make_list (size_t len, enum Sass_Separator sep)
33
+ attach_function :sass_make_list, [:size_t, SassSeparator], :sass_value_ptr
34
+
35
+ # ADDAPI union Sass_Value* ADDCALL sass_make_boolean (boolean val);
36
+ attach_function :sass_make_boolean, [:bool], :sass_value_ptr
37
+
38
+ # ADDAPI void ADDCALL sass_map_set_key (union Sass_Value* v, size_t i, union Sass_Value*);
39
+ attach_function :sass_map_set_key, [:sass_value_ptr, :size_t, :sass_value_ptr], :void
40
+
41
+ # ADDAPI union Sass_Value* ADDCALL sass_map_get_key (const union Sass_Value* v, size_t i);
42
+ attach_function :sass_map_get_key, [:sass_value_ptr, :size_t], :sass_value_ptr
43
+
44
+ # ADDAPI void ADDCALL sass_map_set_value (union Sass_Value* v, size_t i, union Sass_Value*);
45
+ attach_function :sass_map_set_value, [:sass_value_ptr, :size_t, :sass_value_ptr], :void
46
+
47
+ # ADDAPI union Sass_Value* ADDCALL sass_map_get_value (const union Sass_Value* v, size_t i);
48
+ attach_function :sass_map_get_value, [:sass_value_ptr, :size_t], :sass_value_ptr
49
+
50
+ # ADDAPI size_t ADDCALL sass_map_get_length (const union Sass_Value* v);
51
+ attach_function :sass_map_get_length, [:sass_value_ptr], :size_t
52
+
53
+ # ADDAPI union Sass_Value* ADDCALL sass_list_get_value (const union Sass_Value* v, size_t i);
54
+ attach_function :sass_list_get_value, [:sass_value_ptr, :size_t], :sass_value_ptr
55
+
56
+ # ADDAPI void ADDCALL sass_list_set_value (union Sass_Value* v, size_t i, union Sass_Value* value);
57
+ attach_function :sass_list_set_value, [:sass_value_ptr, :size_t, :sass_value_ptr], :void
58
+
59
+ # ADDAPI size_t ADDCALL sass_list_get_length (const union Sass_Value* v);
60
+ attach_function :sass_list_get_length, [:sass_value_ptr], :size_t
61
+
62
+ # ADDAPI union Sass_Value* ADDCALL sass_make_error (const char* msg);
63
+ attach_function :sass_make_error, [:string], :sass_value_ptr
64
+
65
+ # ADDAPI enum Sass_Tag ADDCALL sass_value_get_tag (const union Sass_Value* v);
66
+ attach_function :sass_value_get_tag, [:sass_value_ptr], SassTag
67
+ attach_function :sass_value_is_null, [:sass_value_ptr], :bool
68
+
69
+ # ADDAPI const char* ADDCALL sass_string_get_value (const union Sass_Value* v);
70
+ attach_function :sass_string_get_value, [:sass_value_ptr], :string
71
+
72
+ # ADDAPI bool ADDCALL sass_string_is_quoted(const union Sass_Value* v);
73
+ attach_function :sass_string_is_quoted, [:sass_value_ptr], :bool
74
+
75
+ # ADDAPI const char* ADDCALL sass_number_get_value (const union Sass_Value* v);
76
+ attach_function :sass_number_get_value, [:sass_value_ptr], :double
77
+
78
+ # ADDAPI const char* ADDCALL sass_number_get_unit (const union Sass_Value* v);
79
+ attach_function :sass_number_get_unit, [:sass_value_ptr], :string
80
+
81
+ # ADDAPI const char* ADDCALL sass_boolean_get_value (const union Sass_Value* v);
82
+ attach_function :sass_boolean_get_value, [:sass_value_ptr], :bool
83
+
84
+ def self.string_get_type(native_value)
85
+ string_is_quoted(native_value) ? :string : :identifier
86
+ end
87
+
88
+ # ADDAPI double ADDCALL sass_color_get_r (const union Sass_Value* v);
89
+ # ADDAPI void ADDCALL sass_color_set_r (union Sass_Value* v, double r);
90
+ # ADDAPI double ADDCALL sass_color_get_g (const union Sass_Value* v);
91
+ # ADDAPI void ADDCALL sass_color_set_g (union Sass_Value* v, double g);
92
+ # ADDAPI double ADDCALL sass_color_get_b (const union Sass_Value* v);
93
+ # ADDAPI void ADDCALL sass_color_set_b (union Sass_Value* v, double b);
94
+ # ADDAPI double ADDCALL sass_color_get_a (const union Sass_Value* v);
95
+ # ADDAPI void ADDCALL sass_color_set_a (union Sass_Value* v, double a);
96
+ ['r', 'g', 'b', 'a'].each do |color_channel|
97
+ attach_function "sass_color_get_#{color_channel}".to_sym, [:sass_value_ptr], :double
98
+ attach_function "sass_color_set_#{color_channel}".to_sym, [:sass_value_ptr, :double], :void
99
+ end
100
+
101
+ # ADDAPI size_t ADDCALL sass_list_get_length(const union Sass_Value* v)
102
+ # ADDAPI union Sass_Value* ADDCALL sass_list_get_value (const union Sass_Value* v, size_t i);
103
+ attach_function :sass_list_get_length, [:sass_value_ptr], :size_t
104
+ attach_function :sass_list_get_value, [:sass_value_ptr, :size_t], :sass_value_ptr
105
+
106
+ # ADDAPI char* ADDCALL sass_error_get_message (const union Sass_Value* v);
107
+ # ADDAPI void ADDCALL sass_error_set_message (union Sass_Value* v, char* msg);
108
+ attach_function :sass_error_get_message, [:sass_value_ptr], :string
109
+ attach_function :sass_error_set_message, [:sass_value_ptr, :pointer], :void
110
+
111
+ # Getters for custom function descriptors
112
+ # ADDAPI const char* ADDCALL sass_function_get_signature (Sass_C_Function_Callback fn);
113
+ # ADDAPI Sass_C_Function ADDCALL sass_function_get_function (Sass_C_Function_Callback fn);
114
+ # ADDAPI void* ADDCALL sass_function_get_cookie (Sass_C_Function_Callback fn);
115
+ attach_function :sass_function_get_signature, [:sass_c_function_callback_ptr], :string
116
+ attach_function :sass_function_get_function, [:sass_c_function_callback_ptr], :sass_c_function
117
+ attach_function :sass_function_get_cookie, [:sass_c_function_callback_ptr], :pointer
118
+
119
+ # Creators for custom importer callback (with some additional pointer)
120
+ # The pointer is mostly used to store the callback into the actual binding
121
+ # ADDAPI Sass_C_Import_Callback ADDCALL sass_make_importer (Sass_C_Import_Fn, void* cookie);
122
+ attach_function :sass_make_importer, [:sass_c_import_function, :pointer], :sass_importer
123
+
124
+ # Getters for import function descriptors
125
+ # ADDAPI Sass_C_Import_Fn ADDCALL sass_import_get_function (Sass_C_Import_Callback fn);
126
+ # ADDAPI void* ADDCALL sass_import_get_cookie (Sass_C_Import_Callback fn);
127
+
128
+ # Deallocator for associated memory
129
+ # ADDAPI void ADDCALL sass_delete_importer (Sass_C_Import_Callback fn);
130
+
131
+ # Creator for sass custom importer return argument list
132
+ # ADDAPI struct Sass_Import** ADDCALL sass_make_import_list (size_t length);
133
+ attach_function :sass_make_import_list, [:size_t], :sass_import_list_ptr
134
+
135
+ # Creator for a single import entry returned by the custom importer inside the list
136
+ # ADDAPI struct Sass_Import* ADDCALL sass_make_import_entry (const char* path, char* source, char* srcmap);
137
+ # ADDAPI struct Sass_Import* ADDCALL sass_make_import (const char* path, const char* base, char* source, char* srcmap);
138
+ attach_function :sass_make_import_entry, [:string, :pointer, :pointer], :sass_import_ptr
139
+
140
+ # Setters to insert an entry into the import list (you may also use [] access directly)
141
+ # Since we are dealing with pointers they should have a guaranteed and fixed size
142
+ # ADDAPI void ADDCALL sass_import_set_list_entry (struct Sass_Import** list, size_t idx, struct Sass_Import* entry);
143
+ attach_function :sass_import_set_list_entry, [:sass_import_list_ptr, :size_t, :sass_import_ptr], :void
144
+ # ADDAPI struct Sass_Import* ADDCALL sass_import_get_list_entry (struct Sass_Import** list, size_t idx);
145
+
146
+ # Getters for import entry
147
+ # ADDAPI const char* ADDCALL sass_import_get_imp_path (struct Sass_Import*);
148
+ attach_function :sass_import_get_imp_path, [:sass_import_ptr], :string
149
+ # ADDAPI const char* ADDCALL sass_import_get_abs_path (struct Sass_Import*);
150
+ attach_function :sass_import_get_abs_path, [:sass_import_ptr], :string
151
+ # ADDAPI const char* ADDCALL sass_import_get_source (struct Sass_Import*);
152
+ attach_function :sass_import_get_source, [:sass_import_ptr], :string
153
+ # ADDAPI const char* ADDCALL sass_import_get_srcmap (struct Sass_Import*);
154
+ # Explicit functions to take ownership of these items
155
+ # The property on our struct will be reset to NULL
156
+ # ADDAPI char* ADDCALL sass_import_take_source (struct Sass_Import*);
157
+ # ADDAPI char* ADDCALL sass_import_take_srcmap (struct Sass_Import*);
158
+
159
+ # Deallocator for associated memory (incl. entries)
160
+ # ADDAPI void ADDCALL sass_delete_import_list (struct Sass_Import**);
161
+ # Just in case we have some stray import structs
162
+ # ADDAPI void ADDCALL sass_delete_import (struct Sass_Import*);
163
+ end
164
+ end