3 ;;; cffiglue -- Interface to C library. Based on the range of CL FFI
4 ;;; "glues" by Luke Tierney.
6 ;;; Copyright (c) 1991, by Luke Tierney.
7 ;;; Copyright (c) 2007, by Carlos Ungil.
8 ;;; Copyright (c) 2007, by AJ Rossini <blindglobe@gmail.com>.
9 ;;; Permission is granted for unrestricted use.
13 (defpackage :lisp-stat-ffi-int
16 (:export ccl-store-integer ccl-store-double ccl-store-ptr
))
18 ;; are there any error message components that need to be exported?
19 ;; More importantly, should we factor them out into a logging package?
21 ;; This package initially loads the liblispstat library for access.
23 (in-package :lisp-stat-ffi-int
)
25 (cffi:load-foreign-library
27 (namestring cl-user
::*lispstat-home-dir
*)
32 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
34 ;;; Callback Support Functions
36 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
38 (cffi:defcfun
("ccl_store_integer" ccl-store-integer
)
40 (cffi:defcfun
("ccl_store_double" ccl-store-double
)
42 (cffi:defcfun
("ccl_store_ptr" ccl-store-ptr
)
45 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
47 ;;; XLISP Internal Error Message Emulation
49 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
51 (defvar *buf
* (make-string 1000))
53 (defun set-buf-char (i c
) (setf (elt *buf
* i
) (code-char c
)))
55 (defun get-buf (&optional
(n (position (code-char 0) *buf
*)))
58 (cffi:defcfun
("register_set_buf_char" register-set-buf-char
)
60 (cffi:defcallback ccl-set-buf-char
:void
((n :int
) (c :int
))
62 (register-set-buf-char (cffi:callback ccl-set-buf-char
))
64 (cffi:defcfun
("register_print_buffer" register-print-buffer
)
66 (cffi:defcallback ccl-print-buffer
:void
((n :int
) (type :int
))
68 (0 (princ (get-buf n
)))
69 (1 (error (get-buf n
))))
71 (register-print-buffer (cffi:callback ccl-print-buffer
))
73 (cffi:defcfun
("stdputstr" stdputstr
)
74 :void
(string :string
))
75 (cffi:defcfun
("xlfail" xlfail
)
76 :void
(string :string
))