[nio-cvs] r28 - in branches/home/psmith/restructure/src: buffer protocol/http protocol/yarpc

psmith at common-lisp.net psmith at common-lisp.net
Sat Jan 6 05:28:55 UTC 2007


Author: psmith
Date: Sat Jan  6 00:28:54 2007
New Revision: 28

Modified:
   branches/home/psmith/restructure/src/buffer/buffer.lisp
   branches/home/psmith/restructure/src/buffer/nio-buffer-package.lisp
   branches/home/psmith/restructure/src/protocol/http/http-state-machine.lisp
   branches/home/psmith/restructure/src/protocol/yarpc/yarpc-state-machine.lisp
Log:
tidy up

Modified: branches/home/psmith/restructure/src/buffer/buffer.lisp
==============================================================================
--- branches/home/psmith/restructure/src/buffer/buffer.lisp	(original)
+++ branches/home/psmith/restructure/src/buffer/buffer.lisp	Sat Jan  6 00:28:54 2007
@@ -78,16 +78,16 @@
 (defclass byte-buffer (buffer)())
 
 (defun byte-buffer (capacity)
-  (make-instance 'byte-buffer :capacity capacity :limit capacity :position 0 :buf (foreign-alloc :uint8 :count capacity)))
+  (make-instance 'byte-buffer :capacity capacity :limit capacity :position 0 :buf (cffi:foreign-alloc :uint8 :count capacity)))
 
 
 (defmethod print-object ((byte-buffer byte-buffer) stream)
   (with-slots (capacity position limit buf) byte-buffer
-    (format stream "<byte-buffer :capacity ~A :position ~A :limit ~A :buf ~%~A>~%" capacity position limit (if buf (hex-dump-memory (pointer-address buf) limit) nil))))
+    (format stream "<byte-buffer :capacity ~A :position ~A :limit ~A :buf ~%~A>~%" capacity position limit (if buf (hex-dump-memory (cffi:pointer-address buf) limit) nil))))
 
 (defmethod free-buffer((byte-buffer byte-buffer))
   (with-slots (capacity position limit buf) byte-buffer
-    (foreign-free buf)
+    (cffi:foreign-free buf)
     (setf buf NIL)
     (setf capacity 0)
     (setf limit 0)
@@ -140,23 +140,13 @@
       0
       (progn	
 	(clear byte-buffer)
-	(let ((bytes-written (mem-write-vector vec (buffer-buf byte-buffer) :unsigned-char)))
+	(let ((bytes-written (cffi:mem-write-vector vec (buffer-buf byte-buffer) :unsigned-char)))
 	  (format t "bytebuffer-write-vector -  byteswritten: ~A" bytes-written)
 	  (inc-position byte-buffer bytes-written)
 	  bytes-written))))
 
 
-(defmethod map-to-foreign ((byte-buffer byte-buffer) seq &optional (start 0) (end (length seq)))
-  "Map SEQ to foreign array."
-  (clear byte-buffer)
-  (let* ((len (- end start)))
-    (loop for i from 0 below len do
-	 (setf (mem-aref (buffer-buf byte-buffer) :uint8 i) (aref seq (+ start i)))))
-  (inc-position byte-buffer end))
-
-
-
-(defcfun ("memset" %memset) :pointer
+(cffi:defcfun ("memset" %memset) :pointer
   (buffer :pointer)
   (byte :int)
   (len :int))

Modified: branches/home/psmith/restructure/src/buffer/nio-buffer-package.lisp
==============================================================================
--- branches/home/psmith/restructure/src/buffer/nio-buffer-package.lisp	(original)
+++ branches/home/psmith/restructure/src/buffer/nio-buffer-package.lisp	Sat Jan  6 00:28:54 2007
@@ -24,8 +24,8 @@
 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 |#
-(defpackage :nio-buffer (:use :cl :cffi)
+(defpackage :nio-buffer (:use :cl)
 	    
 	    (:export
-	     byte-buffer free-buffer remaining inc-position get-string buffer-buf bytebuffer-write-vector bytebuffer-write-string flip map-to-foreign
+	     byte-buffer free-buffer remaining inc-position get-string buffer-buf bytebuffer-write-vector bytebuffer-write-string flip
 	     ))

Modified: branches/home/psmith/restructure/src/protocol/http/http-state-machine.lisp
==============================================================================
--- branches/home/psmith/restructure/src/protocol/http/http-state-machine.lisp	(original)
+++ branches/home/psmith/restructure/src/protocol/http/http-state-machine.lisp	Sat Jan  6 00:28:54 2007
@@ -38,7 +38,7 @@
 (defmethod process-read((sm http-state-machine))
   (with-slots (foreign-read-buffer foreign-write-buffer) sm 
 #+nio-debug    (format t "process-read got: ~A~%" (get-string foreign-read-buffer))
-    (nio-buffer:map-to-foreign foreign-write-buffer (get-bytes (http-response :status :ok :html "<html> ock </html>")))
+    (nio-buffer:bytebuffer-write-vector foreign-write-buffer (get-bytes (http-response :status :ok :html "<html> ock </html>")))
     (close-sm sm)))
 
 

Modified: branches/home/psmith/restructure/src/protocol/yarpc/yarpc-state-machine.lisp
==============================================================================
--- branches/home/psmith/restructure/src/protocol/yarpc/yarpc-state-machine.lisp	(original)
+++ branches/home/psmith/restructure/src/protocol/yarpc/yarpc-state-machine.lisp	Sat Jan  6 00:28:54 2007
@@ -39,7 +39,7 @@
 ;; Escape character is '^]'.
 ;; (test-rpc "who" 2 's)
 ;; response - who 2 'S ∑
-
+;;
 (defclass yarpc-state-machine (async-fd)())
 
 (defmethod print-object ((sm yarpc-state-machine) stream)



More information about the Nio-cvs mailing list