Skip to content

Commit

Permalink
cleanup: add PTR as an alias for I64
Browse files Browse the repository at this point in the history
  • Loading branch information
zshipko committed Nov 2, 2023
1 parent d7af36d commit 2152236
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
1 change: 1 addition & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ GEM

PLATFORMS
arm64-darwin-22
x86_64-linux

DEPENDENCIES
debug
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ class KvEnvironment

# We need to describe the wasm function signature of each host function
# to register them to this environment
register_import :kv_read, [Extism::ValType::I64], [Extism::ValType::I64]
register_import :kv_write, [Extism::ValType::I64, Extism::ValType::I64], []
register_import :kv_read, [Extism::ValType::PTR], [Extism::ValType::PTR]
register_import :kv_write, [Extism::ValType::PTR, Extism::ValType::PTR], []

def kv_read(plugin, inputs, outputs, _user_data)
key = plugin.input_as_string(inputs.first)
Expand Down
3 changes: 3 additions & 0 deletions lib/extism/wasm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ module Extism
module ValType
I32 = 0
I64 = 1
PTR = 1
F32 = 2
F64 = 3
V128 = 4
Expand All @@ -26,6 +27,8 @@ def type
:i32
when :I64
:i64
when :PTR
:i64
when :F32
:f32
when :F64
Expand Down
8 changes: 4 additions & 4 deletions test/test_extism.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
class KvEnvironment
include Extism::HostEnvironment

register_import :kv_read, [Extism::ValType::I64], [Extism::ValType::I64]
register_import :kv_write, [Extism::ValType::I64, Extism::ValType::I64], []
register_import :kv_read, [Extism::ValType::PTR], [Extism::ValType::PTR]
register_import :kv_write, [Extism::ValType::PTR, Extism::ValType::PTR], []

def kv_read(plugin, inputs, outputs, _user_data)
key = plugin.input_as_string(inputs.first)
Expand All @@ -41,8 +41,8 @@ def kv_write(plugin, inputs, _outputs, _user_data)
class Environment
include Extism::HostEnvironment

register_import :add_credit, [Extism::ValType::I64, Extism::ValType::I64], [Extism::ValType::I64]
register_import :send_email, [Extism::ValType::I64, Extism::ValType::I64], []
register_import :add_credit, [Extism::ValType::PTR, Extism::ValType::PTR], [Extism::ValType::PTR]
register_import :send_email, [Extism::ValType::PTR, Extism::ValType::PTR], []

attr_accessor :credit_args, :email_args

Expand Down

0 comments on commit 2152236

Please sign in to comment.