@tishlang/tish 1.10.0 → 1.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -70,6 +70,14 @@ pub type NativeFn = std::rc::Rc<dyn Fn(&[Value]) -> Value>;
70
70
 
71
71
  /// Trait for opaque Rust types exposed to Tish (e.g. Polars DataFrame).
72
72
  /// Implementors provide method dispatch so Tish can call methods on the value.
73
+ ///
74
+ /// The `Send + Sync` supertrait bound is conditional on the `send-values`
75
+ /// feature. When `send-values` is off (single-threaded VMs: wasm browser /
76
+ /// wasi / interpreter / cranelift), `NativeFn` is already `Rc<dyn Fn>`, so
77
+ /// `Value` is `!Send` anyway — dropping the bound here loses nothing and lets
78
+ /// `!Send` opaques like `JsHandle(wasm_bindgen::JsValue)` be stored in a
79
+ /// `Value::Opaque` on the browser runtime.
80
+ #[cfg(feature = "send-values")]
73
81
  pub trait TishOpaque: Send + Sync {
74
82
  /// Display name for the type (e.g. "DataFrame").
75
83
  fn type_name(&self) -> &'static str;
@@ -81,6 +89,19 @@ pub trait TishOpaque: Send + Sync {
81
89
  fn as_any(&self) -> &dyn std::any::Any;
82
90
  }
83
91
 
92
+ /// Single-threaded variant (no `Send + Sync` bound); see the `send-values` doc above.
93
+ #[cfg(not(feature = "send-values"))]
94
+ pub trait TishOpaque {
95
+ /// Display name for the type (e.g. "DataFrame").
96
+ fn type_name(&self) -> &'static str;
97
+
98
+ /// Get a method by name. Returns a native function if the method exists.
99
+ fn get_method(&self, name: &str) -> Option<NativeFn>;
100
+
101
+ /// For downcasting `Arc<dyn TishOpaque>` in native crates (e.g. Polars → `DataFrame`).
102
+ fn as_any(&self) -> &dyn std::any::Any;
103
+ }
104
+
84
105
  /// Trait for Promise-like values that can be awaited (block until settled).
85
106
  /// Implemented by the runtime for native compile; interpreter uses its own Promise.
86
107
  pub trait TishPromise: Send + Sync {
@@ -103,7 +103,7 @@ fn main() {{
103
103
  message: format!("Cannot write build.rs: {}", e),
104
104
  })?;
105
105
 
106
- tishlang_build_utils::run_cargo_build(&build_dir, None)
106
+ tishlang_build_utils::run_cargo_build(&build_dir, None, None)
107
107
  .map_err(|e| CraneliftError { message: e })?;
108
108
 
109
109
  let binary_dir = build_dir.join("target").join("release");