Created
December 30, 2021 15:32
-
-
Save telent/02f8023a3f1f7f41026846f13dcb9c2d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(let [buf (unsafe.alloc 25)] | |
(unsafe.poke buf 0 1 0x55) | |
(unsafe.poke buf 1 1 0xaa) | |
(unsafe.poke buf 2 1 0x11) | |
(unsafe.poke buf 3 1 0xff) | |
(unsafe.poke buf 4 4 0xdeadbeef) | |
(assert (= 0x11 (unsafe.peek buf 2 1))) | |
(assert (= 0xdeadbeef (unsafe.peek buf 4 4))) | |
;; this next one is confusing, because | |
;; (1) values are little-endian | |
;; (2) lua returns them as signed | |
(assert (= (- 0xde 0x100) (unsafe.peek buf 7 1))) | |
(trace buf)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment