Skip to content

Commit

Permalink
autocommit
Browse files Browse the repository at this point in the history
  • Loading branch information
nbittich committed Sep 23, 2023
1 parent 73e7c2d commit 502725f
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ jobs:
# targets: x86_64-unknown-linux-musl
- run: cargo test --verbose -- --nocapture
- run: cargo clippy --all-targets --all-features -- -D warnings
- run: cargo publish --dry-run
#- run: cargo publish --dry-run
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified dynamic_lib/libplugin_example.so
Binary file not shown.
16 changes: 14 additions & 2 deletions src/adana_script/compute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,6 @@ fn compute_recur(
parent
};


unsafe {
let lib = NativeLibrary::new(
file_path.as_path(),
Expand Down Expand Up @@ -714,7 +713,20 @@ fn compute_recur(
if cfg!(test) {
dbg!(&parameters);
}
unsafe { lib.call_function(key.as_str(), parameters) }

let mut cloned_ctx = ctx.clone();
let slb = shared_lib.as_ref().to_path_buf();
let fun = move |v, extra_ctx| {
cloned_ctx.extend(extra_ctx);
compute_lazy(v, &mut cloned_ctx, &slb)
};
unsafe {
lib.call_function(
key.as_str(),
parameters,
Box::new(fun),
)
}
//Ok(function(vec![Primitive::String("s".into())]))
} else {
Ok(Primitive::Error(format!(
Expand Down
19 changes: 19 additions & 0 deletions src/adana_script/tests/dynload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,22 @@ fn load_dynamic_lib_test() {
dbg!(ctx);
println!("{res:?}");
}
#[test]
#[serial]
fn callback_dynamic_lib_test() {
let file_path = r#"
lib = require("libplugin_example.so")
callback = (input) => {input + " Nordine! ca va?"}
text = lib.callback(callback)
"#;
let mut ctx = BTreeMap::new();
let res = compute(file_path, &mut ctx, "dynamic_lib").unwrap();

assert_eq!(
Primitive::String("Hello Nordine! ca va?".to_string()),
ctx["text"].read().unwrap().clone()
);

dbg!(ctx);
println!("{res:?}");
}

0 comments on commit 502725f

Please sign in to comment.