bytevectors.scm 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. ;;; Bytevectors
  2. ;;; Copyright (C) 2024 David Thompson <dave@spritely.institute>
  3. ;;;
  4. ;;; Licensed under the Apache License, Version 2.0 (the "License");
  5. ;;; you may not use this file except in compliance with the License.
  6. ;;; You may obtain a copy of the License at
  7. ;;;
  8. ;;; http://www.apache.org/licenses/LICENSE-2.0
  9. ;;;
  10. ;;; Unless required by applicable law or agreed to in writing, software
  11. ;;; distributed under the License is distributed on an "AS IS" BASIS,
  12. ;;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. ;;; See the License for the specific language governing permissions and
  14. ;;; limitations under the License.
  15. ;;; Commentary:
  16. ;;;
  17. ;;; R6RS bytevectors.
  18. ;;;
  19. ;;; Code:
  20. (define-module (rnrs bytevectors)
  21. #:use-module ((hoot bytevectors)
  22. #:hide (bytevector-copy
  23. bytevector-copy!))
  24. #:use-module ((hoot bytevectors)
  25. #:prefix hoot:
  26. #:select (bytevector-copy
  27. bytevector-copy!))
  28. #:use-module ((hoot strings) #:select (string->utf8 utf8->string))
  29. ;; Missing bindings:
  30. ;; bytevector=?
  31. ;; bytevector-fill!
  32. ;; uniform-array->bytevector
  33. ;; u8-list->bytevector
  34. ;; bytevector->sint-list
  35. ;; bytevector->uint-list
  36. ;; uint-list->bytevector
  37. ;; sint-list->bytevector
  38. ;; string->utf16
  39. ;; string->utf32
  40. ;; utf16->string
  41. ;; utf32->string
  42. #:export (bytevector-copy
  43. bytevector-copy!)
  44. #:re-export (endianness
  45. native-endianness
  46. make-bytevector
  47. bytevector?
  48. bytevector-length
  49. bytevector-u8-ref
  50. bytevector-u8-set!
  51. bytevector-s8-ref
  52. bytevector-s8-set!
  53. bytevector-u16-native-ref
  54. bytevector-u16-ref
  55. bytevector-u16-native-set!
  56. bytevector-s16-ref
  57. bytevector-s16-native-ref
  58. bytevector-s16-set!
  59. bytevector-s16-native-set!
  60. bytevector-u32-ref
  61. bytevector-u32-native-ref
  62. bytevector-u32-set!
  63. bytevector-u32-native-set!
  64. bytevector-s32-ref
  65. bytevector-s32-native-ref
  66. bytevector-s32-set!
  67. bytevector-s32-native-set!
  68. bytevector-u64-ref
  69. bytevector-u64-native-ref
  70. bytevector-u64-set!
  71. bytevector-u64-native-set!
  72. bytevector-s64-ref
  73. bytevector-s64-native-ref
  74. bytevector-s64-set!
  75. bytevector-s64-native-set!
  76. bytevector-uint-ref
  77. bytevector-uint-set!
  78. bytevector-sint-ref
  79. bytevector-sint-set!
  80. bytevector-ieee-single-ref
  81. bytevector-ieee-single-native-ref
  82. bytevector-ieee-single-set!
  83. bytevector-ieee-single-native-set!
  84. bytevector-ieee-double-ref
  85. bytevector-ieee-double-native-ref
  86. bytevector-ieee-double-set!
  87. bytevector-ieee-double-native-set!
  88. string->utf8
  89. utf8->string))
  90. (define (bytevector-copy bv)
  91. (hoot:bytevector-copy bv))
  92. (define (bytevector-copy! source source-start target target-start len)
  93. (hoot:bytevector-copy! target target-start source source-start (+ source-start len)))