fucking weird bug where it overwrites cffi functions?????

master
Avril 5 years ago
parent a4d142cf97
commit 7aa51baa06
Signed by: flanchan
GPG Key ID: 284488987C31F630

@ -1,6 +1,7 @@
;; cl-sipc ;; cl-sipc
(in-package :cl-sipc) (in-package :cl-sipc)
(use-package :cl-sipc-mem)
(defparameter *on-error* #'(lambda (err) nil)) (defparameter *on-error* #'(lambda (err) nil))
(defparameter *on-message* #'(lambda (msg) (defparameter *on-message* #'(lambda (msg)

@ -4,3 +4,6 @@
(:use #:cl (:use #:cl
#:cffi) #:cffi)
(:nicknames :sipc)) (:nicknames :sipc))
(defpackage #:cl-sipc-mem
(:use #:cl))

@ -1,6 +1,6 @@
;; pointer ;; pointer
(in-package :cl-sipc) (in-package :cl-sipc-mem)
(defstruct pointer (defstruct pointer
memory memory
@ -44,18 +44,18 @@
(type (or (caddr desc) :unsigned-char)) (type (or (caddr desc) :unsigned-char))
(pointer-from-type-infer (gensym))) (pointer-from-type-infer (gensym)))
(let ((makeptr (let ((makeptr
(cond ((eql type0 :string) `(pointer-from-string ,from)) (cond ((eql type0 :string) `(pointer-from-string ,from))
((eql type0 :sequence) `(pointer-from-seq ,from ,type)) ((eql type0 :sequence) `(pointer-from-seq ,from ,type))
((eql type0 :single) `(pointer-from ,from ,type)) ((eql type0 :single) `(pointer-from ,from ,type))
(t `(,pointer-from-type-infer ,from ,type))))) (t `(,pointer-from-type-infer ,from ,type)))))
`(flet ((,pointer-from-type-infer (fr ty) `(flet ((,pointer-from-type-infer (fr ty)
(cond ((stringp fr) (pointer-from-string fr)) (cond ((stringp fr) (pointer-from-string fr))
((or (vectorp fr) ((or (vectorp fr)
(listp fr)) (pointer-from-seq fr ty)) (listp fr)) (pointer-from-seq fr ty))
(t (pointer-from fr ty))))) (t (pointer-from fr ty)))))
(let* ((,name ,makeptr) (let* ((,name ,makeptr)
(result (result
(progn ,@body))) (progn ,@body)))
(pointer-free ,name) (pointer-free ,name)
result))))) result)))))
@ -67,18 +67,19 @@
"pointer to Lisp vector" "pointer to Lisp vector"
(let ((vec (make-array (pointer-size ptr) :initial-element 0))) (let ((vec (make-array (pointer-size ptr) :initial-element 0)))
(loop for x from 0 below (pointer-size ptr) (loop for x from 0 below (pointer-size ptr)
do (setf (aref vec x) (mem-aref (pointer-memory ptr) type x))) do (setf (aref vec x) (mem-aref (pointer-memory ptr) type x)))
vec)) vec))
(mapc #'export '( make-pointer (mapc #'export '(
pointer
pointer-memory pointer
pointer-p pointer-memory
pointer-size pointer-p
pointer-size
pointer-from-string pointer-from-string
pointer-from-seq pointer-from-seq
pointer-from pointer-from
with-pointer with-pointer
pointer-to-array pointer-to-array
pointer-free)) pointer-free))

Loading…
Cancel
Save