sass-embedded 1.69.1 → 1.69.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/exe/sass +2 -2
  4. data/ext/sass/Rakefile +8 -24
  5. data/ext/sass/embedded_sass_pb.rb +1 -1
  6. data/ext/sass/package.json +1 -1
  7. data/lib/sass/calculation_value/calculation_operation.rb +2 -5
  8. data/lib/sass/calculation_value.rb +10 -4
  9. data/lib/sass/compiler/connection.rb +92 -0
  10. data/lib/sass/{embedded → compiler}/dispatcher.rb +54 -38
  11. data/lib/sass/compiler/dispatcher_manager.rb +44 -0
  12. data/lib/sass/{embedded → compiler}/host/function_registry.rb +3 -3
  13. data/lib/sass/{embedded → compiler}/host/importer_registry.rb +4 -4
  14. data/lib/sass/{embedded → compiler}/host/logger_registry.rb +1 -1
  15. data/lib/sass/compiler/host/protofier.rb +88 -0
  16. data/lib/sass/compiler/host/structifier.rb +37 -0
  17. data/lib/sass/{embedded → compiler}/host/value_protofier.rb +3 -3
  18. data/lib/sass/{embedded → compiler}/host.rb +26 -15
  19. data/lib/sass/{embedded → compiler}/varint.rb +3 -5
  20. data/lib/sass/compiler.rb +191 -0
  21. data/lib/sass/elf.rb +2 -2
  22. data/lib/sass/embedded/version.rb +2 -2
  23. data/lib/sass/embedded.rb +65 -208
  24. data/lib/sass/exception.rb +65 -0
  25. data/lib/sass/fork_tracker.rb +51 -0
  26. data/lib/sass/serializer.rb +41 -0
  27. data/lib/sass/value/argument_list.rb +2 -2
  28. data/lib/sass/value/calculation.rb +3 -1
  29. data/lib/sass/value/color.rb +6 -6
  30. data/lib/sass/value/function.rb +6 -4
  31. data/lib/sass/value/map.rb +1 -1
  32. data/lib/sass/value/number.rb +11 -11
  33. data/lib/sass/value/string.rb +5 -8
  34. data/lib/sass/value.rb +1 -9
  35. metadata +25 -23
  36. data/ext/sass/win32_api.rb +0 -133
  37. data/lib/sass/compile_error.rb +0 -31
  38. data/lib/sass/embedded/connection.rb +0 -71
  39. data/lib/sass/embedded/protofier.rb +0 -86
  40. data/lib/sass/embedded/resilient_dispatcher.rb +0 -44
  41. data/lib/sass/embedded/structifier.rb +0 -35
  42. data/lib/sass/script_error.rb +0 -10
