Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cleanup: add Val_type.ptr as an alias for ValType::I64 #11

Merged
merged 1 commit into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ let make_kv_plugin () =

let kv_read =
let open Val_type in
Function.create "kv_read" ~params:[ I64 ] ~results:[ I64 ] ~user_data:()
Function.create "kv_read" ~params:[ ptr ] ~results:[ ptr ] ~user_data:()
@@ fun plugin () ->
let key = Host_function.input_string plugin in
Printf.printf "Reading from key=%s\n" key;
Expand All @@ -177,7 +177,7 @@ let make_kv_plugin () =

let kv_write =
let open Val_type in
Function.create "kv_write" ~params:[ I64; I64 ] ~results:[] ~user_data:()
Function.create "kv_write" ~params:[ ptr; ptr ] ~results:[] ~user_data:()
@@ fun plugin () ->
let key = Host_function.input_string ~index:0 plugin in
let value = Host_function.input_string ~index:1 plugin in
Expand Down
4 changes: 2 additions & 2 deletions examples/kv.ml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ let make_kv_plugin () =

let kv_read =
let open Val_type in
Function.create "kv_read" ~params:[ I64 ] ~results:[ I64 ] ~user_data:()
Function.create "kv_read" ~params:[ ptr ] ~results:[ ptr ] ~user_data:()
@@ fun plugin () ->
let key = Host_function.input_string plugin in
Printf.printf "Reading from key=%s\n" key;
Expand All @@ -28,7 +28,7 @@ let make_kv_plugin () =

let kv_write =
let open Val_type in
Function.create "kv_write" ~params:[ I64; I64 ] ~results:[] ~user_data:()
Function.create "kv_write" ~params:[ ptr; ptr ] ~results:[] ~user_data:()
@@ fun plugin () ->
let key = Host_function.input_string ~index:0 plugin in
let value = Host_function.input_string ~index:1 plugin in
Expand Down
4 changes: 2 additions & 2 deletions examples/runner.ml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ let functions =
let v = Host_function.param plugin 0 in
Host_function.set_result plugin 0 v
in
let params = [ Val_type.I64 ] in
let results = [ Val_type.I64 ] in
let params = [ Val_type.ptr ] in
let results = [ Val_type.ptr ] in
[
Function.create "hello_world" ~user_data:() ~params ~results id;
Function.create "transform_string" ~user_data:() ~params ~results id;
Expand Down
3 changes: 3 additions & 0 deletions src/extism.mli
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ module Val_type : sig
| FuncRef
| ExternRef (** Value type *)

val ptr : t
(** An alias for [I64] to signify an Extism pointer value *)

val of_int : int -> t
(** Convert from [int] to {!t},
@raise Invalid_argument if the integer isn't valid *)
Expand Down
2 changes: 2 additions & 0 deletions src/val_type.ml
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
include Bindings.Extism_val_type

let ptr = I64
Loading