-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
216 additions
and
226 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
type rec_14 = variant {Leaf; Branch:rec_14}; | ||
service: (rec_14) -> { | ||
type rec_0 = variant {Leaf; Branch:rec_0}; | ||
service: (rec_0) -> { | ||
countBranches: () -> (nat) query; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,16 @@ | ||
use std::convert::TryInto; | ||
use wasmedge_quickjs::{Context, JsFn, JsValue}; | ||
|
||
use quickjs_wasm_rs::{to_qjs_value, CallbackArg, JSContextRef, JSValue, JSValueRef}; | ||
pub struct NativeFunction; | ||
impl JsFn for NativeFunction { | ||
fn call(context: &mut Context, this_val: JsValue, argv: &[JsValue]) -> JsValue { | ||
let new_pages_string = if let JsValue::String(js_string) = argv.get(0).unwrap() { | ||
js_string.to_string() | ||
} else { | ||
panic!("conversion from JsValue to JsString failed") | ||
}; | ||
|
||
pub fn native_function<'a>( | ||
context: &'a JSContextRef, | ||
_this: &CallbackArg, | ||
args: &[CallbackArg], | ||
) -> Result<JSValueRef<'a>, anyhow::Error> { | ||
let new_pages_string: String = args | ||
.get(0) | ||
.expect("stable64Grow must have one argument") | ||
.to_js_value()? | ||
.try_into()?; | ||
|
||
let return_js_value: JSValue = ic_cdk::api::stable::stable64_grow(new_pages_string.parse()?)? | ||
.to_string() | ||
.into(); | ||
|
||
to_qjs_value(&context, &return_js_value) | ||
ic_cdk::api::stable::stable64_grow(new_pages_string.parse().unwrap()) | ||
.unwrap() | ||
.into() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,24 @@ | ||
use std::convert::TryInto; | ||
use wasmedge_quickjs::{Context, JsFn, JsValue}; | ||
|
||
use quickjs_wasm_rs::{to_qjs_value, CallbackArg, JSContextRef, JSValueRef}; | ||
pub struct NativeFunction; | ||
impl JsFn for NativeFunction { | ||
fn call(context: &mut Context, this_val: JsValue, argv: &[JsValue]) -> JsValue { | ||
let offset_string = if let JsValue::String(js_string) = argv.get(0).unwrap() { | ||
js_string.to_string() | ||
} else { | ||
panic!("conversion from JsValue to JsString failed") | ||
}; | ||
|
||
pub fn native_function<'a>( | ||
context: &'a JSContextRef, | ||
_this: &CallbackArg, | ||
args: &[CallbackArg], | ||
) -> Result<JSValueRef<'a>, anyhow::Error> { | ||
let offset_string: String = args | ||
.get(0) | ||
.expect("stable64Read must have two arguments") | ||
.to_js_value()? | ||
.try_into()?; | ||
let length_string = if let JsValue::String(js_string) = argv.get(1).unwrap() { | ||
js_string.to_string() | ||
} else { | ||
panic!("conversion from JsValue to JsString failed") | ||
}; | ||
|
||
let length_string: String = args | ||
.get(1) | ||
.expect("stable64Read must have two arguments") | ||
.to_js_value()? | ||
.try_into()?; | ||
let mut buf: Vec<u8> = vec![0; length_string.parse().unwrap()]; | ||
|
||
let mut buf: Vec<u8> = vec![0; length_string.parse()?]; | ||
ic_cdk::api::stable::stable64_read(offset_string.parse()?, &mut buf); | ||
to_qjs_value(&context, &buf.into()) | ||
ic_cdk::api::stable::stable64_read(offset_string.parse().unwrap(), &mut buf); | ||
|
||
context.new_array_buffer(&buf).into() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,8 @@ | ||
use quickjs_wasm_rs::{to_qjs_value, CallbackArg, JSContextRef, JSValue, JSValueRef}; | ||
use wasmedge_quickjs::{Context, JsFn, JsValue}; | ||
|
||
pub fn native_function<'a>( | ||
context: &'a JSContextRef, | ||
_this: &CallbackArg, | ||
_args: &[CallbackArg], | ||
) -> Result<JSValueRef<'a>, anyhow::Error> { | ||
let return_js_value: JSValue = ic_cdk::api::stable::stable64_size().to_string().into(); | ||
to_qjs_value(&context, &return_js_value) | ||
pub struct NativeFunction; | ||
impl JsFn for NativeFunction { | ||
fn call(context: &mut Context, this_val: JsValue, argv: &[JsValue]) -> JsValue { | ||
ic_cdk::api::stable::stable64_size().into() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,24 @@ | ||
use std::convert::TryInto; | ||
|
||
use quickjs_wasm_rs::{CallbackArg, JSContextRef, JSValueRef}; | ||
use wasmedge_quickjs::{Context, JsFn, JsValue}; | ||
|
||
pub fn native_function<'a>( | ||
context: &'a JSContextRef, | ||
_this: &CallbackArg, | ||
args: &[CallbackArg], | ||
) -> Result<JSValueRef<'a>, anyhow::Error> { | ||
let offset_string: String = args | ||
.get(0) | ||
.expect("stable64Write must have two arguments") | ||
.to_js_value()? | ||
.try_into()?; | ||
pub struct NativeFunction; | ||
impl JsFn for NativeFunction { | ||
fn call(context: &mut Context, this_val: JsValue, argv: &[JsValue]) -> JsValue { | ||
let offset_string = if let JsValue::String(js_string) = argv.get(0).unwrap() { | ||
js_string.to_string() | ||
} else { | ||
panic!("conversion from JsValue to JsString failed") | ||
}; | ||
|
||
let buf: Vec<u8> = args | ||
.get(1) | ||
.expect("stable64Write must have two arguments") | ||
.to_js_value()? | ||
.try_into()?; | ||
let buf = if let JsValue::ArrayBuffer(js_array_buffer) = argv.get(1).unwrap() { | ||
js_array_buffer.to_vec() | ||
} else { | ||
panic!("conversion from JsValue to JsArrayBuffer failed") | ||
}; | ||
|
||
ic_cdk::api::stable::stable64_write(offset_string.parse()?, &buf); | ||
ic_cdk::api::stable::stable64_write(offset_string.parse().unwrap(), &buf); | ||
|
||
context.undefined_value() | ||
JsValue::UnDefined | ||
} | ||
} |
Oops, something went wrong.