Changeset 4770 in project


Ignore:
Timestamp:
06/30/07 02:34:44 (13 years ago)
Author:
arto
Message:

php-s11n: Added support for PHP's NULL object.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • php-s11n/trunk/php-s11n.scm

    r4767 r4770  
    4242
    4343(define (php-s11n-write value #!optional (port (current-output-port)))
    44   (cond ((boolean? value) ; => boolean
     44  (cond ((void? value) ; => NULL
     45         (fprintf port "N;"))
     46        ((boolean? value) ; => boolean
    4547         (fprintf port "b:~A;" (if value 1 0)))
    4648        ((and (number? value) (exact? value)) ; => integer
     
    5052        ((symbol? value) ; => string
    5153         (php-s11n-write (symbol->string value) port))
     54        ((char? value) ; => string
     55         (php-s11n-write (string value) port))
    5256        ((string? value) ; => string
    5357         (fprintf port "s:~A:~S;" (string-length value) value))
     
    8488
    8589;;;; Internal procedures
     90
     91(define (php-s11n-read-null port)
     92  (expect-string port "N;")
     93  (void))
    8694
    8795(define (php-s11n-read-boolean port)
     
    120128
    121129(define php-s11n-readers
    122   `((#\b . ,php-s11n-read-boolean)
     130  `((#\N . ,php-s11n-read-null)
     131    (#\b . ,php-s11n-read-boolean)
    123132    (#\i . ,php-s11n-read-integer)
    124133    (#\d . ,php-s11n-read-float)
     
    156165;;;; General helper procedures
    157166
     167(define (void? x) (eq? x (void)))
     168
    158169(define (alist? x)
    159170  (and (proper-list? x)
Note: See TracChangeset for help on using the changeset viewer.