1 ;;;; -*- Mode: lisp; indent-tabs-mode: nil -*-
3 ;;; package.lisp --- Package definition for CFFI.
5 ;;; Copyright (C) 2005-2006, James Bielman <jamesjb@jamesjb.com>
6 ;;; Copyright (C) 2009, Luis Oliveira <loliveira@common-lisp.net>
7 ;;; Copyright (C) 2012, Mark Evenson <evenson.not.org@gmail.com>
9 ;;; Permission is hereby granted, free of charge, to any person
10 ;;; obtaining a copy of this software and associated documentation
11 ;;; files (the "Software"), to deal in the Software without
12 ;;; restriction, including without limitation the rights to use, copy,
13 ;;; modify, merge, publish, distribute, sublicense, and/or sell copies
14 ;;; of the Software, and to permit persons to whom the Software is
15 ;;; furnished to do so, subject to the following conditions:
17 ;;; The above copyright notice and this permission notice shall be
18 ;;; included in all copies or substantial portions of the Software.
20 ;;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 ;;; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 ;;; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 ;;; NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
24 ;;; HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
25 ;;; WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26 ;;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
27 ;;; DEALINGS IN THE SOFTWARE.
31 (eval-when (:compile-toplevel
:load-toplevel
:execute
)
32 (require :abcl-contrib
)
38 (defpackage #:cffi-sys
39 (:use
#:common-lisp
#:alexandria
42 #+cmu
#:alien
#+cmu
#:c-call
46 (:import-from
#:si
#:null-pointer-p
)
47 (:shadow
#:copy-file
; Conflicts with ccl:copy-file
50 ;; Platform-specific functionality
51 #+ecl
#:*cffi-ecl-method
*
54 #:canonicalize-symbol-name-case
55 #:defcfun-helper-forms
72 #:%foreign-symbol-pointer
77 #:with-foreign-pointer
81 #:%foreign-funcall-pointer
82 #:%foreign-funcall-varargs
83 #:%foreign-funcall-pointer-varargs
84 #:%foreign-type-alignment
90 #:%load-foreign-library
91 #:%close-foreign-library
99 #:make-shareable-byte-vector
100 #:with-pointer-to-vector-data
102 ;; Compiler macro utils
104 #:constant-form-value
))
106 ;;; Create a package to contain the symbols for callback functions.
107 ;;; We want to redefine callbacks with the same symbol so the internal
108 ;;; data structures are reused.
109 #+(or allegro ccl cmu ecl lispworks mkcl
)
110 (defpackage #:cffi-callbacks
113 (defpackage #:cffi-features
118 ;; Features related to the CFFI-SYS backend. Why no-*? This
119 ;; reflects the hope that these symbols will go away completely
120 ;; meaning that at some point all lisps will support long-longs,
121 ;; the foreign-funcall primitive, etc...
127 ;; Only ECL and SCL support long-double...
130 ;; Features related to the operating system.
131 ;; More should be added.
136 ;; Features related to the processor.
137 ;; More should be added.
147 (:use
#:common-lisp
#:cffi-sys
#:babel-encodings
)
148 (:import-from
#:alexandria
155 #:ignore-some-conditions
162 #:simple-style-warning
164 #:unwind-protect-case
171 ;; FIXME: the following types are undocumented. They should
172 ;; probably be replaced with a proper type introspection API
174 #:*built-in-foreign-types
*
175 #:*other-builtin-types
*
176 #:*built-in-integer-types
*
177 #:*built-in-float-types
*
179 ;; Primitive pointer operations.
191 #:with-foreign-pointer
195 ;; Shareable vectors.
196 #:make-shareable-byte-vector
197 #:with-pointer-to-vector-data
199 ;; Foreign string operations.
200 #:*default-foreign-encoding
*
201 #:foreign-string-alloc
202 #:foreign-string-free
203 #:foreign-string-to-lisp
204 #:lisp-string-to-foreign
205 #:with-foreign-string
206 #:with-foreign-strings
207 #:with-foreign-pointer-as-string
209 ;; Foreign array operations.
210 ;; TODO: document these
211 #:foreign-array-alloc
213 #:foreign-array-to-lisp
214 #:lisp-array-to-foreign
218 ;; Foreign function operations.
221 #:foreign-funcall-pointer
222 #:foreign-funcall-varargs
223 #:foreign-funcall-pointer-varargs
224 #:translate-camelcase-name
225 #:translate-name-from-foreign
226 #:translate-name-to-foreign
227 #:translate-underscore-separated-name
229 ;; Foreign library operations.
230 #:*foreign-library-directories
*
231 #:*darwin-framework-directories
*
233 #:foreign-library-load-state
234 #:foreign-library-name
235 #:foreign-library-pathname
236 #:foreign-library-type
237 #:foreign-library-loaded-p
238 #:list-foreign-libraries
239 #:define-foreign-library
240 #:load-foreign-library
241 #:load-foreign-library-error
242 #:use-foreign-library
243 #:close-foreign-library
244 #:reload-foreign-libraries
251 ;; Foreign type operations.
257 #:define-foreign-type
258 #:define-parse-method
259 #:define-c-struct-wrapper
260 #:foreign-enum-keyword
261 #:foreign-enum-keyword-list
263 #:foreign-bitfield-symbol-list
264 #:foreign-bitfield-symbols
265 #:foreign-bitfield-value
266 #:foreign-slot-pointer
269 #:foreign-slot-offset
272 #:foreign-type-alignment
274 #:with-foreign-object
275 #:with-foreign-objects
278 #:convert-from-foreign
279 #:convert-into-foreign-memory
280 #:free-converted-object
281 #:translation-forms-for-class
283 ;; Extensible foreign type operations.
284 #:define-translation-method
; FIXME: undocumented
285 #:translate-to-foreign
286 #:translate-from-foreign
287 #:translate-into-foreign-memory
288 #:free-translated-object
289 #:expand-to-foreign-dyn
291 #:expand-from-foreign
292 #:expand-into-foreign-memory
297 #:foreign-symbol-pointer