Class: Extism::Val

Inherits:
Object
  • Object
show all
Defined in:
lib/extism/wasm.rb

Overview

A raw Wasm value. Contains the type and the data

Instance Method Summary collapse

Constructor Details

#initialize(ptr) ⇒ Val

Returns a new instance of Val.



20
21
22
# File 'lib/extism/wasm.rb', line 20

def initialize(ptr)
  @c_val = LibExtism::ExtismVal.new(ptr)
end

Instance Method Details

#typeObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/extism/wasm.rb', line 24

def type
  case @c_val[:t]
  when :I32
    :i32
  when :I64
    :i64
  when :PTR
    :i64
  when :F32
    :f32
  when :F64
    :f64
  else
    raise "Unsupported wasm value type #{type}"
  end
end

#valueObject



41
42
43
# File 'lib/extism/wasm.rb', line 41

def value
  @c_val[:v][type]
end

#value=(val) ⇒ Object



45
46
47
# File 'lib/extism/wasm.rb', line 45

def value=(val)
  @c_val[:v][type] = val
end