Changeset 16139 in project


Ignore:
Timestamp:
10/07/09 04:13:34 (10 years ago)
Author:
Ivan Raikov
Message:

save

Location:
release/4/byte-blob/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • release/4/byte-blob/trunk/byte-blob.scm

    r16131 r16139  
    4343         byte-blob-empty
    4444         list->byte-blob
     45         byte-blob-replicate
     46         byte-blob-object
     47         byte-blob-offset
    4548         byte-blob-cons
    4649         byte-blob-car
     
    7275  )
    7376
     77(define byte-blob->blob byte-blob-object)
    7478
    7579(define (byte-blob-size b)
     
    9195    (foreign-lambda* void ((nonnull-blob b) (integer offset) (byte value))
    9296#<<END
    93    C_word result;
    9497   b[offset] = value;
    95    C_return (result);
    96 END
    97 ))
    98 
     98END
     99))
    99100
    100101(define blob-ref
     
    115116                 (loop (cdr lst) (+ i 1)))))))
    116117   
     118
     119
     120(define blob-fill
     121    (foreign-lambda* void ((nonnull-blob b) (unsigned-int n) (integer offset) (byte value))
     122#<<END
     123   unsigned int i;
     124   b[offset] = value;
     125   for (i=offset+n; i>offset; i--)
     126   {
     127     b[i-1] = value;
     128   }
     129END
     130))
     131
     132(define (byte-blob-replicate n v)
     133  (assert (positive? n))
     134  (let* ((ob (make-blob n))
     135         (bb (make-byte-blob ob 0)))
     136    (blob-fill ob n 0 v)
     137    bb))
    117138
    118139;; 'blob-cons' is analogous to list cons, but of different complexity,
     
    355376    (blob-write (port->fileno port) ob n offset)))
    356377
     378
     379
    357380)
  • release/4/byte-blob/trunk/tests/run.scm

    r16125 r16139  
    55(define a (byte-blob-cons 1 (byte-blob-cons 2 (byte-blob-empty))))
    66(define b (byte-blob-cons 3 (byte-blob-cons 4 (byte-blob-empty))))
    7 (define c (list->byte-blob 7 8 9))
    8 
     7(define c (list->byte-blob (list 7 8 9)))
     8(define d (byte-blob-replicate 10 6))
    99   
    1010
    1111
    1212(test-group "byte-blob test"
     13
     14            (test (sprintf "byte-blob-replicate")
     15                  '(6 6 6 6 6 6 6 6 6 6)
     16                  (byte-blob->list d))
    1317
    1418            (test (sprintf "byte-blob-cons" )
Note: See TracChangeset for help on using the changeset viewer.