source: project/release/4/remote-mailbox/trunk/remote-mailbox-adapter.scm @ 35329

Last change on this file since 35329 was 35329, checked in by kon, 13 months ago

add types, deprecate '/' style identifiers, use moremacros define-warning-parameter, reflow

File size: 1.9 KB
Line 
1;;;; remote-mailbox-adapter.scm
2;;;; Kon Lovett, Sep '17
3
4(module remote-mailbox-adapter
5
6(;export
7  serializer deserializer
8  serializer-output deserializer-input
9  serialize deserialize)
10
11(import scheme chicken)
12(use
13  (prefix s11n s11n::)
14  (only moremacros define-warning-parameter)
15  (only type-errors warning-argument-type)
16  condition-utils)
17
18;;;
19
20;;
21
22(define (serializer? x)
23  (or (not x) (procedure? x)) )
24
25(: serializer (#!optional (or boolean procedure) -> procedure))
26;
27(define-warning-parameter serializer s11n::serialize serializer
28  ;ugh, automagic identifier injection
29  (unless obj (set! obj s11n::serialize)) )
30
31(define (deserializer? x)
32  (or (not x) (procedure? x)) )
33
34(: deserializer (#!optional (or boolean procedure) -> procedure))
35;
36(define-warning-parameter deserializer s11n::deserialize deserializer
37  ;ugh, automagic identifier injection
38  (unless obj (set! obj s11n::deserialize)) )
39
40(define DEFAULT-DESERIALIZER-INPUT (current-input-port))
41(define DEFAULT-SERIALIZER-OUTPUT (current-output-port))
42
43(define (deserializer-input? x)
44  (or (not x) (input-port? x)) )
45
46(: deserializer-input (#!optional (or boolean input-port) -> input-port))
47;
48(define-warning-parameter deserializer-input DEFAULT-DESERIALIZER-INPUT deserializer-input
49  ;ugh, automagic identifier injection
50  (unless obj (set! obj DEFAULT-DESERIALIZER-INPUT)) )
51
52(define (serializer-output? x)
53  (or (not x) (output-port? x)) )
54
55(: serializer-output (#!optional (or boolean output-port) -> output-port))
56;
57(define-warning-parameter serializer-output DEFAULT-SERIALIZER-OUTPUT serializer-output
58  ;ugh, automagic identifier injection
59  (unless obj (set! obj DEFAULT-SERIALIZER-OUTPUT)) )
60
61;;
62
63(: serialize (* #!optional output-port -> void))
64;
65(define (serialize x #!optional (port (serializer-output)))
66  ((serializer) x port) )
67
68(: deserialize (#!optional input-port -> *))
69;
70(define (deserialize #!optional (port (deserializer-input)))
71  ((deserializer) port) )
72
73) ;module remote-mailbox-adapter
Note: See TracBrowser for help on using the repository browser.