Ignore:
Timestamp:
03/25/18 07:42:09 (2 years ago)
Author:
Kon Lovett
Message:

add define-types include, add types, reflow

File:
1 edited

Legend:

Unmodified
Added
Removed
  • release/4/message-digest/trunk/message-digest-type.scm

    r35338 r35339  
    4242;;; Support
    4343
     44;;
     45
     46(include "message-digest-types")
     47
     48;;
     49
    4450(define-constant MINIMUM-BUFFER-SIZE 8)
    4551
     
    4753(define-constant DEFAULT-RESULT-TYPE 'hex-string)
    4854
     55;-> *
    4956(define (error-result-form loc obj)
    5057  (error-argument-type loc obj "symbol in {string hex blob u8vector}" 'result-form) )
     
    5259;perform any conversion necessary for final result representation
    5360;assumes blob 'res' may not be of result size
     61
     62(define: (get-result-form (loc symbol) (res blob) (rt symbol)) -> message-digest-result-form
     63  (case (canonical-result-name rt)
     64    ((blob)           res )
     65    ((byte-string)    (blob->string res) )
     66    ((hex-string)     (blob->hex res) )
     67    ((u8vector)       (blob->u8vector/shared res) )
     68    (else
     69      (error-result-form loc rt) ) ) )
     70
    5471#;
    55 (define (get-result-form loc res rt len)
     72(define: (get-result-form (loc symbol) (res blob) (rt symbol)) -> message-digest-result-form
    5673  (case rt
    5774    ((blob)
     
    7188      (error-result-form loc rt) ) ) )
    7289
    73 ;perform any conversion necessary for final result representation
    74 ;assumes blob 'res' is of result size
    75 (define (get-result-form loc res rt)
    76   (case (canonical-result-name rt)
    77     ((blob)           res )
    78     ((byte-string)    (blob->string res) )
    79     ((hex-string)     (blob->hex res) )
    80     ((u8vector)       (blob->u8vector/shared res) )
    81     (else
    82       (error-result-form loc rt) ) ) )
    83 
    84 (define (canonical-result-name x)
     90(define: (canonical-result-name (x symbol)) -> (or boolean symbol)
    8591  (case x
    8692    ((blob)                       'blob )
     
    9197      #f ) ) )
    9298
    93 (define (check-result-type loc mdp obj)
     99(define: (check-result-type (loc symbol) (mdp message-digest-primitive) (obj message-digest-result-form)) -> message-digest-result-form
    94100  (let (
    95101    (siz
     
    113119;;
    114120
     121(: message-digest-result-form (#!optional symbol -> symbol))
     122;
    115123(define-parameter message-digest-result-form #;DEFAULT-RESULT-TYPE 'hex-string
    116124  (lambda (x)
     
    123131
    124132;;
    125 
    126 (define-type srfi4vector (or u8vector s8vector u16vector s16vector u32vector s32vector f32vector f64vector))
    127 
    128 ;(define-type message-digest-buffer (or string blob srfi4vector procedure input-port pointer))
    129 (define-type message-digest-buffer (or string blob u8vector))
    130 
    131 (define-type message-digest-result-form (or string blob u8vector))
    132 
    133 (define-type message-digest-context (or fixnum procedure))
    134 
    135 (define-type message-digest-primitive (struct message-digest-primitive))
    136133
    137134(define:-record-type message-digest
Note: See TracChangeset for help on using the changeset viewer.