File: ffi-buffer.lisp

package info (click to toggle)
cl-plus-ssl 20071127-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 132 kB
  • ctags: 102
  • sloc: lisp: 853; makefile: 32
file content (22 lines) | stat: -rw-r--r-- 701 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
(in-package :cl+ssl)

(defun make-buffer (size)
  (cffi-sys::make-shareable-byte-vector size))

(defun buffer-length (buf)
  (length buf))

(defun buffer-elt (buf index)
  (elt buf index))
(defun set-buffer-elt (buf index val)
  (setf (elt buf index) val))
(defsetf buffer-elt set-buffer-elt)

(defun v/b-replace (vec buf &key (start1 0) end1 (start2 0) end2)
  (replace vec buf :start1 start1 :end1 end1 :start2 start2 :end2 end2))
(defun b/v-replace (buf vec &key (start1 0) end1 (start2 0) end2)
  (replace buf vec :start1 start1 :end1 end1 :start2 start2 :end2 end2))

(defmacro with-pointer-to-vector-data ((ptr buf) &body body)
  `(cffi-sys::with-pointer-to-vector-data (,ptr ,buf)
    ,@body))