marine/examples/ipfs_node/wasm/ipfs_rpc/wit

140 lines
4.4 KiB
Plaintext
Raw Normal View History

2020-05-29 22:55:39 +00:00
;; allocate function type
2020-05-31 23:45:04 +00:00
(@interface type (func (param i32) (result i32))) ;; 0
2020-05-29 22:55:39 +00:00
;; deallocate function
2020-05-31 23:45:04 +00:00
(@interface type (func (param i32 i32))) ;; 1
2020-05-29 22:55:39 +00:00
;; invoke function
2020-05-31 23:45:04 +00:00
(@interface type (func (param string) (result string))) ;; 2
2020-05-29 22:55:39 +00:00
;; result extractor functions
2020-05-31 23:45:04 +00:00
(@interface type (func (result i32))) ;; 3
2020-05-29 22:55:39 +00:00
;; result setter functions
2020-05-31 23:45:04 +00:00
(@interface type (func (param i32))) ;; 4
2020-05-29 22:55:39 +00:00
;; import ipfs put/get function
2020-05-31 23:45:04 +00:00
(@interface type (func (param i32 i32))) ;; 5
2020-05-29 22:55:39 +00:00
2020-05-31 23:45:04 +00:00
;; import ipfs put/get function
2020-06-07 09:33:26 +00:00
(@interface type (func (param i32 i32))) ;; 6
2020-05-31 23:45:04 +00:00
;; import ipfs put/get function
(@interface type (func (param string) (result string))) ;; 7
;; import ipfs put/get function
2020-06-07 09:33:26 +00:00
(@interface type (func (param string) (result string))) ;; 8
;; import ipfs put/get function
2020-06-11 00:10:37 +00:00
(@interface type (func (param i32 i32))) ;; 9
2020-06-07 09:33:26 +00:00
;; import ipfs put/get function
2020-06-11 00:10:37 +00:00
(@interface type (func (param i32 i32))) ;; 10
;; export ipfs put/get function
(@interface type (func (param string) (result string))) ;; 11
;; export ipfs put/get function
(@interface type (func (param string) (result string))) ;; 12
2020-05-31 23:45:04 +00:00
(@interface export "allocate" (func 0)) ;; 0
(@interface export "deallocate" (func 1)) ;; 1
(@interface export "invoke" (func 2)) ;; 2
(@interface export "get_result_size" (func 3)) ;; 3
(@interface export "get_result_ptr" (func 3)) ;; 4
(@interface export "set_result_size" (func 4)) ;; 5
(@interface export "set_result_ptr" (func 4)) ;; 6
2020-06-11 00:10:37 +00:00
(@interface export "put" (func 11)) ;; 7
(@interface export "get" (func 12)) ;; 8
2020-05-29 22:55:39 +00:00
2020-06-06 18:34:13 +00:00
(@interface import "ipfs_node.wasm" "get" (func (type 5)))
2020-06-07 09:33:26 +00:00
(@interface import "ipfs_node.wasm" "put" (func (type 6)))
2020-05-31 23:45:04 +00:00
2020-06-11 21:05:04 +00:00
(@interface import "ipfs_node.wasm" "get" (func (type 7))) ;; 9
(@interface import "ipfs_node.wasm" "put" (func (type 8))) ;; 10
2020-05-29 22:55:39 +00:00
2020-06-11 00:10:37 +00:00
;; adapter for export invoke function
2020-05-29 22:55:39 +00:00
(@interface func (type 2)
arg.get 0
string.size
2020-05-31 23:45:04 +00:00
call-core 0 ;; call allocate
2020-05-29 22:55:39 +00:00
arg.get 0
string.lower_memory
2020-05-31 23:45:04 +00:00
call-core 2 ;; call invoke
2020-06-07 19:57:30 +00:00
call-core 4 ;; call get_result_size
call-core 3 ;; call get_result_ptr
2020-05-31 23:45:04 +00:00
string.lift_memory
2020-06-07 19:57:30 +00:00
call-core 4 ;; call get_result_size
call-core 3 ;; call get_result_ptr
2020-05-31 23:45:04 +00:00
call-core 1 ;; call deallocate
)
2020-06-11 00:10:37 +00:00
;; adapter for export put function
(@interface func (type 11)
arg.get 0
string.size
call-core 0 ;; call allocate
arg.get 0
string.lower_memory
call-core 7 ;; call put
call-core 4 ;; call get_result_size
call-core 3 ;; call get_result_ptr
string.lift_memory
call-core 4 ;; call get_result_size
call-core 3 ;; call get_result_ptr
call-core 1 ;; call deallocate
)
;; adapter for export get function
(@interface func (type 12)
arg.get 0
string.size
call-core 0 ;; call allocate
arg.get 0
string.lower_memory
call-core 8 ;; call get
call-core 4 ;; call get_result_size
call-core 3 ;; call get_result_ptr
string.lift_memory
call-core 4 ;; call get_result_size
call-core 3 ;; call get_result_ptr
call-core 1 ;; call deallocate
)
2020-06-07 19:57:30 +00:00
;; adapter for import function ipfs.get
2020-06-07 09:33:26 +00:00
(@interface func (type 9)
2020-05-31 23:45:04 +00:00
arg.get 0
arg.get 1
2020-05-29 22:55:39 +00:00
string.lift_memory
2020-06-11 21:05:04 +00:00
call-core 9 ;; call ipfs_node.get that returns string
2020-06-01 09:14:12 +00:00
dup
string.size
call-core 0 ;; call allocate
swap2
2020-05-31 23:45:04 +00:00
string.lower_memory
2020-06-07 19:57:30 +00:00
call-core 5 ;; call set_result_size
call-core 6 ;; call set_result_ptr
2020-05-29 22:55:39 +00:00
)
2020-06-07 19:57:30 +00:00
;; adapter for import function ipfs.put
2020-06-07 09:33:26 +00:00
(@interface func (type 10)
arg.get 0
arg.get 1
string.lift_memory
2020-06-11 21:05:04 +00:00
call-core 10 ;; call ipfs_node.put that returns string
2020-06-07 09:33:26 +00:00
dup
string.size
call-core 0 ;; call allocate
swap2
string.lower_memory
2020-06-07 19:57:30 +00:00
call-core 5 ;; call set_result_size
call-core 6 ;; call set_result_ptr
2020-06-07 09:33:26 +00:00
)
2020-05-29 22:55:39 +00:00
;; Implementations
2020-05-31 23:45:04 +00:00
(@interface implement (func 2) (func 2))
2020-06-07 09:33:26 +00:00
(@interface implement (func 5) (func 9))
(@interface implement (func 6) (func 10))
2020-06-11 00:10:37 +00:00
(@interface implement (func 11) (func 11))
(@interface implement (func 12) (func 12))