Refactor core package definitions
[cffi.git] / src / features.lisp
blobfc39efc1a32ed28f5bb17738fe00801923f49582
1 ;;;; -*- Mode: lisp; indent-tabs-mode: nil -*-
2 ;;;
3 ;;; features.lisp --- CFFI-specific features (DEPRECATED).
4 ;;;
5 ;;; Copyright (C) 2006-2007, Luis Oliveira <loliveira@common-lisp.net>
6 ;;;
7 ;;; Permission is hereby granted, free of charge, to any person
8 ;;; obtaining a copy of this software and associated documentation
9 ;;; files (the "Software"), to deal in the Software without
10 ;;; restriction, including without limitation the rights to use, copy,
11 ;;; modify, merge, publish, distribute, sublicense, and/or sell copies
12 ;;; of the Software, and to permit persons to whom the Software is
13 ;;; furnished to do so, subject to the following conditions:
14 ;;;
15 ;;; The above copyright notice and this permission notice shall be
16 ;;; included in all copies or substantial portions of the Software.
17 ;;;
18 ;;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 ;;; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 ;;; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 ;;; NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
22 ;;; HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23 ;;; WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 ;;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25 ;;; DEALINGS IN THE SOFTWARE.
26 ;;;
28 (in-package #:cl-user)
30 (eval-when (:compile-toplevel :load-toplevel :execute)
31 (pushnew :cffi *features*))
33 ;;; CFFI-SYS backends take care of pushing the appropriate features to
34 ;;; *features*. See each cffi-*.lisp file.
35 ;;;
36 ;;; Not anymore, I think we should use TRIVIAL-FEATURES for the
37 ;;; platform features instead. Less pain. CFFI-FEATURES is now
38 ;;; deprecated and this code will stay here for a while for backwards
39 ;;; compatibility purposes, to be removed in a future release.
41 (in-package #:cffi-features)
43 (defun cffi-feature-p (feature-expression)
44 "Matches a FEATURE-EXPRESSION against those symbols in *FEATURES*
45 that belong to the CFFI-FEATURES package."
46 (when (eql feature-expression t)
47 (return-from cffi-feature-p t))
48 (let ((features-package (find-package '#:cffi-features)))
49 (flet ((cffi-feature-eq (name feature-symbol)
50 (and (eq (symbol-package feature-symbol) features-package)
51 (string= name (symbol-name feature-symbol)))))
52 (etypecase feature-expression
53 (symbol
54 (not (null (member (symbol-name feature-expression) *features*
55 :test #'cffi-feature-eq))))
56 (cons
57 (ecase (first feature-expression)
58 (:and (every #'cffi-feature-p (rest feature-expression)))
59 (:or (some #'cffi-feature-p (rest feature-expression)))
60 (:not (not (cffi-feature-p (cadr feature-expression))))))))))
62 ;;; for backwards compatibility
63 (mapc (lambda (sym) (pushnew sym *features*))
64 '(#+darwin darwin
65 #+unix unix
66 #+windows windows
67 #+ppc ppc32
68 #+x86 x86
69 #+x86-64 x86-64
70 #+sparc sparc
71 #+sparc64 sparc64
72 #+hppa hppa
73 #+hppa64 hppa64
74 #+cffi-sys::no-long-long no-long-long
75 #+cffi-sys::flat-namespace flat-namespace
76 #+cffi-sys::no-foreign-funcall no-foreign-funcall
77 #+cffi-sys::no-stdcall no-stdcall