diff options
author | dos-reis <gdr@axiomatics.org> | 2011-03-20 19:21:34 +0000 |
---|---|---|
committer | dos-reis <gdr@axiomatics.org> | 2011-03-20 19:21:34 +0000 |
commit | 5887c54d95b5bc62167a5e22e56e515cda7a7244 (patch) | |
tree | edc430accc6075c307a40f252f7f50643b6c9f0f /src/algebra/data.spad.pamphlet | |
parent | adac8d95735aa3dc001658f2438b79d1c38a58d4 (diff) | |
download | open-axiom-5887c54d95b5bc62167a5e22e56e515cda7a7244.tar.gz |
* interp/g-opt.boot ($VMsideEffectFreeOperators): Include
%bytevec2str and %str2bytevec opcode.
* interp/lisp-backend.boot: Expand them.
* algebra/data.spad.pamphlet (ByteBuffer): Tidy.
Diffstat (limited to 'src/algebra/data.spad.pamphlet')
-rw-r--r-- | src/algebra/data.spad.pamphlet | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/src/algebra/data.spad.pamphlet b/src/algebra/data.spad.pamphlet index 6810cbb1..5f060343 100644 --- a/src/algebra/data.spad.pamphlet +++ b/src/algebra/data.spad.pamphlet @@ -301,25 +301,29 @@ import Byte ++ Note: a value of type ByteBuffer is 0-based indexed, as opposed ++ Vector, but not unlike PrimitiveArray Byte. ByteBuffer(): Public == Private where + macro NNI == NonNegativeInteger Public == Join(OneDimensionalArrayAggregate Byte,_ CoercibleTo PrimitiveArray Byte,CoercibleTo String) with - byteBuffer: NonNegativeInteger -> % + byteBuffer: NNI -> % ++ byteBuffer(n) creates a buffer of capacity n, and length 0. - capacity: % -> NonNegativeInteger + capacity: % -> NNI ++ capacity(buf) returns the pre-allocated maximum size of `buf'. - setLength!: (%,NonNegativeInteger) -> NonNegativeInteger + setLength!: (%,NNI) -> NNI ++ setLength!(buf,n) sets the number of active bytes in the ++ `buf'. Error if `n' is more than the capacity. finiteAggregate ++ A ByteBuffer object is a finite aggregate Private == add + import %bytevec2str: (PrimitiveArray Byte,NNI) -> String + from Foreign Builtin + -- A buffer object is a pair of a simple array, and the count -- of active number in the array. Note that we cannot use -- Lisp-level fill pointers because that would not guarantee that -- the implementation uses a simple representation, therefore -- complicating FFI interface. - Rep == Record(ary: PrimitiveArray Byte, sz: NonNegativeInteger) + Rep == Record(ary: PrimitiveArray Byte, sz: NNI) - makeByteBuffer(n: NonNegativeInteger): % == + makeByteBuffer(n: NNI): % == per [makeByteBuffer(n)$Foreign(Builtin),n]$Rep byteBuffer n == makeByteBuffer n @@ -359,11 +363,8 @@ ByteBuffer(): Public == Private where coerce(buf: %): PrimitiveArray Byte == rep(buf).ary - coerce(buf: %): String == - s: String := MAKE_-STRING(#buf)$Foreign(Builtin) - for i in 0..maxIndex buf repeat - qsetelt!(s,i + 1,qelt(buf,i)::Character)$String - s + coerce(buf: %): String == + %bytevec2str(rep(buf).ary,#buf) construct l == buf := makeByteBuffer(#l) |