lib/ffi/flock.rb in ffi-libfuse-0.4.0 vs lib/ffi/flock.rb in ffi-libfuse-0.4.1

- old
+ new

@@ -16,34 +16,38 @@ LockCmd = enum :int, [:getlk, 5, :setlk, 6, :setlkw, 7] end include(Accessors) - layout(l_type: Enums::LockType, l_whence: Enums::SeekWhenceShort, l_start: :off_t, l_len: :off_t, l_pid: :pid_t) + layout( + # @!attribute [r] type + # @return [Symbol] lock type, :rdlck, :wrlck, :unlck + l_type: Enums::LockType, - l_members = members.grep(/^l_/).map { |m| m[2..].to_sym } + # @!attribute [r] whence + # @return [Symbol] specifies what the offset is relative to, one of :seek_set, :seek_cur or :seek_end + # corresponding to the whence argument to fseek(2) or lseek(2), + l_whence: Enums::SeekWhenceShort, - ffi_attr_reader(*l_members, format: 'l_%s') + # @!attribute [r] start + # @return [Integer] the offset of the start of the region to which the lock applies, and is given in bytes + # relative to the point specified by #{whence} member. + l_start: :off_t, - # @!attribute [r] type - # @return [Symbol] lock type, :rdlck, :wrlck, :unlck + # @!attribute [r] len + # @return [Integer] the length of the region to be locked. + # + # A value of 0 means the region extends to the end of the file. + l_len: :off_t, - # @!attribute [r] whence - # @return [Symbol] specifies what the offset is relative to, one of :seek_set, :seek_cur or :seek_end - # corresponding to the whence argument to fseek(2) or lseek(2), + # @!attribute [r] pid + # @return [Integer] the process ID (see Process Creation Concepts) of the process holding the lock. + # It is filled in by calling fcntl with the F_GETLK command, but is ignored when making a lock. If the + # conflicting lock is an open file description lock (see Open File Description Locks), then this field will be + # set to -1. + l_pid: :pid_t + ) - # @!attribute [r] start - # @return [Integer] the offset of the start of the region to which the lock applies, and is given in bytes - # relative to the point specified by #{whence} member. - - # @!attribute [r] len - # @return [Integer] the length of the region to be locked. - # - # A value of 0 means the region extends to the end of the file. - - # @!attribute [r] pid - # @return [Integer] the process ID (see Process Creation Concepts) of the process holding the lock. - # It is filled in by calling fcntl with the F_GETLK command, but is ignored when making a lock. If the - # conflicting lock is an open file description lock (see Open File Description Locks), then this field will be - # set to -1. + # Strip leading 'l_' to make attribute names + ffi_attr_reader(**members.to_h { |m| [m[2..].to_sym, m] }) end end