diagram plugins
This commit is contained in:
parent
1cdb558823
commit
e8a0051ea7
29 changed files with 1781 additions and 267 deletions
1
test_files/.gitignore
vendored
Normal file
1
test_files/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
sv39_mmu_cache_sim/
|
431
test_files/cache_diagram.excalidraw
Normal file
431
test_files/cache_diagram.excalidraw
Normal file
|
@ -0,0 +1,431 @@
|
|||
{
|
||||
"type": "excalidraw",
|
||||
"version": 2,
|
||||
"source": "http://localhost:8080",
|
||||
"elements": [
|
||||
{
|
||||
"type": "text",
|
||||
"version": 174,
|
||||
"versionNonce": 1552336377,
|
||||
"isDeleted": false,
|
||||
"id": "xPhIioz8O3Vjc7QcLfYes",
|
||||
"fillStyle": "solid",
|
||||
"strokeWidth": 2,
|
||||
"strokeStyle": "solid",
|
||||
"roughness": 0,
|
||||
"opacity": 100,
|
||||
"angle": 0,
|
||||
"x": 60,
|
||||
"y": 120,
|
||||
"strokeColor": "#1e1e1e",
|
||||
"backgroundColor": "transparent",
|
||||
"width": 1153.125,
|
||||
"height": 57.599999999999994,
|
||||
"seed": 1317703821,
|
||||
"groupIds": [],
|
||||
"frameId": null,
|
||||
"roundness": null,
|
||||
"boundElements": [],
|
||||
"updated": 1732565113996,
|
||||
"link": null,
|
||||
"locked": false,
|
||||
"fontSize": 16,
|
||||
"fontFamily": 3,
|
||||
"text": "1. Extract 'test_files/sv39_mmu_cache_sim.zip' to 'test_files/sv39_mmu_cache_sim'\n2. Load file 'test_files/sv39_mmu_cache_sim/fst/wave.fst'\n3. Run command 'FW.add_diagram_connectors([\"../test_files/components/rust_diagram_connector/rust_diagram_connector.wasm\"])'",
|
||||
"textAlign": "left",
|
||||
"verticalAlign": "top",
|
||||
"containerId": null,
|
||||
"originalText": "1. Extract 'test_files/sv39_mmu_cache_sim.zip' to 'test_files/sv39_mmu_cache_sim'\n2. Load file 'test_files/sv39_mmu_cache_sim/fst/wave.fst'\n3. Run command 'FW.add_diagram_connectors([\"../test_files/components/rust_diagram_connector/rust_diagram_connector.wasm\"])'",
|
||||
"lineHeight": 1.2,
|
||||
"baseline": 54
|
||||
},
|
||||
{
|
||||
"type": "rectangle",
|
||||
"version": 133,
|
||||
"versionNonce": 631769070,
|
||||
"isDeleted": false,
|
||||
"id": "WORIbkpEkf5c85sK8DhU-",
|
||||
"fillStyle": "solid",
|
||||
"strokeWidth": 4,
|
||||
"strokeStyle": "solid",
|
||||
"roughness": 0,
|
||||
"opacity": 100,
|
||||
"angle": 0,
|
||||
"x": 460,
|
||||
"y": 220,
|
||||
"strokeColor": "#1e1e1e",
|
||||
"backgroundColor": "#a5d8ff",
|
||||
"width": 300,
|
||||
"height": 440.00000000000006,
|
||||
"seed": 1957721512,
|
||||
"groupIds": [],
|
||||
"frameId": null,
|
||||
"roundness": {
|
||||
"type": 3
|
||||
},
|
||||
"boundElements": [],
|
||||
"updated": 1732565668461,
|
||||
"link": null,
|
||||
"locked": false
|
||||
},
|
||||
{
|
||||
"type": "text",
|
||||
"version": 90,
|
||||
"versionNonce": 1920851711,
|
||||
"isDeleted": false,
|
||||
"id": "mBGA6gGm1aDhGnBNB8gPz",
|
||||
"fillStyle": "solid",
|
||||
"strokeWidth": 2,
|
||||
"strokeStyle": "solid",
|
||||
"roughness": 0,
|
||||
"opacity": 100,
|
||||
"angle": 0,
|
||||
"x": 541.5560073852539,
|
||||
"y": 260,
|
||||
"strokeColor": "#1e1e1e",
|
||||
"backgroundColor": "transparent",
|
||||
"width": 144.50794982910156,
|
||||
"height": 35,
|
||||
"seed": 1040757672,
|
||||
"groupIds": [],
|
||||
"frameId": null,
|
||||
"roundness": null,
|
||||
"boundElements": [],
|
||||
"updated": 1732566083274,
|
||||
"link": null,
|
||||
"locked": false,
|
||||
"fontSize": 28,
|
||||
"fontFamily": 1,
|
||||
"text": "SV39 MMU",
|
||||
"textAlign": "center",
|
||||
"verticalAlign": "top",
|
||||
"containerId": null,
|
||||
"originalText": "SV39 MMU",
|
||||
"lineHeight": 1.25,
|
||||
"baseline": 24
|
||||
},
|
||||
{
|
||||
"type": "text",
|
||||
"version": 153,
|
||||
"versionNonce": 302406585,
|
||||
"isDeleted": false,
|
||||
"id": "8eNVs3Eiiy6Ns1KqVK-zj",
|
||||
"fillStyle": "solid",
|
||||
"strokeWidth": 2,
|
||||
"strokeStyle": "solid",
|
||||
"roughness": 0,
|
||||
"opacity": 100,
|
||||
"angle": 0,
|
||||
"x": 480,
|
||||
"y": 440,
|
||||
"strokeColor": "#1e1e1e",
|
||||
"backgroundColor": "transparent",
|
||||
"width": 73.369140625,
|
||||
"height": 23,
|
||||
"seed": 1170025128,
|
||||
"groupIds": [],
|
||||
"frameId": null,
|
||||
"roundness": null,
|
||||
"boundElements": [],
|
||||
"updated": 1732565113996,
|
||||
"link": null,
|
||||
"locked": false,
|
||||
"fontSize": 20,
|
||||
"fontFamily": 2,
|
||||
"text": "Address",
|
||||
"textAlign": "left",
|
||||
"verticalAlign": "top",
|
||||
"containerId": null,
|
||||
"originalText": "Address",
|
||||
"lineHeight": 1.15,
|
||||
"baseline": 18
|
||||
},
|
||||
{
|
||||
"type": "rectangle",
|
||||
"version": 116,
|
||||
"versionNonce": 57845422,
|
||||
"isDeleted": false,
|
||||
"id": "IhK6hwJEwdKZ9bG8aTkN7",
|
||||
"fillStyle": "solid",
|
||||
"strokeWidth": 2,
|
||||
"strokeStyle": "solid",
|
||||
"roughness": 0,
|
||||
"opacity": 100,
|
||||
"angle": 0,
|
||||
"x": 480,
|
||||
"y": 473.5732012743411,
|
||||
"strokeColor": "#1e1e1e",
|
||||
"backgroundColor": "transparent",
|
||||
"width": 260,
|
||||
"height": 40,
|
||||
"seed": 590079912,
|
||||
"groupIds": [],
|
||||
"frameId": null,
|
||||
"roundness": {
|
||||
"type": 3
|
||||
},
|
||||
"boundElements": [
|
||||
{
|
||||
"type": "text",
|
||||
"id": "ITxhJ7NtZ74YFd9JQ0_pl"
|
||||
}
|
||||
],
|
||||
"updated": 1732565668739,
|
||||
"link": null,
|
||||
"locked": false
|
||||
},
|
||||
{
|
||||
"type": "text",
|
||||
"version": 37,
|
||||
"versionNonce": 761868063,
|
||||
"isDeleted": false,
|
||||
"id": "ITxhJ7NtZ74YFd9JQ0_pl",
|
||||
"fillStyle": "solid",
|
||||
"strokeWidth": 2,
|
||||
"strokeStyle": "solid",
|
||||
"roughness": 0,
|
||||
"opacity": 100,
|
||||
"angle": 0,
|
||||
"x": 486.953125,
|
||||
"y": 481.5732012743411,
|
||||
"strokeColor": "#1e1e1e",
|
||||
"backgroundColor": "transparent",
|
||||
"width": 246.09375,
|
||||
"height": 24,
|
||||
"seed": 684450162,
|
||||
"groupIds": [],
|
||||
"frameId": null,
|
||||
"roundness": null,
|
||||
"boundElements": [],
|
||||
"updated": 1732566156524,
|
||||
"link": null,
|
||||
"locked": false,
|
||||
"fontSize": 20,
|
||||
"fontFamily": 3,
|
||||
"text": " UNKNOWN ",
|
||||
"textAlign": "center",
|
||||
"verticalAlign": "middle",
|
||||
"containerId": "IhK6hwJEwdKZ9bG8aTkN7",
|
||||
"originalText": " UNKNOWN ",
|
||||
"lineHeight": 1.2,
|
||||
"baseline": 19
|
||||
},
|
||||
{
|
||||
"type": "text",
|
||||
"version": 301,
|
||||
"versionNonce": 873757849,
|
||||
"isDeleted": false,
|
||||
"id": "Lcp_kf4ZNFv0MtP5S6q91",
|
||||
"fillStyle": "solid",
|
||||
"strokeWidth": 2,
|
||||
"strokeStyle": "solid",
|
||||
"roughness": 0,
|
||||
"opacity": 100,
|
||||
"angle": 0,
|
||||
"x": 480,
|
||||
"y": 554.9486030561815,
|
||||
"strokeColor": "#1e1e1e",
|
||||
"backgroundColor": "transparent",
|
||||
"width": 56.69921875,
|
||||
"height": 23,
|
||||
"seed": 1685601960,
|
||||
"groupIds": [],
|
||||
"frameId": null,
|
||||
"roundness": null,
|
||||
"boundElements": [],
|
||||
"updated": 1732565113996,
|
||||
"link": null,
|
||||
"locked": false,
|
||||
"fontSize": 20,
|
||||
"fontFamily": 2,
|
||||
"text": "Status",
|
||||
"textAlign": "left",
|
||||
"verticalAlign": "top",
|
||||
"containerId": null,
|
||||
"originalText": "Status",
|
||||
"lineHeight": 1.15,
|
||||
"baseline": 18
|
||||
},
|
||||
{
|
||||
"type": "text",
|
||||
"version": 148,
|
||||
"versionNonce": 586282359,
|
||||
"isDeleted": false,
|
||||
"id": "cHL582ZJrMvSgzJTCSVQg",
|
||||
"fillStyle": "solid",
|
||||
"strokeWidth": 2,
|
||||
"strokeStyle": "solid",
|
||||
"roughness": 0,
|
||||
"opacity": 100,
|
||||
"angle": 0,
|
||||
"x": 480,
|
||||
"y": 320,
|
||||
"strokeColor": "#1e1e1e",
|
||||
"backgroundColor": "transparent",
|
||||
"width": 83.701171875,
|
||||
"height": 23,
|
||||
"seed": 1428509096,
|
||||
"groupIds": [],
|
||||
"frameId": null,
|
||||
"roundness": null,
|
||||
"boundElements": [],
|
||||
"updated": 1732565113996,
|
||||
"link": null,
|
||||
"locked": false,
|
||||
"fontSize": 20,
|
||||
"fontFamily": 2,
|
||||
"text": "Time (ps)",
|
||||
"textAlign": "left",
|
||||
"verticalAlign": "top",
|
||||
"containerId": null,
|
||||
"originalText": "Time (ps)",
|
||||
"lineHeight": 1.15,
|
||||
"baseline": 18
|
||||
},
|
||||
{
|
||||
"type": "rectangle",
|
||||
"version": 160,
|
||||
"versionNonce": 896237945,
|
||||
"isDeleted": false,
|
||||
"id": "KsSzJicTZlMzyYamex99O",
|
||||
"fillStyle": "solid",
|
||||
"strokeWidth": 2,
|
||||
"strokeStyle": "solid",
|
||||
"roughness": 0,
|
||||
"opacity": 100,
|
||||
"angle": 0,
|
||||
"x": 480,
|
||||
"y": 352,
|
||||
"strokeColor": "#1e1e1e",
|
||||
"backgroundColor": "#ffffff",
|
||||
"width": 260,
|
||||
"height": 40,
|
||||
"seed": 825642664,
|
||||
"groupIds": [],
|
||||
"frameId": null,
|
||||
"roundness": {
|
||||
"type": 3
|
||||
},
|
||||
"boundElements": [
|
||||
{
|
||||
"type": "text",
|
||||
"id": "afXu8_6Kqfq-q2IsjtAcP"
|
||||
}
|
||||
],
|
||||
"updated": 1732565113996,
|
||||
"link": null,
|
||||
"locked": false
|
||||
},
|
||||
{
|
||||
"type": "text",
|
||||
"version": 170,
|
||||
"versionNonce": 1243754135,
|
||||
"isDeleted": false,
|
||||
"id": "afXu8_6Kqfq-q2IsjtAcP",
|
||||
"fillStyle": "solid",
|
||||
"strokeWidth": 2,
|
||||
"strokeStyle": "solid",
|
||||
"roughness": 0,
|
||||
"opacity": 100,
|
||||
"angle": 0,
|
||||
"x": 485,
|
||||
"y": 360,
|
||||
"strokeColor": "#1e1e1e",
|
||||
"backgroundColor": "transparent",
|
||||
"width": 46.875,
|
||||
"height": 24,
|
||||
"seed": 902183336,
|
||||
"groupIds": [],
|
||||
"frameId": null,
|
||||
"roundness": null,
|
||||
"boundElements": [],
|
||||
"updated": 1732565113996,
|
||||
"link": null,
|
||||
"locked": false,
|
||||
"fontSize": 20,
|
||||
"fontFamily": 3,
|
||||
"text": "3125",
|
||||
"textAlign": "left",
|
||||
"verticalAlign": "middle",
|
||||
"containerId": "KsSzJicTZlMzyYamex99O",
|
||||
"originalText": "3125",
|
||||
"lineHeight": 1.2,
|
||||
"baseline": 20
|
||||
},
|
||||
{
|
||||
"type": "rectangle",
|
||||
"version": 42,
|
||||
"versionNonce": 55503449,
|
||||
"isDeleted": false,
|
||||
"id": "4l74x5uAeTeBuxx_8t_QY",
|
||||
"fillStyle": "solid",
|
||||
"strokeWidth": 2,
|
||||
"strokeStyle": "solid",
|
||||
"roughness": 0,
|
||||
"opacity": 100,
|
||||
"angle": 0,
|
||||
"x": 480,
|
||||
"y": 584.4962525171356,
|
||||
"strokeColor": "#1e1e1e",
|
||||
"backgroundColor": "transparent",
|
||||
"width": 260,
|
||||
"height": 40,
|
||||
"seed": 595254712,
|
||||
"groupIds": [],
|
||||
"frameId": null,
|
||||
"roundness": {
|
||||
"type": 3
|
||||
},
|
||||
"boundElements": [
|
||||
{
|
||||
"type": "text",
|
||||
"id": "0iH5yRbH4IEseV3mnof3A"
|
||||
}
|
||||
],
|
||||
"updated": 1732565113996,
|
||||
"link": null,
|
||||
"locked": false
|
||||
},
|
||||
{
|
||||
"type": "text",
|
||||
"version": 321,
|
||||
"versionNonce": 940641777,
|
||||
"isDeleted": false,
|
||||
"id": "0iH5yRbH4IEseV3mnof3A",
|
||||
"fillStyle": "solid",
|
||||
"strokeWidth": 2,
|
||||
"strokeStyle": "solid",
|
||||
"roughness": 0,
|
||||
"opacity": 100,
|
||||
"angle": 0,
|
||||
"x": 486.953125,
|
||||
"y": 592.4962525171356,
|
||||
"strokeColor": "#1e1e1e",
|
||||
"backgroundColor": "transparent",
|
||||
"width": 246.09375,
|
||||
"height": 24,
|
||||
"seed": 2011882973,
|
||||
"groupIds": [],
|
||||
"frameId": null,
|
||||
"roundness": null,
|
||||
"boundElements": [],
|
||||
"updated": 1732566143666,
|
||||
"link": null,
|
||||
"locked": false,
|
||||
"fontSize": 20,
|
||||
"fontFamily": 3,
|
||||
"text": " UNKNOWN ",
|
||||
"textAlign": "center",
|
||||
"verticalAlign": "middle",
|
||||
"containerId": "4l74x5uAeTeBuxx_8t_QY",
|
||||
"originalText": " UNKNOWN ",
|
||||
"lineHeight": 1.2,
|
||||
"baseline": 19
|
||||
}
|
||||
],
|
||||
"appState": {
|
||||
"gridSize": 20,
|
||||
"viewBackgroundColor": "#f5faff"
|
||||
},
|
||||
"files": {}
|
||||
}
|
10
test_files/components/rust_diagram_connector/.vscode/settings.json
vendored
Normal file
10
test_files/components/rust_diagram_connector/.vscode/settings.json
vendored
Normal file
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"rust-analyzer.check.overrideCommand": [
|
||||
"cargo",
|
||||
"component",
|
||||
"check",
|
||||
"--workspace",
|
||||
"--all-targets",
|
||||
"--message-format=json"
|
||||
],
|
||||
}
|
26
test_files/components/rust_diagram_connector/Cargo.toml
Normal file
26
test_files/components/rust_diagram_connector/Cargo.toml
Normal file
|
@ -0,0 +1,26 @@
|
|||
[package]
|
||||
name = "rust_diagram_connector"
|
||||
version.workspace = true
|
||||
edition.workspace = true
|
||||
repository.workspace = true
|
||||
authors.workspace = true
|
||||
readme.workspace = true
|
||||
publish.workspace = true
|
||||
|
||||
[dependencies]
|
||||
wit-bindgen-rt = { version = "0.26.0", features = ["bitflags"] }
|
||||
|
||||
[lib]
|
||||
crate-type = ["cdylib"]
|
||||
|
||||
[profile.release]
|
||||
codegen-units = 1
|
||||
opt-level = "s"
|
||||
debug = false
|
||||
strip = true
|
||||
lto = true
|
||||
|
||||
[package.metadata.component]
|
||||
package = "component:rust-diagram-connector"
|
||||
|
||||
[package.metadata.component.dependencies]
|
7
test_files/components/rust_diagram_connector/README.md
Normal file
7
test_files/components/rust_diagram_connector/README.md
Normal file
|
@ -0,0 +1,7 @@
|
|||
How to create and build the Rust component:
|
||||
|
||||
1. `cargo install cargo-component`
|
||||
2. `cargo component new rust_diagram_connector --lib`
|
||||
3. `cd rust_diagram_connector`
|
||||
4. Update code as needed
|
||||
5. `cargo component build --release --target wasm32-unknown-unknown && cp ../../../target/wasm32-unknown-unknown/release/rust_diagram_connector.wasm .`
|
Binary file not shown.
329
test_files/components/rust_diagram_connector/src/bindings.rs
Normal file
329
test_files/components/rust_diagram_connector/src/bindings.rs
Normal file
|
@ -0,0 +1,329 @@
|
|||
// Generated by `wit-bindgen` 0.25.0. DO NOT EDIT!
|
||||
// Options used:
|
||||
#[allow(dead_code)]
|
||||
pub mod component {
|
||||
#[allow(dead_code)]
|
||||
pub mod diagram_connector {
|
||||
#[allow(dead_code, clippy::all)]
|
||||
pub mod host {
|
||||
#[used]
|
||||
#[doc(hidden)]
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
static __FORCE_SECTION_REF: fn() =
|
||||
super::super::super::__link_custom_section_describing_imports;
|
||||
use super::super::super::_rt;
|
||||
#[allow(unused_unsafe, clippy::all)]
|
||||
pub fn log(message: &str) {
|
||||
unsafe {
|
||||
let vec0 = message;
|
||||
let ptr0 = vec0.as_ptr().cast::<u8>();
|
||||
let len0 = vec0.len();
|
||||
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
#[link(wasm_import_module = "component:diagram-connector/host")]
|
||||
extern "C" {
|
||||
#[link_name = "log"]
|
||||
fn wit_import(_: *mut u8, _: usize);
|
||||
}
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
fn wit_import(_: *mut u8, _: usize) {
|
||||
unreachable!()
|
||||
}
|
||||
wit_import(ptr0.cast_mut(), len0);
|
||||
}
|
||||
}
|
||||
#[allow(unused_unsafe, clippy::all)]
|
||||
pub fn listen_for_component_text_changes(
|
||||
diagram_connect_name: &str,
|
||||
component_id: &str,
|
||||
) {
|
||||
unsafe {
|
||||
let vec0 = diagram_connect_name;
|
||||
let ptr0 = vec0.as_ptr().cast::<u8>();
|
||||
let len0 = vec0.len();
|
||||
let vec1 = component_id;
|
||||
let ptr1 = vec1.as_ptr().cast::<u8>();
|
||||
let len1 = vec1.len();
|
||||
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
#[link(wasm_import_module = "component:diagram-connector/host")]
|
||||
extern "C" {
|
||||
#[link_name = "listen-for-component-text-changes"]
|
||||
fn wit_import(_: *mut u8, _: usize, _: *mut u8, _: usize);
|
||||
}
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
fn wit_import(_: *mut u8, _: usize, _: *mut u8, _: usize) {
|
||||
unreachable!()
|
||||
}
|
||||
wit_import(ptr0.cast_mut(), len0, ptr1.cast_mut(), len1);
|
||||
}
|
||||
}
|
||||
#[allow(unused_unsafe, clippy::all)]
|
||||
pub fn set_component_text(component_id: &str, text: &str) {
|
||||
unsafe {
|
||||
let vec0 = component_id;
|
||||
let ptr0 = vec0.as_ptr().cast::<u8>();
|
||||
let len0 = vec0.len();
|
||||
let vec1 = text;
|
||||
let ptr1 = vec1.as_ptr().cast::<u8>();
|
||||
let len1 = vec1.len();
|
||||
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
#[link(wasm_import_module = "component:diagram-connector/host")]
|
||||
extern "C" {
|
||||
#[link_name = "set-component-text"]
|
||||
fn wit_import(_: *mut u8, _: usize, _: *mut u8, _: usize);
|
||||
}
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
fn wit_import(_: *mut u8, _: usize, _: *mut u8, _: usize) {
|
||||
unreachable!()
|
||||
}
|
||||
wit_import(ptr0.cast_mut(), len0, ptr1.cast_mut(), len1);
|
||||
}
|
||||
}
|
||||
#[allow(unused_unsafe, clippy::all)]
|
||||
pub fn address_and_way(time_text: &str) -> Result<(_rt::String, Option<u32>), ()> {
|
||||
unsafe {
|
||||
#[repr(align(4))]
|
||||
struct RetArea([::core::mem::MaybeUninit<u8>; 20]);
|
||||
let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 20]);
|
||||
let vec0 = time_text;
|
||||
let ptr0 = vec0.as_ptr().cast::<u8>();
|
||||
let len0 = vec0.len();
|
||||
let ptr1 = ret_area.0.as_mut_ptr().cast::<u8>();
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
#[link(wasm_import_module = "component:diagram-connector/host")]
|
||||
extern "C" {
|
||||
#[link_name = "address-and-way"]
|
||||
fn wit_import(_: *mut u8, _: usize, _: *mut u8);
|
||||
}
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
fn wit_import(_: *mut u8, _: usize, _: *mut u8) {
|
||||
unreachable!()
|
||||
}
|
||||
wit_import(ptr0.cast_mut(), len0, ptr1);
|
||||
let l2 = i32::from(*ptr1.add(0).cast::<u8>());
|
||||
match l2 {
|
||||
0 => {
|
||||
let e = {
|
||||
let l3 = *ptr1.add(4).cast::<*mut u8>();
|
||||
let l4 = *ptr1.add(8).cast::<usize>();
|
||||
let len5 = l4;
|
||||
let bytes5 = _rt::Vec::from_raw_parts(l3.cast(), len5, len5);
|
||||
let l6 = i32::from(*ptr1.add(12).cast::<u8>());
|
||||
|
||||
(
|
||||
_rt::string_lift(bytes5),
|
||||
match l6 {
|
||||
0 => None,
|
||||
1 => {
|
||||
let e = {
|
||||
let l7 = *ptr1.add(16).cast::<i32>();
|
||||
|
||||
l7 as u32
|
||||
};
|
||||
Some(e)
|
||||
}
|
||||
_ => _rt::invalid_enum_discriminant(),
|
||||
},
|
||||
)
|
||||
};
|
||||
Ok(e)
|
||||
}
|
||||
1 => {
|
||||
let e = ();
|
||||
Err(e)
|
||||
}
|
||||
_ => _rt::invalid_enum_discriminant(),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#[allow(dead_code)]
|
||||
pub mod exports {
|
||||
#[allow(dead_code)]
|
||||
pub mod component {
|
||||
#[allow(dead_code)]
|
||||
pub mod diagram_connector {
|
||||
#[allow(dead_code, clippy::all)]
|
||||
pub mod diagram_connector {
|
||||
#[used]
|
||||
#[doc(hidden)]
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
static __FORCE_SECTION_REF: fn() =
|
||||
super::super::super::super::__link_custom_section_describing_imports;
|
||||
use super::super::super::super::_rt;
|
||||
#[doc(hidden)]
|
||||
#[allow(non_snake_case)]
|
||||
pub unsafe fn _export_init_cabi<T: Guest>() {
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
_rt::run_ctors_once();
|
||||
T::init();
|
||||
}
|
||||
#[doc(hidden)]
|
||||
#[allow(non_snake_case)]
|
||||
pub unsafe fn _export_name_cabi<T: Guest>() -> *mut u8 {
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
_rt::run_ctors_once();
|
||||
let result0 = T::name();
|
||||
let ptr1 = _RET_AREA.0.as_mut_ptr().cast::<u8>();
|
||||
let vec2 = (result0.into_bytes()).into_boxed_slice();
|
||||
let ptr2 = vec2.as_ptr().cast::<u8>();
|
||||
let len2 = vec2.len();
|
||||
::core::mem::forget(vec2);
|
||||
*ptr1.add(4).cast::<usize>() = len2;
|
||||
*ptr1.add(0).cast::<*mut u8>() = ptr2.cast_mut();
|
||||
ptr1
|
||||
}
|
||||
#[doc(hidden)]
|
||||
#[allow(non_snake_case)]
|
||||
pub unsafe fn __post_return_name<T: Guest>(arg0: *mut u8) {
|
||||
let l0 = *arg0.add(0).cast::<*mut u8>();
|
||||
let l1 = *arg0.add(4).cast::<usize>();
|
||||
_rt::cabi_dealloc(l0, l1, 1);
|
||||
}
|
||||
#[doc(hidden)]
|
||||
#[allow(non_snake_case)]
|
||||
pub unsafe fn _export_on_component_text_changed_cabi<T: Guest>(
|
||||
arg0: *mut u8,
|
||||
arg1: usize,
|
||||
arg2: *mut u8,
|
||||
arg3: usize,
|
||||
) {
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
_rt::run_ctors_once();
|
||||
let len0 = arg1;
|
||||
let bytes0 = _rt::Vec::from_raw_parts(arg0.cast(), len0, len0);
|
||||
let len1 = arg3;
|
||||
let bytes1 = _rt::Vec::from_raw_parts(arg2.cast(), len1, len1);
|
||||
T::on_component_text_changed(
|
||||
_rt::string_lift(bytes0),
|
||||
_rt::string_lift(bytes1),
|
||||
);
|
||||
}
|
||||
pub trait Guest {
|
||||
fn init();
|
||||
fn name() -> _rt::String;
|
||||
fn on_component_text_changed(component_id: _rt::String, text: _rt::String);
|
||||
}
|
||||
#[doc(hidden)]
|
||||
|
||||
macro_rules! __export_component_diagram_connector_diagram_connector_cabi{
|
||||
($ty:ident with_types_in $($path_to_types:tt)*) => (const _: () = {
|
||||
|
||||
#[export_name = "component:diagram-connector/diagram-connector#init"]
|
||||
unsafe extern "C" fn export_init() {
|
||||
$($path_to_types)*::_export_init_cabi::<$ty>()
|
||||
}
|
||||
#[export_name = "component:diagram-connector/diagram-connector#name"]
|
||||
unsafe extern "C" fn export_name() -> *mut u8 {
|
||||
$($path_to_types)*::_export_name_cabi::<$ty>()
|
||||
}
|
||||
#[export_name = "cabi_post_component:diagram-connector/diagram-connector#name"]
|
||||
unsafe extern "C" fn _post_return_name(arg0: *mut u8,) {
|
||||
$($path_to_types)*::__post_return_name::<$ty>(arg0)
|
||||
}
|
||||
#[export_name = "component:diagram-connector/diagram-connector#on-component-text-changed"]
|
||||
unsafe extern "C" fn export_on_component_text_changed(arg0: *mut u8,arg1: usize,arg2: *mut u8,arg3: usize,) {
|
||||
$($path_to_types)*::_export_on_component_text_changed_cabi::<$ty>(arg0, arg1, arg2, arg3)
|
||||
}
|
||||
};);
|
||||
}
|
||||
#[doc(hidden)]
|
||||
pub(crate) use __export_component_diagram_connector_diagram_connector_cabi;
|
||||
#[repr(align(4))]
|
||||
struct _RetArea([::core::mem::MaybeUninit<u8>; 8]);
|
||||
static mut _RET_AREA: _RetArea = _RetArea([::core::mem::MaybeUninit::uninit(); 8]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
mod _rt {
|
||||
pub use alloc_crate::string::String;
|
||||
pub use alloc_crate::vec::Vec;
|
||||
pub unsafe fn string_lift(bytes: Vec<u8>) -> String {
|
||||
if cfg!(debug_assertions) {
|
||||
String::from_utf8(bytes).unwrap()
|
||||
} else {
|
||||
String::from_utf8_unchecked(bytes)
|
||||
}
|
||||
}
|
||||
pub unsafe fn invalid_enum_discriminant<T>() -> T {
|
||||
if cfg!(debug_assertions) {
|
||||
panic!("invalid enum discriminant")
|
||||
} else {
|
||||
core::hint::unreachable_unchecked()
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
pub fn run_ctors_once() {
|
||||
wit_bindgen_rt::run_ctors_once();
|
||||
}
|
||||
pub unsafe fn cabi_dealloc(ptr: *mut u8, size: usize, align: usize) {
|
||||
if size == 0 {
|
||||
return;
|
||||
}
|
||||
let layout = alloc::Layout::from_size_align_unchecked(size, align);
|
||||
alloc::dealloc(ptr as *mut u8, layout);
|
||||
}
|
||||
extern crate alloc as alloc_crate;
|
||||
pub use alloc_crate::alloc;
|
||||
}
|
||||
|
||||
/// Generates `#[no_mangle]` functions to export the specified type as the
|
||||
/// root implementation of all generated traits.
|
||||
///
|
||||
/// For more information see the documentation of `wit_bindgen::generate!`.
|
||||
///
|
||||
/// ```rust
|
||||
/// # macro_rules! export{ ($($t:tt)*) => (); }
|
||||
/// # trait Guest {}
|
||||
/// struct MyType;
|
||||
///
|
||||
/// impl Guest for MyType {
|
||||
/// // ...
|
||||
/// }
|
||||
///
|
||||
/// export!(MyType);
|
||||
/// ```
|
||||
#[allow(unused_macros)]
|
||||
#[doc(hidden)]
|
||||
|
||||
macro_rules! __export_component_impl {
|
||||
($ty:ident) => (self::export!($ty with_types_in self););
|
||||
($ty:ident with_types_in $($path_to_types_root:tt)*) => (
|
||||
$($path_to_types_root)*::exports::component::diagram_connector::diagram_connector::__export_component_diagram_connector_diagram_connector_cabi!($ty with_types_in $($path_to_types_root)*::exports::component::diagram_connector::diagram_connector);
|
||||
)
|
||||
}
|
||||
#[doc(inline)]
|
||||
pub(crate) use __export_component_impl as export;
|
||||
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
#[link_section = "component-type:wit-bindgen:0.25.0:component:encoded world"]
|
||||
#[doc(hidden)]
|
||||
pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 550] = *b"\
|
||||
\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\xa6\x03\x01A\x02\x01\
|
||||
A\x04\x01B\x0b\x01@\x01\x07messages\x01\0\x04\0\x03log\x01\0\x01@\x02\x14diagram\
|
||||
-connect-names\x0ccomponent-ids\x01\0\x04\0!listen-for-component-text-changes\x01\
|
||||
\x01\x01@\x02\x0ccomponent-ids\x04texts\x01\0\x04\0\x12set-component-text\x01\x02\
|
||||
\x01ky\x01o\x02s\x03\x01j\x01\x04\0\x01@\x01\x09time-texts\0\x05\x04\0\x0faddres\
|
||||
s-and-way\x01\x06\x03\x01\x20component:diagram-connector/host\x05\0\x01B\x06\x01\
|
||||
@\0\x01\0\x04\0\x04init\x01\0\x01@\0\0s\x04\0\x04name\x01\x01\x01@\x02\x0ccompon\
|
||||
ent-ids\x04texts\x01\0\x04\0\x19on-component-text-changed\x01\x02\x04\x01-compon\
|
||||
ent:diagram-connector/diagram-connector\x05\x01\x04\x01%component:diagram-connec\
|
||||
tor/component\x04\0\x0b\x0f\x01\0\x09component\x03\0\0\0G\x09producers\x01\x0cpr\
|
||||
ocessed-by\x02\x0dwit-component\x070.208.1\x10wit-bindgen-rust\x060.25.0";
|
||||
|
||||
#[inline(never)]
|
||||
#[doc(hidden)]
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
pub fn __link_custom_section_describing_imports() {
|
||||
wit_bindgen_rt::maybe_link_cabi_realloc();
|
||||
}
|
63
test_files/components/rust_diagram_connector/src/lib.rs
Normal file
63
test_files/components/rust_diagram_connector/src/lib.rs
Normal file
|
@ -0,0 +1,63 @@
|
|||
use std::borrow::Cow;
|
||||
use std::cell::RefCell;
|
||||
|
||||
#[allow(warnings)]
|
||||
mod bindings;
|
||||
|
||||
use bindings::component::diagram_connector::host;
|
||||
use bindings::exports::component::diagram_connector::diagram_connector;
|
||||
|
||||
macro_rules! log {
|
||||
($($arg:tt)*) => (host::log(&format!($($arg)*)))
|
||||
}
|
||||
|
||||
static NAME: &str = "Rust Test Diagram Connector";
|
||||
|
||||
// Note: Ids from `test_files/cache_diagram.excalidraw`
|
||||
const ADDRESS_COMPONENT_ID: &str = "ITxhJ7NtZ74YFd9JQ0_pl";
|
||||
const TIME_COMPONENT_ID: &str = "afXu8_6Kqfq-q2IsjtAcP";
|
||||
const STATUS_COMPONENT_ID: &str = "0iH5yRbH4IEseV3mnof3A";
|
||||
|
||||
thread_local! {
|
||||
static TIME_TEXT: RefCell<String> = <_>::default();
|
||||
}
|
||||
|
||||
struct Component;
|
||||
|
||||
impl diagram_connector::Guest for Component {
|
||||
fn init() {
|
||||
host::listen_for_component_text_changes(NAME, TIME_COMPONENT_ID);
|
||||
log!("'{NAME}' initialized")
|
||||
}
|
||||
|
||||
fn name() -> String {
|
||||
NAME.to_string()
|
||||
}
|
||||
|
||||
fn on_component_text_changed(component_id: String, text: String) {
|
||||
match component_id.as_str() {
|
||||
TIME_COMPONENT_ID => {
|
||||
TIME_TEXT.set(text);
|
||||
refresh_fields();
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn refresh_fields() {
|
||||
let way = TIME_TEXT.with_borrow(|time_text| host::address_and_way(&time_text));
|
||||
let Ok((address, way)) = way else {
|
||||
return;
|
||||
};
|
||||
host::set_component_text(ADDRESS_COMPONENT_ID, &address);
|
||||
|
||||
let status_text: Cow<str> = if let Some(way) = way {
|
||||
format!("VALID, WAY: {way}").into()
|
||||
} else {
|
||||
"NOT VALID".into()
|
||||
};
|
||||
host::set_component_text(STATUS_COMPONENT_ID, &status_text);
|
||||
}
|
||||
|
||||
bindings::export!(Component with_types_in bindings);
|
19
test_files/components/rust_diagram_connector/wit/world.wit
Normal file
19
test_files/components/rust_diagram_connector/wit/world.wit
Normal file
|
@ -0,0 +1,19 @@
|
|||
package component:diagram-connector;
|
||||
|
||||
interface host {
|
||||
log: func(message: string);
|
||||
listen-for-component-text-changes: func(diagram-connect-name: string, component-id: string);
|
||||
set-component-text: func(component-id: string, text: string);
|
||||
address-and-way: func(time-text: string) -> result<tuple<string, option<u32>>>;
|
||||
}
|
||||
|
||||
interface diagram-connector {
|
||||
init: func();
|
||||
name: func() -> string;
|
||||
on-component-text-changed: func(component-id: string, text: string);
|
||||
}
|
||||
|
||||
world component {
|
||||
import host;
|
||||
export diagram-connector;
|
||||
}
|
BIN
test_files/sv39_mmu_cache_sim.zip
Normal file
BIN
test_files/sv39_mmu_cache_sim.zip
Normal file
Binary file not shown.
Reference in a new issue