make interpreter extend the interpreter core class
This commit is contained in:
1 parent
f196514b4f
commit
8a969a26dc
4 files changed
+171
-179
No files matched your search
Generated
+152
-154
File diff suppressed because it is too large.
Load diff
@@ -17,7 +17,7 @@ web-sys = { version = "0.3.56", optional = true, features = [
|
|||||||
"Element",
|
"Element",
|
||||||
"Node",
|
"Node",
|
||||||
] }
|
] }
|
||||||
sledgehammer_bindgen = { version = "0.4.0", default-features = false, optional = true }
|
sledgehammer_bindgen = { git = "https://github.com/ealmloff/sledgehammer_bindgen", default-features = false, optional = true }
|
||||||
sledgehammer_utils = { version = "0.2", optional = true }
|
sledgehammer_utils = { version = "0.2", optional = true }
|
||||||
serde = { version = "1.0", features = ["derive"], optional = true }
|
serde = { version = "1.0", features = ["derive"], optional = true }
|
||||||
|
|
||||||
|
|||||||
@@ -4,42 +4,37 @@ use js_sys::Function;
|
|||||||
#[cfg(feature = "webonly")]
|
#[cfg(feature = "webonly")]
|
||||||
use web_sys::Node;
|
use web_sys::Node;
|
||||||
|
|
||||||
|
#[cfg(feature = "webonly")]
|
||||||
|
use wasm_bindgen::prelude::wasm_bindgen;
|
||||||
|
|
||||||
use sledgehammer_bindgen::bindgen;
|
use sledgehammer_bindgen::bindgen;
|
||||||
|
|
||||||
pub const SLEDGEHAMMER_JS: &str = GENERATED_JS;
|
pub const SLEDGEHAMMER_JS: &str = GENERATED_JS;
|
||||||
|
|
||||||
#[cfg(feature = "webonly")]
|
#[cfg(feature = "webonly")]
|
||||||
#[wasm_bindgen::prelude::wasm_bindgen(inline_js = r#"
|
#[wasm_bindgen(module = "src/js/web.js")]
|
||||||
export function save_template(channel, nodes, tmpl_id) {
|
|
||||||
channel.save_template(nodes, tmpl_id);
|
|
||||||
}
|
|
||||||
export function hydrate(channel, ids) {
|
|
||||||
channel.hydrate(ids);
|
|
||||||
}
|
|
||||||
export function get_node(channel, id) {
|
|
||||||
return channel.get_node(id);
|
|
||||||
}
|
|
||||||
export function initialize(channel, root, handler) {
|
|
||||||
channel.initialize(root, handler);
|
|
||||||
}
|
|
||||||
"#)]
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn save_template(channel: &JSChannel, nodes: Vec<Node>, tmpl_id: u16);
|
#[wasm_bindgen]
|
||||||
|
pub type Interpreter;
|
||||||
|
|
||||||
pub fn hydrate(channel: &JSChannel, ids: Vec<u32>);
|
#[wasm_bindgen(method)]
|
||||||
|
pub fn save_template(this: &Interpreter, nodes: Vec<Node>, tmpl_id: u16);
|
||||||
|
|
||||||
pub fn get_node(channel: &JSChannel, id: u32) -> Node;
|
#[wasm_bindgen(method)]
|
||||||
|
pub fn hydrate(this: &Interpreter, ids: Vec<u32>);
|
||||||
|
|
||||||
pub fn initialize(channel: &JSChannel, root: Node, handler: &Function);
|
#[wasm_bindgen(method)]
|
||||||
|
pub fn get_node(this: &Interpreter, id: u32) -> Node;
|
||||||
|
|
||||||
|
#[wasm_bindgen(method)]
|
||||||
|
pub fn initialize(this: &Interpreter, root: Node, handler: &Function);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[bindgen(module)]
|
#[bindgen(module)]
|
||||||
mod js {
|
mod js {
|
||||||
// Load in the JavaScript file with all the imports
|
/// The interpreter extends the core interpreter which contains the state for the interpreter along with some functions that all platforms use like `AppendChildren`.
|
||||||
const JS_FILE: &str = "./src/gen/interpreter.js";
|
#[extends(Interpreter)]
|
||||||
|
pub struct InterpreterInterface;
|
||||||
// Boot the interpreter and attach us some bindings!
|
|
||||||
const JS: &str = r#""#;
|
|
||||||
|
|
||||||
fn mount_to_root() {
|
fn mount_to_root() {
|
||||||
"{this.AppendChildren(this.root, this.stack.length-1);}"
|
"{this.AppendChildren(this.root, this.stack.length-1);}"
|
||||||
|
|||||||
@@ -43,7 +43,6 @@ mod hot_reload;
|
|||||||
#[cfg(feature = "hydrate")]
|
#[cfg(feature = "hydrate")]
|
||||||
mod rehydrate;
|
mod rehydrate;
|
||||||
|
|
||||||
|
|
||||||
/// Runs the app as a future that can be scheduled around the main thread.
|
/// Runs the app as a future that can be scheduled around the main thread.
|
||||||
///
|
///
|
||||||
/// Polls futures internal to the VirtualDOM, hence the async nature of this function.
|
/// Polls futures internal to the VirtualDOM, hence the async nature of this function.
|
||||||
|
|||||||
Reference in new issue
Block a user