@@ -0,0 +1,65 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Sass
4
+ # An exception thrown because a Sass compilation failed.
5
+ class CompileError < StandardError
6
+ # @return [String, nil]
7
+ attr_reader :sass_stack
8
+
9
+ # @return [Logger::SourceSpan, nil]
10
+ attr_reader :span
11
+
12
+ # @return [Array<String>]
13
+ attr_reader :loaded_urls
14
+
15
+ # @!visibility private
16
+ def initialize(message, full_message, sass_stack, span, loaded_urls)
17
+ super(message)
18
+
19
+ @full_message = full_message
20
+ @sass_stack = sass_stack
21
+ @span = span
22
+ @loaded_urls = loaded_urls
23
+ end
24
+
25
+ # @return [String]
26
+ def full_message(highlight: nil, order: nil, **)
27
+ return super if @full_message.nil?
28
+
29
+ highlight = Exception.respond_to?(:to_tty?) && Exception.to_tty? if highlight.nil?
30
+ if highlight
31
+ +@full_message
32
+ else
33
+ @full_message.gsub(/\e\[[0-9;]*m/, '')
34
+ end
35
+ end
36
+
37
+ # @return [String]
38
+ def to_css
39
+ content = full_message(highlight: false, order: :top)
40
+
41
+ <<~CSS
42
+ /* #{content.gsub('*/', "*\u2060/").gsub("\r\n", "\n").split("\n").join("\n * ")} */
43
+
44
+ body::before {
45
+ position: static;
46
+ display: block;
47
+ padding: 1em;
48
+ margin: 0 0 1em;
49
+ border-width: 0 0 2px;
50
+ border-bottom-style: solid;
51
+ font-family: monospace, monospace;
52
+ white-space: pre;
53
+ content: #{Serializer.serialize_quoted_string(content, ascii_only: true)};
54
+ }
55
+ CSS
56
+ end
57
+ end
58
+
59
+ # An exception thrown by Sass Script.
60
+ class ScriptError < StandardError
61
+ def initialize(message, name = nil)
62
+ super(name.nil? ? message : "$#{name}: #{message}")
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Sass
4
+ # The {ForkTracker} module.
5
+ #
6
+ # It tracks objects that need to be closed after `Process.fork`.
7
+ module ForkTracker
8
+ HASH = {}.compare_by_identity
9
+
10
+ MUTEX = Mutex.new
11
+
12
+ private_constant :HASH, :MUTEX
13
+
14
+ module_function
15
+
16
+ def add(obj)
17
+ MUTEX.synchronize do
18
+ HASH[obj] = true
19
+ end
20
+ end
21
+
22
+ def delete(obj)
23
+ MUTEX.synchronize do
24
+ HASH.delete(obj)
25
+ end
26
+ end
27
+
28
+ def each(...)
29
+ MUTEX.synchronize do
30
+ HASH.keys
31
+ end.each(...)
32
+ end
33
+
34
+ # The {CoreExt} module.
35
+ #
36
+ # It closes objects after `Process.fork`.
37
+ module CoreExt
38
+ def _fork
39
+ pid = super
40
+ ForkTracker.each(&:close) if pid.zero?
41
+ pid
42
+ end
43
+ end
44
+
45
+ private_constant :CoreExt
46
+
47
+ Process.singleton_class.prepend(CoreExt) if Process.respond_to?(:_fork)
48
+ end
49
+
50
+ private_constant :ForkTracker
51
+ end
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Sass
4
+ # The {Serializer} module.
5
+ module Serializer
6
+ module_function
7
+
8
+ def serialize_quoted_string(string, ascii_only: false)
9
+ buffer = [0x22]
10
+ string.each_codepoint do |codepoint|
11
+ if codepoint.zero?
12
+ # If the character is NULL (U+0000), then the REPLACEMENT CHARACTER (U+FFFD).
13
+ buffer << 0xFFFD
14
+ elsif codepoint == 0x22
15
+ # If the character is '"' (U+0022) or "\" (U+005C), then the escaped character.
16
+ buffer << 0x5C << 0x22
17
+ elsif codepoint == 0x5C
18
+ # If the character is '"' (U+0022) or "\" (U+005C), then the escaped character.
19
+ buffer << 0x5C << 0x5C
20
+ elsif codepoint < 0x20 || (ascii_only ? codepoint >= 0x7F : codepoint == 0x7F)
21
+ # If the character is in the range [\1-\1f] (U+0001 to U+001F) or is U+007F,
22
+ # then the character escaped as code point.
23
+ buffer << 0x5C
24
+ buffer.concat(codepoint.to_s(16).codepoints)
25
+ buffer << 0x20
26
+ else
27
+ # Otherwise, the character itself.
28
+ buffer << codepoint
29
+ end
30
+ end
31
+ buffer << 0x22
32
+ buffer.pack('U*')
33
+ end
34
+
35
+ def serialize_unquoted_string(string)
36
+ string.tr("\0", "\uFFFD").gsub(/\n */, ' ')
37
+ end
38
+ end
39
+
40
+ private_constant :Serializer
41
+ end
@@ -8,12 +8,12 @@ module Sass
8
8
  # map as well as the positional arguments.
9
9
  #
10
10
  # @see https://sass-lang.com/documentation/js-api/classes/sassargumentlist/
11
- class ArgumentList < Value::List
11
+ class ArgumentList < List
12
12
  # @param contents [Array<Value>]
13
13
  # @param keywords [Hash<::String, Value>]
14
14
  # @param separator [::String]
15
15
  def initialize(contents = [], keywords = {}, separator = ',')
16
- super(contents, separator: separator)
16
+ super(contents, separator:)
17
17
 
18
18
  @id = 0
19
19
  @keywords_accessed = false
@@ -53,7 +53,9 @@ module Sass
53
53
  private
54
54
 
55
55
  def initialize(name, arguments)
56
- arguments.each(&:assert_calculation_value)
56
+ arguments.each do |value|
57
+ assert_calculation_value(value)
58
+ end
57
59
 
58
60
  @name = name.freeze
59
61
  @arguments = arguments.freeze
@@ -50,42 +50,42 @@ module Sass
50
50
 
51
51
  # @return [Integer]
52
52
  def red
53
- hsl_to_rgb unless defined? @red
53
+ hsl_to_rgb unless defined?(@red)
54
54
 
55
55
  @red
56
56
  end
57
57
 
58
58
  # @return [Integer]
59
59
  def green
60
- hsl_to_rgb unless defined? @green
60
+ hsl_to_rgb unless defined?(@green)
61
61
 
62
62
  @green
63
63
  end
64
64
 
65
65
  # @return [Integer]
66
66
  def blue
67
- hsl_to_rgb unless defined? @blue
67
+ hsl_to_rgb unless defined?(@blue)
68
68
 
69
69
  @blue
70
70
  end
71
71
 
72
72
  # @return [Numeric]
73
73
  def hue
74
- rgb_to_hsl unless defined? @hue
74
+ rgb_to_hsl unless defined?(@hue)
75
75
 
76
76
  @hue
77
77
  end
78
78
 
79
79
  # @return [Numeric]
80
80
  def saturation
81
- rgb_to_hsl unless defined? @saturation
81
+ rgb_to_hsl unless defined?(@saturation)
82
82
 
83
83
  @saturation
84
84
  end
85
85
 
86
86
  # @return [Numeric]
87
87
  def lightness
88
- rgb_to_hsl unless defined? @lightness
88
+ rgb_to_hsl unless defined?(@lightness)
89
89
 
90
90
  @lightness
91
91
  end
@@ -10,9 +10,11 @@ module Sass
10
10
 
11
11
  # @param signature [::String]
12
12
  # @param callback [Proc]
13
- def initialize(signature, callback)
14
- @signature = signature
15
- @callback = callback
13
+ def initialize(signature, &callback)
14
+ raise Sass::ScriptError, 'no block given' unless signature.nil? || callback
15
+
16
+ @signature = signature.freeze
17
+ @callback = callback.freeze
16
18
  end
17
19
 
18
20
  # @return [Integer, nil]
@@ -29,7 +31,7 @@ module Sass
29
31
  # @return [::Boolean]
30
32
  def ==(other)
31
33
  if id.nil?
32
- other.equal? self
34
+ other.equal?(self)
33
35
  else
34
36
  other.is_a?(Sass::Value::Function) && other.id == id
35
37
  end
@@ -30,7 +30,7 @@ module Sass
30
30
  # @param index [Numeric, Value]
31
31
  # @return [List<(Value, Value)>, Value]
32
32
  def at(index)
33
- if index.is_a? Numeric
33
+ if index.is_a?(Numeric)
34
34
  index = index.floor
35
35
  index = to_a_length + index if index.negative?
36
36
  return nil if index.negative? || index >= to_a_length
@@ -25,12 +25,12 @@ module Sass
25
25
  denominator_units = []
26
26
  when ::Hash
27
27
  numerator_units = unit.fetch(:numerator_units, [])
28
- unless numerator_units.is_a? Array
28
+ unless numerator_units.is_a?(Array)
29
29
  raise Sass::ScriptError, "invalid numerator_units #{numerator_units.inspect}"
30
30
  end
31
31
 
32
32
  denominator_units = unit.fetch(:denominator_units, [])
33
- unless denominator_units.is_a? Array
33
+ unless denominator_units.is_a?(Array)
34
34
  raise Sass::ScriptError, "invalid denominator_units #{denominator_units.inspect}"
35
35
  end
36
36
  else
@@ -75,7 +75,7 @@ module Sass
75
75
 
76
76
  # @return [::Boolean]
77
77
  def ==(other)
78
- return false unless other.is_a? Sass::Value::Number
78
+ return false unless other.is_a?(Sass::Value::Number)
79
79
 
80
80
  return false if numerator_units.length != other.numerator_units.length ||
81
81
  denominator_units.length != other.denominator_units.length
@@ -183,7 +183,7 @@ module Sass
183
183
  def convert_value(new_numerator_units, new_denominator_units, name = nil)
184
184
  coerce_or_convert_value(new_numerator_units, new_denominator_units,
185
185
  coerce_unitless: false,
186
- name: name)
186
+ name:)
187
187
  end
