Skip to content

Commit

Permalink
Define Rust bindings (#2053)
Browse files Browse the repository at this point in the history
Close #2046.
  • Loading branch information
raviqqe authored Jan 28, 2025
1 parent f93e449 commit 05760ef
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
9 changes: 5 additions & 4 deletions engine/src/fight.scm
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
(import (scheme base) (stak base))
(import (scheme base) (stak rust))

(define make-person (primitive 1000))
(define person-throw-pie (primitive 1001))
(define person-wasted (primitive 1002))
(define-rust
make-person
person-throw-pie
person-wasted)

(define me (make-person 4 0.2))
(define you (make-person 2 0.6))
Expand Down
21 changes: 21 additions & 0 deletions prelude.scm
Original file line number Diff line number Diff line change
Expand Up @@ -3354,3 +3354,24 @@
'())))))))

(define environment list)))

(define-library (stak rust)
(export define-rust)

(import
(only (stak base) primitive)
(scheme base))

(begin
(define-syntax define-rust
(syntax-rules ()
((_ "count" index name1 name2 ...)
(begin
(define name1 (primitive index))
(define-rust "count" (+ index 1) name2 ...)))

((_ "count" index)
#f)

((_ name1 name2 ...)
(define-rust "count" 1000 name1 name2 ...))))))

0 comments on commit 05760ef

Please sign in to comment.