Module: WGPU::Native::OptionalFunctions
- Included in:
- WGPU::Native
- Defined in:
- lib/wgpu/native/loader.rb
Instance Method Summary collapse
-
#attach_optional_function(name, arguments, result) ⇒ void
Attaches a native function without failing library initialization.
-
#optional_capabilities ⇒ Hash{Symbol => Boolean}
Returns availability information for optional native functions.
-
#optional_function_available?(name) ⇒ Boolean
Reports whether an optional native function was attached.
Instance Method Details
#attach_optional_function(name, arguments, result) ⇒ void
This method returns an undefined value.
Attaches a native function without failing library initialization.
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/wgpu/native/loader.rb', line 15 def attach_optional_function(name, arguments, result) attach_function(name, arguments, result) optional_functions[name] = true rescue FFI::NotFoundError optional_functions[name] = false define_singleton_method(name) do |*| raise WGPU::Error, "Optional wgpu-native function #{name} is unavailable in the loaded library " \ "(expected #{Distribution::VERSION})" end end |
#optional_capabilities ⇒ Hash{Symbol => Boolean}
Returns availability information for optional native functions.
37 38 39 |
# File 'lib/wgpu/native/loader.rb', line 37 def optional_capabilities optional_functions.dup.freeze end |
#optional_function_available?(name) ⇒ Boolean
Reports whether an optional native function was attached.
30 31 32 |
# File 'lib/wgpu/native/loader.rb', line 30 def optional_function_available?(name) optional_functions.fetch(name, false) end |