Sha256: 36776c161fb9866d1e3c56cfe089e6919390da8db7bcec040372349666688018

Contents?: true

Size: 1.11 KB

Versions: 9

Compression:

Stored size: 1.11 KB

Contents

# frozen_string_literal: true
require 'ffi'

module Lxi
  module FFIFunctions
    extend FFI::Library

    ffi_lib '/opt/homebrew/lib/liblxi.dylib'
    ffi_lib_flags :now, :global

    # Define liblxi structs
    class LxiInfo < FFI::Struct
      layout :broadcast,
             callback(%i[pointer pointer], :void),
             :device,
             callback(%i[pointer pointer], :void),
             :service,
             callback(%i[pointer pointer pointer int], :void)
    end

    # Define liblxi enums
    enum :lxi_protocol_type, %i[vxi11 raw hyslip]
    enum :lxi_discover_type, %i[vxi11 mdns]

    # Expose liblxi functions
    attach_function :lxi_init, [], :int
    attach_function :lxi_discover_internal, :lxi_discover, [LxiInfo.ptr, :int, :lxi_discover_type], :int
    attach_function :lxi_discover_if, [LxiInfo.ptr, :string, :int, :lxi_discover_type], :int
    attach_function :lxi_connect, %i[string int string int lxi_protocol_type], :int
    attach_function :lxi_send, %i[int string int int], :int
    attach_function :lxi_receive, %i[int pointer int int], :int
    attach_function :lxi_disconnect, [:int], :int
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
lxi_rb-0.4.9 lib/lxi/functions.rb
lxi_rb-0.4.8 lib/lxi/functions.rb
lxi_rb-0.4.6 lib/lxi/functions.rb
lxi_rb-0.4.1 lib/lxi/functions.rb
lxi_rb-0.4.0 lib/lxi/functions.rb
lxi_rb-0.2.26 lib/lxi/functions.rb
lxi_rb-0.2.25 lib/lxi/functions.rb
lxi_rb-0.2.18 lib/lxi/functions.rb
lxi_rb-0.2.12 lib/lxi/functions.rb