timetags, nested bundles, higher-level API and various tweaks #2
2 changed files with 16 additions and 8 deletions
|
@ -27,5 +27,5 @@
|
|||
address port #\Tab timetag #\Tab
|
||||
(when timetag (timetag->unix-time timetag))
|
||||
#\Tab #\Tab)
|
||||
(format-osc-data data stream)
|
||||
(format-osc-data data :stream stream)
|
||||
(format stream "~%"))
|
||||
|
|
|
@ -35,15 +35,23 @@
|
|||
:timetag timetag
|
||||
:elements elements))
|
||||
|
||||
(defgeneric format-osc-data (data &optional stream))
|
||||
(defgeneric format-osc-data (data &key stream width))
|
||||
|
||||
(defmethod format-osc-data ((message message) &optional (stream t))
|
||||
(format stream "~a~{ ~a~}~%"
|
||||
(command message)
|
||||
(args message)))
|
||||
(defmethod format-osc-data ((message message) &key (stream t)
|
||||
(width 80))
|
||||
(let ((args-string (format nil "~{~a~^ ~}" (args message))))
|
||||
(when (> (length args-string) width)
|
||||
(setf args-string
|
||||
(concatenate 'string
|
||||
(subseq args-string 0 width)
|
||||
"...")))
|
||||
(format stream "~a~a ~a~%"
|
||||
#\Tab
|
||||
(command message)
|
||||
args-string)))
|
||||
|
||||
(defmethod format-osc-data ((bundle bundle) &optional (stream t))
|
||||
(defmethod format-osc-data ((bundle bundle) &key (stream t) (width 80))
|
||||
(format stream "~&[ ~a~%" (timetag bundle))
|
||||
(dolist (element (elements bundle))
|
||||
(format-osc-data element stream))
|
||||
(format-osc-data element :stream stream :width width))
|
||||
(format stream "~&]~%"))
|
||||
|
|
Loading…
Reference in a new issue