Class: Dommy::Js::Wasmtime::Engines::Quickjs::JsRef

Inherits:
Object
  • Object
show all
Defined in:
lib/dommy/js/wasmtime/engines/quickjs.rb

Overview

A handle to a live JS value in the quickjs VM, exposing the same bridge ABI Dommy objects do.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(bridge, jsvalue) ⇒ JsRef

Returns a new instance of JsRef.



34
35
36
37
# File 'lib/dommy/js/wasmtime/engines/quickjs.rb', line 34

def initialize(bridge, jsvalue)
  @bridge = bridge
  @jsvalue = jsvalue
end

Instance Attribute Details

#jsvalueObject (readonly)

Returns the value of attribute jsvalue.



32
33
34
# File 'lib/dommy/js/wasmtime/engines/quickjs.rb', line 32

def jsvalue
  @jsvalue
end

Instance Method Details

#__js_call__(method, args) ⇒ Object



48
49
50
# File 'lib/dommy/js/wasmtime/engines/quickjs.rb', line 48

def __js_call__(method, args)
  @bridge.wrap_result(@bridge.wb.call(@jsvalue, method, args.map { |a| @bridge.unwrap_arg(a) }))
end

#__js_get__(key) ⇒ Object



39
40
41
# File 'lib/dommy/js/wasmtime/engines/quickjs.rb', line 39

def __js_get__(key)
  @bridge.wrap_result(@bridge.wb.get(@jsvalue, key))
end

#__js_new__(args) ⇒ Object



52
53
54
# File 'lib/dommy/js/wasmtime/engines/quickjs.rb', line 52

def __js_new__(args)
  @bridge.wrap_result(@bridge.wb.construct(@jsvalue, args.map { |a| @bridge.unwrap_arg(a) }))
end

#__js_set__(key, value) ⇒ Object



43
44
45
46
# File 'lib/dommy/js/wasmtime/engines/quickjs.rb', line 43

def __js_set__(key, value)
  @bridge.wb.set(@jsvalue, key, @bridge.unwrap_arg(value))
  value
end