Class: Libcall::OutputReader

Inherits:
Object
  • Object
show all
Defined in:
lib/libcall/output_reader.rb

Overview

Handles reading output parameters after FFI calls

Instance Method Summary collapse

Constructor Details

#initialize(out_refs) ⇒ OutputReader

Returns a new instance of OutputReader.



6
7
8
# File 'lib/libcall/output_reader.rb', line 6

def initialize(out_refs)
  @out_refs = out_refs
end

Instance Method Details

#empty?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/libcall/output_reader.rb', line 23

def empty?
  @out_refs.empty?
end

#readObject



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/libcall/output_reader.rb', line 10

def read
  @out_refs.map do |ref|
    case ref[:kind]
    when :out
      read_single_output(ref)
    when :out_array
      read_array_output(ref)
    else
      raise Error, "Unknown out reference kind: #{ref[:kind]}"
    end
  end
end