Skip to content

Instantly share code, notes, and snippets.

@telent
Created December 30, 2021 15:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save telent/02f8023a3f1f7f41026846f13dcb9c2d to your computer and use it in GitHub Desktop.
Save telent/02f8023a3f1f7f41026846f13dcb9c2d to your computer and use it in GitHub Desktop.
(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