188
188
 
189
189
  # @param other [Number]
@@ -200,9 +200,9 @@ module Sass
200
200
  def convert_value_to_match(other, name = nil, other_name = nil)
201
201
  coerce_or_convert_value(other.numerator_units, other.denominator_units,
202
202
  coerce_unitless: false,
203
- name: name,
204
- other: other,
205
- other_name: other_name)
203
+ name:,
204
+ other:,
205
+ other_name:)
206
206
  end
207
207
 
208
208
  # @param new_numerator_units [Array<::String>]
@@ -221,7 +221,7 @@ module Sass
221
221
  def coerce_value(new_numerator_units, new_denominator_units, name = nil)
222
222
  coerce_or_convert_value(new_numerator_units, new_denominator_units,
223
223
  coerce_unitless: true,
224
- name: name)
224
+ name:)
225
225
  end
226
226
 
227
227
  # @param unit [::String]
@@ -244,9 +244,9 @@ module Sass
244
244
  def coerce_value_to_match(other, name = nil, other_name = nil)
245
245
  coerce_or_convert_value(other.numerator_units, other.denominator_units,
246
246
  coerce_unitless: true,
247
- name: name,
248
- other: other,
249
- other_name: other_name)
247
+ name:,
248
+ other:,
249
+ other_name:)
250
250
  end
