Skip to content

feat: Timeline extension #2668

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 20 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
900 changes: 860 additions & 40 deletions Cargo.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ members = [
# xtask, testing and the bindings should only be built when invoked explicitly.
default-members = ["benchmarks", "crates/*"]
resolver = "2"
exclude = ["crates/matrix-sdk-extensions/guests"]

[workspace.package]
rust-version = "1.70"
Expand Down
1 change: 1 addition & 0 deletions bindings/matrix-sdk-ffi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ uniffi = { workspace = true, features = ["tokio"] }
url = "2.2.2"
zeroize = { workspace = true }
uuid = { version = "1.4.1", features = ["v4"] }
javascriptcore = { git = "https://github.com/endoli/javascriptcore.rs", branch = "main" }

[target.'cfg(target_os = "android")'.dependencies]
log-panics = { version = "2", features = ["with-backtrace"] }
Expand Down
22 changes: 22 additions & 0 deletions bindings/matrix-sdk-ffi/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,28 @@ impl Client {

Ok(())
}

pub fn test_wasm(&self) {
use javascriptcore::{JSContext, JSValue};

let mut bytes =
b"\x00asm\x01\x00\x00\x00\x01\x07\x01`\x02\x7f\x7f\x01\x7f\x03\x02\x01\x00\x05\x03\x01\x00\x10\x06\x11\x02\x7f\x00A\x80\x80\xc0\x00\x0b\x7f\x00A\x80\x80\xc0\x00\x0b\x07+\x04\x06memory\x02\x00\x03sum\x00\x00\n__data_end\x03\x00\x0b__heap_base\x03\x01\n\t\x01\x07\x00 \x00 \x01j\x0b\x00,\x0ftarget_features\x02+\x0fmutable-globals+\x08sign-ext".to_owned();

let ctx = JSContext::default();
let global = ctx.global_object().unwrap();
let wasm = global.get_property("WebAssembly").as_object().unwrap();
let module = wasm.get_property("Module").as_object().unwrap();
let bytes = unsafe { JSValue::new_typed_array_with_bytes(&ctx, &mut bytes[..]).unwrap() };
let compiled_module = module.call_as_constructor(&[bytes]).unwrap();
let instance = wasm.get_property("Instance").as_object().unwrap();
let instance = instance.call_as_constructor(&[compiled_module]).unwrap().as_object().unwrap();
let exports = instance.get_property("exports").as_object().unwrap();
let sum = exports.get_property("sum").as_object().unwrap();

let result = sum.call_as_function(None, &[JSValue::new_number(&ctx, 1.), JSValue::new_number(&ctx, 2.)]).unwrap();

assert_eq!(result.as_number().unwrap(), 3.);
}
}

impl Client {
Expand Down
23 changes: 23 additions & 0 deletions crates/matrix-sdk-extensions-macros/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[package]
authors = ["Ivan Enderlin <[email protected]>"]
edition = "2021"
name = "matrix-sdk-extensions-macros"
repository = "https://github.com/matrix-org/matrix-rust-sdk"
rust-version = { workspace = true }
version = "0.0.1"

[lib]
proc-macro = true

[features]
default = ["wasmtime", "javascriptcore"]
wasmtime = ["dep:wasmtime-wit-bindgen"]
javascriptcore = []

[dependencies]
heck = { version = "0.4.1" }
proc-macro2 = "1.0.69"
quote = "1.0.33"
syn = { version = "2.0.39", features = ["full"] }
wasmtime-wit-bindgen = { version = "14.0.4", optional = true }
wit-parser = "0.12.1"
Loading