git.delta.rocks / jrsonnet / refs/commits / 63230e6bbdf4

difftreelog

refactor drop wasm interop from bindings

qstsyplpYaroslav Bolyukin2026-05-05parent: #387e99d.patch.diff
in: master
Not needed with the introducion of jrsonnet-web

2 files changed

modifiedbindings/jsonnet/Cargo.tomldiffbeforeafterboth
30crate-type = ["cdylib", "staticlib"]30crate-type = ["cdylib", "staticlib"]
3131
32[features]32[features]
33default = ["interop-common", "interop-wasm", "interop-threading"]33default = ["interop-common", "interop-threading"]
34# Export additional functions for native integration, i.e ability to set custom trace format34# Export additional functions for native integration, i.e ability to set custom trace format
35interop-common = []35interop-common = []
36# Provide ability to statically override callbacks from WASM (by using imports)
37interop-wasm = []
38# Provide ability to move jsonnet vm state between threads36# Provide ability to move jsonnet vm state between threads
39interop-threading = []37interop-threading = []
4038
modifiedbindings/jsonnet/src/interop.rsdiffbeforeafterboth
1//! Jrsonnet specific additional binding helpers1//! Jrsonnet specific additional binding helpers
2
3#[cfg(feature = "interop-wasm")]
4pub mod wasm {
5 use std::ffi::{c_char, c_int, c_void};
6
7 use jrsonnet_evaluator::Val;
8
9 use crate::VM;
10
11 unsafe extern "C" {
12 pub fn _jrsonnet_static_import_callback(
13 ctx: *mut c_void,
14 base: *const c_char,
15 rel: *const c_char,
16 found_here: *mut *const c_char,
17 buf: *mut *mut c_char,
18 buflen: *mut usize,
19 ) -> c_int;
20
21 #[allow(improper_ctypes)]
22 pub fn _jrsonnet_static_native_callback(
23 ctx: *const c_void,
24 argv: *const *const Val,
25 success: *mut c_int,
26 ) -> *mut Val;
27 }
28
29 #[unsafe(no_mangle)]
30 #[cfg(feature = "interop-wasm")]
31 // ctx arg is passed as-is to callback
32 #[allow(clippy::not_unsafe_ptr_arg_deref)]
33 pub extern "C" fn jrsonnet_apply_static_import_callback(vm: &VM, ctx: *mut c_void) {
34 unsafe { crate::import::jsonnet_import_callback(vm, _jrsonnet_static_import_callback, ctx) }
35 }
36
37 /// # Safety
38 ///
39 /// `name` and `raw_params` should be correctly initialized
40 #[unsafe(no_mangle)]
41 #[cfg(feature = "interop-wasm")]
42 pub unsafe extern "C" fn jrsonnet_apply_static_native_callback(
43 vm: &VM,
44 name: *const c_char,
45 ctx: *mut c_void,
46 raw_params: *const *const c_char,
47 ) {
48 unsafe {
49 crate::native::jsonnet_native_callback(
50 vm,
51 name,
52 _jrsonnet_static_native_callback,
53 ctx,
54 raw_params,
55 );
56 }
57 }
58}
592
60#[cfg(feature = "interop-common")]3#[cfg(feature = "interop-common")]
61mod common {4mod common {