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

- old
+ new

@@ -1,12 +1,12 @@ # frozen_string_literal: true require_relative '../accessors' +require_relative '../boolean_int' require_relative 'fuse_loop_config' module FFI module Libfuse - # # struct fuse_cmdline_opts { # int singlethread; # int foreground; # int debug; # int nodefault_subtype; @@ -14,31 +14,34 @@ # int show_version; # int show_help; # int clone_fd; # unsigned int max_idle_threads; # }; + + # Command line options # @!visibility private class FuseCmdlineOpts < FFI::Struct include(FFI::Accessors) - layout( - single_thread: :int, - foreground: :int, - debug: :int, - nodefault_subtype: :int, + spec = { + single_thread: :bool_int, + foreground: :bool_int, + debug: :bool_int, + nodefault_subtype: :bool_int, mountpoint: :string, - show_version: :int, - show_help: :int, - clone_fd: :int, - max_idle_threads: :int - ) + show_version: :bool_int, + show_help: :bool_int, + clone_fd: :bool_int, + max_idle_threads: :uint + } + spec[:max_threads] = :uint if FUSE_MINOR_VERSION >= 12 - # int to booleans - ffi_attr_reader(:single_thread, :foreground, :debug, :nodefault_subtype, :show_version, :show_help, - :clone_fd) do |v| - v != 0 - end + layout(spec) + bool, = spec.partition { |_, v| v == :bool_int } + ffi_attr_reader(*bool.map { |k, _| "#{k}?" }) + ffi_attr_reader(:max_idle_threads, :mountpoint) + ffi_attr_reader(:max_threads) if FUSE_MINOR_VERSION >= 12 end end end