251
251
 
252
252
  # @return [Number]
@@ -39,14 +39,6 @@ module Sass
39
39
  self
40
40
  end
41
41
 
42
- # @return [CalculationValue]
43
- # @raise [ScriptError]
44
- def assert_calculation_value(name = nil)
45
- raise Sass::ScriptError.new("Expected #{self} to be an unquoted string.", name) if quoted?
46
-
47
- self
48
- end
49
-
50
42
  # @param sass_index [Number]
51
43
  # @return [Integer]
52
44
  def sass_index_to_string_index(sass_index, name = nil)
@@ -59,6 +51,11 @@ module Sass
59
51
 
60
52
  index.negative? ? text.length + index : index - 1
61
53
  end
54
+
55
+ # @return [String]
56
+ def to_s
57
+ @quoted ? Serializer.serialize_quoted_string(@text) : Serializer.serialize_unquoted_string(@text)
58
+ end
62
59
  end
63
60
  end
64
61
  end
data/lib/sass/value.rb CHANGED
@@ -1,8 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative 'calculation_value'
4
- require_relative 'script_error'
5
-
6
3
  module Sass
7
4
  # The abstract base class of Sass's value types.
8
5
  #
@@ -67,12 +64,6 @@ module Sass
67
64
  raise Sass::ScriptError.new("#{self} is not a calculation", name)
68
65
  end
69
66
 
70
- # @return [CalculationValue]
71
- # @raise [ScriptError]
72
- def assert_calculation_value(name = nil)
73
- raise Sass::ScriptError.new("#{self} is not a calculation value", name)
74
- end
75
-
76
67
  # @return [Color]
77
68
  # @raise [ScriptError]
78
69
  def assert_color(name = nil)
