can we compile the std library with special features
This commit is contained in:
@@ -409,6 +409,27 @@ impl Instance {
|
||||
debug!("spawning thread: {}", name_to_move);
|
||||
let my_thread_id = my_thread_id_no_mutex_guard;
|
||||
|
||||
|
||||
#[cfg(feature = "wasm-target")]
|
||||
unsafe {
|
||||
// console_log macro
|
||||
use wasm_bindgen::prelude::*;
|
||||
#[wasm_bindgen]
|
||||
extern "C" {
|
||||
#[wasm_bindgen(js_namespace = console)]
|
||||
fn log(s: &str);
|
||||
}
|
||||
macro_rules! console_log {
|
||||
// Note that this is using the `log` function imported above during
|
||||
// `bare_bones`
|
||||
($($t:tt)*) => (log(&format_args!($($t)*).to_string()))
|
||||
}
|
||||
//end of console_log macro
|
||||
console_log!("in other threadddddddddddddd");
|
||||
}
|
||||
|
||||
|
||||
|
||||
func()?;
|
||||
|
||||
let mut threads_inner = thread_mutex.lock()?;
|
||||
|
||||
@@ -49,6 +49,23 @@ pub fn updater_thread(operation_rx : Receiver<Operation>, instance: &Instance) -
|
||||
}
|
||||
|
||||
pub fn handle_operation(operation: &mut Operation, instance: &Instance) -> MizeResult<()> {
|
||||
#[cfg(feature = "wasm-target")]
|
||||
unsafe {
|
||||
// console_log macro
|
||||
use wasm_bindgen::prelude::*;
|
||||
#[wasm_bindgen]
|
||||
extern "C" {
|
||||
#[wasm_bindgen(js_namespace = console)]
|
||||
fn log(s: &str);
|
||||
}
|
||||
macro_rules! console_log {
|
||||
// Note that this is using the `log` function imported above during
|
||||
// `bare_bones`
|
||||
($($t:tt)*) => (log(&format_args!($($t)*).to_string()))
|
||||
}
|
||||
//end of console_log macro
|
||||
console_log!("handle operation....");
|
||||
}
|
||||
match operation {
|
||||
Operation::Set(id, value, maybe_conn) => {
|
||||
let item_data: ItemData = value.to_owned();
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
use wasm_bindgen::prelude::*;
|
||||
use std::ptr::NonNull;
|
||||
use std::panic;
|
||||
use web_sys::js_sys;
|
||||
@@ -10,9 +9,11 @@ use crate::instance::{self, Instance};
|
||||
use crate::error::MizeResult;
|
||||
use crate::{mize_err, Module};
|
||||
use crate::MizeError;
|
||||
use crate::core::item::IntoItemData;
|
||||
|
||||
|
||||
// console_log macro
|
||||
use wasm_bindgen::prelude::*;
|
||||
#[wasm_bindgen]
|
||||
extern "C" {
|
||||
#[wasm_bindgen(js_namespace = console)]
|
||||
@@ -131,6 +132,12 @@ impl JsInstance {
|
||||
return js_instance;
|
||||
}
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub unsafe fn test(&mut self) -> () {
|
||||
console_log!("hiiiiiiiiiiiiiiii from test");
|
||||
self.inner.as_mut().set("0/config/hello", "hello world".into_item_data());
|
||||
}
|
||||
|
||||
//#[wasm_bindgen]
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user