diff --git a/src/ikarus.boot b/src/ikarus.boot index b04a456..823e464 100644 Binary files a/src/ikarus.boot and b/src/ikarus.boot differ diff --git a/src/ikarus.bytevectors.ss b/src/ikarus.bytevectors.ss index d0d7728..c902219 100644 --- a/src/ikarus.bytevectors.ss +++ b/src/ikarus.bytevectors.ss @@ -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) diff --git a/src/ikarus.syntax.ss b/src/ikarus.syntax.ss index ecc85af..ae2e661 100644 --- a/src/ikarus.syntax.ss +++ b/src/ikarus.syntax.ss @@ -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] diff --git a/src/makefile.ss b/src/makefile.ss index 2e7a32d..c006ed9 100755 --- a/src/makefile.ss +++ b/src/makefile.ss @@ -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] diff --git a/src/todo-r6rs.ss b/src/todo-r6rs.ss index 81115c8..422fa48 100755 --- a/src/todo-r6rs.ss +++ b/src/todo-r6rs.ss @@ -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]