@@ -130,6 +121,7 @@ module Sass
130
121
  end
131
122
  end
132
123
 
124
+ require_relative 'calculation_value'
133
125
  require_relative 'value/list'
134
126
  require_relative 'value/argument_list'
135
127
  require_relative 'value/boolean'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sass-embedded
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.69.1
4
+ version: 1.69.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - なつき
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-10-10 00:00:00.000000000 Z
11
+ date: 2024-01-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: google-protobuf
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '3.23'
19
+ version: '3.25'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '3.23'
26
+ version: '3.25'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -55,32 +55,33 @@ files:
55
55
  - ext/sass/embedded_sass_pb.rb
56
56
  - ext/sass/expand-archive.ps1
57
57
  - ext/sass/package.json
58
- - ext/sass/win32_api.rb
59
58
  - lib/sass-embedded.rb
60
59
  - lib/sass/calculation_value.rb
61
60
  - lib/sass/calculation_value/calculation_operation.rb
62
61
  - lib/sass/canonicalize_context.rb
63
- - lib/sass/compile_error.rb
64
62
  - lib/sass/compile_result.rb
63
+ - lib/sass/compiler.rb
64
+ - lib/sass/compiler/connection.rb
65
+ - lib/sass/compiler/dispatcher.rb
66
+ - lib/sass/compiler/dispatcher_manager.rb
67
+ - lib/sass/compiler/host.rb
68
+ - lib/sass/compiler/host/function_registry.rb
69
+ - lib/sass/compiler/host/importer_registry.rb
70
+ - lib/sass/compiler/host/logger_registry.rb
71
+ - lib/sass/compiler/host/protofier.rb
72
+ - lib/sass/compiler/host/structifier.rb
73
+ - lib/sass/compiler/host/value_protofier.rb
74
+ - lib/sass/compiler/varint.rb
65
75
  - lib/sass/elf.rb
66
76
  - lib/sass/embedded.rb
67
- - lib/sass/embedded/connection.rb
68
- - lib/sass/embedded/dispatcher.rb
69
- - lib/sass/embedded/host.rb
70
- - lib/sass/embedded/host/function_registry.rb
71
- - lib/sass/embedded/host/importer_registry.rb
72
- - lib/sass/embedded/host/logger_registry.rb
73
- - lib/sass/embedded/host/value_protofier.rb
74
- - lib/sass/embedded/protofier.rb
75
- - lib/sass/embedded/resilient_dispatcher.rb
76
- - lib/sass/embedded/structifier.rb
77
- - lib/sass/embedded/varint.rb
78
77
  - lib/sass/embedded/version.rb
79
78
  - lib/sass/embedded_protocol.rb
79
+ - lib/sass/exception.rb
80
+ - lib/sass/fork_tracker.rb
80
81
  - lib/sass/logger/silent.rb
81
82
  - lib/sass/logger/source_location.rb
82
83
  - lib/sass/logger/source_span.rb
83
- - lib/sass/script_error.rb
84
+ - lib/sass/serializer.rb
84
85
  - lib/sass/value.rb
85
86
  - lib/sass/value/argument_list.rb
86
87
  - lib/sass/value/boolean.rb
@@ -95,13 +96,14 @@ files:
95
96
  - lib/sass/value/number.rb
96
97
  - lib/sass/value/number/unit.rb
97
98
  - lib/sass/value/string.rb
98
- homepage: https://github.com/ntkme/sass-embedded-host-ruby
99
+ homepage: https://github.com/sass-contrib/sass-embedded-host-ruby
99
100
  licenses:
100
101
  - MIT
101
102
  metadata:
102
- documentation_uri: https://rubydoc.info/gems/sass-embedded/1.69.1
103
- source_code_uri: https://github.com/ntkme/sass-embedded-host-ruby/tree/v1.69.1
103
+ documentation_uri: https://rubydoc.info/gems/sass-embedded/1.69.7
104
+ source_code_uri: https://github.com/sass-contrib/sass-embedded-host-ruby/tree/v1.69.7
104
105
  funding_uri: https://github.com/sponsors/ntkme
