(define c-bytevector-get (lambda (pointer type offset) (cond ((equal? type 'int8) (c-bytevector-s8-ref pointer offset)) ((equal? type 'uint8) (c-bytevector-u8-ref pointer offset)) ((equal? type 'int16) (c-bytevector-s16-ref pointer offset)) ((equal? type 'uint16) (c-bytevector-u16-ref pointer offset)) ((equal? type 'int32) (c-bytevector-s32-ref pointer offset)) ((equal? type 'uint32) (c-bytevector-u32-ref pointer offset)) ((equal? type 'int64) (c-bytevector-s64-ref pointer offset)) ((equal? type 'uint64) (c-bytevector-u64-ref pointer offset)) ((equal? type 'char) (integer->char (c-bytevector-s8-ref pointer offset))) ((equal? type 'unsigned-char) (integer->char (c-bytevector-u8-ref pointer offset))) ((equal? type 'short) (c-bytevector-sint-ref pointer offset (native-endianness) (c-size-of 'short))) ((equal? type 'unsigned-short) (c-bytevector-sint-ref pointer offset (native-endianness) (c-size-of 'unsigned-short))) ((equal? type 'int) (c-bytevector-sint-ref pointer offset (native-endianness) (c-size-of 'int))) ((equal? type 'unsigned-int) (c-bytevector-sint-ref pointer offset (native-endianness) (c-size-of 'unsigned-int))) ((equal? type 'long) (c-bytevector-sint-ref pointer offset (native-endianness) (c-size-of 'long))) ((equal? type 'unsigned-long) (c-bytevector-sint-ref pointer offset (native-endianness) (c-size-of 'unsigned-long))) ((equal? type 'float) (c-bytevector-ieee-single-native-ref pointer offset)) ((equal? type 'double) (c-bytevector-ieee-double-native-ref pointer offset)) ((equal? type 'pointer) (c-bytevector-pointer-ref pointer offset)) ((not (equal? type 'void)) (error "No such foreign type" type)) ;; Return unspecified on purpose if type is void )))