* Added endianness and native-endianness
This commit is contained in:
parent
64b06d698b
commit
009a25ad30
BIN
src/ikarus.boot
BIN
src/ikarus.boot
Binary file not shown.
|
@ -11,7 +11,8 @@
|
|||
bytevector-uint-ref bytevector-sint-ref
|
||||
bytevector-uint-set! bytevector-sint-set!
|
||||
bytevector->uint-list bytevector->sint-list
|
||||
uint-list->bytevector sint-list->bytevector)
|
||||
uint-list->bytevector sint-list->bytevector
|
||||
native-endianness)
|
||||
(import
|
||||
(except (ikarus)
|
||||
make-bytevector bytevector-length bytevector-s8-ref
|
||||
|
@ -25,12 +26,16 @@
|
|||
bytevector-uint-ref bytevector-sint-ref
|
||||
bytevector-uint-set! bytevector-sint-set!
|
||||
bytevector->uint-list bytevector->sint-list
|
||||
uint-list->bytevector sint-list->bytevector)
|
||||
uint-list->bytevector sint-list->bytevector
|
||||
native-endianness)
|
||||
(ikarus system $fx)
|
||||
(ikarus system $bignums)
|
||||
(ikarus system $pairs)
|
||||
(ikarus system $bytevectors))
|
||||
|
||||
(define (native-endianness) 'big) ;;; HARDCODED
|
||||
|
||||
|
||||
(define ($bytevector-fill x i j fill)
|
||||
(cond
|
||||
[($fx= i j) x]
|
||||
|
@ -101,7 +106,7 @@
|
|||
(error 'bytevector-u8-set! "invalid index ~s for ~s" i x))
|
||||
(error 'bytevector-u8-set! "~s is not a bytevector" x))))
|
||||
|
||||
(define bytevector-u16-native-ref
|
||||
(define bytevector-u16-native-ref ;;; HARDCODED
|
||||
(lambda (x i)
|
||||
(if (bytevector? x)
|
||||
(if (and (fixnum? i)
|
||||
|
@ -114,7 +119,7 @@
|
|||
(error 'bytevector-u16-native-ref "invalid index ~s" i))
|
||||
(error 'bytevector-u16-native-ref "~s is not a bytevector" x))))
|
||||
|
||||
(define bytevector-u16-native-set!
|
||||
(define bytevector-u16-native-set! ;;; HARDCODED
|
||||
(lambda (x i n)
|
||||
(if (bytevector? x)
|
||||
(if (and (fixnum? n)
|
||||
|
@ -132,7 +137,7 @@
|
|||
(error 'bytevector-u16-native-set! "~s is not a bytevector" x))))
|
||||
|
||||
|
||||
(define bytevector-s16-native-set!
|
||||
(define bytevector-s16-native-set! ;;; HARDCODED
|
||||
(lambda (x i n)
|
||||
(if (bytevector? x)
|
||||
(if (and (fixnum? n)
|
||||
|
@ -149,7 +154,7 @@
|
|||
(error 'bytevector-s16-native-set! "invalid value ~s" n))
|
||||
(error 'bytevector-s16-native-set! "~s is not a bytevector" x))))
|
||||
|
||||
(define bytevector-s16-native-ref
|
||||
(define bytevector-s16-native-ref ;;; HARDCODED
|
||||
(lambda (x i)
|
||||
(if (bytevector? x)
|
||||
(if (and (fixnum? i)
|
||||
|
|
|
@ -810,6 +810,14 @@
|
|||
[(_ expr)
|
||||
(bless `(unless ,expr
|
||||
(error 'assert "~s failed" ',expr)))])))
|
||||
(define endianness-macro
|
||||
(lambda (stx)
|
||||
(syntax-match stx ()
|
||||
[(_ e)
|
||||
(case (syntax->datum e)
|
||||
[(little) (bless `'little)]
|
||||
[(big) (bless `'big)]
|
||||
[else (stx-error stx "endianness must be big or little")])])))
|
||||
(define identifier-syntax-macro
|
||||
(lambda (stx)
|
||||
(syntax-match stx ()
|
||||
|
@ -1658,6 +1666,7 @@
|
|||
[(time) time-macro]
|
||||
[(delay) delay-macro]
|
||||
[(assert) assert-macro]
|
||||
[(endianness) endianness-macro]
|
||||
[(... => _ else unquote unquote-splicing
|
||||
unsyntax unsyntax-splicing)
|
||||
incorrect-usage-macro]
|
||||
|
|
|
@ -114,6 +114,7 @@
|
|||
[or (macro . or)]
|
||||
[time (macro . time)]
|
||||
[delay (macro . delay)]
|
||||
[endianness (macro . endianness)]
|
||||
[assert (macro . assert)]
|
||||
[... (macro . ...)]
|
||||
[=> (macro . =>)]
|
||||
|
@ -251,6 +252,7 @@
|
|||
[or i r ne]
|
||||
[time i]
|
||||
[delay i ne]
|
||||
[endianness i ]
|
||||
[assert i r]
|
||||
[... i r ne]
|
||||
[=> i r ne]
|
||||
|
@ -415,6 +417,7 @@
|
|||
[sint-list->bytevector i]
|
||||
[string->utf8-bytevector i]
|
||||
[utf8-bytevector->string i]
|
||||
[native-endianness i]
|
||||
|
||||
[for-each i r]
|
||||
[map i r]
|
||||
|
|
|
@ -398,8 +398,8 @@
|
|||
[bytevector-uint-set! C bv]
|
||||
[bytevector=? C bv]
|
||||
[bytevector? C bv]
|
||||
[endianness S bv]
|
||||
[native-endianness S bv]
|
||||
[endianness C bv]
|
||||
[native-endianness C bv]
|
||||
[sint-list->bytevector C bv]
|
||||
[string->utf16 S bv]
|
||||
[string->utf32 S bv]
|
||||
|
|
Loading…
Reference in New Issue