Sha256: 8ce681cb292c032dfb08e56e343217fc71f334cb90891e9f3e673536e3e7093b

Contents?: true

Size: 1.04 KB

Versions: 1

Compression:

Stored size: 1.04 KB

Contents

# frozen_string_literal: true
require 'ffi'

module Lxi
  module FFIFunctions
    extend FFI::Library

    ffi_lib LIBLXI_PATHS
    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 :init, :lxi_init, [], :int
    attach_function :discover, :lxi_discover, [LxiInfo.ptr, :int, :lxi_discover_type], :int
    attach_function :connect, :lxi_connect, %i[string int string int lxi_protocol_type], :int
    attach_function :__send, :lxi_send, %i[int string int int], :int
    attach_function :receive, :lxi_receive, %i[int pointer int int], :int
    attach_function :disconnect, :lxi_disconnect, [:int], :int
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
lxi_rb-0.10.5 lib/lxi/functions.rb