Added c-bytevector character accessors

This commit is contained in:
retropikzel 2025-06-08 09:28:16 +03:00
parent b776994b36
commit 6a2caa06ff
5 changed files with 67 additions and 0 deletions

View File

@ -406,6 +406,30 @@ If _k_ is not a valid index of c-bytevector the behaviour is undefined.
Returns the byte at index _k_ of _c-bytevector_.
(**c-bytevector-char-set!** _c-bytevector_ _k_ _char_)
If _k_ is not a valid index of c-bytevector the behaviour is undefined.
Stores the _char_ in element _k_ of _c-bytevector_.
(**c-bytevector-char-ref** _c-bytevector_ _k_)
If _k_ is not a valid index of c-bytevector the behaviour is undefined.
Returns the char at index _k_ of _c-bytevector_.
(**c-bytevector-uchar-set!** _c-bytevector_ _k_ _char_)
If _k_ is not a valid index of c-bytevector the behaviour is undefined.
Stores the unsigned _char_ in element _k_ of _c-bytevector_.
(**c-bytevector-uchar-ref** _c-bytevector_ _k_)
If _k_ is not a valid index of c-bytevector the behaviour is undefined.
Returns the unsigned char at index _k_ of _c-bytevector_.
(**c-bytevector-uint-ref** _c-bytevector_ _k_ _endianness_ _size_)</br>
(**c-bytevector-sint-ref** _c-bytevector_ _k_ _endianness_ _size_)</br>
(**c-bytevector-uint-set!** _c-bytevector_ _k_ _n_ _endianness_ _size_)</br>

View File

@ -21,6 +21,8 @@ Schemes - 0.10.0</title>
tracker</a></p>
<p><a href="https://sr.ht/~retropikzel/foreign-c/lists">Maling
lists</a></p>
<p><a
href="https://jenkins.scheme.org/job/foreign_c/job/foreign-c/">Jenkins</a></p>
<ul>
<li><a href="#installation">Installation</a></li>
<li><a href="#documentation">Documentation</a>
@ -595,6 +597,30 @@ func(&amp;i);</code></pre>
behaviour is undefined.</p>
<p>Returns the byte at index <em>k</em> of
<em>c-bytevector</em>.</p>
<p>(<strong>c-bytevector-char-set!</strong>
<em>c-bytevector</em> <em>k</em> <em>char</em>)</p>
<p>If <em>k</em> is not a valid index of c-bytevector the
behaviour is undefined.</p>
<p>Stores the <em>char</em> in element <em>k</em> of
<em>c-bytevector</em>.</p>
<p>(<strong>c-bytevector-char-ref</strong> <em>c-bytevector</em>
<em>k</em>)</p>
<p>If <em>k</em> is not a valid index of c-bytevector the
behaviour is undefined.</p>
<p>Returns the char at index <em>k</em> of
<em>c-bytevector</em>.</p>
<p>(<strong>c-bytevector-uchar-set!</strong>
<em>c-bytevector</em> <em>k</em> <em>char</em>)</p>
<p>If <em>k</em> is not a valid index of c-bytevector the
behaviour is undefined.</p>
<p>Stores the unsigned <em>char</em> in element <em>k</em> of
<em>c-bytevector</em>.</p>
<p>(<strong>c-bytevector-uchar-ref</strong>
<em>c-bytevector</em> <em>k</em>)</p>
<p>If <em>k</em> is not a valid index of c-bytevector the
behaviour is undefined.</p>
<p>Returns the unsigned char at index <em>k</em> of
<em>c-bytevector</em>.</p>
<p>(<strong>c-bytevector-uint-ref</strong> <em>c-bytevector</em>
<em>k</em> <em>endianness</em> <em>size</em>)</br>
(<strong>c-bytevector-sint-ref</strong> <em>c-bytevector</em>

Binary file not shown.

View File

@ -205,6 +205,11 @@
;; TODO c-bytevector->u8-list
;; TODO u8-list->c-bytevector
c-bytevector-uchar-ref
c-bytevector-char-ref
c-bytevector-char-set!
c-bytevector-uchar-set!
c-bytevector-uint-ref
c-bytevector-sint-ref
c-bytevector-sint-set!

View File

@ -520,6 +520,18 @@
(c-bytevector-u8-set! b i (car vals)))
b))
(define (c-bytevector-uchar-ref c-bytevector index)
(integer->char (c-bytevector-u8-ref c-bytevector index)))
(define (c-bytevector-uchar-set! c-bytevector index char)
(c-bytevector-u8-set! c-bytevector index (char->integer char)))
(define (c-bytevector-char-ref c-bytevector index)
(integer->char (c-bytevector-s8-ref c-bytevector index)))
(define (c-bytevector-char-set! c-bytevector index char)
(c-bytevector-s8-set! c-bytevector index (char->integer char)))
(define (c-bytevector-uint-ref c-bytevector index endness size)
(case endness
((big)