feat: patch js-wasm
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
[package]
|
||||
name = "web_console"
|
||||
version = "0.3.7"
|
||||
authors = ["Richard Anaya"]
|
||||
edition = "2018"
|
||||
license = "MIT OR Apache-2.0"
|
||||
description = "Web functions for console"
|
||||
repository = "https://github.com/richardanaya/js-wasm"
|
||||
readme = "README.md"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
js = {path="../js",version="0"}
|
||||
@@ -0,0 +1,20 @@
|
||||
# web_console
|
||||
|
||||
<a href="https://docs.rs/web_console"><img src="https://img.shields.io/badge/docs-latest-blue.svg?style=flat-square" alt="docs.rs docs" /></a>
|
||||
|
||||
# License
|
||||
|
||||
This project is licensed under either of
|
||||
|
||||
* Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
|
||||
http://www.apache.org/licenses/LICENSE-2.0)
|
||||
* MIT license ([LICENSE-MIT](LICENSE-MIT) or
|
||||
http://opensource.org/licenses/MIT)
|
||||
|
||||
at your option.
|
||||
|
||||
### Contribution
|
||||
|
||||
Unless you explicitly state otherwise, any contribution intentionally submitted
|
||||
for inclusion in 'web_console' by you, as defined in the Apache-2.0 license, shall be
|
||||
dual licensed as above, without any additional terms or conditions.
|
||||
@@ -0,0 +1,55 @@
|
||||
#![no_std]
|
||||
|
||||
use js::*;
|
||||
|
||||
pub fn console_clear() {
|
||||
let func = js!(r###"function(){
|
||||
console.clear();
|
||||
}"###);
|
||||
func.invoke_0();
|
||||
}
|
||||
|
||||
pub fn console_log(msg: &str) {
|
||||
let a0 = msg.as_ptr() as u32;
|
||||
let a1 = msg.len() as u32;
|
||||
let func = js!(r###"function(msgPtr,msgLen){
|
||||
console.log(this.readUtf8FromMemory(msgPtr,msgLen));
|
||||
}"###);
|
||||
func.invoke_2(a0, a1);
|
||||
}
|
||||
|
||||
pub fn console_warning(msg: &str) {
|
||||
let a0 = msg.as_ptr() as u32;
|
||||
let a1 = msg.len() as u32;
|
||||
let func = js!(r###"function(msgPtr,msgLen){
|
||||
console.warn(this.readUtf8FromMemory(msgPtr,msgLen));
|
||||
}"###);
|
||||
func.invoke_2(a0, a1);
|
||||
}
|
||||
|
||||
pub fn console_error(msg: &str) {
|
||||
let a0 = msg.as_ptr() as u32;
|
||||
let a1 = msg.len() as u32;
|
||||
let func = js!(r###"function(msgPtr,msgLen){
|
||||
console.error(this.readUtf8FromMemory(msgPtr,msgLen));
|
||||
}"###);
|
||||
func.invoke_2(a0, a1);
|
||||
}
|
||||
|
||||
pub fn console_time(msg: &str) {
|
||||
let a0 = msg.as_ptr() as u32;
|
||||
let a1 = msg.len() as u32;
|
||||
let func = js!(r###"function(msgPtr,msgLen){
|
||||
console.time(this.readUtf8FromMemory(msgPtr,msgLen));
|
||||
}"###);
|
||||
func.invoke_2(a0, a1);
|
||||
}
|
||||
|
||||
pub fn console_time_end(msg: &str) {
|
||||
let a0 = msg.as_ptr() as u32;
|
||||
let a1 = msg.len() as u32;
|
||||
let func = js!(r###"function(msgPtr,msgLen){
|
||||
console.timeEnd(this.readUtf8FromMemory(msgPtr,msgLen));
|
||||
}"###);
|
||||
func.invoke_2(a0, a1);
|
||||
}
|
||||
Reference in New Issue
Block a user