106
+ rubygems_mfa_required: 'true'
105
107
  post_install_message:
106
108
  rdoc_options: []
107
109
  require_paths:
@@ -110,14 +112,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
110
112
  requirements:
111
113
  - - ">="
112
114
  - !ruby/object:Gem::Version
113
- version: 3.0.0
115
+ version: 3.1.3
114
116
  required_rubygems_version: !ruby/object:Gem::Requirement
115
117
  requirements:
116
118
  - - ">="
117
119
  - !ruby/object:Gem::Version
118
120
  version: '0'
119
121
  requirements: []
120
- rubygems_version: 3.4.20
122
+ rubygems_version: 3.5.3
121
123
  signing_key:
122
124
  specification_version: 4
123
125
  summary: Use dart-sass with Ruby!
@@ -1,133 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'fiddle'
4
-
5
- # @!visibility private
6
- module SassConfig
7
- # @see https://learn.microsoft.com/en-us/windows/win32/api/
8
- module Win32API
9
- Kernel32 = Fiddle.dlopen('Kernel32.dll')
10
-
11
- # @see https://learn.microsoft.com/en-us/windows/win32/sysinfo/image-file-machine-constants
12
- module ImageFileMachineConstants
13
- IMAGE_FILE_MACHINE_I386 = 0x014c
14
- IMAGE_FILE_MACHINE_ARMNT = 0x01c4
15
- IMAGE_FILE_MACHINE_AMD64 = 0x8664
16
- IMAGE_FILE_MACHINE_ARM64 = 0xaa64
17
- end
18
-
19
- private_constant :ImageFileMachineConstants
20
-
21
- # @see https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/ne-processthreadsapi-machine_attributes
22
- module MachineAttributes
23
- USER_ENABLED = 0x00000001
24
- KERNEL_ENABLED = 0x00000002
25
- WOW64_CONTAINER = 0x00000004
26
- end
27
-
28
- private_constant :MachineAttributes
29
-
30
- # Specifies the ways in which an architecture of code can run on a host operating system.
31
- class MachineTypeAttributes
32
- def initialize(machine_type_attributes)
33
- @machine_type_attributes = machine_type_attributes
34
- end
35
-
36
- # The specified architecture of code can run in user mode.
37
- def user_enabled?
38
- @machine_type_attributes & MachineAttributes::USER_ENABLED == MachineAttributes::USER_ENABLED
39
- end
40
-
41
- # The specified architecture of code can run in kernel mode.
42
- def kernel_enabled?
43
- @machine_type_attributes & MachineAttributes::KERNEL_ENABLED == MachineAttributes::KERNEL_ENABLED
44
- end
45
-
46
- # The specified architecture of code runs on WOW64.
47
- def wow64_container?
48
- @machine_type_attributes & MachineAttributes::WOW64_CONTAINER == MachineAttributes::WOW64_CONTAINER
49
- end
50
- end
51
-
52
- private_constant :MachineTypeAttributes
53
-
54
- class << self
55
- def x86?
56
- get_machine_type_attributes(ImageFileMachineConstants::IMAGE_FILE_MACHINE_I386).user_enabled?
57
- end
58
-
59
- def arm?
60
- get_machine_type_attributes(ImageFileMachineConstants::IMAGE_FILE_MACHINE_ARMNT).user_enabled?
61
- end
62
-
63
- def x64?
64
- get_machine_type_attributes(ImageFileMachineConstants::IMAGE_FILE_MACHINE_AMD64).user_enabled?
65
- end
66
-
67
- def arm64?
68
- get_machine_type_attributes(ImageFileMachineConstants::IMAGE_FILE_MACHINE_ARM64).user_enabled?
69
- end
70
-
71
- private
72
-
73
- begin
74
- # @see https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-getmachinetypeattributes
75
- GetMachineTypeAttributes = Fiddle::Function.new(
76
- Kernel32['GetMachineTypeAttributes'],
77
- [-Fiddle::TYPE_SHORT, Fiddle::TYPE_VOIDP],
78
- Fiddle::TYPE_LONG
79
- )
80
-
81
- def get_machine_type_attributes(machine)
82
- p_machine_type_attributes = Fiddle::Pointer.malloc(Fiddle::SIZEOF_INT, Fiddle::RUBY_FREE)
83
- raise Fiddle.win32_last_error unless GetMachineTypeAttributes.call(machine, p_machine_type_attributes).zero?
84
-
85
- MachineTypeAttributes.new(p_machine_type_attributes.to_str.unpack1('i'))
86
- end
87
- rescue Fiddle::DLError
88
- # @see https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-getcurrentprocess
89
- GetCurrentProcess = Fiddle::Function.new(
90
- Kernel32['GetCurrentProcess'],
91
- [],
92
- Fiddle::TYPE_VOIDP
93
- )
94
-
95
- # @see https://learn.microsoft.com/en-us/windows/win32/api/wow64apiset/nf-wow64apiset-iswow64process2
96
- IsWow64Process2 = Fiddle::Function.new(
97
- Kernel32['IsWow64Process2'],
98
- [Fiddle::TYPE_VOIDP, Fiddle::TYPE_VOIDP, Fiddle::TYPE_VOIDP],
99
- Fiddle::TYPE_CHAR
100
- )
101
-
102
- # @see https://learn.microsoft.com/en-us/windows/win32/api/wow64apiset/nf-wow64apiset-iswow64guestmachinesupported
103
- IsWow64GuestMachineSupported = Fiddle::Function.new(
104
- Kernel32['IsWow64GuestMachineSupported'],
105
- [-Fiddle::TYPE_SHORT, Fiddle::TYPE_VOIDP],
106
- Fiddle::TYPE_LONG
107
- )
108
-
109
- def get_machine_type_attributes(machine)
110
- h_process = GetCurrentProcess.call
111
- p_process_machine = Fiddle::Pointer.malloc(Fiddle::SIZEOF_SHORT, Fiddle::RUBY_FREE)
112
- p_native_machine = Fiddle::Pointer.malloc(Fiddle::SIZEOF_SHORT, Fiddle::RUBY_FREE)
113
- raise Fiddle.win32_last_error if IsWow64Process2.call(h_process, p_process_machine, p_native_machine).zero?
114
-
115
- if p_native_machine.to_str.unpack1('S!') == machine
116
- return MachineTypeAttributes.new(MachineAttributes::USER_ENABLED | MachineAttributes::KERNEL_ENABLED)
117
- end
118
-
119
- p_machine_is_supported = Fiddle::Pointer.malloc(Fiddle::SIZEOF_CHAR, Fiddle::RUBY_FREE)
120
- raise Fiddle.win32_last_error unless IsWow64GuestMachineSupported.call(machine, p_machine_is_supported).zero?
121
-
122
- if p_machine_is_supported.to_str.unpack1('c').zero?
123
- MachineTypeAttributes.new(0)
124
- else
125
- MachineTypeAttributes.new(MachineAttributes::USER_ENABLED | MachineAttributes::WOW64_CONTAINER)
126
- end
127
- end
128
- end
129
- end
130
- end
131
-
132
- private_constant :Win32API
133
- end
@@ -1,31 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Sass
4
- # An exception thrown because a Sass compilation failed.
5
- class CompileError < StandardError
6
- # @return [String, nil]
7
- attr_reader :sass_stack
8
-
9
- # @return [Logger::SourceSpan, nil]
10
- attr_reader :span
11
-
12
- # @return [Array<String>]
13
- attr_reader :loaded_urls
14
-
15
- # @!visibility private
16
- def initialize(message, full_message, sass_stack, span, loaded_urls)
17
- super(message)
18
- @full_message = full_message
19
- @sass_stack = sass_stack
20
- @span = span
21
- @loaded_urls = loaded_urls
22
- end
23
-
24
- # @return [String]
25
- def full_message(...)
26
- return super(...) if @full_message.nil?
27
-
28
- @full_message = +@full_message
29
- end
30
- end
31
- end