Changeset 3714

Show
Ignore:
Timestamp:
08/01/08 06:41:26 (4 months ago)
Author:
hans
Message:

Re-rename stream->output-stream

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/projects/quickhoney/src/json.lisp

    r3713 r3714  
    44 
    55(defclass json-output-stream () 
    6   ((stream :reader stream 
    7            :initarg :stream) 
     6  ((output-stream :reader output-stream 
     7                  :initarg :output-stream) 
    88   (stack :accessor stack 
    99          :initform nil))) 
     
    1111(defun next-aggregate-element () 
    1212  (if (car (stack *json-output*)) 
    13       (princ (car (stack *json-output*)) (stream *json-output*)) 
     13      (princ (car (stack *json-output*)) (output-stream *json-output*)) 
    1414      (setf (car (stack *json-output*)) #\,))) 
    1515 
    1616(defmacro with-json-output ((stream) &body body) 
    17   `(let ((*json-output* (make-instance 'json-output-stream :stream ,stream))) 
     17  `(let ((*json-output* (make-instance 'json-output-stream :output-stream ,stream))) 
    1818     ,@body)) 
    1919 
     
    2727     (when (stack *json-output*) 
    2828       (next-aggregate-element)) 
    29      (princ ,begin-char (stream *json-output*)) 
     29     (princ ,begin-char (output-stream *json-output*)) 
    3030     (push nil (stack *json-output*)) 
    3131     (prog1 
    3232         (progn ,@body) 
    3333       (pop (stack *json-output*)) 
    34        (princ ,end-char (stream *json-output*))))) 
     34       (princ ,end-char (output-stream *json-output*))))) 
    3535 
    3636(defmacro with-json-array (() &body body) 
     
    4444(defun encode-array-element (object) 
    4545  (next-aggregate-element) 
    46   (json:encode-json object (stream *json-output*))) 
     46  (json:encode-json object (output-stream *json-output*))) 
    4747 
    4848(defun encode-object-element (key value) 
    4949  (next-aggregate-element) 
    50   (json:encode-json key (stream *json-output*)) 
    51   (princ #\: (stream *json-output*)) 
    52   (json:encode-json value (stream *json-output*))) 
     50  (json:encode-json key (output-stream *json-output*)) 
     51  (princ #\: (output-stream *json-output*)) 
     52  (json:encode-json value (output-stream *json-output*))) 
    5353 
    5454(defmacro with-object-element ((key) &body body) 
    5555  `(progn 
    5656     (next-aggregate-element) 
    57      (json:encode-json ,key (stream *json-output*)) 
     57     (json:encode-json ,key (output-stream *json-output*)) 
    5858     (setf (car (stack *json-output*)) #\:) 
    5959     (unwind-protect 
     
    6363(defmacro with-json-response (() &body body) 
    6464  `(with-http-response (:content-type "application/json") 
    65     (with-json-output-to-string () 
    66       (with-json-object () 
    67         ,@body)))) 
     65    (with-json-output-to-string () 
     66      (with-json-object () 
     67        ,@body))))