No description
  • Scheme 92.4%
  • Makefile 4.8%
  • M4 2.7%
  • Shell 0.1%
Find a file
2025-05-09 21:21:30 +08:00
.github/workflows fixup! fixup! fixup! add github action 2023-02-23 17:00:59 +08:00
.guix/modules make this repo to a guix channel. 2024-11-09 19:11:54 +08:00
build-aux init 2023-01-02 21:31:56 +08:00
tests fix cstring-pointer* for gc and syntax. 2025-05-09 20:47:20 +08:00
.gitignore init 2023-01-02 21:31:56 +08:00
.guix-channel make this repo to a guix channel. 2024-11-09 19:11:54 +08:00
AUTHORS init 2023-01-02 21:31:56 +08:00
bootstrap change bootstrap mode. 2023-02-23 17:05:12 +08:00
bytestructure-class.scm fix cstring-pointer* for gc and syntax. 2025-05-09 20:47:20 +08:00
ChangeLog init 2023-01-02 21:31:56 +08:00
channels-lock.scm add channels.scm and channels-lock.scm 2024-11-09 20:55:35 +08:00
channels.scm add channels.scm and channels-lock.scm 2024-11-09 20:55:35 +08:00
configure.ac update email. 2025-05-09 21:21:30 +08:00
COPYING init 2023-01-02 21:31:56 +08:00
guix.scm make this repo to a guix channel. 2024-11-09 19:11:54 +08:00
INSTALL init 2023-01-02 21:31:56 +08:00
Makefile.am add github action 2023-02-23 16:47:15 +08:00
NEWS init 2023-01-02 21:31:56 +08:00
pre-inst-env.in init 2023-01-02 21:31:56 +08:00
README add cstring-pointer*. 2023-01-15 20:50:11 +08:00

# -*- mode: org -*-
#+begin_src scheme
  (use-modules (bytestructures guile)
               (bytestructure-class))
  (define %wl-list-struct
    (bs:struct
     `((prev ,(bs:pointer (delay %wl-list-struct)))
       (next ,(bs:pointer (delay %wl-list-struct))))))
  (define-bytestructure-class <wl-list> ()
    %wl-list-struct
    wrap-wl-list unwrap-wl-list wl-list?
    (prev #:accessor .prev)
    (next #:accessor .next))


  (define %wl-signal-struct
    (bs:struct `((listener-list ,%wl-list-struct))))
  (define-bytestructure-class <wl-signal> ()
    %wl-signal-struct wrap-wl-signal unwrap-wl-signal wl-signal?
    (listener-list #:accessor .listener-list))
  ;; (.listener-list (wrap-wl-signal a-pointer)) => return a <wl-list>.
#+end_src

* 4 new descriptor.
** bs:unknow
use by descriptor only
Can't use bytestructure-set! for it.
#+begin_src c
  struct wl_client;
#+end_src

#+begin_src scheme
  (define %wl-client-struct (bs:unknow))
#+end_src
** cstring-pointer*

#+begin_src scheme
  (define bs (bytestructure cstring-pointer*))
  (bytestructure-ref bs) ;; => #f
  (bytestructure-set! bs "hhh")
  (bytestructure-ref bs);; => "hhh"
#+end_src

** bs:enum

#+begin_src scheme
  (define enum (bs:enum '(A (B 2))))
  (define enum-1 (bytestructure enum 'A))
  (define enum-2 (bytestructure enum 2))
  (bytestructure-ref enum-1) ;; => 'A
  (bytestructure-ref enum-2) ;; => 'B
  (bytestructure-set! enum-1 'B) ;; enum-1: 'B
  (bytestructure-set! enum-2 0) ;; enum-2: 'A
#+end_src

** stdbool

#+begin_src scheme
  (define bool (bytestructure stdbool))
  (bytestructure-ref bool) ;; => #f
  (bytestructure-set! bool #t) ;; bool: #t
  (bytestructure-ref bool) ;; => #t
#+end_src