@raviqqe/stak 0.3.26 → 0.3.27

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.
package/README.md CHANGED
@@ -49,15 +49,6 @@ First, prepare a Scheme script named `src/fight.scm`:
49
49
  ; Import a base library and the library named `(stak rust)` for Rust integration.
50
50
  (import (scheme base) (stak rust))
51
51
 
52
- ; Use the `define-rust` procedure to import native functions written in Rust.
53
- ; The order of the functions should match the ones passed into the `Engine::new()`
54
- ; function in Rust.
55
- (define-rust
56
- make-person
57
- person-pies
58
- person-wasted
59
- person-throw-pie)
60
-
61
52
  ; Make two people with a number of pies they have and their dodge rates.
62
53
  (define me (make-person 4 0.2))
63
54
  (define friend (make-person 2 0.6))
@@ -151,24 +142,21 @@ impl Person {
151
142
  }
152
143
 
153
144
  fn main() -> Result<(), Box<dyn Error>> {
154
- // Import a Scheme module of the script.
155
- static MODULE: UniversalModule = include_module!("fight.scm");
156
-
157
- // Run the Scheme module.
158
- run_scheme(&MODULE)?;
145
+ // Include and run the Scheme module.
146
+ run_scheme(&include_module!("fight.scm"))?;
159
147
 
160
148
  Ok(())
161
149
  }
162
150
 
163
- fn run_scheme(module: &'static UniversalModule) -> Result<(), EngineError> {
151
+ fn run_scheme(module: &UniversalModule) -> Result<(), EngineError> {
164
152
  // Initialize a heap memory for a Scheme scripting engine.
165
153
  let mut heap = [Default::default(); HEAP_SIZE];
166
154
  // Define Rust functions to pass to the engine.
167
155
  let mut functions = [
168
- r#fn(Person::new),
169
- r#fn::<(Ref<_>,), _>(Person::pies),
170
- r#fn::<(Ref<_>,), _>(Person::wasted),
171
- r#fn(Person::throw_pie),
156
+ ("make-person", r#fn(Person::new)),
157
+ ("person-pies", r#fn::<(Ref<_>,), _>(Person::pies)),
158
+ ("person-wasted", r#fn::<(Ref<_>,), _>(Person::wasted)),
159
+ ("person-throw-pie", r#fn(Person::throw_pie)),
172
160
  ];
173
161
  // Initialize the engine.
174
162
  let mut engine = Engine::new(&mut heap, &mut functions)?;
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@raviqqe/stak",
3
3
  "type": "module",
4
4
  "description": "Stak Scheme in WebAssembly",
5
- "version": "0.3.26",
5
+ "version": "0.3.27",
6
6
  "license": "SEE LICENSE IN ../LICENSE",
7
7
  "repository": {
8
8
  "type": "git",
package/stak_wasm_bg.wasm CHANGED
Binary file