Module: HDF5::Native
- Defined in:
- lib/hdf5/native.rb
Overview
Internal helpers for native return values and resource cleanup.
Class Method Summary collapse
- .check(value, message) ⇒ Object
-
.close(*handles) ⇒ Object
Attempt every close, while preserving an exception already in flight.
- .close_object(object) ⇒ Object
- .datatype_class(type_id) ⇒ Object
- .extent_type(space_id) ⇒ Object
Class Method Details
.check(value, message) ⇒ Object
8 9 10 11 12 |
# File 'lib/hdf5/native.rb', line 8 def check(value, ) raise NativeError, if value.negative? value end |
.close(*handles) ⇒ Object
Attempt every close, while preserving an exception already in flight.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/hdf5/native.rb', line 29 def close(*handles) active_error = $ERROR_INFO close_error = nil handles.each do |function, id| next unless id && id >= 0 begin check(HDF5::FFI.public_send(function, id), "Failed to close HDF5 resource (#{function})") rescue StandardError => error close_error ||= error end end raise close_error if close_error && active_error.nil? end |
.close_object(object) ⇒ Object
44 45 46 47 48 49 |
# File 'lib/hdf5/native.rb', line 44 def close_object(object) active_error = $ERROR_INFO object&.close rescue StandardError raise if active_error.nil? end |
.datatype_class(type_id) ⇒ Object
14 15 16 17 18 19 |
# File 'lib/hdf5/native.rb', line 14 def datatype_class(type_id) value = HDF5::FFI.H5Tget_class(type_id) raise NativeError, 'Failed to get datatype class' if value == :H5T_NO_CLASS value end |
.extent_type(space_id) ⇒ Object
21 22 23 24 25 26 |
# File 'lib/hdf5/native.rb', line 21 def extent_type(space_id) value = HDF5::FFI.H5Sget_simple_extent_type(space_id) raise NativeError, 'Failed to get dataspace type' if value == :H5S_NO_CLASS value end |